/* =============================================================
   grammar.css — Responsive stylesheet for grammar, word-order,
   and connectors pages.
   Design: minimalist dark, mobile-first, content-first.

   This file is loaded AFTER style.css and overrides ONLY the
   content width (--site-width -> 1000px). The header / nav bar use
   --shell-width from style.css, which is the same on every page,
   so the navbar does not move when navigating to/from the trainer.
   ============================================================= */

/* ── GRAMMAR-PAGE WIDTH OVERRIDE ──
   Reference pages are 1000px wide. We do this by overriding the CSS
   custom property so every container that uses --site-width picks it up
   automatically without duplicating selectors.
*/
:root {
  --site-width: 1000px;
}

/* ── PAGE CONTAINER ──
   max-width includes the horizontal padding, so the *content box* is exactly
   --site-width wide and its edges line up with the navbar (which is
   --shell-width wide, with no inner padding). */
.page-container {
  width: 100%;
  max-width: calc(var(--site-width) + 2 * var(--site-pad));
  margin: 0 auto;
  padding: 24px var(--site-pad) 64px;
  box-sizing: border-box;
}

/* ── HERO BANNER ── */
.hero-banner {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 28px 24px;
  margin-bottom: 32px;
  position: relative;
}

.hero-title {
  font-size: clamp(22px, 5vw, 42px);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 10px;
  color: var(--text);
  overflow-wrap: break-word;
  word-break: normal;
}

.hero-subtitle {
  font-size: clamp(13px, 2vw, 16px);
  color: var(--text-dim);
  max-width: 100%;
  line-height: 1.6;
  overflow-wrap: break-word;
}

/* ── CATEGORY SECTION HEADING ──
   Used to introduce groups of related grammar cards,
   e.g. "Tenses & Time" above the tense cards.
*/
.category-heading {
  margin: 36px 0 8px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.category-heading h2 {
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  color: var(--text);
}

.category-heading .category-desc {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── QUICK NAVIGATION GRID ── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 36px;
}

/* Quick cards are anchor elements — make the whole card clickable */
.quick-card {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 14px 16px;
  transition: border-color 0.2s, background 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  /* Ensure no child can force the card wider than the grid column */
  min-width: 0;
}

.quick-card:hover {
  border-color: var(--accent);
  background: rgba(204, 0, 0, 0.04);
}

.quick-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quick-card:active {
  background: rgba(204, 0, 0, 0.08);
}

.quick-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: break-word;
}

.quick-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

/* Small arrow to signal clickability */
.quick-card::after {
  content: '→';
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  transition: color 0.2s, transform 0.2s;
  display: block;
  transform: translateX(0);
}

.quick-card:hover::after {
  color: var(--accent);
  transform: translateX(3px);
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.filter-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 0px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-tab:hover {
  color: var(--text);
  border-color: var(--accent);
}

.filter-tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ── TENSE CARD (grammar.html) ── */
.tense-card {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 28px 24px;
  margin-bottom: 28px;
  box-shadow: none;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.tense-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.tense-name-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.tense-title {
  font-size: clamp(17px, 3vw, 24px);
  font-weight: 800;
  color: var(--text);
  overflow-wrap: break-word;
  min-width: 0;
}

.tense-de-name {
  font-size: clamp(12px, 1.8vw, 16px);
  color: var(--text-dim);
  font-weight: 500;
  overflow-wrap: break-word;
  min-width: 0;
}

.badge-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.level-badge {
  background: transparent;
  border: 1px solid var(--akk);
  color: var(--akk);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 0px;
  white-space: nowrap;
}

.freq-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 0px;
  white-space: nowrap;
}

.freq-badge.essential {
  background: transparent;
  color: var(--freq-green);
  border: 1px solid var(--freq-green);
}

.freq-badge.common {
  background: transparent;
  color: var(--freq-yellow);
  border: 1px solid var(--freq-yellow);
}

.freq-badge.formal {
  background: transparent;
  color: var(--freq-gray);
  border: 1px solid var(--freq-gray);
}

/* ── FORMULA BOX ──
   The formula itself stays on ONE line.
   The container scrolls horizontally on narrow screens.
   The page does NOT get wider — only the formula container scrolls.
   ── */
.formula-box {
  /* Scrollable container */
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  /* Visual appearance */
  background: transparent;
  border-left: 4px solid var(--accent);
  border-radius: 0px;
  padding: 14px 18px;
  margin-bottom: 16px;
  /* Layout of inner content */
  display: flex;
  align-items: center;
  gap: 8px;
  /* Keep formula intact on one line */
  white-space: nowrap;
  /* Monospace for grammar formulas */
  font-family: 'Inter', monospace;
  font-size: clamp(12px, 2vw, 15px);
  color: var(--text);
}

.formula-tag {
  background: transparent;
  border: 1px solid var(--akk);
  color: var(--akk);
  padding: 3px 7px;
  border-radius: 0px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── USAGE LIST ── */
.usage-list {
  margin-bottom: 20px;
  padding-left: 20px;
  color: var(--text-dim);
  line-height: 1.7;
  font-size: clamp(12px, 1.8vw, 14px);
}

.usage-list li {
  margin-bottom: 8px;
  overflow-wrap: break-word;
  word-break: normal;
}

.usage-list strong {
  color: var(--text);
}

/* Inline italic examples — allow wrapping; they are not formulas */
.usage-list li i {
  font-size: clamp(11px, 1.6vw, 14px);
  overflow-wrap: break-word;
  word-break: normal;
}

/* ── TABLE WRAPPER ──
   Every .example-table must be wrapped in a .table-scroll div.
   ── */
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  margin: 16px 0;
}

.example-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: clamp(12px, 1.8vw, 14px);
  table-layout: auto;
}

