:root {
  --marble: #edf0ef;
  --marble-2: #e1e6e5;
  --vein: #8b959b;
  --ink: #14223a;
  --sea: #2b5a87;
  --saffron: #d39a2c;
  --on-dark: #f4f6f5;

  --greek: "GFS Didot", "Gentium Book Plus", serif;
  --text: "Gentium Book Plus", "GFS Didot", Georgia, serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.75rem;
  --step-3: clamp(2rem, 4.6vw, 4.25rem);
  --gutter: clamp(16px, 4vw, 56px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--marble);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h2 { font: 400 var(--step-2)/1.2 var(--greek); margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.hosting-notice { max-width: 48rem; padding: 10px 14px; border-left: 2px solid var(--saffron); background: rgb(20 34 58 / .82); color: var(--on-dark); font-size: .9rem; line-height: 1.4; }

/* Header, floating over the painting */
.bar {
  position: absolute; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 20px var(--gutter);
  color: var(--on-dark);
  text-shadow: 0 1px 12px rgb(0 0 0 / .45);
  pointer-events: none;   /* the bar spans the hero; only its links take taps */
}
.bar a { pointer-events: auto; }
.mark { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; text-decoration: none; }
.mark-gr { font: 400 1.9rem/1 var(--greek); }
.mark-en { font-style: italic; font-size: var(--step--1); opacity: .85; }
.bar nav { display: flex; gap: 1.5rem; }
.bar nav a { text-decoration: none; border-bottom: 1px solid transparent; }
.bar nav a:hover { border-color: currentColor; }

/* Hero */
.hero {
  position: relative;
  min-height: max(620px, 100svh);
  color: var(--on-dark);
  overflow: hidden;
  background: #0d1522;
}
.stage { position: absolute; inset: 0; }
.stage canvas, .stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; object-fit: cover; image-rendering: pixelated;
}
/* Header legibility only; the shadow behind the quote is drawn (and dithered) in the shader. */
.scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgb(10 18 32 / .45), rgb(10 18 32 / 0) 18%);
}
/* Shadow behind the quote, laid over the dither as two layers:
   .shade darkens (a radial gradient with gaussian-like stops), .shade-blur softens
   (backdrop blur under a matching mask). Kept separate because some renderers drop
   the darkening when a backdrop-filter and a mask share one element. */
