/* grammar-extras.css — styling for constructs introduced by the generated
   chapters (Glossing, §1, §5–§14). The existing preview/style.css remains the
   base and is untouched; everything here only ADDS classes the older
   hand-iterated chapters (§2–§4) don't use.
   Conventions follow the dictionary (authoritative styling): Teulgi italic
   red comes from .teulgi in the base sheet; .tug never wraps. */

/* Glossed six-line examples (corpus formatting, book-faithful) */
.gloss-example { margin: 1.1rem 0 1.5rem; }
.gloss-example .cell { padding: 1px 6px; }
.gloss-example .line-teulgi .cell { font-size: 1.05em; }
.gloss-example .line-tugvut .cell .tug { font-size: 1.45em; line-height: 1.55; white-space: nowrap; }
.gloss-example .line-ipa .cell { font-family: "Charis SIL", "Doulos SIL", serif; opacity: .85; }
.gloss-example .line-morph .cell { opacity: .85; }
.gloss-example .line-gloss .cell { font-size: .92em; }
.gloss-example .line-english .cell { padding-top: 3px; }

/* Plain numbered lists in running text */
ol.chapter-list { margin: .8rem 0 1.2rem; padding-left: 2.2rem; }
ol.chapter-list li { margin: .25rem 0; }

/* Standalone Tuġvut display lines */
p.tug-line { margin: .6rem 0; }
p.tug-line .tug { font-size: 1.5em; line-height: 1.6; white-space: nowrap; }

/* Inline figures extracted from the book */
figure.chapter-figure { margin: 1.2rem 0; }
figure.chapter-figure img { max-width: 100%; height: auto; }

