/* FLATLINE — rice paper, ink, one red. */
:root {
  --paper: #f1e9d8;
  --paper-2: #ebe1cc;
  --paper-3: #e2d5bb;
  --art-bg: #efe6d3;
  --ink: #1a1612;
  --ink-2: #463e35;
  --ink-3: #62584b;
  --rule: #cbbb9c;
  --red: #b0271c;
  --serif-d: "Cormorant Garamond", "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --serif: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --art-h: clamp(280px, 56vh, 540px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 50% -20%, rgba(255, 252, 244, 0.7), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(190, 170, 130, 0.18), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: var(--rule); }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1, "zero" 0; letter-spacing: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 0.875rem; }
.warn { color: var(--red); }
code { font-family: var(--mono); font-size: 0.88em; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--gutter); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

.demo-banner {
  margin: 0;
  padding: 7px var(--gutter);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-align: center;
}
.demo-banner strong { font-weight: 500; letter-spacing: 0.12em; }

/* ---------------------------------------------------------------- header */
.site-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1240px; margin-inline: auto;
  padding: 18px var(--gutter) 0;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.32em; }
.brand img { display: block; }
.site-head nav { display: flex; gap: clamp(12px, 3vw, 30px); }
.site-head nav a { text-decoration: none; font-family: var(--serif-d); font-size: 1.12rem; color: var(--ink-2); padding: 4px 0; border-bottom: 1px solid transparent; }
.site-head nav a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------------------------------------------------------------- live */
.live-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 24px 40px;
  padding-top: clamp(20px, 5vh, 56px); padding-bottom: 22px;
}
h1, h2, h3 { font-family: var(--serif-d); font-weight: 400; line-height: 1.1; }
#live-h { font-size: clamp(2.4rem, 5vw, 4rem); letter-spacing: 0.14em; margin: 0; line-height: 1; }
.tagline { margin: 10px 0 0; color: var(--ink-2); font-size: 1.08rem; max-width: 46ch; }
.tagline em { color: var(--ink); }

.vitals { display: flex; flex-wrap: wrap; gap: 10px 32px; margin: 0; }
.vital { display: flex; flex-direction: column-reverse; gap: 2px; min-width: 0; }
.vital dt { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.vital dd { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.vital-status dd { font-family: var(--serif-d); font-size: 1.5rem; letter-spacing: 0.2em; }
#status[data-status="dead"] { color: var(--red); }
.vital-countdown dd { font-size: 1.35rem; }
#countdown { font-weight: 500; white-space: nowrap; }
#countdown.is-urgent { color: var(--red); }
:root[data-status="dead"] #countdown { font-size: 0.95rem; font-weight: 400; }

/* heir of the sealed scroll: one sober line under the vitals, central to the work */
.heir {
  grid-column: 2; margin: -6px 0 0; padding-top: 12px; border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; min-width: 0;
}
.heir-label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.heir[data-final="1"] .heir-label { color: var(--red); }
.heir-who { font-size: 1.05rem; }
.heir-note { color: var(--ink-2); font-style: italic; font-size: 1rem; font-variant-numeric: tabular-nums; }
.heir-sep { font-style: normal; color: var(--ink-3); }

.notice { color: var(--ink-2); font-style: italic; margin-block: 0 12px; }

/* the scroll */
.scroll {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  cursor: grab;
  background: var(--paper-3);
  border-block: 1px solid var(--rule);
  box-shadow: inset 0 8px 10px -8px rgba(60, 45, 20, 0.25), inset 0 -8px 10px -8px rgba(60, 45, 20, 0.25);
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  touch-action: pan-x pan-y;
}
.scroll:focus-visible { outline-offset: -3px; }
.scroll.is-dragging { cursor: grabbing; user-select: none; }
.scroll-track { display: flex; width: max-content; padding-block: 10px 0; }
.tile { flex: none; margin: 0; position: relative; }
.tile-art { position: relative; height: var(--art-h); background: var(--art-bg); overflow: hidden; }
.tile-art img { display: block; width: 100%; max-width: none; height: 100%; opacity: 0; transition: opacity 0.5s ease; user-select: none; -webkit-user-drag: none; }
.tile.is-rendered .tile-art img { opacity: 1; }
.tile figcaption {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); padding: 7px 10px 9px; border-left: 1px solid var(--rule); white-space: nowrap;
}
.tile:first-child figcaption { border-left-color: transparent; }
.tip {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--ink); pointer-events: none;
}
.tip::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 1px solid var(--ink); opacity: 0; animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(0.3); opacity: 0.55; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tip::after { animation: none; } .tile-art img { transition: none; } }

