/* Middle Egyptian reader sample. Light and dark follow the system unless the
   reader picks one; colours are tokens so the two themes stay in step. */

@font-face {
  font-family: "Gentium Plus";
  src: url("fonts/GentiumPlus-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Gentium Plus";
  src: url("fonts/GentiumPlus-Italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #f5efe3;
  --surface: #fffcf5;
  --sunk: #ece4d3;
  --ink: #1f1b16;
  --muted: #655c4f;
  --line: #d9cfbb;
  --accent: #1c4f7a;
  --accent-soft: #dbe7f1;
  --warn: #8a4b08;
  --warn-soft: #f6e6cc;
  --role-comp: #2a6db0;
  --role-log: #a85a0c;
  --role-det: #0c7468;
  --role-gram: #5d7419;
  --serif: "Gentium Plus", "Charis SIL", "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hiero: 3.5rem;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161411;
    --surface: #201d19;
    --sunk: #2a2620;
    --ink: #ece4d6;
    --muted: #a99f8f;
    --line: #3d372e;
    --accent: #8fc0e8;
    --accent-soft: #1d3345;
    --warn: #f0b566;
    --warn-soft: #3a2a12;
    --role-comp: #7db7ee;
    --role-log: #f0a54a;
    --role-det: #56d3c4;
    --role-gram: #b3cf63;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #161411;
  --surface: #201d19;
  --sunk: #2a2620;
  --ink: #ece4d6;
  --muted: #a99f8f;
  --line: #3d372e;
  --accent: #8fc0e8;
  --accent-soft: #1d3345;
  --warn: #f0b566;
  --warn-soft: #3a2a12;
  --role-comp: #7db7ee;
  --role-log: #f0a54a;
  --role-det: #56d3c4;
  --role-gram: #b3cf63;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}
.wrap { max-width: 82rem; margin-inline: auto; padding-inline: 1rem; }
.visually-hidden, .defs {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: .5rem; top: .5rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent); }
button, select { font: inherit; color: inherit; }

/* Header */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.head-row { display: flex; align-items: center; gap: .75rem 1.5rem; flex-wrap: wrap; padding-block: .6rem; }
.eyebrow { margin: 0; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.site-head nav { display: flex; gap: .25rem 1.1rem; flex-wrap: wrap; margin-left: auto; font-size: .93rem; }
.site-head nav a { text-decoration: none; color: var(--ink); padding-block: .2rem; border-bottom: 2px solid transparent; }
.site-head nav a:hover { border-bottom-color: var(--accent); }
.theme {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: .25rem .8rem; font-size: .82rem; cursor: pointer;
}

/* Title */
.title-block { padding-block: 2.2rem 1.2rem; max-width: 46rem; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.1; margin: 0; text-wrap: balance; }
.subtitle { font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--muted); margin: .4rem 0 1rem; }
.lede { margin: 0 0 .8rem; }
.draft-note {
  margin: 0; padding: .6rem .85rem; font-size: .9rem;
  background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: 0 var(--radius) var(--radius) 0;
}
h2 { font-family: var(--serif); font-weight: 400; font-size: 1.8rem; margin: 0 0 .3rem; text-wrap: balance; }
h3 { font-size: 1rem; margin: 1.4rem 0 .3rem; }
.section-lede { color: var(--muted); margin: 0 0 1rem; max-width: 46rem; }
.sections > section { padding-block: 2.5rem; border-top: 1px solid var(--line); }
.sections p, .sections li { max-width: 46rem; }

/* Reading layout */
.layout { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 62rem) {
  .layout { grid-template-columns: minmax(0, 1fr) 24rem; }
}
.title-row { display: grid; gap: 0 1.5rem; align-items: end; }
@media (min-width: 62rem) {
  .title-row { grid-template-columns: minmax(0, 1fr) 24rem; }
}
.voice-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem .85rem; margin-bottom: 1.2rem;
}
.voice-title, .toolbar-label {
  font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0;
}
.voice-title { margin-bottom: .5rem; }
.voice-title::before { content: "▶" / ""; font-size: .7em; margin-right: .5em; color: var(--accent); vertical-align: 1px; }
.voice-note { margin: .55rem 0 0; font-size: .82rem; color: var(--muted); line-height: 1.35; }

/* Pills: checkboxes and radios drawn as rounded switches */
.pills { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.toolbar-label { margin-right: .3rem; }
.pill {
  position: relative; display: inline-flex; align-items: center; gap: .4rem;
  padding: .28rem .8rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: .9rem; line-height: 1.3;
  cursor: pointer; user-select: none;
}
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.pill:hover { border-color: var(--accent); color: var(--ink); }
.pill:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.pill:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.pill-check span::before {
  content: ""; display: inline-block; width: .8rem; height: .8rem; margin-right: .45rem; vertical-align: -1px;
  border-radius: 50%; border: 1.5px solid var(--muted);
}
.pill-check:has(input:checked) span::before {
  border-color: var(--accent);
  background: var(--accent) radial-gradient(circle, var(--surface) 0 28%, transparent 32%);
}
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; margin: .6rem 0 0; }
.legend[hidden] { display: none; }
.key::before { content: ""; display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; background: currentColor; margin-right: .35rem; vertical-align: -1px; }
.key { color: var(--ink); }
.key.role-comp { color: var(--role-comp); }
.key.role-log { color: var(--role-log); }
.key.role-det { color: var(--role-det); }
.key.role-gram { color: var(--role-gram); }

.lines { list-style: none; margin: 1rem 0 0; padding: 0; }
.line { padding: 1.1rem 0 1.3rem; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; }
.cols { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.play {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .1rem .7rem; font-size: .82rem; cursor: pointer;
}
.play::before { content: "▶"; font-size: .65em; margin-right: .4em; vertical-align: 1px; color: var(--accent); }
.play.is-playing { border-color: var(--accent); background: var(--accent-soft); }
/* pause bars drawn with borders: the ❚ character is missing from many fonts */
.play.is-playing::before {
  content: ""; display: inline-block; width: .3em; height: .78em; margin-right: .45em; vertical-align: -.06em;
  border-inline: .22em solid var(--accent);
}
.play:hover { border-color: var(--accent); }

.words { display: flex; flex-wrap: wrap; gap: .9rem .35rem; align-items: flex-start; }
.word {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .45rem .5rem .35rem; border-radius: var(--radius); border: 1px solid transparent;
  position: relative;
}
.word:hover { background: var(--surface); border-color: var(--line); }
.word.is-selected { background: var(--surface); border-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
.word.has-check::after {
  content: "?"; position: absolute; top: .15rem; right: .25rem; font-size: .7rem; font-weight: 700;
  width: 1.05rem; height: 1.05rem; line-height: 1.05rem; text-align: center; border-radius: 50%;
  background: var(--warn-soft); color: var(--warn);
}
.hiero { height: var(--hiero); width: calc(var(--hiero) * var(--ar)); display: block; overflow: visible; }
.sign { cursor: pointer; fill: var(--ink); }
.sign .hit { fill: transparent; }
.sign:hover .hit { fill: var(--accent-soft); }
.sign.is-selected .hit { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 18; }
.sign.is-same use { fill: var(--accent); }
body.show-colour .sign.role-comp { fill: var(--role-comp); }
body.show-colour .sign.role-log { fill: var(--role-log); }
body.show-colour .sign.role-det { fill: var(--role-det); }
body.show-colour .sign.role-gram { fill: var(--role-gram); }

.word-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  background: none; border: 0; padding: .1rem .2rem; cursor: pointer; border-radius: 6px; max-width: 9.5rem;
}
.translit { font-family: var(--serif); font-style: italic; font-size: 1.15rem; line-height: 1.25; }
.word-btn .gloss { font-size: .82rem; color: var(--muted); line-height: 1.25; text-align: center; }
body.hide-translit .word-btn .translit,
body.hide-gloss .word-btn .gloss,
body.hide-translation .line-foot { display: none; }
/* keep something to press when both captions are hidden */
body.hide-translit.hide-gloss .word-btn::after { content: "·"; color: var(--muted); }

.line-foot { margin-top: .7rem; }
.translation { font-family: var(--serif); font-size: 1.2rem; margin: 0; max-width: 44rem; text-wrap: pretty; }
.literal { margin: .15rem 0 0; font-size: .86rem; color: var(--muted); max-width: 44rem; }
.literal span { text-transform: uppercase; letter-spacing: .05em; font-size: .72rem; margin-right: .4rem; }

/* Notes panel */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem; font-size: .95rem;
}
@media (min-width: 62rem) {
  .panel { position: sticky; top: 4.2rem; max-height: calc(100vh - 5.2rem); overflow: auto; }
  .panel-close { display: none; }
}
@media (max-width: 61.99rem) {
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 55vh; overflow: auto;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; box-shadow: 0 -8px 24px rgb(0 0 0 / .18);
    transform: translateY(105%); visibility: hidden;
  }
  .panel.is-open { transform: none; visibility: visible; }
  body.panel-open { padding-bottom: 55vh; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 61.99rem) {
  .panel { transition: transform .2s ease, visibility .2s; }
}
.panel-close { float: right; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: .1rem .7rem; font-size: .82rem; cursor: pointer; }
.panel-empty { color: var(--muted); }
.panel-hint-title { font-family: var(--serif); font-size: 1.25rem; color: var(--ink); margin: 0 0 .3rem; }
.p-hiero { margin: .2rem 0 .5rem; }
.p-hiero .hiero { --hiero: 4.6rem; }
.p-translit { font-family: var(--serif); font-style: italic; font-size: 1.7rem; line-height: 1.1; margin: 0; }
.p-gloss { font-size: 1.05rem; margin: .15rem 0 .5rem; }
.p-say { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: 0 0 .7rem; color: var(--muted); font-size: .92rem; }
.p-say strong { color: var(--ink); font-weight: 600; }
.p-dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .8rem; margin: 0 0 .8rem; }
.p-dl dt { color: var(--muted); font-size: .82rem; padding-top: .12rem; }
.p-dl dd { margin: 0; }
.p-h { font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 1.1rem 0 .35rem; font-weight: 600; }
.p-grammar { margin: 0; }
.p-check { margin: .7rem 0 0; padding: .45rem .7rem; background: var(--warn-soft); border-left: 3px solid var(--warn); font-size: .88rem; border-radius: 0 6px 6px 0; }
.form-card { margin-top: .6rem; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; background: var(--paper); }
.form-name { font-weight: 600; margin: 0 0 .2rem; }
.form-plain { margin: 0 0 .5rem; font-size: .9rem; }
.form-labels { width: 100%; border-collapse: collapse; font-size: .86rem; }
.form-labels th { text-align: left; font-weight: 600; padding: .2rem .6rem .2rem 0; vertical-align: top; white-space: nowrap; color: var(--muted); }
.form-labels td { padding: .2rem 0; }
.form-also { margin: .45rem 0 0; font-size: .84rem; color: var(--muted); }