.example-table th,
.example-table td {
  padding: 9px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: clamp(11px, 1.6vw, 14px);
}

.example-table td:first-child {
  white-space: nowrap;
  font-size: clamp(11px, 1.5vw, 13px);
  padding-right: 20px;
}

.example-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: clamp(10px, 1.3vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.example-table tr:last-child td {
  border-bottom: none;
}

/* ── TEXT HIGHLIGHT CLASSES ── */
.hl-verb {
  color: var(--akk);
  font-weight: 700;
}

.hl-aux {
  color: var(--dat);
  font-weight: 700;
}

.translation {
  color: var(--text-muted);
  font-style: italic;
}

/* ── SECTION CARD (word-order.html) ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 28px 24px;
  margin-bottom: 28px;
  box-shadow: none;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.section-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.section-title {
  font-size: clamp(16px, 2.8vw, 22px);
  font-weight: 800;
  color: var(--text);
  overflow-wrap: break-word;
  min-width: 0;
}

.badge-v2 {
  background: transparent;
  border: 1px solid var(--akk);
  color: var(--akk);
  padding: 4px 10px;
  border-radius: 0px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.badge-end {
  background: transparent;
  border: 1px solid var(--wrong);
  color: var(--wrong);
  padding: 4px 10px;
  border-radius: 0px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

/* ── SENTENCE DIAGRAM ──
   Blocks must stay on ONE line — horizontal scroll inside container.
   ── */
.sentence-diagram {
  display: flex;
  gap: clamp(8px, 1.5vw, 16px);
  margin: 20px 0;
  flex-wrap: nowrap;
  align-items: flex-start;
  border-left: 2px solid var(--border);
  padding-left: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.block-pos {
  font-size: clamp(8px, 1.2vw, 11px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.block.pos1 .block-pos { color: var(--dat); }
.block.pos2 .block-pos { color: var(--akk); }
.block.end  .block-pos { color: var(--wrong); }

.block-text {
  font-weight: 700;
  font-size: clamp(13px, 2.2vw, 18px);
  color: var(--text);
  white-space: nowrap;
}

.block.pos2 .block-text {
  color: var(--akk);
  border-bottom: 2px solid var(--akk);
  display: inline-block;
}

/* ── TEKAMOLO GRID ── */
.tekamolo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.tekamolo-card {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 14px;
}

.tekamolo-letter {
  font-size: 22px;
  font-weight: 800;
  color: var(--akk);
  margin-bottom: 4px;
}

.tekamolo-type {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}

.tekamolo-question {
  font-size: 11px;
  color: var(--dat);
  font-weight: 600;
  margin-bottom: 4px;
}

.tekamolo-example {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* ── RULE BOX ── */
.rule-box {
  background: transparent;
  border-left: 4px solid var(--accent);
  border-radius: 0px;
  padding: 14px 18px;
  margin: 14px 0;
  color: var(--text-dim);
  font-size: clamp(12px, 1.8vw, 14px);
  line-height: 1.6;
  overflow-wrap: break-word;
}

.rule-box strong {
  color: var(--text);
}

/* ── GROUP HEADER (connectors.html) ── */
.group-header {
  margin: 32px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.group-title {
  font-size: clamp(17px, 3vw, 22px);
  font-weight: 800;
  color: var(--text);
  overflow-wrap: break-word;
  min-width: 0;
}

.effect-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 0px;
  white-space: nowrap;
  flex-shrink: 0;
}

.effect-pill.pos0 {
  background: transparent;
  color: var(--correct);
  border: 1px solid var(--correct);
}

.effect-pill.pos1 {
  background: transparent;
  color: var(--akk);
  border: 1px solid var(--akk);
}

.effect-pill.end {
  background: transparent;
  color: var(--wrong);
  border: 1px solid var(--wrong);
}

/* ── CONNECTOR GRID (connectors.html) ──
   Desktop:  3 columns
   Tablet:   2 columns (≤ 700px)
   Mobile:   1 column  (≤ 480px)

   Uses minmax(0, 1fr) — the `0` prevents any child's intrinsic
   min-size from making the column wider than its fraction share.
   Long German words will wrap instead of stretching the grid.
*/
.connector-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

/* ── CONNECTOR CARD ── */
.connector-card {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 20px;
  transition: border-color 0.2s;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Critical: prevent content from expanding past the grid column */
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.connector-card:hover {
  border-color: var(--accent);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 10px;
  /* Both children can shrink */
  min-width: 0;
}

.term-title {
  font-size: clamp(16px, 2.5vw, 20px);
  font-weight: 800;
  color: var(--text);
  /* Allow long compound words to wrap */
  overflow-wrap: break-word;
  word-break: normal;
  min-width: 0;
}

.level-tag {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 0px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sense-text {
  font-size: 13px;
  color: var(--dat-light);
  font-weight: 600;
  margin-bottom: 6px;
  overflow-wrap: break-word;
}

.translation-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
  overflow-wrap: break-word;
}

/* ── EXAMPLE BOX ──
   Educational sentences must NOT be truncated.
   Allow wrapping — the card stays within the grid column.
*/
.example-box {
  background: transparent;
  border-radius: 0px;
  padding: 10px 16px;
  font-size: clamp(11px, 1.8vw, 13.5px);
  line-height: 1.65;
  border-left: 4px solid var(--accent);
  /* No overflow:hidden — we want text to wrap, not clip */
  min-width: 0;
}

.example-de {
  color: var(--text);
  margin-bottom: 4px;
  /* Allow sentences to wrap naturally — do NOT truncate */
  overflow-wrap: break-word;
  word-break: normal;
  font-size: clamp(11px, 1.8vw, 13.5px);
}

.example-de mark {
  background: transparent;
  color: var(--akk);
  font-weight: 800;
  padding: 0;
  border-radius: 0px;
  border-bottom: 2px solid var(--akk);
}

.example-en {
  font-size: clamp(10px, 1.4vw, 12px);
  color: var(--text-muted);
  font-style: italic;
  /* Allow sentences to wrap naturally — do NOT truncate */
  overflow-wrap: break-word;
  word-break: normal;
}

/* ── RESPONSIVE BREAKPOINTS ── */

/* Tablet */
@media (max-width: 700px) {
  .connector-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablet / small desktop — card padding reduction */
@media (max-width: 768px) {
  .page-container {
    padding-top: 20px;
    padding-bottom: 48px;
  }

  .tense-card,
  .section-card {
    padding: 20px 16px;
  }

  .hero-banner {
    padding: 22px 18px;
  }
}

/* Mobile — single column */
@media (max-width: 480px) {
  .connector-grid {
    grid-template-columns: 1fr;
  }

  .page-container {
    padding-top: 16px;
    padding-bottom: 40px;
  }

  .tense-card,
  .section-card {
    padding: 16px 12px;
  }

  .hero-banner {
    padding: 18px 14px;
  }

  .formula-box {
    font-size: 12px;
    padding: 11px 14px;
  }

  .tense-header {
    flex-direction: column;
    gap: 8px;
  }

  .badge-wrap {
    flex-wrap: wrap;
  }

  .tekamolo-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .group-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* Extra-small phone (~320-390px) */
@media (max-width: 390px) {
  .page-container {
    padding-top: 14px;
    padding-bottom: 36px;
  }

  .tense-card,
  .section-card {
    padding: 14px 10px;
  }

  .hero-banner {
    padding: 16px 12px;
  }

  .tekamolo-grid {
    grid-template-columns: 1fr;
  }

  .connector-grid {
    gap: 12px;
  }

  .quick-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}