/* Ten Years: paper and ink. One red, used for warnings, losses and stamps. */
:root {
  --paper: #ebe2ca;
  --card: #f4eedd;
  --ink: #1b1813;
  --ink2: #3a342a;
  --mute: #6f6553;
  --dim: #a39780;
  --line: #cdbf9f;
  --red: #8b2a1a;
  --serif: 'PT Serif', Georgia, 'Times New Roman', serif;
  --mono: 'PT Mono', ui-monospace, Menlo, Consolas, monospace;
  --display: 'Old Standard TT', 'PT Serif', Georgia, serif;
}
* { box-sizing: border-box; }
html { background: var(--paper); min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .11  0 0 0 0 .09  0 0 0 0 .07  0 0 0 .075 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  min-height: 100vh;
  font: 17px/1.68 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { position: relative; max-width: 720px; margin: 0 auto; padding: 18px 16px 120px; }
.red { color: var(--red); }

/* ---------- sound toggle ---------- */
#top .tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 16px; flex: none; }
#snd, #keep, #again { all: unset; flex: none; cursor: pointer; font: 12px/1.4 var(--mono); color: var(--mute); letter-spacing: .02em; }
#keep.test { color: var(--red); cursor: default; }
#again { display: none; }
#again.on { display: inline; }
#snd:hover, #snd:focus-visible, #keep:hover, #keep:focus-visible, #again:hover, #again:focus-visible { color: var(--red); }

/* ---------- status ---------- */
#top { font: 13px/1.45 var(--mono); color: var(--mute); padding: 0 0 10px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
#top .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
#top.bare { border-bottom-color: transparent; padding-bottom: 0; margin-bottom: 8px; }
#top.bare #detail { display: none; }
#idline { padding-left: 1px; }
#idline b { color: var(--ink); font-weight: 400; }
#meters { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; align-items: center; }
.m { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.m i { font-style: normal; }
.bar { position: relative; width: 52px; height: 7px; border: 1px solid var(--ink2); }
.bar b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink2); transition: width .7s ease; }
.m em, .t b { font-style: normal; font-weight: 400; color: var(--ink); }
.m.down em, .t.down b { color: var(--red); animation: flash 1.8s ease-out; }
.m.up em, .t.up b { animation: flash-up 1.8s ease-out; }
.m.down .bar { border-color: var(--red); }
@keyframes flash { 0% { background: rgba(139, 42, 26, .22); } 100% { background: transparent; } }
@keyframes flash-up { 0% { background: rgba(27, 24, 19, .14); } 100% { background: transparent; } }
.t { white-space: nowrap; }
.pips { display: inline-flex; gap: 3px; vertical-align: -1px; margin-left: 2px; }
.pips i { width: 9px; height: 9px; border: 1px solid var(--ink2); }
.pips i.on { background: var(--ink2); }
#strip { display: flex; gap: 1px; height: 9px; margin-top: 12px; }
#strip i { flex: 1 1 0; min-width: 0; background: rgba(27, 24, 19, .08); }
#strip i.now { background: transparent; box-shadow: inset 0 0 0 1px var(--red); transform: scaleY(1.6); }
.d-good { background: var(--ink) !important; }
.d-ok { background: #554d3e !important; }
.d-day { background: #9a8f78 !important; }
.d-bad { background: var(--red) !important; }
#months { position: relative; height: 15px; margin-top: 3px; font-size: 11px; color: var(--dim); }
#months span { position: absolute; top: 0; white-space: nowrap; }
#months span.end { right: 0; color: var(--mute); }
#months .end .short { display: none; position: static; }
#months .end .long { position: static; }

/* ---------- frame ---------- */
#frame { position: relative; margin: 0 0 22px; aspect-ratio: 16 / 9; overflow: hidden; background: var(--paper); }
/* the stage holds the print and its living overlay; frames.js holds it still, or leans or looks round */
#frame .stage { position: absolute; inset: 0; transform-origin: 50% 50%; transform: scale(1.04); will-change: transform;
  filter: var(--season, none) grayscale(calc(var(--weak, 0) * .35)); transition: filter 4s ease; }
#frame[data-month="jan"] { --season: brightness(.9) contrast(1.1); }
#frame[data-month="feb"] { --season: brightness(.94) contrast(1.06); }
#frame[data-month="mar"] { --season: brightness(.98) contrast(1.02); }
#frame[data-month="apr"] { --season: sepia(.08) brightness(1.02); }
#frame[data-month="may"] { --season: sepia(.16) brightness(1.05) saturate(1.1); }
#frame[data-dark="1"] { --season: brightness(.5) contrast(1.25); }   /* a daylight print shown at night, until it is redrawn */
#frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--fade, 1.1s) ease; }
#frame img.on { opacity: 1; }
#frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* the living print: when WebGL draws the picture, the <img> layers stand down */
#frame #gl { opacity: 0; transition: opacity .6s ease; }
#frame #gl.on { opacity: 1; }
#frame.living img { visibility: hidden; }
#frame img.twin { opacity: 0; transition: opacity 1.4s ease-in-out; }
#frame img.twin.on { opacity: 1; }
#frame #loop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.1s ease; pointer-events: none; }
#frame #loop.on { opacity: 1; }
/* the vignette closes in as the body fails */
#frame::after { content: ''; position: absolute; inset: 0; pointer-events: none; transition: box-shadow 4s ease;
  box-shadow: inset 0 0 calc(70px + var(--weak, 0) * 90px) calc(4px + var(--weak, 0) * 30px) rgba(27, 24, 19, calc(.22 + var(--weak, 0) * .38)); }

