/* ==========================================================================
   Eustrhálon Reader — styles
   Ported 1:1 from the design reference (design-reference/source.dc.html).
   Theme tokens live on :root and are switched by reader.js (Day/Night,
   accent, text scale). Everything under "fixed palette" ignores the theme.
   ========================================================================== */

:root {
  --paper: #f4f2ec;
  --ink: #262b30;
  --muted: #9aa6b0;
  --accent: #3f5c74;
  --scale: 1;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Spectral', Georgia, serif;
  min-height: 100vh;
}
::selection { background: #3f5c74; color: #f4f2ec; }
button { font: inherit; }

@keyframes eustRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- progress bar ---------- */
#eust-progbar {
  position: fixed; top: 0; left: 0;
  height: 3px; width: 0%;
  background: var(--accent);
  z-index: 60;
  transition: width 0.08s linear;
}

/* ---------- top bar ---------- */
.eust-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 55;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 18px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
}
.eust-menubtn {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none; cursor: pointer;
  color: var(--ink); font-family: 'Spectral', serif;
  padding: 4px 6px;
}
.eust-menubtn span {
  font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase;
  padding-left: 0.26em;
}
.eust-bartitle {
  min-width: 0; flex: 1; text-align: center;
  font-family: 'Marcellus', serif; font-size: 15px; letter-spacing: 0.03em;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0.86;
}
.eust-barbtns { display: flex; align-items: center; gap: 4px; }
.eust-arrow {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: none; border: none; cursor: pointer; color: var(--ink);
}
.eust-arrow[data-dim] { opacity: 0.25; }
.eust-aa {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: none; border: none; cursor: pointer; color: var(--ink);
  font-family: 'Marcellus', serif; font-size: 15px; letter-spacing: 0.02em;
  opacity: 0.86;
}

/* ---------- reading settings popover ---------- */
#eust-settings {
  position: fixed; top: 54px; right: 14px; z-index: 65;
  width: 250px;
  background: color-mix(in srgb, var(--paper) 97%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  border-radius: 3px;
  box-shadow: 0 14px 44px rgba(10, 16, 22, 0.18);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 16px;
  animation: eustRise 0.22s ease;
}
#eust-settings[hidden] { display: none; }
.eust-set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.eust-set-label {
  font-family: 'Spectral', serif; font-size: 11px;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: color-mix(in srgb, var(--ink) 64%, transparent);
  white-space: nowrap;
}
.eust-set-opts { display: flex; align-items: center; gap: 8px; }
.eust-pill {
  background: none; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 2px; padding: 5px 12px;
  font-family: 'Spectral', serif; font-size: 12px; letter-spacing: 0.08em;
  color: var(--ink);
}
.eust-pill[data-on] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
#eust-scale { width: 118px; accent-color: var(--accent); }
.eust-swatch {
  width: 15px; height: 15px; transform: rotate(45deg);
  border: 1px solid transparent; cursor: pointer; padding: 0;
  outline-offset: 3px;
}
.eust-swatch[data-on] { outline: 1px solid var(--ink); }

