/* ============================================
   BrummiHonigtopf Learn - Wabendesign
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,800;1,9..144,600&family=Albert+Sans:wght@400;500;600;700&display=swap');

:root {
    --honey-deep: #b86b1c;
    --honey: #e8a93b;
    --honey-light: #f6c95b;
    --cream: #fbf3dc;
    --cream-warm: #f5e6b8;
    --bark: #2a1810;
    --bark-soft: #4a2e1c;
    --muted: #8a7355;
    --line: rgba(184, 107, 28, 0.18);
    --error: #a83a1c;
    --success: #4d7a3a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: 'Albert Sans', system-ui, sans-serif;
    background: var(--cream);
    color: var(--bark);
    min-height: 100vh;
    position: relative;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* === Hintergrund === */
.honeycomb-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.55;
    background-image:
      radial-gradient(circle at 50% 0%, var(--cream-warm) 0%, transparent 60%),
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='84' height='96' viewBox='0 0 84 96'><g fill='none' stroke='%23b86b1c' stroke-opacity='0.18' stroke-width='1.5'><polygon points='42,2 80,24 80,68 42,90 4,68 4,24'/><polygon points='0,48 38,70 38,114 0,136 -38,114 -38,70'/><polygon points='84,48 122,70 122,114 84,136 46,114 46,70'/></g></svg>");
    background-size: cover, 84px 96px;
}

.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    z-index: 0;
    pointer-events: none;
}
.blob-1 { width: 480px; height: 480px; background: var(--honey-light); top: -180px; left: -160px; }
.blob-2 { width: 380px; height: 380px; background: var(--honey); bottom: -140px; right: -120px; opacity: 0.25; }

/* === Layout === */
.page {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* === Header === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 32px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.brand {
    font-family: 'Fraunces', serif;
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
    color: var(--bark);
    text-decoration: none;
}
.brand .dot { color: var(--honey-deep); }
.brand .sub {
    display: block;
    font-family: 'Fraunces', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 2px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
}
.header-nav a {
    color: var(--bark-soft);
    text-decoration: none;
    transition: color 0.2s;
}
.header-nav a:hover { color: var(--honey-deep); }

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(232, 169, 59, 0.15);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--honey-deep);
}
.user-pill .role-admin {
    color: white;
    background: var(--bark);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* === Breadcrumbs === */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 24px;
}
.breadcrumbs a {
    color: var(--bark-soft);
    text-decoration: none;
}
.breadcrumbs a:hover { color: var(--honey-deep); }
.breadcrumbs .sep { color: var(--line); }

/* === Headings === */
h1, h2, h3 {
    font-family: 'Fraunces', serif;
    font-weight: 800;
    color: var(--bark);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: 12px; }
h1 .accent { color: var(--honey-deep); font-style: italic; font-weight: 400; }
h2 { font-size: 1.6rem; margin-bottom: 16px; }
h3 { font-size: 1.2rem; margin-bottom: 8px; font-weight: 600; }

.eyebrow {
    font-family: 'Fraunces', serif;
    font-style: italic;
    font-weight: 600;
    color: var(--honey-deep);
    font-size: 1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.eyebrow::before {
    content: '';
    display: inline-block;
    width: 32px; height: 2px;
    background: var(--honey-deep);
    border-radius: 2px;
}

.lede {
    font-size: 1.1rem;
    color: var(--bark-soft);
    max-width: 640px;
    margin-bottom: 32px;
}

/* === Hex-Cards (Kategorien) === */
.hex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.hex-card {
    position: relative;
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px 24px 28px 24px;
    text-decoration: none;
    color: var(--bark);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.hex-card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 120px;
    height: 120px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><polygon points='50,5 90,28 90,72 50,95 10,72 10,28' fill='none' stroke='%23b86b1c' stroke-width='2' stroke-opacity='0.15'/></svg>") no-repeat center/contain;
    pointer-events: none;
}
.hex-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(42, 24, 16, 0.1);
    border-color: var(--honey-deep);
}
.hex-card .card-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 8px;
    line-height: 1.2;
    color: var(--bark);
}
.hex-card .card-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: auto;
    padding-top: 12px;
}
.hex-card .card-desc {
    font-size: 0.95rem;
    color: var(--bark-soft);
    margin-bottom: 12px;
}