/* ---------- text ---------- */
#text > * { animation: rise .5s ease-out both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
#text p { margin: 0 0 .85em; }
#text .small { font: 13px/1.6 var(--mono); color: var(--mute); }
#text .q { margin-left: 1.4em; color: var(--ink2); font-style: italic; }
#text h1 { font: 400 50px/1.05 var(--display); letter-spacing: .16em; margin: 6px 0 4px; }
body.title #text .small { font: 15px/1.4 var(--display); letter-spacing: .3em; color: var(--mute); }
.ep { margin: 1.5em 0 1.2em; padding-left: 16px; border-left: 2px solid var(--line); font-style: italic; color: var(--ink2); }
.ep cite { display: block; margin-top: 6px; font: normal 12px/1.4 var(--mono); color: var(--mute); }
.note { font: italic 15px/1.5 var(--serif); color: var(--ink2); border-left: 2px solid var(--red); padding: 1px 0 1px 11px; margin: 0 0 10px !important; }

/* ---------- days that ran ---------- */
.run { font: 13px/1.6 var(--mono); color: var(--ink2); border: 1px dashed var(--line); background: rgba(244, 238, 221, .55); padding: 10px 14px; margin: 0 0 18px; }
.run p { margin: 0 !important; }
.run .marks { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 7px; }
.run .marks i { width: 11px; height: 11px; }
.run ul { margin: 6px 0 0; padding-left: 18px; }
.run .reason { color: var(--red); margin-top: 6px !important; }