/* ---------- contents drawer ---------- */
#eust-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10, 16, 22, 0.5);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
#eust-backdrop[hidden] { display: none; }
#eust-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 71;
  width: min(380px, 86vw);
  background: radial-gradient(130% 90% at 30% 0%, #1e2b38 0%, #141e28 100%);
  color: #dbe4ec;
  box-shadow: 2px 0 40px rgba(0, 0, 0, 0.4);
  overflow-y: auto;
  animation: eustRise 0.3s ease;
  display: block;
}
#eust-drawer[hidden] { display: none; }
.eust-drawer-head { padding: 30px 30px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.eust-drawer-eyebrow {
  font-family: 'Spectral', serif; font-size: 11px; letter-spacing: 0.36em;
  text-transform: uppercase; color: #7f97ab; padding-left: 0.36em;
}
.eust-drawer-title { font-family: 'Marcellus', serif; font-size: 26px; color: #eef4f9; margin-top: 10px; }
#eust-toc { padding: 12px 0 30px; }
.eust-toc-item {
  display: flex; align-items: baseline; gap: 16px; width: 100%;
  text-align: left; cursor: pointer; border: none;
  background: none; border-left: 2px solid transparent;
  color: #b3c2ce; padding: 13px 30px;
  font-family: 'Spectral', serif;
}
.eust-toc-item .eust-toc-num {
  font-family: 'Marcellus SC', 'Marcellus', serif; font-size: 12px;
  letter-spacing: 0.14em; color: #6f8499; min-width: 34px;
}
.eust-toc-item .eust-toc-title { font-family: 'Marcellus', serif; font-size: 17px; }
.eust-toc-item[data-current] {
  background: rgba(127, 152, 171, 0.16);
  border-left: 2px solid #a9c0d3;
  color: #eef4f9;
}
.eust-toc-item[data-current] .eust-toc-num { color: #a9c0d3; }

/* ---------- chapter crossfade container ---------- */
#eust-content { opacity: 1; transition: opacity 0.28s ease; }

/* ---------- cover plate (fixed palette — never themed) ---------- */
.eust-plate {
  position: relative;
  min-height: clamp(540px, 82vh, 900px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 96px 28px 64px;
  background: radial-gradient(120% 90% at 50% 8%, #223140 0%, #182430 46%, #101a24 100%);
  color: #dfe7ee;
  overflow: hidden;
}
.eust-plate-art {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0.38;
  pointer-events: none;
}
.eust-plate-art[hidden] { display: none; }
.eust-plate-pinstripe {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.028) 0px, rgba(255,255,255,0.028) 1px, transparent 1px, transparent 3px);
  pointer-events: none;
}
.eust-plate-inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 26px;
  max-width: 760px;
}
.eust-overline {
  font-family: 'Spectral', serif; font-size: 12.5px;
  letter-spacing: 0.42em; text-transform: uppercase;
  color: #8fa6ba; padding-left: 0.42em;
}
#eust-sigil { display: flex; }
#eust-sigil img { width: 58px; height: 58px; opacity: 0.92; }
.eust-partblock { display: flex; flex-direction: column; gap: 5px; }
.eust-partlabel {
  font-family: 'Marcellus SC', 'Marcellus', serif; font-size: 13px;
  letter-spacing: 0.34em; color: #9fb4c6;
}
.eust-partname { font-family: 'Spectral', serif; font-style: italic; font-size: 16px; color: #7f97ab; }
.eust-plate-rule { width: 1px; height: 30px; background: linear-gradient(#7c98ae, transparent); }
.eust-chlabel {
  font-family: 'Marcellus SC', 'Marcellus', serif; font-size: 14px;
  letter-spacing: 0.44em; color: #a9c0d3; padding-left: 0.44em;
}
.eust-plate h1 {
  font-family: 'Marcellus', serif; font-weight: 400;
  font-size: clamp(46px, 8.5vw, 88px);
  line-height: 1.0; margin: 2px 0 0;
  color: #f2f6fa; letter-spacing: 0.005em;
}
.eust-chsubtitle {
  font-family: 'Spectral', serif; font-style: italic;
  font-size: clamp(15px, 2.3vw, 18px);
  line-height: 1.6; color: #b9cad8; max-width: 460px; margin: 12px 0 0;
}
.eust-scrollcue {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: #7f97ab;
}
.eust-scrollcue span {
  font-family: 'Spectral', serif; font-size: 11px;
  letter-spacing: 0.34em; text-transform: uppercase; padding-left: 0.34em;
}

/* ---------- prose column ---------- */
#eust-prose {
  max-width: 680px; margin: 0 auto;
  padding: clamp(56px, 8vw, 96px) 28px clamp(40px, 6vw, 64px);
}
#eust-prose p.eust-p {
  font-size: calc(20px * var(--scale, 1));
  line-height: 1.86;
  margin: 1.35em 0 0;
  text-wrap: pretty;
}
#eust-prose p.eust-p:first-child { margin-top: 0; }
.eust-drop {
  float: left;
  font-family: 'Marcellus', serif;
  font-size: 4.4em; line-height: 0.72;
  padding: 6px 14px 0 0;
  color: var(--accent);
}
.eust-pull {
  font-family: 'Marcellus', serif; text-align: center;
  font-size: calc(30px * var(--scale, 1));
  letter-spacing: 0.06em; color: var(--accent);
  margin: 1.5em 0; line-height: 1.2;
}
.eust-hr {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 2.6em 0;
}
.eust-hr .eust-hr-l { height: 1px; width: 54px; background: linear-gradient(90deg, transparent, var(--muted)); }
.eust-hr .eust-hr-d { width: 8px; height: 8px; border: 1px solid var(--accent); transform: rotate(45deg); display: block; }
.eust-hr .eust-hr-r { height: 1px; width: 54px; background: linear-gradient(90deg, var(--muted), transparent); }
.eust-end { display: flex; justify-content: center; margin: 2.8em 0 0; }
.eust-end span { width: 11px; height: 11px; background: var(--accent); transform: rotate(45deg); display: block; }

/* images & symbols within prose */
.eust-fig { margin: 2.4em 0 0; }
.eust-fig img { width: 100%; height: auto; display: block; border-radius: 2px; }
.eust-fig figcaption {
  font-family: 'Spectral', serif; font-style: italic;
  font-size: calc(14px * var(--scale, 1)); line-height: 1.6;
  color: color-mix(in srgb, var(--ink) 62%, transparent);
  text-align: center; margin-top: 12px;
}
.eust-symblock { display: flex; justify-content: center; margin: 2.6em 0; }
.eust-symblock img { width: 64px; height: 64px; opacity: 0.85; }
/* the marks are dark ink on transparent — lift them to pale steel in Night */
[data-theme="Night"] .eust-symblock img { filter: invert(0.85); }

/* ---------- bottom chapter nav ---------- */
.eust-bottomnav {
  max-width: 680px; margin: 0 auto;
  padding: 8px 28px clamp(56px, 8vw, 90px);
  display: flex; gap: 16px; flex-wrap: wrap;
}
.eust-navcard {
  flex: 1 1 240px; text-align: left; cursor: pointer;
  background: none;
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: 2px; padding: 18px 22px;
  color: var(--ink); font-family: 'Spectral', serif;
  display: flex; flex-direction: column; gap: 5px;
  transition: border-color 0.15s ease;
}
.eust-navcard:hover { border-color: var(--accent); }
.eust-navcard.eust-navnext { text-align: right; align-items: flex-end; }
.eust-navcard .eust-nav-eyebrow {
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--accent);
}
.eust-navcard .eust-nav-title { font-family: 'Marcellus', serif; font-size: 19px; }

/* ---------- colophon (fixed palette — never themed) ---------- */
.eust-colophon {
  background: radial-gradient(120% 120% at 50% 0%, #1c2a37 0%, #121c26 100%);
  color: #cdd8e2;
  padding: clamp(52px, 7vw, 78px) 28px clamp(44px, 6vw, 66px);
  text-align: center;
}
.eust-colophon-inner {
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.eust-colophon-realm { font-family: 'Marcellus', serif; font-size: 25px; color: #eef4f9; }
.eust-colophon-sub {
  font-family: 'Spectral', serif; font-style: italic; font-size: 14px;
  letter-spacing: 0.14em; color: #8ba0b3; text-transform: uppercase;
}
.eust-colophon-motto { font-family: 'Spectral', serif; font-size: 18px; line-height: 1.7; color: #b7c6d4; margin: 4px 0 0; }
.eust-colophon-hairline { width: 40px; height: 1px; background: #4a5f72; margin: 4px 0; }
.eust-colophon-caption {
  font-family: 'Spectral', serif; font-size: 11.5px;
  letter-spacing: 0.3em; text-transform: uppercase;
  color: #6f8398; padding-left: 0.3em;
}
