/* ===========================================================
   Deutsche Lernen — base styles
   =========================================================== */

/* ---- Manrope Variable (self-hosted, weights 200-800) ---- */
@font-face {
  font-family: 'Manrope Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  /* Tweakable */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --density-pad-sm: 12px;
  --density-pad-md: 20px;
  --density-pad-lg: 32px;
  --font-base: 'Manrope Variable', system-ui, -apple-system, sans-serif;
  --weight-heading: 800;

  /* Palette — light (default, milky/warm) */
  --bg: #F5F5F0;
  --bg-elev: #FBFAF5;
  --bg-sunk: #EFEEE8;
  --border: #E2E1D8;
  --border-strong: #C9C7BB;
  --text: #1A1A1A;
  --text-muted: #5A5A55;
  --text-dim: #8A8A82;

  --accent: #C9A227;        /* gold, slightly muted from #FFCE00 */
  --accent-strong: #B08A12;
  --accent-soft: #F5E9B8;
  --accent-bg: #FAF1CC;

  --danger: #C20A0A;        /* red, slightly muted from #DD0000 */
  --danger-soft: #F8D7D7;

  --success: #2E7D4F;
  --success-soft: #D9EBDF;

  /* Primary button — softer warm charcoal instead of harsh pure black */
  --btn-bg: #3D3B34;
  --btn-fg: #F7F6F1;

  --shadow-sm: 0 1px 2px rgba(20, 20, 16, 0.04);
  --shadow-md: 0 2px 8px rgba(20, 20, 16, 0.06), 0 1px 2px rgba(20, 20, 16, 0.04);
  --shadow-lg: 0 8px 24px rgba(20, 20, 16, 0.08), 0 2px 6px rgba(20, 20, 16, 0.04);
}

