/* Ithreth, the site. The tokens below are the game's own, copied by the build from
   Game/styles.css so the two can never drift: change a color there, not here. */

:root {
  --bg: #f1eadc;
  --bg2: #e8dfcd;
  --panel: #f7f2e8;
  --ink: #26211b;
  --ink2: #4f463b;
  --faint: #8a7f6f;
  --rule: #cdc1ac;
  --madder: #9b3a25;
  --tallow: #9a6714;
  --tide: #4d6470;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 30px -18px rgba(38, 33, 27, 0.35);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --col: 36rem;
  --gutter: 16px;
  --t-fast: 160ms;
  --t-slow: 520ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13110f;
    --bg2: #1a1714;
    --panel: #1d1a16;
    --ink: #e7dbc4;
    --ink2: #c2b6a0;
    --faint: #7c725f;
    --rule: #39332b;
    --madder: #d4664b;
    --tallow: #e3ad4d;
    --tide: #8aa0ab;
    --shadow: 0 0 0 1px rgba(255, 240, 210, 0.03), 0 18px 40px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #13110f;
  --bg2: #1a1714;
  --panel: #1d1a16;
  --ink: #e7dbc4;
  --ink2: #c2b6a0;
  --faint: #7c725f;
  --rule: #39332b;
  --madder: #d4664b;
  --tallow: #e3ad4d;
  --tide: #8aa0ab;
  --shadow: 0 0 0 1px rgba(255, 240, 210, 0.03), 0 18px 40px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* The site's own rules, under the game's tokens. One column and one serif, as in the game; the
   papers differ only as papers differ: a letter, a broadside, a slip, a board, a copy-sheet.
   Every screen keeps one thing unfinished (the frame's open corner): the tide's share, §4.15.1. */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(17px, 0.6vw + 14.5px, 19.5px);
  line-height: 1.62;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color var(--t-slow) ease, color var(--t-slow) ease;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--tallow); outline-offset: 3px; border-radius: 2px; }