/* ---------- cards ---------- */
.card {
  position: relative; background: var(--card); border: 1px solid var(--line); padding: 13px 18px 15px; margin: 4px 0 20px;
  font: 14px/1.6 var(--mono); color: var(--ink2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 12px 26px -16px rgba(27, 24, 19, .5);
}
.card .hd { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 8px; }
.ledger { transform: rotate(-.35deg); }
.ledger ul {
  list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid rgba(139, 42, 26, .4);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.6em - 1px), rgba(27, 24, 19, .1) calc(1.6em - 1px), rgba(27, 24, 19, .1) 1.6em);
}
.ledger li { min-height: 1.6em; }
.ledger .good { margin-top: 10px; }
.ledger .good span { display: block; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin-bottom: 2px; }
.ledger .good ul { border-left: none; background-image: none; padding-left: 0; }
.ledger .good li { color: var(--ink); font-style: italic; font-family: var(--serif); font-size: 15px; }
.ledger .good li::before { content: '✶ '; color: var(--mute); font-style: normal; }
.ledger .v { margin-top: 10px; font: italic 18px/1.4 var(--serif); color: var(--ink); }
.ledger .v-good { font-weight: 700; }
.ledger .v-bad { color: var(--red); }
.plan ul { list-style: none; padding: 0; margin: 0; }
.plan li { position: relative; padding: 5px 0 7px 26px; border-bottom: 1px dotted var(--line); color: var(--mute); }
.plan li.have { color: var(--ink); }
.plan li b { position: absolute; left: 0; top: 4px; font-weight: 400; font-size: 16px; color: var(--ink2); }
.plan li small { display: block; font-size: 12px; line-height: 1.45; color: var(--mute); }
.plan .odds { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 10px; }
.plan .odds em { font-style: normal; color: var(--red); }
.record { transform: rotate(.3deg); }
.record dl { display: grid; grid-template-columns: 140px 1fr; gap: 2px 12px; margin: 4px 0 8px; }
.record dt { color: var(--mute); }
.record dd { margin: 0; color: var(--ink); border-bottom: 1px dotted var(--line); }
.record .outcome { font: italic 19px/1.4 var(--serif); color: var(--ink); margin: 12px 0 4px; }
.unsaid { margin: 1.1em 0 .4em; }
.unsaid .sub { font: 11.5px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin-bottom: 6px; }
.unsaid ul { margin: 0; padding-left: 18px; font-size: .94em; }
.unsaid li { margin: 1px 0; }
.stamp {
  position: absolute; right: 20px; top: 46px; color: var(--red); border: 3px double var(--red); padding: 3px 12px 2px;
  font: 700 22px/1.2 var(--display); letter-spacing: .1em; opacity: .85; mix-blend-mode: multiply;
  transform: rotate(-11deg); animation: stamp .4s cubic-bezier(.2, 1.5, .4, 1) .55s both;
}
@keyframes stamp { from { transform: rotate(-11deg) scale(2.3); opacity: 0; } to { transform: rotate(-11deg) scale(1); opacity: .85; } }
.record-spring .stamp, .record-escaped .stamp { color: var(--ink2); border-color: var(--ink2); }

.keep-offer { background: transparent; box-shadow: none; border-style: dashed; font-size: 13px; }
.keep-offer p { margin: 0 !important; }
.keep-offer .opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.keep-offer button { all: unset; cursor: pointer; padding: 4px 12px; border: 1px solid var(--ink2); color: var(--ink); font: 13px/1.5 var(--mono); }
.keep-offer button:first-child { background: var(--ink); color: var(--paper); }
.keep-offer button:hover, .keep-offer button:focus-visible { border-color: var(--red); }

/* ---------- choices ---------- */
/* held: a story screen is still speaking; the choices wait, faintly, and arrive when it has finished */
#choices.held button { opacity: .28; pointer-events: none; animation: none; transition: opacity .2s; }
#choices button { transition: opacity .9s ease, border-color .15s, background .15s; }
#choices.held::before { content: '· · ·'; display: block; font: 13px/1 var(--mono); color: var(--mute); letter-spacing: .3em; margin: -6px 0 2px; animation: listen 1.6s ease-in-out infinite; }
@keyframes listen { 50% { opacity: .25; } }
#choices { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
#choices button {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px 10px 10px; border: 1px solid var(--line); background: rgba(244, 238, 221, .45);
  color: var(--ink); font: 16px/1.45 var(--serif); transition: border-color .15s, background .15s;
  animation: rise .45s ease-out both; animation-delay: calc(var(--i, 0) * 55ms + 160ms);
}
#choices .k { flex: none; width: 22px; height: 22px; display: grid; place-items: center; margin-top: 1px; font: 12px/1 var(--mono); color: var(--mute); border: 1px solid var(--line); transition: all .15s; }
#choices small { display: block; margin-top: 2px; font: 12px/1.45 var(--mono); color: var(--mute); }
#choices button:hover, #choices button:focus-visible { border-color: var(--ink2); background: var(--card); }
#choices button:hover .k, #choices button:focus-visible .k { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#choices button.danger .k { color: var(--red); border-color: var(--red); }
#choices button.danger:hover .k { background: var(--red); color: var(--paper); }
/* the clock on a choice: a hairline along the bottom of the default, draining; a little darker at the end */
#choices button { position: relative; }
#choices .clock { position: absolute; left: -1px; right: -1px; bottom: -1px; height: 2px; pointer-events: none;
  background: var(--dim); opacity: .45; transform-origin: 0 50%; transition: transform .12s linear, opacity 3s ease, background-color 3s ease; }