[data-theme="dark"] {
  --bg: #14130F;
  --bg-elev: #1C1B17;
  --bg-sunk: #0F0E0B;
  --border: #2C2A24;
  --border-strong: #3A3830;
  --text: #F0EFE8;
  --text-muted: #A6A49B;
  --text-dim: #6E6C64;

  --accent: #E5BC3C;
  --accent-strong: #FFCE00;
  --accent-soft: #4A3A0F;
  --accent-bg: #2E2616;

  --danger: #E64545;
  --danger-soft: #3A1A1A;

  --success: #5DBA82;
  --success-soft: #1A2E22;

  /* Primary button — soft light surface on dark */
  --btn-bg: #EAE8DF;
  --btn-fg: #1A1A1A;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Density variants applied to <body> */
body[data-density="compact"] {
  --density-pad-sm: 8px;
  --density-pad-md: 14px;
  --density-pad-lg: 22px;
}
body[data-density="spacious"] {
  --density-pad-sm: 16px;
  --density-pad-md: 28px;
  --density-pad-lg: 44px;
}

/* Reset-ish */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* ===========================================================
   Top bar
   =========================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-text small {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
@media (max-width: 480px) {
  .brand-text { display: none; }
}

.nav-main {
  display: flex;
  gap: 4px;
  flex: 1;
  margin-left: 16px;
  flex-wrap: wrap;
}
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.nav-link:hover { background: var(--bg-sunk); color: var(--text); }
.nav-link.active { color: var(--text); background: var(--bg-sunk); }
.nav-link.active::after {
  content: '';
  display: block;
  height: 2px;
  width: 100%;
  background: var(--accent);
  margin-top: 6px;
  border-radius: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 16px; height: 16px; }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.lang-switch button {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-switch button.active {
  background: var(--text);
  color: var(--bg);
}
.lang-switch button:hover:not(.active) { color: var(--text); }

.menu-btn { display: none; }
@media (max-width: 920px) {
  .nav-main { display: none; }
  .menu-btn { display: inline-flex; }
  .nav-main.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    margin: 0;
    gap: 4px;
  }
  .nav-main.open .nav-link.active::after { display: none; }
}

/* ===========================================================
   Layout
   =========================================================== */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.page-header {
  margin-bottom: var(--density-pad-lg);
}
.crumb {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 12px;
}

/* Breadcrumb — clickable path blocks */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.breadcrumb .bc-item,
.breadcrumb .bc-current {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.1;
  border: 1px solid transparent;
  white-space: nowrap;
}
.breadcrumb .bc-item {
  color: var(--text-muted);
  background: var(--bg-sunk);
  border-color: var(--border);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.breadcrumb .bc-item:hover {
  color: var(--text);
  background: var(--accent-bg);
  border-color: var(--accent);
}
.breadcrumb .bc-current {
  color: var(--accent-strong);
  background: var(--accent-bg);
  border-color: var(--accent-soft);
}
.breadcrumb .bc-sep {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  user-select: none;
}
@media (pointer: coarse) {
  .breadcrumb .bc-item,
  .breadcrumb .bc-current { padding: 9px 15px; }
}
h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(36px, 5vw, 56px); line-height: 1.05; }
h2 { font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
h3 { font-size: 18px; line-height: 1.3; }

.lede {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 60ch;
  text-wrap: pretty;
}

/* ===========================================================
   Cards / buttons
   =========================================================== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--density-pad-md);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  border-color: var(--border-strong);
}
.card-link {
  display: block;
  cursor: pointer;
}
.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
}
.btn-primary:hover { background: var(--accent-strong); color: #1A1A1A; }
.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-sunk); }
.btn-accent {
  background: var(--accent);
  color: #1A1A1A;
  border-color: var(--accent-strong);
}
.btn-accent:hover { background: var(--accent-strong); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }

/* ===========================================================
   Tags / badges / chips
   =========================================================== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.tag-level {
  background: var(--accent-bg);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}
.tag-soon {
  background: var(--bg-sunk);
  color: var(--text-dim);
}

/* Pill toggle: shared by task tabs, level buttons, timer switch */
.pill-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pill-toggle.is-active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-strong);
}
.pill-toggle.is-static {
  cursor: default;
  color: var(--text-dim);
}
.pill-toggle.pill-level {
  min-width: 56px;
  font-weight: 700;
}

/* ===========================================================
   Progress
   =========================================================== */
.progress-track {
  height: 6px;
  background: var(--bg-sunk);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(.2,.7,.2,1);
}

/* Decorative band */
.flag-band {
  display: flex;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  width: 48px;
}
.flag-band span:nth-child(1) { background: #1A1A1A; flex: 1; }
.flag-band span:nth-child(2) { background: var(--danger); flex: 1; }
.flag-band span:nth-child(3) { background: var(--accent); flex: 1; }

/* Utility */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 20px; }
/* Narrow centered column — matches home stage width */
.content-col { max-width: 476px; margin-left: auto; margin-right: auto; }
/* Reading view column — wider than the default content column */
.content-col.lesen-read { max-width: 980px; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Soon / placeholder */
.soon-card {
  text-align: center;
  padding: 80px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}
.soon-card .icon {
  width: 56px; height: 56px;
  margin: 0 auto 20px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg);
  color: var(--accent-strong);
}

/* ===========================================================
   Grammatik — theory blocks
   =========================================================== */
.theory { display: flex; flex-direction: column; gap: 16px; padding-left: 3%; }
.theory p { margin: 0; line-height: 1.65; }
.theory h2 {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 18px 0 0;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.theory h2:first-child { margin-top: 0; }
.theory h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 10px 0 0;
  color: var(--text);
  line-height: 1.4;
}
.theory h3:first-child { margin-top: 0; }
/* Headings that introduce a table sit centered above it */
.theory h3:has(+ .table-wrap) { text-align: center; }
.theory h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 8px 0 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.theory hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}
/* Drop the divider that sits directly under a table */
.theory .table-wrap + hr { display: none; }
/* Drop the divider that sits directly under a Wichtig callout */
.theory blockquote + hr { display: none; }
/* Extra breathing room between a table and the text right under it */
.theory .table-wrap + p { margin-top: 10px; }
.theory strong { font-weight: 700; color: var(--text); }
.theory code {
  font-family: 'IBM Plex Sans', ui-monospace, monospace;
  font-size: 0.92em;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}
