@font-face { font-family: 'DM Sans'; font-weight: 400 500; font-display: swap; src: url(fonts/dm-sans-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: 'DM Sans'; font-weight: 400 500; font-display: swap; src: url(fonts/dm-sans-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Libre Caslon Display'; font-weight: 400; font-display: swap; src: url(fonts/libre-caslon-display-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: 'Libre Caslon Display'; font-weight: 400; font-display: swap; src: url(fonts/libre-caslon-display-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Each mood is a room. The tokens are registered as colors so rooms cross-fade.
   There is no system dark mode: the rooms are the theme, and two of them are dark. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #f2f2ef; }
@property --ink { syntax: '<color>'; inherits: true; initial-value: #1e1f1c; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #a24b37; }

:root {
  color-scheme: light;
  --bg: #f2f2ef; --ink: #1e1f1c; --accent: #a24b37;
  --muted: color-mix(in oklab, var(--ink) 66%, var(--bg));
  --line: color-mix(in oklab, var(--ink) 16%, var(--bg));
  --serif: 'Libre Caslon Display', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --edge: clamp(26px, 8vw, 132px);
  --ease: cubic-bezier(.2, .7, .1, 1);
  --ribbon-x: 76vw;
  transition: --bg .9s ease, --ink .9s ease, --accent .9s ease;
}
[data-room=comfort]     { --bg: #dde4da; --ink: #26362a; --accent: #557657; }
[data-room=courage]     { --bg: #4f2523; --ink: #f1e4dc; --accent: #e6a57f; color-scheme: dark; }
[data-room=perspective] { --bg: #d7dee9; --ink: #1c2839; --accent: #46668f; }
[data-room=love]        { --bg: #ead7d7; --ink: #45202a; --accent: #9e3f55; }
[data-room=bittersweet] { --bg: #191c23; --ink: #d5d9e2; --accent: #93a7cc; color-scheme: dark; }

* { box-sizing: border-box; }
html { height: 100%; }
body {
  height: 100vh; height: 100svh; min-height: 460px; margin: 0;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .3; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
.stage:focus { outline: none; }
[hidden] { display: none !important; }
html:not(.js) .needs-js { display: none !important; }
kbd { font: inherit; padding: 0 4px; border: 1px solid var(--line); border-radius: 3px; }
.skip-link { position: absolute; left: var(--edge); top: -60px; padding: 10px 14px; background: var(--bg); z-index: 9; }
.skip-link:focus { top: 8px; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; padding: 30px var(--edge) 0; position: relative; z-index: 3; }
/* The mark: a small open book. It opens from the spine on load, and turns a
   page with each new quote (see turnPage in app.js). */
.mark { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; color: var(--ink); cursor: pointer; }
.mark svg { width: 30px; height: 23px; flex: none; overflow: visible; transition: transform .4s var(--ease); }
.mark .name { font-size: 15px; font-weight: 500; letter-spacing: -.3px; }
.mark .dot { color: var(--accent); }
.js .mark .name { animation: slide-in .7s var(--ease) .55s backwards; }
.mark:hover svg { transform: translateY(-2px) rotate(-3deg); }
.mark path { fill: var(--bg); stroke: currentColor; stroke-width: 1.45; stroke-linejoin: round; stroke-linecap: round; }
.mark .lines { fill: none; stroke: var(--accent); stroke-width: 1.2; }
.mark .page, .mark .leaf { transform-box: view-box; transform-origin: 17px 14px; }
.mark .leaf { opacity: 0; }
.js .mark:not(.ready) .page { animation: book-open .75s var(--ease) .15s backwards; }
.js .mark:not(.ready) .page.right { animation-delay: .25s; }
.js .mark:not(.ready) .lines { animation: fade .5s ease .8s backwards; }
/* Every 5–7 seconds the book closes and opens again (scheduled in app.js). */
.mark.blink .page { animation: book-blink 1.5s cubic-bezier(.5, 0, .3, 1); }
.mark.blink .page.right { animation-delay: .08s; }
.mark.blink .lines { animation: lines-blink 1.5s ease; }
.mark.turn .leaf { animation: leaf-forward .7s cubic-bezier(.45, .05, .25, 1); }
.mark.turn-back .leaf { animation: leaf-back .7s cubic-bezier(.45, .05, .25, 1); }
@keyframes book-open { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes book-blink { 0%, 100% { transform: scaleX(1); } 38%, 52% { transform: scaleX(.06); } }
@keyframes lines-blink { 0%, 100% { opacity: 1; } 25%, 60% { opacity: 0; } }
@keyframes leaf-forward {
  0% { opacity: 1; transform: scaleX(1); }
  50% { transform: scaleX(.08) skewY(-10deg); }
  99% { opacity: 1; transform: scaleX(-1); }
  100% { opacity: 0; transform: scaleX(-1); }
}
@keyframes leaf-back {
  0% { opacity: 1; transform: scaleX(-1); }
  50% { transform: scaleX(-.08) skewY(10deg); }
  99% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}
.note { position: relative; }
.note summary { list-style: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 8px 0; }
.note summary::-webkit-details-marker { display: none; }
.note summary:hover, .note[open] summary { color: var(--ink); }
.chev { display: inline-block; margin-left: 6px; font-size: .85em; transition: transform .3s var(--ease); }
.note[open] .chev, .mood-phrase[aria-expanded=true] .chev { transform: rotate(180deg); }
/* "What's this?": slides in after the book opens; an underline draws in on
   hover while the arrow bobs; the note's lines rise in one after another. */
.js .note summary { animation: slide-in .7s var(--ease) .7s backwards; }
.note .ask { background: linear-gradient(var(--accent), var(--accent)) left bottom / 0 1px no-repeat; padding-bottom: 2px; transition: background-size .45s var(--ease); }
.note summary:hover .ask, .note[open] .ask, .note summary:focus-visible .ask { background-size: 100% 1px; }
.note:not([open]) summary:hover .chev { animation: bob 1s var(--ease) infinite; }
.note[open] .note-panel > * { animation: rise-in .55s var(--ease) backwards; }
.note[open] .note-panel > :nth-child(2) { animation-delay: 60ms; }
.note[open] .note-panel > :nth-child(3) { animation-delay: 120ms; }
.note[open] .note-panel > :nth-child(4) { animation-delay: 180ms; }
.note[open] .note-panel > :nth-child(5) { animation-delay: 260ms; }
.note[open] .note-panel > :nth-child(6) { animation-delay: 320ms; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.note-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(370px, calc(100vw - 2 * var(--edge)));
  max-height: calc(100vh - 120px); max-height: calc(100svh - 120px); overflow: auto; padding: 28px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 24px 60px -20px color-mix(in oklab, var(--ink) 30%, transparent);
  animation: unfold .35s var(--ease);
}
.note-panel h2 { font: 400 30px/1.08 var(--serif); margin: 0 0 18px; }
.note-panel p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.note-panel .welcome { color: var(--ink); margin-top: 22px; }
.note-panel .fine { margin: 24px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; }

/* Mood sentence */
.mood-line { position: relative; z-index: 2; padding: clamp(18px, 5vh, 52px) var(--edge) 0; font: 400 clamp(19px, 1.7vw, 24px)/1.35 var(--serif); }
.lead { color: var(--muted); }
.mood-phrase { font: inherit; color: var(--ink); border-bottom: 1px solid var(--accent); padding-bottom: 1px; }
.mood-phrase:hover { color: var(--accent); }
.mood-phrase .chev { font-family: var(--sans); font-size: .62em; vertical-align: .18em; }
.saved-note { color: var(--muted); }
.mood-menu {
  position: absolute; left: var(--edge); top: calc(100% + 12px); margin: 0; padding: 10px 0; list-style: none;
  min-width: min(340px, calc(100vw - 2 * var(--edge)));
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 24px 60px -20px color-mix(in oklab, var(--ink) 30%, transparent);
  animation: unfold .35s var(--ease);
}
.mood-menu button { display: flex; width: 100%; align-items: center; gap: 14px; padding: 9px 24px; font: 400 clamp(21px, 1.9vw, 26px)/1.25 var(--serif); color: var(--muted); text-align: left; }
.mood-menu button:hover, .mood-menu button:focus-visible { color: var(--ink); }
.mood-menu button[aria-checked=true] { color: var(--ink); }
.mood-menu button[aria-checked=true]::after { content: '·'; color: var(--accent); margin-left: auto; font-size: 1.4em; line-height: .5; }
.swatch { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--sw); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 25%, transparent); }
@keyframes unfold { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Stage and typesetting: type is sized to the quote in five steps. */
.stage { grid-row: 3; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; padding: 3vh var(--edge); scrollbar-width: none; }
.stage::-webkit-scrollbar { display: none; }
.quote { margin: auto 0; padding: 2vh 0 1vh; max-width: 100%; }
.js .quote[aria-busy=true] { visibility: hidden; }
blockquote { position: relative; margin: 0; font-family: var(--serif); font-weight: 400; letter-spacing: -.012em; text-wrap: pretty; overflow-wrap: break-word; white-space: pre-line; }
blockquote::before { content: '“'; position: absolute; right: 100%; top: -.16em; margin-right: .05em; font-size: 1.5em; line-height: 1; color: var(--accent); }
blockquote.no-mark::before { content: none; }
.quote[data-size="1"] blockquote { font-size: clamp(54px, min(10.5vw, 17vh), 156px); line-height: 1.0;  max-width: 10ch; letter-spacing: -.02em; }
.quote[data-size="2"] blockquote { font-size: clamp(40px, min(6.6vw, 11vh), 104px); line-height: 1.04; max-width: 13ch; letter-spacing: -.018em; }
.quote[data-size="3"] blockquote { font-size: clamp(33px, min(5vw, 8.4vh), 76px);   line-height: 1.08; max-width: 17ch; }
.quote[data-size="4"] blockquote { font-size: clamp(29px, min(3.9vw, 6.6vh), 58px); line-height: 1.12; max-width: 21ch; }
.quote[data-size="5"] blockquote { font-size: clamp(25px, min(3.1vw, 5.3vh), 46px); line-height: 1.16; max-width: 25ch; }
.quote[data-size="0"] blockquote { font-size: clamp(28px, 3.4vw, 48px); line-height: 1.12; max-width: 20ch; color: var(--muted); }
.w { display: inline-block; }

.translation { margin: 22px 0 0; max-width: 46ch; color: var(--muted); font-size: 15px; line-height: 1.6; }
.translation:empty, figcaption:empty { display: none; }
figcaption { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-top: clamp(22px, 4vh, 38px); color: var(--muted); }
figcaption::before { content: ''; width: 30px; height: 1px; background: var(--accent); align-self: center; }
.who { font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.where { font: 400 17px/1.3 var(--serif); }
.where a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.where a:hover { text-decoration-color: currentColor; }
.noscript { margin: 0 0 2vh; color: var(--muted); font-size: 13px; }

/* Motion: lines rise in one after another; the old quote lifts away. */
.quote.enter .w { animation: rise .85s var(--ease) both; animation-delay: calc(var(--l, 0) * 85ms + 60ms); }
.quote.enter blockquote::before { animation: fade .9s ease both; }
.quote.enter .translation, .quote.enter figcaption { animation: fade .8s ease both; animation-delay: calc(var(--lines, 1) * 85ms + 220ms); }
.quote.leave { opacity: 0; transform: translateY(-.6rem); transition: opacity .2s ease, transform .2s ease; }
.quote.leave.back { transform: translateY(.6rem); }
@keyframes rise { from { opacity: 0; transform: translateY(.38em); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Saved: a ribbon bookmark drops from the top edge. */
.ribbon {
  position: fixed; top: 0; left: var(--ribbon-x); z-index: 1; width: 22px; height: clamp(86px, 17vh, 158px);
  background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  transform: scaleY(0); transform-origin: top; pointer-events: none;
  transition: transform .45s cubic-bezier(.5, 0, .75, 0);
}
.is-saved .ribbon { transform: scaleY(1); transition: transform .7s cubic-bezier(.25, 1.35, .45, 1); }

/* Controls */
.controls { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 10px var(--edge) clamp(40px, 6vh, 56px); font-size: 14px; }
.step, .keep { display: flex; align-items: center; }
.step { position: relative; }
.controls button { min-height: 44px; color: var(--muted); }
.controls button:hover:not(:disabled) { color: var(--ink); }
.prev { position: absolute; right: 100%; margin-right: 16px; font-size: 17px; min-width: 28px; }
.prev:disabled { opacity: 0; pointer-events: none; }
.controls .another { color: var(--ink); font-size: 15px; display: inline-flex; align-items: center; gap: 10px; }
.arrow { display: inline-block; transition: transform .35s var(--ease); }
.another:hover:not(:disabled) .arrow { transform: translateX(5px); }

/* Icon controls: a bookmark to save, copy (briefly a check), and the saved shelf. */
.controls .keep { gap: 4px; margin-right: -11px; }
.controls .icon { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; }
.icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease); }
.icon .fillable { fill: transparent; transition: fill .25s ease; }
.controls .icon[aria-pressed=true] { color: var(--accent); }
.icon[aria-pressed=true] .fillable { fill: currentColor; }
.icon:active:not(:disabled) svg { transform: scale(.88); }
.icon .when-done, .icon.done .when-idle { display: none; }
.icon.done .when-done { display: block; color: var(--accent); }
.saved-view .count { position: absolute; top: 6px; left: 31px; font-size: 10.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.status { position: absolute; left: var(--edge); right: var(--edge); bottom: calc(clamp(40px, 6vh, 56px) - 26px); margin: 0; font-size: 12.5px; color: var(--muted); text-align: right; pointer-events: none; }

@media (max-width: 640px) {
  :root { --ribbon-x: 58vw; }
  .top { padding-top: 22px; }
  .note summary, .mark .name { font-size: 13.5px; }
  .mark { gap: 10px; }
  .mark svg { width: 27px; height: 21px; }
  .mood-line { font-size: 19px; }
  blockquote::before { font-size: 1.1em; top: -.04em; }
  .quote[data-size="1"] blockquote { font-size: clamp(54px, min(17vw, 13vh), 96px); }
  .quote[data-size="2"] blockquote { font-size: clamp(38px, min(12vw, 9vh), 64px); }
  .quote[data-size="3"] blockquote { font-size: clamp(31px, min(9.6vw, 7vh), 52px); }
  .quote[data-size="4"] blockquote { font-size: clamp(28px, min(8.4vw, 6vh), 44px); }
  .quote[data-size="5"] blockquote { font-size: clamp(25px, min(7.4vw, 5.2vh), 38px); }
  .prev { margin-right: 0; min-width: 24px; }
  .controls { gap: 10px; }
  .status { text-align: left; }
  .ribbon { width: 18px; height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