.shade, .shade-blur {
  --at: 26% 74%;
  --ellipse: ellipse 78% 72% at var(--at);
  position: absolute; left: 0; bottom: 0; z-index: 1;
  width: min(1300px, 100%); height: 100%;
  pointer-events: none;
}
.shade {
  --k: var(--shade, .9);
  background: radial-gradient(var(--ellipse),
    rgb(0 0 0 / var(--k)) 0%,
    rgb(0 0 0 / var(--k)) 30%,
    rgb(0 0 0 / calc(var(--k) * .88)) 50%,
    rgb(0 0 0 / calc(var(--k) * .6)) 68%,
    rgb(0 0 0 / calc(var(--k) * .24)) 85%,
    rgb(0 0 0 / 0) 100%);
}
.shade-blur {
  backdrop-filter: blur(var(--shade-blur, 3px));
  -webkit-backdrop-filter: blur(var(--shade-blur, 3px));
  --falloff: radial-gradient(var(--ellipse), #000 0%, rgb(0 0 0 / .8) 35%, rgb(0 0 0 / .3) 65%, transparent 90%);
  -webkit-mask-image: var(--falloff);
  mask-image: var(--falloff);
}
.hero { touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.hero-copy {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: clamp(28px, 7vh, 72px);
  max-width: 44rem; z-index: 2;
}
.verse { margin: 0 0 1.75rem; }
.verse p {
  margin: 0;
  font: 400 var(--step-3)/1.08 var(--greek);
  text-wrap: balance;
  text-shadow: 0 2px 24px rgb(0 0 0 / .5);
}
.verse footer { margin-top: .6rem; font-style: italic; font-size: var(--step-0); opacity: .9; }
.verse cite { font-style: normal; opacity: .75; margin-left: .35rem; }

.search {
  display: flex; background: rgb(244 246 245 / .94); color: var(--ink);
  border-radius: 3px; box-shadow: 0 10px 40px rgb(0 0 0 / .35);
}
.search input {
  flex: 1; min-width: 0; border: 0; background: none; padding: 1rem 1.1rem;
  font-size: var(--step-1);
}
.search input::placeholder { color: #5d6770; font-size: var(--step-0); }
.search input:focus { outline: none; }
.search:focus-within { outline: 2px solid var(--saffron); outline-offset: 3px; }
.search button {
  border: 0; background: var(--ink); color: var(--on-dark);
  padding: 0 1.4rem; border-radius: 0 3px 3px 0; cursor: pointer;
}

.plate {
  position: absolute; right: var(--gutter); bottom: clamp(28px, 7vh, 72px); z-index: 2;
  margin: 0; text-align: right; max-width: 20rem;
}
.plate figcaption { font-size: var(--step--1); line-height: 1.4; margin-bottom: .7rem; text-shadow: 0 1px 10px rgb(0 0 0 / .6); }
.plate figcaption i { display: block; font-size: var(--step-0); }
.thumbs { display: flex; gap: 8px; justify-content: flex-end; }
.thumbs button {
  width: 52px; height: 52px; padding: 0; border: 1px solid rgb(255 255 255 / .35);
  background: center / cover no-repeat; cursor: pointer; opacity: .6;
  image-rendering: pixelated;
}
.thumbs button[aria-selected="true"] { opacity: 1; border-color: var(--saffron); box-shadow: 0 0 0 1px var(--saffron); }
.thumbs button:hover { opacity: .9; }

/* Dither controls */
.tune-toggle {
  position: absolute; z-index: 4; right: var(--gutter); top: 76px;
  background: rgb(20 34 58 / .72); color: var(--on-dark);
  border: 1px solid rgb(255 255 255 / .25); border-radius: 3px;
  padding: .4rem .8rem; font-size: var(--step--1); cursor: pointer; backdrop-filter: blur(6px);
}
.tune {
  position: absolute; z-index: 4; right: var(--gutter); top: 118px;
  width: min(300px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100% - 140px); overflow: auto;
  background: rgb(14 24 41 / .86); backdrop-filter: blur(10px);
  border: 1px solid rgb(255 255 255 / .14); border-radius: 4px;
  padding: 1rem 1.1rem; font-size: var(--step--1);
  display: grid; gap: .7rem;
}
.tune[hidden] { display: none; }
.tune-head { display: flex; justify-content: space-between; align-items: baseline; }
.tune h2 { font-size: var(--step-1); }
.tune h3 { font: italic 400 var(--step--1)/1.2 var(--text); margin: .5rem 0 0; padding-top: .7rem; border-top: 1px solid rgb(255 255 255 / .14); opacity: .8; }
.tune label { display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; align-items: center; }
.tune label > select, .tune label > input[type="range"] { grid-column: 1 / -1; width: 100%; }
.tune select { background: rgb(255 255 255 / .08); border: 1px solid rgb(255 255 255 / .2); border-radius: 3px; padding: .3rem; }
.tune option { color: var(--ink); }
.tune output { font-variant-numeric: tabular-nums; opacity: .8; }
.tune input[type="range"] { accent-color: var(--saffron); }
.tune .switch { display: flex; gap: .4rem; align-items: center; }
.tune kbd { font: inherit; font-size: .75rem; border: 1px solid rgb(255 255 255 / .3); border-radius: 2px; padding: 0 .3rem; opacity: .7; }
.tune-close { background: none; border: 1px solid rgb(255 255 255 / .3); border-radius: 3px; padding: .25rem .7rem; cursor: pointer; }
.tune-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.tune-actions button {
  flex: 1; background: none; border: 1px solid rgb(255 255 255 / .3); border-radius: 3px;
  padding: .35rem .5rem; cursor: pointer;
}
.tune-actions button:hover { border-color: var(--saffron); }

/* Lexicon */
main { padding: 0 var(--gutter); }
.lexicon { max-width: 76rem; margin: 0 auto; padding: 4.5rem 0 3rem; }
.lex-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--vein); padding-bottom: .8rem; }
.count { margin: 0; color: #56616b; font-style: italic; }
.lex-body { display: grid; grid-template-columns: minmax(15rem, 20rem) 1fr; gap: 3rem; margin-top: 1.5rem; }

.results { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow: auto; }
.results button {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: .55rem .75rem; border-left: 2px solid transparent;
  display: grid; gap: .05rem;
}
.results button:hover { background: var(--marble-2); }
.results button[aria-current="true"] { border-left-color: var(--saffron); background: var(--marble-2); }
.results .lm { font: 400 var(--step-1)/1.25 var(--greek); }
.results .gl { font-size: var(--step--1); color: #56616b; font-style: italic; }
.results .empty { padding: .75rem; color: #56616b; }

.entry { max-width: 44rem; }
.entry:focus { outline: none; }
.entry h3 { font: 400 clamp(2.6rem, 6vw, 4.5rem)/1 var(--greek); margin: 0; letter-spacing: -.005em; }
.entry .meta { margin: .6rem 0 0; font-size: var(--step-1); }
.entry .meta em { color: #56616b; margin-right: .5rem; }
.entry .note { color: #3c4957; margin: .8rem 0 0; }
.spread { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin: 1.6rem 0 0; padding: 0; list-style: none; font-size: var(--step--1); color: #3c4957; }
.spread b { font-weight: 400; color: var(--sea); }
.attest { list-style: none; margin: 2rem 0 0; padding: 0; border-top: 1px solid var(--vein); }
.attest li { padding: 1.1rem 0; border-bottom: 1px solid #cdd4d6; display: grid; grid-template-columns: 9rem 1fr; gap: 1.2rem; }
.attest .src { font-size: var(--step--1); color: #3c4957; line-height: 1.4; }
.attest .src span { display: block; color: var(--ink); font-size: var(--step-0); }
.attest .gr { font: 400 var(--step-1)/1.45 var(--text); margin: 0; }
.attest .gr mark { background: none; color: var(--sea); border-bottom: 2px solid var(--saffron); }
.attest .tr { margin: .25rem 0 0; font-style: italic; color: #3c4957; }

/* Poets timeline: a real sequence, so it gets order and a line */
.poets { max-width: 76rem; margin: 0 auto; padding: 3rem 0 4rem; border-top: 1px solid var(--vein); }
.timeline {
  list-style: none; margin: 2rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  position: relative;
}
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 1px; background: var(--vein); }
.timeline li { position: relative; padding: 1.4rem .5rem 0 0; }
.timeline li::before { content: ""; position: absolute; top: 2px; left: 0; width: 9px; height: 9px; background: var(--ink); }
.timeline li.has::before { background: var(--saffron); }
.timeline .nm { font: 400 var(--step-1)/1.2 var(--greek); display: block; }
.timeline .en { display: block; }
.timeline .dt { display: block; font-size: var(--step--1); color: #56616b; }
.timeline button { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.timeline button:hover .en { text-decoration: underline; }
.aside { font-size: var(--step--1); color: #56616b; font-style: italic; margin-top: 1.5rem; }

.colophon { background: var(--ink); color: #c8d0d6; padding: 2.5rem var(--gutter); font-size: var(--step--1); }
.colophon p { max-width: 60rem; margin: 0 0 .5rem; }

@media (max-width: 820px) {
  .mark-en, .bar nav { display: none; }
  .plate { left: var(--gutter); right: auto; top: 76px; bottom: auto; text-align: left; }
  .plate figcaption { display: none; }
  .thumbs { justify-content: flex-start; }
  .thumbs button { width: 44px; height: 44px; }
  .tune-toggle { top: 18px; padding: .55rem .8rem; }
  /* Controls become a bottom sheet on phones */
  .tune {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; max-height: 62vh; border-radius: 10px 10px 0 0;
    padding: 1rem 16px calc(1rem + env(safe-area-inset-bottom));
  }
  .tune input[type="range"] { height: 28px; }
  .hero-copy { bottom: 24px; }
  .shade, .shade-blur { --at: 45% 84%; width: 100%; height: 80%; }
  .verse { margin-bottom: 1.1rem; }
  .verse footer { font-size: var(--step--1); }
  .search input { padding: .85rem .9rem; font-size: 1.05rem; }
  .search button { padding: 0 1rem; }
  .lex-body { grid-template-columns: 1fr; gap: 1.5rem; }
  .results { max-height: 16rem; border-bottom: 1px solid var(--vein); }
  .attest li { grid-template-columns: 1fr; gap: .3rem; }
  .timeline { grid-template-columns: 1fr; }
  .timeline::before { left: 4px; right: auto; top: 0; bottom: 0; width: 1px; height: auto; }
  .timeline li { padding: 0 0 1rem 1.6rem; }
  .timeline li::before { top: .45rem; }
}

/* Quote and caption hand over with the painting */
.verse, .plate figcaption { transition: opacity .2s ease; }
.verse.out, .plate figcaption.out { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .verse, .plate figcaption { transition: none; } }