main:focus { outline: none; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color var(--t-fast) ease, color var(--t-fast) ease;
}
a:hover { text-decoration-color: var(--madder); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip {
  position: absolute; left: var(--gutter); top: -60px; z-index: 30;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.3em 1em; font-size: 0.85em; text-decoration: none;
}
.skip:focus { top: 14px; }

/* ---- the frame, with its open corner (the game's own) ---------------------------------------- */

.frame { position: fixed; inset: 10px; pointer-events: none; z-index: 0; }
.frame svg { width: 100%; height: 100%; display: block; overflow: visible; }
.frame path { fill: none; stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ---- the bar ----------------------------------------------------------------------------------- */

.bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 22px var(--gutter) 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.wordmark {
  font-family: var(--serif);
  font-variant: small-caps;
  letter-spacing: 0.32em;
  font-size: 16px;
  color: var(--ink2);
  text-decoration: none;
  padding: 6px 0;
}
.wordmark:hover { color: var(--ink); }
.wordmark .last { opacity: 0.55; }

.seg { display: none; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; flex: none; }
.js .seg { display: inline-flex; }
.seg button {
  border: 0; background: none; padding: 0.45em 0.9em; min-height: 32px;
  font-family: var(--sans); font-size: 11.5px; letter-spacing: 0.06em; color: var(--faint);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--bg2); color: var(--ink); }

/* ---- the page ---------------------------------------------------------------------------------- */

main {
  position: relative;
  z-index: 1;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 8px var(--gutter) 30px;
}

.paper-head { margin: 2.4em 0 1.5em; }
.paper-head .kind {
  margin: 0 0 0.7em;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.paper-head h1 {
  margin: 0;
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: clamp(1.5rem, 2.6vw + 0.9rem, 2.05rem);
  line-height: 1.18;
  text-wrap: balance;
}

h2.sh {
  margin: 1.9em 0 0.7em;
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: 0.09em;
  font-size: 1em;
  color: var(--ink2);
}

/* ---- a line, with its mark in the margin (as the game's log draws it) ---------------------------- */

.ln {
  position: relative;
  margin: 0 0 0.8em;
  padding-right: 5.4em;
}
.ln .mk {
  position: absolute;
  right: 0;
  top: 0.32em;
  width: 8em;
  font-family: var(--sans);
  font-style: normal;
  font-variant: normal;
  font-weight: normal;
  text-transform: none;
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.1em;
  color: var(--faint);
  text-align: right;
  user-select: none;
}
.ln .mk em {
  display: block;
  margin-top: 1px;
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.mi {
  font-family: var(--sans);
  font-size: 0.6em;
  letter-spacing: 0.1em;
  color: var(--faint);
  vertical-align: 0.3em;
  margin: 0 0.15em;
  white-space: nowrap;
}
.mw { font-weight: normal; font-style: normal; color: var(--madder); }

.ln.cap { font-style: italic; color: var(--faint); font-size: 0.92em; }
.ln.doc {
  margin-left: 0.9em;
  padding-left: 0.95em;
  border-left: 1px solid var(--rule);
}
.ln.sig { font-variant: small-caps; letter-spacing: 0.08em; color: var(--ink2); }
.ln.quiet { color: var(--ink2); font-style: italic; }
.ln.big { font-size: 1.12em; }

.blank {
  display: inline-block;
  width: 3.2em;
  height: 0.9em;
  border-bottom: 1px solid var(--faint);
  vertical-align: -0.05em;
}
.card .blank { width: 9em; }
.ln.practice { padding-right: 0; }

/* ---- the cover: the title, the cord drawn, the bundle -------------------------------------------- */

.cover { text-align: center; padding: 6vh 0 1.4em; }
.cover h1 {
  margin: 0;
  font-weight: normal;
  font-size: clamp(2.5rem, 9vw, 4.2rem);
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  font-variant: small-caps;
  line-height: 1;
}
.cover h1 .last { opacity: 0.55; }
.cover .sub { margin: 0.9em 0 0; font-style: italic; color: var(--ink2); }
.cover .proverb { color: var(--faint); font-size: 0.92em; margin: 0 auto; max-width: 26em; }
.drawn { display: block; width: min(340px, 82%); height: 46px; margin: 2em auto 1.8em; overflow: visible; }
.drawn .line { fill: none; stroke: var(--ink2); stroke-width: 1.3; stroke-linecap: round; stroke-dasharray: 420; stroke-dashoffset: 420; animation: draw 2.4s cubic-bezier(.4, 0, .2, 1) 0.2s forwards; }
.drawn .k { fill: var(--ink2); opacity: 0; transform-box: fill-box; transform-origin: center; animation: knot 500ms ease forwards; }
.drawn .k.m { fill: var(--madder); }
.drawn .k.d1 { animation-delay: 0.5s; }
.drawn .k.d2 { animation-delay: 0.8s; }
.drawn .k.d3 { animation-delay: 1.1s; }
.drawn .k.d4 { animation-delay: 1.4s; }
.drawn .k.d5 { animation-delay: 1.7s; }
.drawn .open { fill: none; stroke: var(--faint); stroke-width: 1.1; stroke-dasharray: 2 3; opacity: 0; animation: knot 600ms ease 2.4s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes knot { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }

.choices { list-style: none; margin: 0.4em 0 0; padding: 0; border-top: 1px solid var(--rule); }
.choices li { border-bottom: 1px solid var(--rule); }
.choice {
  display: grid;
  grid-template-columns: 1.7em 1fr;
  padding: 0.66em 0.2em 0.7em 0;
  text-decoration: none;
  color: var(--ink);
  transition: background-color var(--t-fast) ease, padding var(--t-fast) ease;
}
.choice .n { font-family: var(--sans); font-size: 11px; color: var(--faint); padding-top: 0.45em; font-variant-numeric: lining-nums; }
.choice .l { display: block; }
.choice .s { display: block; font-size: 0.8em; color: var(--faint); margin-top: 0.12em; line-height: 1.45; }
.choice:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); padding-left: 0.35em; }
.choice:hover .n { color: var(--madder); }

/* ---- the way in -------------------------------------------------------------------------------- */

.way-in { text-align: center; margin: 2.6em 0 1.6em; }
.way-in .ln { padding-left: 5.4em; }
.btn {
  display: inline-block;
  border: 1px solid var(--rule);
  background: var(--panel);
  border-radius: 999px;
  padding: 0.55em 1.5em;
  min-width: 13em;
  font-size: 0.95em;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color var(--t-fast) ease, transform var(--t-fast) ease;
}
.btn:hover { border-color: var(--madder); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--madder); }
.way-in .small { margin: 1.1em auto 0; }

.small {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  line-height: 1.6;
  color: var(--faint);
  max-width: 32em;
}

/* ---- the papers' own bodies -------------------------------------------------------------------- */

/* a letter */
.letter .ln.doc { font-style: italic; color: var(--ink2); }
.letter .ln.doc.sig, .letter .ln.doc.ps { font-style: normal; }

/* a broadside */
.broadside {
  border-top: 3px double var(--rule);
  border-bottom: 3px double var(--rule);
  padding: 1em 0 0.4em;
  margin: 0.4em 0 1.2em;
}
.broadside .crier {
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 1.05em;
  padding-left: 5.4em;
  margin-bottom: 1em;
}
.lots { list-style: none; margin: 0; padding: 0; }
.lots .ln { padding-left: 3.6em; }
.lots .ln .no {
  position: absolute; left: 0; top: 0.3em;
  font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint);
}