/* === Lerneinheits-Liste === */
.unit-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}
.unit-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px 24px;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.unit-card:hover {
    border-color: var(--honey);
    transform: translateY(-1px);
}
.unit-card.locked {
    background: rgba(255, 255, 255, 0.5);
    border-style: dashed;
}
.unit-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.unit-card-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--bark);
}
.unit-card-desc {
    color: var(--bark-soft);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

/* === Datei-Liste === */
.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: background 0.2s;
}
.file-item:hover { background: var(--cream-warm); }
.file-item.locked { opacity: 0.6; }
.file-icon {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: var(--honey-light);
    border-radius: 8px;
    flex-shrink: 0;
    color: var(--bark);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.file-icon.pdf { background: #ffd6c2; color: #a83a1c; }
.file-icon.img { background: #d4f0d4; color: #4d7a3a; }
.file-icon.audio { background: #e0d4f0; color: #6b3a7a; }
.file-icon.video { background: #f0d4d4; color: #a83a4d; }
.file-icon.doc { background: #d4e0f0; color: #3a4d7a; }

.file-info { flex: 1; min-width: 0; }
.file-name {
    font-weight: 500;
    color: var(--bark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-meta { font-size: 0.8rem; color: var(--muted); }
.file-actions { display: flex; gap: 8px; }
.preview-badge {
    display: inline-block;
    background: var(--honey);
    color: var(--bark);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 8px;
}
.locked-badge {
    display: inline-block;
    background: rgba(138, 74, 20, 0.1);
    color: #8a4a14;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* === Buttons === */
.btn {
    font-family: 'Albert Sans', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 20px;
    border-radius: 999px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.btn-primary {
    background: var(--bark);
    color: var(--cream);
    box-shadow: 0 4px 0 var(--honey-deep);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 var(--honey-deep), 0 8px 16px rgba(42, 24, 16, 0.15);
}
.btn-primary:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--honey-deep);
}
.btn-ghost {
    background: transparent;
    color: var(--bark);
    border-color: var(--line);
}
.btn-ghost:hover {
    background: var(--bark);
    color: var(--cream);
    border-color: var(--bark);
}
.btn-honey {
    background: var(--honey);
    color: var(--bark);
}
.btn-honey:hover { background: var(--honey-deep); color: var(--cream); }
.btn-danger {
    background: var(--error);
    color: white;
}
.btn-danger:hover { background: #8a2c10; }
.btn-small { font-size: 0.85rem; padding: 6px 14px; }

/* === Forms === */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-weight: 600;
    color: var(--bark);
    margin-bottom: 6px;
    font-size: 0.9rem;
}
.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--bark);
    transition: border-color 0.2s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--honey-deep);
    box-shadow: 0 0 0 3px rgba(184, 107, 28, 0.1);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-help { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* === Cards / Boxen === */
.card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
}
.card-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.alert-info { background: rgba(232, 169, 59, 0.15); border: 1px solid rgba(184, 107, 28, 0.25); color: var(--honey-deep); }
.alert-success { background: rgba(77, 122, 58, 0.1); border: 1px solid rgba(77, 122, 58, 0.3); color: var(--success); }
.alert-error { background: rgba(168, 58, 28, 0.1); border: 1px solid rgba(168, 58, 28, 0.3); color: var(--error); }

/* === Login-Box === */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
    position: relative;
    z-index: 2;
}
.auth-box {
    background: white;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(42, 24, 16, 0.08);
}
.auth-box h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    text-align: center;
}
.auth-box .auth-sub {
    text-align: center;
    color: var(--muted);
    margin-bottom: 32px;
    font-style: italic;
    font-family: 'Fraunces', serif;
}

/* === 2FA Code Input === */
.code-input {
    font-family: 'Courier New', monospace;
    font-size: 1.8rem;
    letter-spacing: 0.5rem;
    text-align: center;
    padding: 16px;
    font-weight: bold;
}

/* === Modal === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(42, 24, 16, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.active { display: flex; }
.modal {
    background: white;
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid; place-items: center;
}
.modal-close:hover { background: var(--cream); color: var(--bark); }
.modal h2 { margin-bottom: 16px; }

/* === Upload === */
.upload-zone {
    border: 2px dashed var(--line);
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    background: var(--cream);
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
    margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--honey-deep);
    background: var(--cream-warm);
}
.upload-zone-text {
    color: var(--bark-soft);
    margin-bottom: 8px;
}
.upload-zone-sub { font-size: 0.85rem; color: var(--muted); }

.upload-progress {
    display: none;
    margin-top: 12px;
}
.upload-progress.active { display: block; }
.upload-bar {
    width: 100%;
    height: 8px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.upload-bar-fill {
    height: 100%;
    background: var(--honey);
    width: 0;
    transition: width 0.2s;
}
.upload-status {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 6px;
    text-align: center;
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
    overflow-x: auto;
}
.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.tab.active {
    color: var(--bark);
    border-bottom-color: var(--honey-deep);
}
.tab:hover { color: var(--bark); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === Tabellen === */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}
.table th {
    text-align: left;
    padding: 14px 16px;
    background: var(--cream-warm);
    font-weight: 600;
    color: var(--bark);
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--cream); }

/* === Footer === */
.footer {
    margin-top: 60px;
    padding: 24px 0;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--muted);
}
.footer a {
    color: var(--bark-soft);
    text-decoration: underline;
    text-decoration-color: var(--honey);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}
.footer a:hover { color: var(--honey-deep); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state h3 {
    color: var(--bark);
    font-style: italic;
    margin-bottom: 8px;
}

/* === Responsive === */
@media (max-width: 720px) {
    .page { padding: 16px 18px; }
    .header { flex-direction: column; align-items: flex-start; }
    .hex-grid { grid-template-columns: 1fr; }
    .unit-card-header { flex-direction: column; }
    .modal { padding: 24px 20px; }
    h1 { font-size: 2rem; }
    .auth-box { padding: 28px 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   Honeycomb-Stream (interaktiver Hintergrund)
   ============================================ */

body.has-stream {
    /* Stream übernimmt den Hintergrund */
}

/*
 * Container hat das gleiche SVG-Pattern wie .honeycomb-bg.
 * Dadurch ist überall ein leeres Wabenraster sichtbar – auch dort,
 * wo gerade kein gefülltes Lerneinheits-Hex liegt.
 */
.honeycomb-stream {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 1;
    background-image:
      radial-gradient(circle at 50% 0%, var(--cream-warm) 0%, transparent 60%),
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='84' height='96' viewBox='0 0 84 96'><g fill='none' stroke='%23b86b1c' stroke-opacity='0.18' stroke-width='1.5'><polygon points='42,2 80,24 80,68 42,90 4,68 4,24'/><polygon points='0,48 38,70 38,114 0,136 -38,114 -38,70'/><polygon points='84,48 122,70 122,114 84,136 46,114 46,70'/></g></svg>");
    background-size: cover, 84px 96px;
    background-color: var(--cream);
}

/*
 * Hex-Tile: 76x88 - exakt dieselbe Größe wie eine Wabe im Hintergrund-Pattern.
 * Position wird per JS gesetzt und richtet sich am Pattern-Grid aus.
 */
.hex-tile {
    position: absolute;
    width: 76px;
    height: 88px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), z-index 0s 0.4s;
    will-change: top, transform;
    transform-origin: center center;
    pointer-events: auto;
}

/* Hexes die durch den Fokus weggedrückt werden */
.hex-tile.pushed {
    z-index: 5;
}
.hex-tile.pushed .hex-tile-inner {
    box-shadow: 0 4px 12px rgba(184, 107, 28, 0.12);
}

.hex-tile-inner {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(184, 107, 28, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    text-align: center;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 6px rgba(184, 107, 28, 0.08);
}

.hex-tile.locked .hex-tile-inner {
    background: rgba(251, 243, 220, 0.85);
    border-color: rgba(184, 107, 28, 0.2);
}

.hex-tile:hover .hex-tile-inner {
    background: rgba(255, 255, 255, 1);
    border-color: var(--honey);
    box-shadow: 0 6px 18px rgba(184, 107, 28, 0.2);
}

/*
 * Beim Fokus deutlich vergrößern, damit der Inhalt lesbar bleibt
 * (kleine 76px-Hex wird zu ~120px durch scale 1.6).
 */
.hex-tile.focused {
    transform: scale(1.6);
    z-index: 50;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hex-tile.focused .hex-tile-inner {
    background: white;
    border-color: var(--honey-deep);
    border-width: 2px;
    box-shadow: 0 12px 32px rgba(184, 107, 28, 0.3);
    padding: 20px 14px;  /* Mehr Padding nach Skalierung wirkt natürlicher */
}

.hex-tile-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 0.7rem;
    line-height: 1.15;
    color: var(--bark);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
    hyphens: auto;
}

.hex-tile.focused .hex-tile-title {
    font-size: 0.62rem;  /* Wegen scale(1.6) effektiv ~1rem */
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

.hex-tile-lock {
    position: absolute;
    top: 8px;
    right: 50%;
    transform: translateX(50%);
    font-size: 0.65rem;
    opacity: 0.55;
}

/* Im Hover-Modus die Page-Card überlagernd lesbar halten */
body.has-stream .page > main > .hero-content,
body.has-stream .page > main > .empty-state,
body.has-stream .page > main > h2,
body.has-stream .page > main > .hex-grid {
    background: rgba(251, 243, 220, 0.92);
    backdrop-filter: blur(6px);
    border-radius: 16px;
    padding: 24px 28px;
    box-shadow: 0 8px 32px rgba(42, 24, 16, 0.06);
    margin-bottom: 16px;
}

body.has-stream .page > main > h2 {
    padding: 16px 28px;
    margin-top: 24px;
}

body.has-stream .page > main > .hex-grid {
    padding: 28px;
}

body.has-stream .header,
body.has-stream .footer {
    background: rgba(251, 243, 220, 0.85);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    padding-left: 16px;
    padding-right: 16px;
}

/*
 * Mobile: Tile-Größe bleibt gleich (76x88), weil das Hintergrund-Pattern
 * überall die gleiche Größe hat (84x96 SVG-Tile).
 */