.sign-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.sign-row {
  display: grid; grid-template-columns: 2.6rem 1fr; gap: .7rem; align-items: center; width: 100%; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; cursor: pointer;
}
.sign-row:hover, .sign-row[aria-expanded="true"] { border-color: var(--accent); }
.sign-row svg { height: 2.2rem; width: 2.6rem; fill: var(--ink); }
.sign-row-top { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.sign-row-code { font-weight: 600; font-size: .86rem; }
.sign-row-role { font-size: .78rem; padding: 0 .45rem; border-radius: 999px; border: 1px solid currentColor; }
.sign-row-role.role-phon { color: var(--ink); }
.sign-row-role.role-comp { color: var(--role-comp); }
.sign-row-role.role-log { color: var(--role-log); }
.sign-row-role.role-det { color: var(--role-det); }
.sign-row-role.role-gram { color: var(--role-gram); }
.sign-row-value { font-family: var(--serif); font-style: italic; font-size: 1.05rem; }
.sign-row-note { display: block; font-size: .82rem; color: var(--muted); }
.sign-detail { border-left: 3px solid var(--accent); padding: .3rem 0 .3rem .7rem; margin: .1rem 0 .4rem .3rem; font-size: .9rem; }
.sign-detail p { margin: 0 0 .3rem; }
.sign-detail .cat { color: var(--muted); font-size: .82rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.chip {
  font-family: var(--serif); font-style: italic; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: .05rem .6rem; cursor: pointer; font-size: .95rem;
}
.chip:hover { border-color: var(--accent); }
.big-sign { display: flex; align-items: center; gap: 1rem; margin: .3rem 0 .6rem; }
.big-sign svg { height: 5rem; width: 5rem; fill: var(--ink); flex: none; }
.big-sign .code { font-family: var(--serif); font-size: 1.7rem; line-height: 1; margin: 0; }
.big-sign .depicts { margin: .2rem 0 0; color: var(--muted); }

/* Sign grid */
.sign-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(8.2rem, 1fr)); }
.sign-card {
  width: 100%; height: 100%; display: grid; grid-template-columns: 1fr auto; gap: .1rem .4rem; align-items: start; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .7rem; cursor: pointer;
}
.sign-card:hover { border-color: var(--accent); }
.sign-card svg { height: 3rem; width: 3.4rem; fill: var(--ink); grid-column: 1; }
.sign-count { grid-column: 2; grid-row: 1; font-size: .78rem; color: var(--muted); }
.sign-code { grid-column: 1 / -1; font-weight: 600; font-size: .86rem; }
.sign-depicts { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); line-height: 1.3; }

