@font-face { font-family: "Inter Tight"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: url("../fonts/inter-tight-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter Tight"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: url("../fonts/inter-tight-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: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/jetbrains-mono-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; }

:root {
  --paper: #ebe5d8;
  --ink: #1f1d1a;
  --dim: #5b564d;
  --rule: rgba(31, 29, 26, 0.18);
  --accent: #b5370f;
  --shade: rgba(235, 229, 216, 0.82);
  --halo: 0 0 2px #ebe5d8, 0 0 8px #ebe5d8, 0 0 14px rgba(235, 229, 216, 0.9);
  --font: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101214;
    --ink: #e8e2d6;
    --dim: #a59f93;
    --rule: rgba(232, 226, 214, 0.2);
    --accent: #e0724a;
    --shade: rgba(16, 18, 20, 0.84);
    --halo: 0 0 2px #101214, 0 0 8px #101214, 0 0 14px rgba(16, 18, 20, 0.9);
  }
}
:root[data-theme="dark"] {
  --paper: #101214;
  --ink: #e8e2d6;
  --dim: #a59f93;
  --rule: rgba(232, 226, 214, 0.2);
  --accent: #e0724a;
  --shade: rgba(16, 18, 20, 0.84);
  --halo: 0 0 2px #101214, 0 0 8px #101214, 0 0 14px rgba(16, 18, 20, 0.9);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#bath {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.lab {
  position: fixed; margin: 0;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  font: 400 11px/1 var(--mono); color: var(--dim);
}

.caption {
  position: fixed;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  margin: 0;
  display: flex; align-items: baseline; gap: 14px;
  max-width: calc(100vw - 140px);
  white-space: nowrap; overflow: hidden;
  font-size: 13px; line-height: 1.5;
  text-shadow: var(--halo);
  pointer-events: none;
}
/* today's inks: four small dots (24 px to the finger); the one you picked wears a ring */
.caption .inks { display: inline-flex; gap: 0; align-items: center; pointer-events: auto; margin: -6px 0; }
.caption .inks button {
  width: 22px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center;
}
.caption .inks button::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  background: var(--c); opacity: 0.85; box-shadow: 0 0 0 1px var(--rule);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.caption .inks button:hover::after { transform: scale(1.25); opacity: 1; }
.caption .inks.picked button::after { opacity: 0.4; }
.caption .inks button[aria-pressed="true"]::after { opacity: 1; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.caption .inks button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 50%; }
.caption .name { font-weight: 500; letter-spacing: 0.01em; }
.back {
  position: fixed; top: max(18px, env(safe-area-inset-top)); left: max(20px, env(safe-area-inset-left));
  font: 12px/1 var(--mono); color: var(--dim); text-decoration: none;
  /* a small plate of bath colour, so the link reads over any ink */
  background: var(--shade); padding: 6px 8px; margin: -6px -8px; border-radius: 4px;
  transition: opacity 1.2s ease;
}
.back:hover { color: var(--ink); }
.back:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
body.calm .back { opacity: 0; }
.caption .line, .caption .hint:not(.short) { display: none; }
.caption .hint, .caption .status { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; transition: opacity 1.2s ease; }
body.touched .caption .hint { display: none; }
body.calm .caption .status { opacity: 0; }

.book {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: row-reverse; align-items: flex-end;
}
.book button {
  width: 40px; height: 52px;
  margin-left: -22px;
  padding: 0; border: 0;
  background: var(--paper) center / cover no-repeat;
  box-shadow: 0 1px 0 var(--rule), 0 4px 14px rgba(0, 0, 0, 0.22);
  border-radius: 2px;
  cursor: pointer;
  transform: rotate(var(--r, 0deg));
  transition: transform 0.25s ease, margin 0.25s ease;
}
.book button:first-child { margin-left: 0; }
.book:hover button, .book:focus-within button { margin-left: 4px; transform: none; }
.book button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.book button.fresh { animation: arrive 0.9s ease; }
@keyframes arrive { from { transform: translateY(-40px) scale(1.4); opacity: 0; } }

.sheet {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--shade);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: zoom-out;
}
.sheet[hidden] { display: none; }
.sheet figure { margin: 0; display: grid; gap: 10px; justify-items: center; }
.sheet canvas {
  width: min(78vw, 60vh); height: auto; aspect-ratio: 3 / 4;
  box-shadow: 0 2px 0 var(--rule), 0 18px 50px rgba(0, 0, 0, 0.3);
}
.sheet figcaption { font-size: 13px; color: var(--dim); }

.curtain {
  position: fixed; left: 0; right: 0; top: 0; height: 100%;
  transform-origin: top; transform: scaleY(0);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

@media (max-width: 520px) {
  /* phones: two lines, the name, inks and clock, then the hint until the first touch */
  .caption { gap: 2px 10px; font-size: 12px; max-width: calc(100vw - 130px); flex-wrap: wrap; white-space: normal; align-items: center; }
  .caption .inks { margin: -6px -4px; }
  .caption .hint.short { flex-basis: 100%; order: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .book button, .caption .status, .caption .hint { transition: none; }
  .book button.fresh { animation: none; }
}