.theory blockquote {
  margin: 0 auto;
  width: 100%;
  background: var(--bg-sunk);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}
.theory blockquote p { margin: 0; }
.theory ul { margin: 8px 0 0; padding-left: 22px; line-height: 1.65; }
.theory ul li { margin-bottom: 4px; }
.theory ol { margin: 8px 0 0; padding-left: 22px; line-height: 1.65; }
.theory ol li { margin-bottom: 4px; }
.theory .note {
  background: var(--bg-sunk);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
}
.theory .ex {
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'IBM Plex Sans', monospace;
  font-size: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.theory table {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.theory th, .theory td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
}
.theory th:last-child, .theory td:last-child { border-right: none; }
.theory tr:last-child td { border-bottom: none; }
.theory th {
  background: var(--bg-sunk);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.theory td:first-child { font-weight: 500; color: var(--text-muted); }

/* breathing room before a table + center it within the column */
.theory .table-wrap {
  width: 100%;
  margin-top: 12px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.topic-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.topic-row:hover { border-color: var(--accent); background: var(--accent-bg); }
.topic-num {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunk);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--text-muted);
}
.topic-title { font-weight: 600; font-size: 15px; }
.topic-cat { font-size: 12px; color: var(--text-dim); margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; }

.kapitel-block { margin-bottom: 28px; }
.kapitel-head {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--text);
}
.kapitel-num {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 700; color: var(--accent-strong);
}
.kapitel-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.topic-list { display: flex; flex-direction: column; gap: 8px; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  margin-top: 80px;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 13px;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

/* ===========================================================
   Responsive / cross-device (phones, tablets, desktops)
   =========================================================== */

/* iOS / touch hardening */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overflow-x: hidden;                 /* guard against accidental sideways scroll */
  -webkit-tap-highlight-color: transparent;
}
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
input, textarea, select { font-size: 16px; }   /* prevents iOS zoom-on-focus */

/* honour notches / safe areas on phones */
.topbar-inner {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}
.page {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

/* grammar tables scroll horizontally instead of breaking layout */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* On touch / coarse pointers, guarantee comfortable hit targets */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .icon-btn { width: 42px; height: 42px; }
  .nav-link { padding: 12px 14px; }
  .lang-switch button { padding: 9px 12px; }
}

/* Tablet */
@media (max-width: 768px) {
  .page { padding: 24px 20px 64px; }
  .lede { font-size: 16px; }
  .footer { padding: 28px 20px; margin-top: 56px; }
  .topbar-inner { padding: 12px 18px; gap: 14px; }
}

/* Phone */
@media (max-width: 560px) {
  body { font-size: 15px; }
  .page { padding: 20px 16px 56px; }
  .page-header { margin-bottom: 24px; }
  .lede { font-size: 15px; }

  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .topbar-actions { gap: 6px; }

  /* let header rows wrap rather than overflow */
  .row-between { flex-wrap: wrap; }

  /* grammar theory: tighter tables + scrollable */
  .theory table { font-size: 13px; }
  .theory th, .theory td { padding: 8px 10px; }
  .theory h2 { font-size: 20px; }

  /* topic rows: drop the trailing chevron column gracefully */
  .topic-row { grid-template-columns: 32px 1fr auto; gap: 10px; padding: 12px 14px; }

  /* dictionary translate panel: stack the two text areas */
  .tr-grid { grid-template-columns: 1fr !important; }

  .kapitel-title { font-size: 18px; }

  .footer-inner { flex-direction: column; gap: 8px; }
}

/* Very small phones */
@media (max-width: 360px) {
  .page { padding: 18px 12px 48px; }
  .lang-switch button { padding: 7px 8px; letter-spacing: 0.04em; }
}

/* Landscape phones / short viewports: don't waste vertical space */
@media (max-height: 480px) and (orientation: landscape) {
  .page { padding-top: 18px; padding-bottom: 32px; }
}