.scroll-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 10px; }
.scroll-help { margin: 0; color: var(--ink-3); font-size: 0.95rem; font-style: italic; text-align: center; }
/* zoom: quiet, like the rest of the controls */
.zoom { display: inline-flex; align-items: center; gap: 2px; }
.zoom button {
  background: none; border: 1px solid transparent; border-radius: 3px; color: var(--ink-2); cursor: pointer;
  font: inherit; line-height: 1; min-height: 34px;
}
.zoom-btn { width: 34px; font-family: var(--serif-d); font-size: 1.35rem; }
.zoom-fit { padding: 0 8px; font-family: var(--serif-d); font-size: 1rem; font-style: italic; white-space: nowrap; }
.zoom-span { font-style: normal; font-size: 0.7rem; letter-spacing: 0.06em; color: var(--ink-3); }
.zoom-fit[aria-pressed="true"] .zoom-fit-label { color: var(--ink-3); }
.zoom button:hover:not(:disabled) { border-color: var(--rule); color: var(--ink); }
.zoom button:disabled { color: var(--rule); cursor: default; }
.btn-link {
  background: none; border: 0; padding: 8px 0; color: var(--ink); cursor: pointer;
  font: inherit; font-family: var(--serif-d); font-size: 1.1rem; white-space: nowrap;
  border-bottom: 1px solid var(--rule);
}
.btn-link:hover { border-bottom-color: var(--ink); }
.btn, .btn-quiet {
  font: inherit; font-size: 0.95rem; cursor: pointer; border-radius: 2px; padding: 8px 14px; color: var(--ink);
}
.btn { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn:hover { background: #342c24; }
.btn:disabled, .btn-quiet:disabled { opacity: 0.4; cursor: default; }
.btn-quiet { background: transparent; border: 1px solid var(--rule); }
.btn-quiet:hover { border-color: var(--ink); }
.btn-quiet[aria-pressed="true"] { border-color: var(--ink); }

/* death */
.death { padding-bottom: 20px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px 48px; align-items: center; }
.death-msg { font-family: var(--serif-d); font-size: clamp(1.45rem, 2.6vw, 2.1rem); line-height: 1.2; margin: 0; font-style: italic; text-wrap: balance; }
:root[data-status="dead"] .tagline { display: none; }
:root[data-status="dead"] .live-head { padding-bottom: 16px; }
.epitaph { border-left: 2px solid var(--red); padding-left: 20px; }
.epitaph h2 { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--red); margin: 0 0 8px; }
.epitaph p { margin: 0 0 4px; }
.ep-wallet { font-size: 0.85rem; word-break: break-all; }
.ep-line { font-size: 1.1rem; }
.ep-death { color: var(--ink-2); }
.ep-life { color: var(--ink-3); font-size: 0.95rem; }

/* recent beats */
.live-lower { display: grid; grid-template-columns: minmax(0, 720px) minmax(220px, 300px); justify-content: space-between; gap: 24px 56px; padding-top: 36px; }
.recent h2, .side-notes h2 { font-size: 1.35rem; margin: 0 0 10px; }
.recent-list { list-style: none; margin: 0; padding: 0; max-width: 620px; }
.beat {
  display: grid; grid-template-columns: 3.2rem 5.4rem 7.5rem 2.6rem 5.6rem 2.6rem;
  gap: 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 55%, transparent);
  font-size: 0.95rem;
}
.beat-time { color: var(--ink-2); font-size: 0.82rem; }
.beat-ago { color: var(--ink-3); font-size: 0.85rem; }
.beat-wallet { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; }
.beat-side { font-style: italic; color: var(--ink-2); }
.beat-sell .beat-side { color: var(--ink-3); }
.beat-sol { text-align: right; font-size: 0.82rem; }
.beat-tx { font-size: 0.82rem; color: var(--ink-3); text-align: right; }
/* heir & patron of the day: quiet, like the vitals */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.live-side { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.bequest { display: flex; flex-direction: column; gap: 16px; }
.bq { border-left: 1px solid var(--rule); padding-left: 14px; }
.bq[data-final="1"] { border-left: 2px solid var(--red); }
.bq p { margin: 0; }
.bq-line[hidden] { display: none; }
.bq-label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px !important; }
.bq-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.bq-who { font-size: 1.05rem; }
.bq-score { font-size: 0.8rem; color: var(--ink-2); }
.bq-note { color: var(--ink-2); font-size: 0.92rem; font-style: italic; }
.bq-note .mono, .bq-note { font-variant-numeric: tabular-nums; }
.bq-foot { max-width: 34ch; margin: 0; }
.day-patron { color: var(--ink-2); font-size: 0.85rem; font-style: italic; }
.side-notes { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.side-notes p { margin: 0; }
.market { margin-top: 8px !important; }

/* ---------------------------------------------------------------- sections */
.section-title { font-size: clamp(2rem, 4vw, 2.8rem); margin: 0 0 8px; letter-spacing: 0.04em; }
.days, .rules, .verify { padding-top: clamp(64px, 11vh, 120px); }
.lede { color: var(--ink-2); max-width: 60ch; margin: 0 0 24px; }

.days-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 28px 24px; }
.day-open { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: zoom-in; color: inherit; font: inherit; }
.day-open > img { display: block; width: 100%; height: auto; aspect-ratio: 1600 / 600; background: var(--art-bg); border: 1px solid var(--rule); box-shadow: 0 1px 0 rgba(60, 45, 20, 0.08), 0 10px 22px -16px rgba(60, 45, 20, 0.5); margin-bottom: 8px; transition: transform 0.25s ease; }
.day-open:hover > img { transform: translateY(-2px); }
.day-title { font-family: var(--serif-d); font-size: 1.3rem; }
.day-meta { color: var(--ink-3); font-size: 0.85rem; }
.day-facts { display: flex; flex-wrap: wrap; gap: 0 10px; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.day-mood:empty { display: none; }
.day-near { color: var(--red); }
.day-near[hidden] { display: none; }
.day-patron-row { display: flex; align-items: center; gap: 8px; min-height: 22px; margin-top: 2px; }
.day-seal { display: block; width: auto; height: 20px; flex: none; }
.day-seal[hidden], .viewer-seal[hidden] { display: none; }

.prose { max-width: 66ch; font-size: 1.12rem; }
.prose h1 { display: none; } /* the page already carries the title */
.prose h3 { font-size: 1.65rem; margin: 1.8em 0 0.4em; }
.prose p:first-of-type em { font-size: 1.3rem; }
.prose ol, .prose ul { padding-left: 1.4em; }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--ink-3); font-family: var(--mono); font-size: 0.85em; }
.prose code { word-break: break-all; background: var(--paper-2); padding: 1px 4px; }
.prose strong { font-weight: 500; }