/* slips from the Shelf */
.slip {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 0.95em 1em 0.35em;
  margin: 0 0 1.3em;
}
.slip::before {
  content: ""; position: absolute; left: 50%; top: 9px; width: 9px; height: 9px; margin-left: -4.5px;
  border-radius: 50%; border: 1px solid var(--rule); background: var(--bg);
}
.slip .ln { margin-bottom: 0.45em; }
.slip .f { font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-right: 0.5em; }

/* the warden's board */
.board {
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.1em 1.1em 0.4em;
  margin: 0.4em 0 1.3em;
}
.board .ln:first-child { font-variant: small-caps; letter-spacing: 0.05em; }
.board .ln.empty { min-height: 1.4em; border-bottom: 1px dashed var(--rule); margin-bottom: 1.2em; }

/* a Standings card */
.card {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1em 1em 0.4em;
  margin: 0.4em 0 1.3em;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.claims { display: grid; gap: 0 1.6em; margin-bottom: 0.6em; }
@media (min-width: 760px) { .claims { grid-template-columns: 1fr 1fr; } }
.claims .ln { padding-right: 0; font-style: italic; }
.claims .ln .mk { position: static; display: inline; width: auto; margin-left: 0.45em; vertical-align: 0.15em; white-space: nowrap; }
.claims .ln .mk em { display: inline; margin-left: 0.3em; }
.claims .who { font-variant: small-caps; letter-spacing: 0.08em; color: var(--ink2); margin: 0.2em 0 0.3em; }
.pencil .ln { color: var(--tide); font-style: italic; }

/* the primer: a printed page */
.primer {
  background: var(--panel);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 1.1em 1.1em 0.5em;
  margin: 0.4em 0 1.4em;
}
.primer .ln.big { font-size: 1.14em; }

/* a copy-sheet */
.copy .pair { margin: 0 0 1.1em; }
.copy .pair .ln { margin-bottom: 0.15em; }
.copy .gloss { display: block; font-style: italic; color: var(--faint); font-size: 0.88em; margin-top: 0.1em; }
.copy .hand {
  color: var(--tide);
  font-style: italic;
  min-height: 1.7em;
  border-bottom: 1px solid var(--rule);
  padding: 0 0 0.1em;
  margin: 0.3em 0 0;
}

/* the almanac */
.almanac .season { margin: 0 0 1.3em; }
.almanac .season h2.sh { margin: 0 0 0.4em; display: flex; justify-content: space-between; gap: 1em; align-items: baseline; }
.almanac .season h2.sh .when { font-family: var(--sans); font-variant: normal; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }

/* the notice on the Rows */
.notice {
  background: var(--panel);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 1.1em 1.1em 0.4em;
  margin: 0.4em 0 1.4em;
}
.notice .nhead { font-variant: small-caps; letter-spacing: 0.1em; font-size: 1.08em; padding-right: 0; }
.lamps { display: block; width: 100%; max-width: 420px; height: auto; margin: 0.6em auto 1.4em; }
.lamps .win { fill: var(--bg2); stroke: var(--rule); stroke-width: 1; }
.lamps .wall, .lamps .door { fill: none; stroke: var(--rule); stroke-width: 1; }
.lamps .lamp { fill: var(--faint); opacity: 0.7; }
.lamps .flame { fill: var(--tallow); filter: drop-shadow(0 0 4px var(--tallow)); animation: flicker 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center bottom; }
.lamps .flame:nth-of-type(2n) { animation-delay: -1.1s; animation-duration: 2.7s; }
.lamps .flame:nth-of-type(3n) { animation-delay: -2.3s; animation-duration: 3.7s; }
@keyframes flicker { 0%, 100% { opacity: 0.95; transform: scaleY(1); } 40% { opacity: 0.8; transform: scaleY(0.92); } 70% { opacity: 1; transform: scaleY(1.04); } }

/* the guide's sketch of the terraces */
.sketch { display: block; width: 100%; max-width: 520px; height: auto; margin: 0.6em auto 0.4em; }
.sketch .t { fill: none; stroke: var(--ink2); stroke-width: 1.2; stroke-linecap: round; }
.sketch .b { fill: none; stroke: var(--faint); stroke-width: 1; stroke-dasharray: 2 4; stroke-linecap: round; }
.sketch text { font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; fill: var(--faint); }
.sketch text.n { fill: var(--ink2); }

/* ---- the next paper, and the foot -------------------------------------------------------------- */

.next { margin: 2.6em 0 0; border-top: 1px solid var(--rule); }
.next a { display: block; padding: 0.8em 0 0.2em; text-decoration: none; }
.next .k { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.next .t { display: block; font-variant: small-caps; letter-spacing: 0.06em; font-size: 1.08em; margin-top: 0.15em; }
.next a:hover .t { color: var(--madder); }

.foot {
  position: relative;
  z-index: 1;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 1.2em var(--gutter) max(34px, env(safe-area-inset-bottom));
}
.cordline svg { width: 100%; max-width: 340px; height: 40px; display: block; overflow: visible; }
.cordline .line { fill: none; stroke: var(--ink2); stroke-width: 1.3; stroke-linecap: round; opacity: 0.8; }
.cordline .open { fill: none; stroke: var(--faint); stroke-width: 1.1; stroke-dasharray: 2 3; }
.cordline .k { fill: var(--bg); stroke: var(--ink2); stroke-width: 1.3; transition: fill var(--t-slow) ease; }
.cordline .k.on { fill: var(--ink2); }
.cordline .k.here { fill: var(--madder); stroke: var(--madder); }
.cordline .caption { margin: 2px 0 0; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.footlist {
  list-style: none; margin: 1em 0 0.9em; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.1em 1.1em;
  font-size: 0.85em;
}
.footlist a { display: inline-block; padding: 0.25em 0; color: var(--ink2); }
.footlist a[aria-current] { color: var(--madder); }
.foot .small a { color: var(--ink2); }

/* ---- the about page: the designer's plain voice ------------------------------------------------ */

.plain p { margin: 0 0 0.9em; }
.plain h2 { font-weight: normal; font-family: var(--sans); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin: 1.8em 0 0.5em; }
.plain ul { margin: 0 0 0.9em; padding-left: 1.2em; }
.plain li { margin: 0 0 0.35em; }

/* ---- small screens ----------------------------------------------------------------------------- */

@media (max-width: 520px) {
  .ln { padding-right: 0; }
  .ln .mk { position: static; display: inline; width: auto; margin-left: 0.45em; font-size: 9px; vertical-align: 0.15em; white-space: nowrap; }
  .ln .mk em { display: inline; margin-left: 0.3em; }
  .lots .ln { padding-left: 3em; }
  .way-in .ln, .broadside .crier { padding-left: 0; }
  .bar { padding-top: 18px; }
  .seg button { padding: 0.45em 0.7em; }
  .slip, .board, .card, .notice { padding-left: 0.85em; padding-right: 0.85em; }
}

@media (prefers-reduced-motion: reduce) {
  .lamps .flame { animation: none; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
:root.calm .lamps .flame { animation: none; }
:root.calm *, :root.calm *::before, :root.calm *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }

@media print {
  .bar, .frame, .foot .cordline, .skip { display: none; }
  body { background: #fff; color: #000; }
}