/* Tables */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; }
.vocab, .lab, .mapping table, .heard { width: 100%; font-size: .93rem; }
.heard { max-width: 46rem; }
.heard th, .heard td { text-align: left; padding: .4rem .8rem .4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.heard th[scope="row"] { font-weight: 400; white-space: nowrap; }
.heard td[dir="rtl"] { text-align: left; }
.vocab th, .vocab td, .lab th, .lab td, .mapping th, .mapping td { text-align: left; padding: .45rem .8rem .45rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.vocab th.translit { font-weight: 400; white-space: nowrap; }
.vocab .kind { color: var(--muted); font-size: .86rem; }
.vocab .occ a { font-family: var(--serif); font-style: italic; margin-right: .5rem; white-space: nowrap; }
.lab th[scope="row"] { font-weight: 400; min-width: 13rem; }
.lab .say, .lab .ipa { display: block; font-size: .84rem; color: var(--muted); }
.lab audio { width: 11rem; height: 2rem; display: block; }
.lab .fed { display: block; font-size: .8rem; color: var(--muted); max-width: 12rem; margin-top: .2rem; word-break: break-word; }
.th-sub { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .76rem; }
.findings { padding-left: 1.1rem; }
.findings li { margin-bottom: .35rem; }
.mapping { margin-top: 1rem; }
.mapping summary { cursor: pointer; font-weight: 600; }
.mapping table { margin-top: .6rem; max-width: 50rem; }

/* Practice */
.practice { max-width: 30rem; }
.deck-pick { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: .8rem; }
.deck-pick button { border: 0; background: var(--surface); padding: .3rem 1rem; cursor: pointer; }
.deck-pick button[aria-pressed="true"] { background: var(--accent); color: var(--paper); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; min-height: 15rem; text-align: center; }
.card-question { color: var(--muted); margin: 0 0 .8rem; font-size: .9rem; }
.card-face { display: flex; justify-content: center; }
.card-face svg { height: 6rem; fill: var(--ink); }
.card-face .hiero { --hiero: 6rem; }
.card-answer { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.card-answer .translit { font-size: 1.5rem; display: block; }
.card-answer p { margin: .2rem auto; }
.card-actions { display: flex; gap: .6rem; margin-top: .8rem; }
.card-actions button, .btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--paper); border-radius: 8px; padding: .4rem 1rem; cursor: pointer;
}
.card-actions #card-next { background: var(--surface); color: var(--ink); border-color: var(--line); }

.about-cols { display: grid; gap: 0 3rem; }
@media (min-width: 52rem) { .about-cols { grid-template-columns: 1fr 1fr; } }
.about-cols h3:first-child { margin-top: .6rem; }
.small { font-size: .84rem; color: var(--muted); }

.site-foot { border-top: 1px solid var(--line); padding-block: 1.2rem 2rem; color: var(--muted); font-size: .85rem; }
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--paper); padding: .5rem 1rem; border-radius: 999px; font-size: .9rem;
  opacity: 0; pointer-events: none;
}
.toast.is-on { opacity: 1; }

@media (forced-colors: active) {
  .word.is-selected, .sign-row[aria-expanded="true"] { outline: 2px solid Highlight; }
}
@media print {
  .site-head, .toolbar, .voice-card, .panel, .play, #practice, .toast { display: none; }
  body { background: #fff; color: #000; }
}
