/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f4f4f9; color: #1a1a2e; }
a { text-decoration: none; color: inherit; }

/* ── Colours ──────────────────────────────────────────────────── */
:root {
  --navy:   #1a1a2e;
  --blue:   #4a4a8a;
  --green:  #2e6e4a;
  --amber:  #92400e;
  --teal:   #0e5f6e;
  --red:    #7f1d1d;
  --muted:  #6b7280;
  --border: #d1d5db;
  --bg-blue:  #eef0f8;
  --bg-green: #eef8f2;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  background: var(--navy);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar h1 { font-size: 1.15rem; flex: 1; }
.topbar .back {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.topbar .back:hover { background: rgba(255,255,255,0.25); }

/* ── Card grid ────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  padding: 2rem 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 1.6rem 1.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.12); }
.card .icon { font-size: 2rem; }
.card .level { font-size: 1.5rem; font-weight: 800; color: var(--navy); }
.card .desc  { font-size: 0.82rem; color: var(--muted); }
.card .badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  margin-top: 0.3rem;
  width: fit-content;
}
.badge-active  { background: #dcfce7; color: #166534; }
.badge-locked  { background: #f3f4f6; color: #9ca3af; }

.card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Section subtitle under topbar ───────────────────────────── */
.page-sub {
  text-align: center;
  padding: 1.4rem 1rem 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Grammar page layout ──────────────────────────────────────── */
.grammar-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}
.grammar-nav {
  background: white;
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.grammar-nav a {
  display: block;
  padding: 0.55rem 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grammar-nav a:hover  { background: var(--bg-blue); color: var(--navy); }
.grammar-nav a.active { border-left-color: var(--blue); color: var(--blue); font-weight: 600; background: var(--bg-blue); }
.grammar-nav .nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  padding: 1rem 1.1rem 0.3rem;
}

.grammar-content { padding: 1.5rem 1.8rem; max-width: 900px; }

/* ── Grammar section card ─────────────────────────────────────── */
.g-section {
  margin-bottom: 2.5rem;
  scroll-margin-top: 1rem;
}
.g-section-title {
  background: var(--navy);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px 8px 0 0;
  font-size: 1rem;
  font-weight: 700;
}
.g-section-title .num { opacity: 0.55; font-size: 0.8rem; margin-right: 0.4rem; }
.g-section-body { background: white; border-radius: 0 0 8px 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow: hidden; }

/* ── Membership lock ─────────────────────────────────────────── */
.grammar-nav a.locked { color: #b6bac4; }
.grammar-nav a.locked:hover { background: var(--bg-blue); color: #b6bac4; }
.grammar-nav a.locked .lock-tag { margin-left: 0.3rem; font-size: 0.7rem; }

.g-body-wrap { position: relative; border-radius: 0 0 8px 8px; overflow: hidden; }
.g-body-wrap .g-section-body {
  filter: blur(6px);
  user-select: none;
}
/* Audio playback stays usable in locked sections — only the small badge
   below intercepts clicks, the blurred text/buttons underneath do not. */
.lock-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  cursor: pointer;
  z-index: 5;
}
.lock-overlay .lock-icon { font-size: 1.9rem; }
.lock-overlay .lock-text {
  background: var(--navy);
  color: white;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

/* ── Block types ──────────────────────────────────────────────── */
.block-label {
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
}
.block-label.blue  { background: var(--blue); }
.block-label.green { background: var(--green); }
.block-label.amber { background: var(--amber); }
.block-label.teal  { background: var(--teal); }
.block-label.red   { background: var(--red); }

/* Table */
.g-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.g-table th {
  text-align: left;
  padding: 0.45rem 0.7rem;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: white;
}
.g-table th.blue  { background: var(--blue); }
.g-table th.green { background: var(--green); }
.g-table th.amber { background: var(--amber); }
.g-table th.teal  { background: var(--teal); }
.g-table td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.g-table tr:last-child td { border-bottom: none; }
.g-table tr:nth-child(odd)  td { background: #f8f9ff; }
.g-table tr:nth-child(even) td { background: white; }
.g-table.green-rows tr:nth-child(odd)  td { background: #f2f9f5; }
.g-table.amber-rows tr:nth-child(odd)  td { background: #fdf8f2; }
.g-table.teal-rows  tr:nth-child(odd)  td { background: #f0f8fa; }

/* Rules & notes */
.g-rule {
  padding: 0.6rem 1rem;
  background: #fffbeb;
  border-left: 3px solid var(--amber);
  font-size: 0.84rem;
  color: #78350f;
  margin: 0;
}
.g-note {
  padding: 0.6rem 1rem;
  background: var(--bg-blue);
  border-left: 3px solid var(--blue);
  font-size: 0.82rem;
  color: #1e3a5f;
  margin: 0;
}

/* Example rows */
.g-examples { padding: 0.5rem 1rem; }
.g-ex-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.84rem;
}
.g-ex-row:last-child { border-bottom: none; }
.g-ex-de { color: var(--green); font-weight: 500; flex: 1; }
.g-ex-en { color: var(--muted); flex: 1; font-style: italic; }

/* Play buttons */
.play-btn {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.5);
  color: white;
  border-radius: 50px;
  padding: 0.3rem 0.9rem;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  transition: background 0.12s;
}
.play-btn:hover   { background: rgba(255,255,255,0.28); }
.play-btn.playing { background: rgba(255,200,0,0.3); border-color: gold; }

.word-play {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.word-play:hover { background: var(--blue); color: white; border-color: var(--blue); }
.word-play svg, .play-btn svg { width: 9px; height: 9px; fill: currentColor; }

/* Spacing helpers */
.mt { margin-top: 0.6rem; }

/* ── Info popup ───────────────────────────────────────────────── */
.info-btn {
  background: none;
  border: 1.5px solid white;
  color: white;
  border-radius: 50px;
  padding: 0.18rem 0.65rem;
  font-size: 0.76rem;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  margin-left: 0.5rem;
}
.info-btn:hover { background: white; color: var(--blue); }

/* Overlay */
.pop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.pop-overlay.open { display: flex; }

/* Modal box */
.pop-box {
  background: white;
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: popIn 0.18s ease;
}
@keyframes popIn {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.pop-header {
  background: var(--navy);
  color: white;
  padding: 1rem 1.2rem;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pop-header h3 { font-size: 1rem; }
.pop-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pop-close:hover { background: rgba(255,255,255,0.3); }

.pop-body {
  padding: 1.2rem 1.4rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #1a1a2e;
}
.pop-body p { margin-bottom: 0.8rem; }

/* Side-by-side case comparison */
.pop-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin: 0.8rem 0;
}
.pop-case {
  border-radius: 8px;
  padding: 0.8rem;
}
.pop-case.akk { background: #eef0f8; border: 1.5px solid var(--blue); }
.pop-case.dat { background: #eef8f2; border: 1.5px solid var(--green); }
.pop-case-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.35rem;
}
.pop-case.akk .pop-case-label { color: var(--blue); }
.pop-case.dat .pop-case-label { color: var(--green); }
.pop-case-de   { font-size: 1rem; font-weight: 600; margin-bottom: 0.15rem; }
.pop-case-en   { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; font-style: italic; }
.pop-case-q    { font-size: 0.8rem; background: white; border-radius: 4px; padding: 0.25rem 0.5rem; margin-bottom: 0.35rem; }
.pop-case-tip  { font-size: 0.8rem; color: #374151; }

.pop-rule {
  background: #fffbeb;
  border-left: 3px solid var(--amber);
  padding: 0.6rem 0.8rem;
  border-radius: 0 4px 4px 0;
  margin: 0.8rem 0;
  font-size: 0.84rem;
  color: #78350f;
  line-height: 1.7;
}
.pop-verbs {
  background: #f8f9ff;
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #374151;
}