#choices .clock.late { background: var(--mute); opacity: .7; }

/* ---------- desktop: two columns that fill the window, nothing to scroll ---------- */
#cards:empty { display: none; }
@media (min-width: 960px) and (min-height: 560px) {
  html, body { height: 100%; overflow: hidden; }
  #app {
    max-width: 1400px; height: 100vh; height: 100dvh; padding: 16px 32px 20px;
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(400px, 1fr); grid-template-rows: auto minmax(0, 1fr);
    column-gap: 44px;
  }
  #top { grid-column: 1 / -1; margin-bottom: 18px; }
  #top.bare { margin-bottom: 10px; }
  #left { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 2px 4px 14px; margin: -2px -4px 0; }
  #frame { flex: 0 1 auto; min-height: 130px; margin: 0; }
  #cards { flex: none; }
  #cards .card, #cards .run { margin: 0 0 12px; }
  #flow > .moved { margin: 0 0 16px; }
  #right { min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
  #choices { margin-top: 18px; padding-bottom: 6px; }
  body.title #right, body.ending #right { display: flex; flex-direction: column; justify-content: center; }
  body.title #left { justify-content: center; }
  body.title #text h1 { font-size: 58px; }
}
@media (min-width: 960px) and (min-height: 560px) and (max-height: 820px) {
  #frame { min-height: 100px; }
  body { font-size: 16px; }
  #text p { margin-bottom: .7em; }
  #choices { gap: 6px; }
  #choices button { padding: 8px 12px 8px 9px; font-size: 15px; }
  .card { padding: 11px 16px 12px; font-size: 13px; }
}

@media (min-width: 960px) and (min-height: 560px) and (max-height: 700px) {
  #app { padding-top: 12px; padding-bottom: 14px; }
  #top { margin-bottom: 12px; padding-bottom: 8px; }
  #strip { margin-top: 8px; }
  body { font-size: 15px; line-height: 1.6; }
  .ep { margin: 1em 0 .8em; }
  .unsaid { margin: .8em 0 .2em; }
  #choices { margin-top: 12px; }
  #left { gap: 12px; }
}

/* ---------- small screens, and people who prefer stillness ---------- */
@media (max-width: 520px) {
  body { font-size: 16px; }
  #text h1 { font-size: 36px; }
  .bar { width: 40px; }
  #meters { gap: 5px 12px; }
  .record dl { grid-template-columns: 1fr; }
  .record dd { margin-bottom: 4px; }
  .stamp { font-size: 16px; top: 40px; right: 10px; }
  .card { padding: 12px 13px 13px; }
  #months .end .long { display: none; }
  #months .end .short { display: inline; }
  /* the id line keeps one line; the tools go under it, to the right */
  #top .row { flex-wrap: wrap; row-gap: 2px; }
  #top .tools { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  #text > *, #choices button, .stamp, .m em, .t b { animation: none !important; }
  #frame img { transition: none; }
  #frame .stage { transition: none !important; transform: scale(1.04) !important; }
}

/* ---------- moving figures (js/sprites.js): ink on the plate, their paper multiplied away ---------- */
#frame #sprites { mix-blend-mode: multiply; opacity: 0; transition: opacity 1.1s ease; }
/* the figures arrive after the plate under them has faded in: paper multiplied over nothing would show as a box */
#frame #sprites.on { opacity: 1; transition-delay: 1.3s; }