/* Footnotes */
sup.fnref a { text-decoration: none; }
.chapter-footnotes { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule, #ccc); }
.chapter-footnotes ol { padding-left: 1.6rem; }
.fn-back { text-decoration: none; margin-left: .35em; }

/* The whole text expands rightward rather than wrapping Tuġvut or wide
   tables — page-level horizontal panning, dictionary logic. */
.text-page.chapter { overflow-x: auto; }

/* First-line indents — the docx leading tab is an indent, per the PDF */
p.p-indent { text-indent: 1.6em; }

/* ---- batch 20260610g ---- */

/* Tables: no frame. The table shrink-wraps to its own content and centres
   in the wrap (matching the PDF, where every table is only as wide as it
   needs to be and sits centred). A table that is genuinely wider than the
   column scrolls inside .grammar-table-wrap; it is never stretched to fill. */
.grammar-table-wrap { border: 0; border-radius: 0; background: transparent; text-align: center; }
.grammar-table-wrap > .grammar-table { width: auto; display: inline-table; margin: 0 auto; }

/* Contents drawer: back link to the chapter list, carried into the
   floating panel because it lives inside the cloned <ol> */
.chapter-toc li.toc-back { list-style: none; margin: 0 0 .55rem; }
.chapter-toc li.toc-back a { font-style: italic; color: var(--ink-faint); }
.chapter-toc li.toc-back a:hover { color: var(--accent); }

/* Example pairs: identical first-column width in every TWO-column block so the
   English glosses align across the whole chapter (book tab-stop behaviour).
   Scoped to 2-cell rows (:nth-last-child(2) on the first cell) so a 3-column
   declension list — case label | sg | pl — is NOT given a 208px label column
   it does not need, which is what pushed those lists past the text column and
   produced a horizontal scrollbar. */
.example-block:not(.gloss-example) td.cell:first-child:nth-last-child(2) { min-width: 13rem; }
.example-block { margin: .9rem 0 1.1rem; }
@media (max-width: 42rem) {
  .example-block:not(.gloss-example) td.cell:first-child:nth-last-child(2) { min-width: 8.5rem; }
}

/* ---- harmonise to the dictionary (authoritative) ---- */
body { background-image: none !important; }   /* no paper grain — match the dictionary */
.theme-toggle.dict-theme {
  background: transparent; border: 1px solid var(--rule); color: var(--ink-soft);
  font: inherit; font-size: 16px; width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1; transition: border-color .12s, color .12s; }
.theme-toggle.dict-theme:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Containment: the page must never pan horizontally. Wide tables and
   long Tugvut lines scroll INSIDE .text-page.chapter (overflow-x:auto there),
   so the sticky header always spans the full page width. ---- */
/* NB: no `html, body { overflow-x: hidden }` here. On iOS that rule stops you
   panning a pinch-zoomed page, so any content past the initial viewport width
   becomes unreachable (reported as "zoom is broken"). Wide content is contained
   instead by its own scrollers: tables in .grammar-table-wrap, interlinear
   examples in .ex-scroll, and any chapter-level overflow in .text-page.chapter
   (overflow-x:auto), so the page itself never needs a horizontal clip. */
.text-page.chapter { max-width: 760px; }

/* Anchor jumps (Index, corpus links, TOC) must not land under the sticky
   header. */
html { scroll-padding-top: 5.4rem; }

/* ---- batch 20260619 (mobile inspection) ----
   Centred single-line table cells + per-block horizontal scroll (the
   dictionary's model), and themed Tuġvut. */

/* Each wide table / example scrolls on its own (like the dictionary's
   .paradigm-block) so the page never has to pan and the text stays
   full-size and legible on a phone. */
.ex-scroll, .grammar-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.ex-scroll { margin: .9rem 0 1.1rem; }

/* Grammar tables: shrink-wrap to content and centre. Never break a cell
   onto several lines; a table wider than the column scrolls in its wrap. */
.grammar-table-wrap > .grammar-table { width: auto; display: inline-table; margin: 0 auto; table-layout: auto; }

/* ---- batch 20260621g: faithful table reproduction ----
   Tables regenerated from the grammar source carry the `gtbl` modifier and
   reproduce the source exactly: every cell carries its own borders (inline,
   one declaration per side that actually has a line), its own horizontal
   alignment (.c centre / .r right / .j justify; left is the document default
   and needs no class), its own vertical alignment (.t top / .bt bottom;
   centre is the default) and the one shaded band the source uses (.s). The
   stylesheet therefore supplies only neutral defaults for gtbl tables and
   must NOT impose a frame, a header band, a uniform grid or forced centring
   — that is what made every table look the same. Border colour is left to
   inherit (currentColor) so rules follow the light/dark theme instead of
   being hard black.
   Any grammar table WITHOUT `gtbl` (i.e. not yet regenerated) keeps its
   previous look via the :not(.gtbl) rule below, so nothing regresses. */
.grammar-table:not(.gtbl) td,
.grammar-table:not(.gtbl) th { white-space: nowrap; text-align: center; vertical-align: middle; }

.grammar-table.gtbl { border-collapse: collapse; border-spacing: 0; }
.grammar-table.gtbl td {
  border: 0;                 /* lines come only from inline per-cell borders */
  padding: 5px 9px;
  font-size: 13.5px;         /* tables are typeset a touch smaller than the
                                body text, as in the PDF; this also lets the
                                wider summary tables fit the column */
  white-space: nowrap;
  text-align: left;          /* document default; .c re-centres */
  vertical-align: middle;    /* the source's common case */
  background: transparent;
  color: inherit;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
}
.grammar-table.gtbl td.c  { text-align: center; }
.grammar-table.gtbl td.r  { text-align: right; }
.grammar-table.gtbl td.j  { text-align: justify; white-space: normal; }
.grammar-table.gtbl td.t  { vertical-align: top; }
.grammar-table.gtbl td.bt { vertical-align: bottom; }
.grammar-table.gtbl td.s  { background: var(--paper-2); }

/* Wide tables (many columns) that genuinely exceed the 760px text column
   scroll horizontally inside their own .grammar-table-wrap (overflow-x:auto),
   exactly like the dictionary's paradigm blocks. A narrow table shrink-wraps
   and sits centred in the column. We deliberately do NOT break the wrapper out
   of the column with negative margins: that clipped the left edge of a wide
   table against the viewport and produced an inconsistent, broken-looking
   scroll. Keeping every table inside the column is predictable and uniform. */
.grammar-table-wrap { scrollbar-width: thin; }
.grammar-table-wrap::-webkit-scrollbar { height: 8px; }
.grammar-table-wrap::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.grammar-table-wrap::-webkit-scrollbar-track { background: transparent; }

/* On a phone, tighten gtbl cell padding and size so tables fit the viewport
   where they can (matching the base table mobile rule, which gtbl's higher
   specificity would otherwise override). */
@media (max-width: 700px) {
  .grammar-table.gtbl td { padding: 4px 6px; font-size: 12.5px; }
}

/* Example tables (interlinears + parallel examples): single-line cells;
   the .ex-scroll wrapper supplies the horizontal scroll. */
.example-block td.cell, .gloss-example td.cell { white-space: nowrap; }
.example-block, .gloss-example { width: auto; }

/* Tuġvut colour in the grammar — green in light, gold-yellow in dark.
   This sheet is loaded only on the grammar, so the dictionary and
   homepage Tuġvut are unaffected. */
:root { --tug-color: #0c5d3a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tug-color: #e8b740; } }
:root[data-theme="dark"]  { --tug-color: #e8b740; }
:root[data-theme="light"] { --tug-color: #0c5d3a; }
.tug { color: var(--tug-color); }

/* ---- batch 20260620a: gnav (grammar primary nav) ----
   The chapters + the grammar TOC carry <nav class="gnav"> (cone + Pine name
   chips for Dictionary / Grammar / Tools, plus a theme toggle) but it had no
   styling. Modelled on the home page's .pine-btn chips: the cone + Pine name
   take the section accent (red / amber / green), the romanised label stays
   neutral. Loaded only on grammar pages, so nothing else is affected. */
.site-header .gnav { display: flex; align-items: center; gap: .2rem .8rem; flex-wrap: wrap; margin-left: auto; }
/* Each chip mirrors the home page's .pine-btn: cone · English name (right-
   aligned against a hairline rule) · 1px vertical rule · Pine block (Tuġvut
   over Teulgi). The cone + English columns are fixed-width so the rule lines
   up across chips when they wrap to a vertical stack on phones. Whole chip in
   the section accent (red / amber / green), Teulgi neutral. */
.gnav-link { display: grid; grid-template-columns: 1.7rem 6.2rem 1px auto;
  align-items: center; column-gap: .5rem; text-decoration: none;
  padding: .2rem .25rem; border-radius: 7px; line-height: 1.1; color: inherit; }
.gnav-link:hover { opacity: .82; }
.gnav-link:focus-visible { outline: 1px solid var(--rule); outline-offset: 3px; }
.gnav-cone { font-family: var(--font-tug, 'Tugvut', serif); font-feature-settings: "liga" 1, "calt" 1;
  font-size: 24px; line-height: 1; display: inline-block; justify-self: center;
  transform: rotate(-90deg); transform-origin: center center; width: 1.1em; height: 1.1em;
  text-align: center; color: inherit; user-select: none; }
.gnav-en { justify-self: end; text-align: right; font-size: 1.2rem; line-height: 1.1;
  color: inherit; white-space: nowrap; }
.gnav-rule { align-self: stretch; width: 1px; min-height: 1.7rem; background: currentColor; opacity: .32; }
.gnav-pine { display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 1px; min-width: 0; }
/* override the grammar's green/gold .tug colour for the nav names: they take
   the per-section accent like the home-page buttons do */
.gnav-pine .tug { font-family: var(--font-tug, 'Tugvut', serif); font-feature-settings: "liga" 1, "calt" 1;
  font-size: 1.25rem; line-height: 1.1; white-space: nowrap; color: inherit; }
.gnav-teulgi { font-style: italic; font-size: .82rem; line-height: 1.1; color: var(--ink-soft); white-space: nowrap; }
.gnav--dict  { color: var(--pine-red,   #d81e14); }
.gnav--gram  { color: var(--pine-amber, #dc9c1e); }
.gnav--tools { color: var(--pine-green, #0c5d3a); }
/* The link to the page you are already on is dropped, not just bolded, so the
   bar shows only the pages you can go to. (Tools/Grammar mark their own link
   is-current; the dictionary has no gnav.) */
.gnav-link.is-current { display: none; }
.gnav-link.is-current .gnav-teulgi { color: var(--ink); }
.theme-toggle.gnav-theme { background: transparent; border: 1px solid var(--rule); color: var(--ink-soft);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; padding: 0; margin-left: .15rem;
  transition: border-color .12s, color .12s; }
.theme-toggle.gnav-theme:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle.gnav-theme svg { width: 17px; height: 17px; }
.gnav-pdf { color: var(--ink-soft); }
.gnav-pdf .gnav-teulgi { color: var(--ink-soft); }
@media (max-width: 75rem) {
  /* Brand keeps the only emblem; the nav becomes plain colour-coded text links
     (Dictionary / Tools) pushed to the right of the brand's row, with the theme
     toggle at the far right. Dropping the per-link cones declutters the bar and
     narrows it enough to sit on one line instead of wrapping. Grammar and Tools
     share this exact treatment so the two headers read identically. */
  .site-header .gnav { flex-wrap: nowrap; justify-content: flex-end; gap: 0 1rem;
    margin-left: auto; align-items: center; }
  .gnav-link { display: inline-flex; align-items: center; padding: .2rem 0; }
  .gnav-cone, .gnav-pine, .gnav-rule { display: none; }
  .gnav-en { font-size: 1rem; line-height: 1.15; white-space: nowrap; }
  .site-brand { padding-right: 0; }
}

/* Grammar TOC: a quiet "read as PDF" link under the subtitle (A2) */
.grammar-pdf-link { margin: .2rem 0 1.4rem; }
.grammar-pdf-link a { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none;
  font-size: .95rem; color: var(--accent); }
.grammar-pdf-link a:hover { text-decoration: underline; }
.grammar-pdf-link .gp-cone { font-family: var(--font-tug, 'Tugvut', serif); font-size: 17px;
  transform: rotate(-90deg); display: inline-block; }

/* Canonical chip order to match the dictionary/tools navs: Tools, Grammar,
   Dictionary (current page omitted via .is-current). DOM order is unchanged. */
.site-header .gnav .gnav--tools { order: 1; }
.site-header .gnav .gnav--gram  { order: 2; }
.site-header .gnav .gnav--dict  { order: 3; }

/* Theme toggle: on phones, pin it to the header's top-right corner (matching the
   homepage and the dictionary) instead of letting it wrap onto the chips row.
   The brand already reserves 52px on its right at <=800px; the <=75rem block
   zeroes that, so restore it here (this block is later in the cascade). */
@media (max-width: 800px) {
  .site-header .gnav-theme { position: absolute; top: 12px; right: 12px; }
  .site-brand { padding-right: 52px; }
}