.never { font-size: 1.2rem; margin: 0 0 28px; padding: 14px 18px; border-left: 2px solid var(--red); background: var(--paper-2); max-width: 60ch; }
.never strong { font-weight: 600; }
.verify > .small { max-width: 72ch; }
.addresses { margin: 0 0 24px; display: grid; gap: 0; max-width: 900px; }
.addr-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 8px 24px; padding: 14px 0; border-top: 1px solid var(--rule); }
.addr-row:last-child { border-bottom: 1px solid var(--rule); }
.addr-row dt { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); padding-top: 3px; }
.addr-row dd { margin: 0; }
.addr { display: block; font-size: 0.95rem; word-break: break-all; margin-bottom: 6px; }
.addr-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.95rem; }
.addr-meta { display: block; margin-top: 4px; }

.site-foot { padding-top: 96px; padding-bottom: 48px; color: var(--ink-2); font-size: 0.92rem; }
.site-foot p { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- viewer */
.viewer { width: min(96vw, 1680px); max-width: none; max-height: 96vh; padding: 0; border: 0; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.viewer::backdrop { background: rgba(26, 22, 18, 0.78); }
.viewer-inner { padding: clamp(12px, 2vw, 24px); display: flex; flex-direction: column; gap: 10px; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.viewer-title { margin: 0; font-size: 1.8rem; }
.viewer-img { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; background: var(--art-bg); }
.viewer-meta { margin: 0; font-size: 0.95rem; }
.viewer-foot { display: flex; align-items: center; gap: 12px; }
.viewer-seal { display: block; width: auto; height: 30px; flex: none; }
.viewer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.viewer-actions .spacer { flex: 1; }

.fatal { position: fixed; bottom: 16px; left: 16px; right: 16px; margin: 0; padding: 12px 16px; background: var(--ink); color: var(--paper); }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 860px) {
  .live-head { grid-template-columns: 1fr; }
  .heir { grid-column: 1; }
  .live-lower { grid-template-columns: 1fr; }
  /* heir & patron come first on narrow screens, above the list of heartbeats */
  .live-side { display: contents; }
  .bequest { order: -1; }
  .death { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --art-h: min(46vh, 340px); }
  body { font-size: 1rem; }
  .demo-banner { font-size: 0.7rem; padding-block: 5px; }
  .site-head { padding-top: 14px; }
  .brand span { display: none; }
  .site-head nav a { font-size: 1.05rem; }
  .live-head { padding-top: 18px; gap: 18px; }
  .vitals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 12px; }
  .vital { grid-column: span 2; }
  .vital-status, .vital-countdown { grid-column: span 3; }
  /* heir: wallet on the first line, what it inherits on the next (no dangling dash) */
  .heir { margin-top: 0; }
  .heir-note { flex-basis: 100%; }
  .heir-sep { display: none; }
  .vital-countdown dd { font-size: 1.6rem; }
  :root[data-status="dead"] .vital-countdown dd #countdown { font-size: 0.85rem; }
  .tagline { font-size: 1rem; }
  .vital-status dd { font-size: 1.3rem; }
  .vital dd { font-size: 1.15rem; }
  .scroll-controls { flex-wrap: wrap; }
  .scroll-help { order: 3; width: 100%; text-align: left; font-size: 0.9rem; }
  .scroll-controls { gap: 6px 8px; }
  .zoom { order: 1; }
  .zoom-btn { width: 30px; }
  .zoom-fit { padding: 0 4px; }
  #to-now { order: 2; }
  .beat { grid-template-columns: 2.9rem minmax(0, 1fr) 2.2rem 4.8rem 2.2rem; gap: 8px; }
  .beat-ago { display: none; }
  .addr-row { grid-template-columns: 1fr; }
  .viewer-actions .spacer { display: none; }
  .viewer-actions button { flex: 1 1 40%; }
}
