/* ==========================================================================
   The Hypenor Archive — design system
   Palette: sea strata (surface glass → abyss → dawn), verdigris + bronze.
   Type: Cardo (text & lapidary display), GFS Porson (Greek verse),
         IBM Plex Mono (catalogue apparatus).
   ========================================================================== */

/* ---- Fonts ---- */
@font-face { font-family: 'Cardo'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('/fonts/cardo-400i-greek-ext.woff2') format('woff2'); unicode-range: U+1F00-1FFF; }
@font-face { font-family: 'Cardo'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('/fonts/cardo-400i-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
@font-face { font-family: 'Cardo'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('/fonts/cardo-400i-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cardo'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/cardo-400-greek-ext.woff2') format('woff2'); unicode-range: U+1F00-1FFF; }
@font-face { font-family: 'Cardo'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/cardo-400-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
@font-face { font-family: 'Cardo'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/cardo-400-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cardo'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/cardo-700-greek-ext.woff2') format('woff2'); unicode-range: U+1F00-1FFF; }
@font-face { font-family: 'Cardo'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/cardo-700-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
@font-face { font-family: 'Cardo'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/cardo-700-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'GFS Porson'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/gfsporson-400-greek.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/plexmono-400-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/plexmono-500-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---- Tokens ---- */
:root {
  --surface-0: #E9EDE0;   /* sea-glass daylight */
  --surface-1: #DDE4D2;
  --shallow:   #C9D8C4;
  --photic:    #9DBCAD;
  --mesal:     #3C5F62;
  --bathyal:   #24424F;
  --deep:      #101F30;
  --abyss:     #070E19;
  --dawn:      #E4DCC6;

  --ink:       #1B2A27;   /* dark sea-ink */
  --ink-soft:  #45564F;
  --bone:      #E3DECB;   /* pale text for deep water */
  --bone-soft: #A8AC9C;

  --verdigris:      #5FA08C;
  --verdigris-deep: #2F6B5C;
  --bronze:         #A97F35;
  --bronze-bright:  #D2A55A;

  --serif: 'Cardo', 'Iowan Old Style', Georgia, serif;
  --greek: 'GFS Porson', 'Cardo', Georgia, serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --measure: 36rem;
  --measure-wide: 44rem;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  background: var(--surface-0);
  color: var(--ink);
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; height: auto; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--bronze-bright); outline-offset: 3px; border-radius: 1px; }
::selection { background: color-mix(in srgb, var(--verdigris) 40%, transparent); }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }

lang-el, .el { font-family: var(--greek); }

/* ---- Page moods ---- */
body.page-deep { background: linear-gradient(175deg, #0E2231 0%, #0A1826 55%, var(--abyss) 100%); color: var(--bone); min-height: 100vh; }
body.page-light { background: var(--surface-0); color: var(--ink); }

/* ---- Site chrome ---- */
.site-head {
  display: flex; flex-wrap: wrap; gap: 0.8rem 1.6rem; align-items: baseline;
  justify-content: space-between;
  padding: 1.4rem clamp(1.2rem, 4vw, 3rem);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
}
.site-head a { text-decoration: none; }
.site-head a:hover, .site-head a[aria-current="page"] { color: var(--bronze); }
body.page-deep .site-head a:hover, body.page-deep .site-head a[aria-current="page"] { color: var(--bronze-bright); }
.wordmark { font-weight: 500; letter-spacing: 0.22em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; }

.site-foot {
  margin-top: clamp(4rem, 10vh, 7rem);
  padding: 2.2rem clamp(1.2rem, 4vw, 3rem) 2.8rem;
  font-size: 0.85rem; line-height: 1.7;
  border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  opacity: 0.85;
}
.site-foot .el { display: block; margin-bottom: 0.3rem; font-size: 1rem; }
.site-foot a { text-decoration-style: dotted; }

/* ---- Display type ---- */
.display {
  font-family: var(--serif);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  line-height: 1.2;
}
.hero .display { text-indent: 0.18em; /* optically recentre the single centred line */ }
/* uppercase mangles polytonic Greek diacritics — never transform it */
.display [lang], .stratum-label [lang], .site-head [lang], .eyebrow [lang] { text-transform: none; }
.eyebrow {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--verdigris-deep);
}
body.page-deep .eyebrow, .stratum-dark .eyebrow { color: var(--verdigris); }

/* ---- Prose pages ---- */
.sheet { max-width: var(--measure); margin: 0 auto; padding: 0 1.2rem; }
.sheet-wide { max-width: var(--measure-wide); margin: 0 auto; padding: 0 1.2rem; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: 1.45rem; font-weight: 700; margin-top: 2.6em; line-height: 1.3; }
.prose h3 { font-size: 1.1rem; font-weight: 700; margin-top: 2em; }
.prose .lead { font-size: 1.32rem; line-height: 1.55; }
.prose blockquote { padding-left: 1.2rem; border-left: 2px solid var(--verdigris); font-style: italic; }
.prose hr { border: 0; text-align: center; margin: 2.4em 0; }
.prose hr::after { content: '⁂'; color: var(--verdigris-deep); letter-spacing: 0.5em; }
.note { font-size: 0.9rem; color: var(--ink-soft); }
body.page-deep .note { color: var(--bone-soft); }

/* ---- Verse ---- */
.verse { font-size: 1.16rem; line-height: 1.75; }
.verse .line { padding-left: 2.2em; text-indent: -2.2em; margin: 0; }
.verse .line.indent { padding-left: 3.4em; }
.verse .lacuna { opacity: 0.55; font-style: italic; }
.verse-el { font-family: var(--greek); font-size: 1.28rem; }
.lineno {
  float: right; margin-left: 1em;
  font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.08em;
  opacity: 0.5; user-select: none; transform: translateY(0.5em);
}

/* ---- Fragment entries ---- */
.fragment { max-width: var(--measure); margin: 0 auto; padding: clamp(3.5rem, 9vh, 6rem) 1.2rem; }
.fragment-head { margin-bottom: 1.6rem; }
.fr-no {
  font-family: var(--mono); font-weight: 500; font-size: 0.85rem; letter-spacing: 0.12em;
  color: var(--bronze);
}
.stratum-dark .fr-no { color: var(--bronze-bright); }
.fr-siglum { display: block; margin-top: 0.35rem; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; opacity: 0.72; }
.fr-title { font-size: 1.32rem; font-weight: 700; margin-top: 0.7rem; line-height: 1.3; }
.fragment-lost .fr-title { font-weight: 400; font-style: italic; }
.fragment-lost .verse, .fragment-lost .lost-note { opacity: 0.66; font-style: italic; }

/* Apparatus & commentary */
details.apparatus { margin-top: 1.8rem; font-size: 0.88rem; }
details.apparatus summary {
  cursor: pointer; list-style: none; display: inline-block;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--verdigris-deep);
  border-bottom: 1px dotted currentColor; padding-bottom: 0.15em;
}
.stratum-dark details.apparatus summary, body.page-deep details.apparatus summary { color: var(--verdigris); }
details.apparatus summary::-webkit-details-marker { display: none; }
details.apparatus summary::after { content: ' +'; }
details.apparatus[open] summary::after { content: ' −'; }
details.apparatus > div { margin-top: 0.9rem; padding-left: 1rem; border-left: 1px solid color-mix(in srgb, currentColor 25%, transparent); }
details.apparatus > div > p + p { margin-top: 0.55em; }
.app-crit { font-family: var(--mono); font-size: 0.78rem; line-height: 1.8; }

/* Glosses */
.gloss {
  border-bottom: 1px dotted var(--bronze);
  cursor: help; position: relative;
}
.stratum-dark .gloss, body.page-deep .gloss { border-bottom-color: var(--bronze-bright); }
.gloss[aria-expanded="true"] { color: var(--bronze); }
.gloss-tip {
  position: absolute; z-index: 30; max-width: 19rem; width: max-content;
  padding: 0.7rem 0.9rem; border-radius: 2px;
  background: var(--ink); color: var(--bone);
  font-size: 0.85rem; line-height: 1.55; font-style: normal; text-indent: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
.gloss-tip .el { color: var(--bronze-bright); }

/* ---- Doorways (landing) ---- */
.doorways { display: grid; gap: 1px; background: color-mix(in srgb, var(--bone) 22%, transparent); border: 1px solid color-mix(in srgb, var(--bone) 22%, transparent); }
.doorway { background: color-mix(in srgb, var(--abyss) 82%, transparent); padding: 1.7rem 1.6rem 1.9rem; text-decoration: none; display: block; transition: background 0.35s ease; }
.doorway:hover { background: color-mix(in srgb, var(--bathyal) 55%, var(--abyss)); }
.doorway .eyebrow { color: var(--verdigris); }
.doorway h2 { font-size: 1.25rem; font-weight: 700; margin-top: 0.5rem; }
.doorway p { margin-top: 0.5rem; font-size: 0.92rem; color: var(--bone-soft); }
.doorway:hover .eyebrow { color: var(--bronze-bright); }
@media (min-width: 720px) { .doorways { grid-template-columns: 1fr 1fr 1fr; } }

/* ---- Timeline (history) ---- */
.timeline { list-style: none; padding: 0; margin-top: 2.5rem; }
.timeline li { position: relative; padding: 0 0 2.4rem 2rem; border-left: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -0.32rem; top: 0.42em;
  width: 0.58rem; height: 0.58rem; border-radius: 50%;
  background: var(--verdigris-deep);
}
.timeline li.moment-loss::before { background: transparent; border: 1px solid var(--ink-soft); }
.timeline li.moment-find::before { background: var(--bronze); }
.timeline .when { font-family: var(--mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.timeline h3 { font-size: 1.08rem; font-weight: 700; margin: 0.3rem 0 0.4rem; }
.timeline p { font-size: 0.95rem; }

/* ---- Scholars ---- */
.scholars { display: grid; gap: 2rem 2.5rem; margin-top: 2.5rem; }
@media (min-width: 680px) { .scholars { grid-template-columns: 1fr 1fr; } }
.scholar h3 { font-size: 1.05rem; font-weight: 700; }
.scholar .role { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); margin-top: 0.2rem; }
.scholar p { font-size: 0.95rem; margin-top: 0.6rem; }

/* ---- Ledger table ---- */
.ledger { margin: 2.2rem 0; overflow-x: auto; }
.ledger table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.ledger th {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; text-align: left;
  color: var(--ink-soft); padding: 0 1rem 0.6rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
}
.ledger td { padding: 0.55rem 1rem 0.55rem 0; vertical-align: top; border-bottom: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.ledger td:first-child { font-family: var(--mono); font-size: 0.78rem; color: var(--bronze); white-space: nowrap; }
.ledger td:last-child { font-style: italic; }

/* ---- Map ---- */
.map-figure { margin: 2.5rem 0; }
.map-figure svg { display: block; width: 100%; }
.map-figure figcaption { margin-top: 0.8rem; font-size: 0.85rem; color: var(--ink-soft); font-style: italic; }

/* ---- Descent page (fragments) ---- */
body.page-descent { background: var(--surface-0); transition: none; position: relative; }
#descent-bg {
  position: absolute; top: 0; left: 0; right: 0; z-index: -2; min-height: 100%;
  /* no-JS fallback: an approximate descent; JS repaints with measured stops */
  background: linear-gradient(to bottom,
    #E9EDE0 0%, #E9EDE0 16%, #A9C4B4 24%, #A9C4B4 36%, #3C5F62 44%, #3C5F62 56%,
    #1B3A4A 62%, #1B3A4A 70%, #070E19 76%, #070E19 86%, #E4DCC6 96%, #E4DCC6 100%);
}
#snow { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

.stratum { position: relative; }
.stratum-light { color: var(--ink); }
.stratum-dark { color: var(--bone); }

/* Depth gauge */
#gauge {
  position: fixed; top: 50%; transform: translateY(-50%);
  left: clamp(0.6rem, 2.2vw, 2.2rem);
  height: min(52vh, 30rem); width: 3.2rem;
  z-index: 5; display: none;
  font-family: var(--mono);
}
@media (min-width: 980px) { #gauge { display: block; } }
#gauge .rail { position: absolute; left: 0.4rem; top: 0; bottom: 0; width: 1px; background: color-mix(in srgb, currentColor 35%, transparent); }
#gauge .tick { position: absolute; left: 0.4rem; width: 0.45rem; height: 1px; background: color-mix(in srgb, currentColor 35%, transparent); }
#gauge .tick.major { width: 0.8rem; }
#gauge .marker {
  position: absolute; left: 0.4rem; width: 0.6rem; height: 0.6rem;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--bronze-bright);
  transition: top 0.18s ease-out;
}
#gauge .readout {
  position: absolute; left: 1.5rem; transform: translateY(-50%);
  font-size: 0.68rem; letter-spacing: 0.1em; white-space: nowrap;
  transition: top 0.18s ease-out;
}
#gauge .readout .unit { opacity: 0.6; }

/* Fragment page header */
.descent-head { max-width: var(--measure); margin: 0 auto; padding: clamp(3rem, 9vh, 6rem) 1.2rem 1rem; }
.descent-head h1 { font-size: clamp(1.5rem, 4.5vw, 2.2rem); }
.descent-head .lead { margin-top: 1.4rem; font-size: 1.05rem; color: var(--ink-soft); max-width: 34rem; }

/* Stratum labels — like depth annotations on a sounding chart */
.stratum-label {
  max-width: var(--measure); margin: 0 auto; padding: clamp(2rem, 6vh, 4rem) 1.2rem 0;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.6;
}

/* ---- Names page ---- */
.tablet-wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.2rem; }
#water { display: block; width: 100%; height: 16rem; margin: 2.2rem 0 0; border: 1px solid color-mix(in srgb, var(--bone) 20%, transparent); background: radial-gradient(120% 100% at 50% 0%, #0F2536 0%, #0A1B2B 55%, #071220 100%); }
.name-form { display: flex; gap: 0.8rem; margin-top: 1.4rem; flex-wrap: wrap; }
.name-form input {
  flex: 1 1 14rem; padding: 0.75rem 1rem;
  font-family: var(--serif); font-size: 1.05rem;
  background: color-mix(in srgb, var(--bone) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--bone) 30%, transparent);
  border-radius: 2px; color: var(--bone);
}
.name-form input::placeholder { color: var(--bone-soft); opacity: 0.8; }
.name-form button {
  padding: 0.75rem 1.5rem; border: 1px solid var(--bronze);
  font-family: var(--mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--bronze-bright); border-radius: 2px;
  transition: background 0.3s ease, color 0.3s ease;
}
.name-form button:hover { background: var(--bronze); color: var(--abyss); }
.name-form button:disabled { opacity: 0.45; cursor: default; }
#tally { margin-top: 2rem; font-size: 0.95rem; color: var(--bone-soft); min-height: 1.6em; }
#tally strong { color: var(--bone); font-weight: 700; }

/* ---- 404 ---- */
.lost-page { min-height: 70vh; display: grid; place-content: center; text-align: center; padding: 2rem 1.2rem; }
.lost-page .fr-no { font-size: 1rem; }
.lost-page h1 { font-size: 1.6rem; margin-top: 1rem; }
.lost-page p { margin-top: 1rem; color: var(--bone-soft); }

/* ---- Motion ---- */
@keyframes surface-rise {
  from { opacity: 0; transform: translateY(1.6rem); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.rise { animation: surface-rise 1.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
.rise-2 { animation-delay: 0.45s; }
.rise-3 { animation-delay: 0.9s; }
.rise-4 { animation-delay: 1.35s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise, .rise-2, .rise-3, .rise-4 { animation: none; }
  #gauge .marker, #gauge .readout { transition: none; }
  * { animation-duration: 0.01ms !important; }
}

/* ---- Small screens ---- */
@media (max-width: 560px) {
  body { font-size: 1.09rem; }
  .verse { font-size: 1.05rem; }
  .verse .line { padding-left: 1.4em; text-indent: -1.4em; }
  .verse .line.indent { padding-left: 2.2em; }
}
