/* birds.cool — The Bird Book
   A storybook on black. Serif reads, sans operates.
   Accent discipline: cardinal red appears in exactly four roles — kickers +
   Fred's feather stamp, the one Wake button, the LIVE dot, and filled hearts.
   Nothing readable renders under 16px.
   The black background is the owner's call (it matches the site's identity
   and makes the feeder photos pop); the older-eyes mitigations stay — warm
   off-white ink (never #FFF), big type, generous weight. */

:root {
  /* Night & ink (the only theme) */
  --paper: #000000;
  --paper-deep: #0b0b0b;
  --ink: #f1f1ed;
  --bark: #a8aca7;
  --feather-line: rgba(255, 255, 255, 0.14);
  --feather-line-soft: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);

  /* Bird accents (spent scarcely) */
  --cardinal: #e05a4e;
  --cardinal-press: #c74437;
  --cardinal-button-text: #22110c; /* coral fill takes dark text for AA (~6:1) */
  --goldfinch-ink: #d9a521;
  --jay: #7fa8d0;

  /* Inside the frame — media matting */
  --frame-dark: #120e0a;
  --frame-text: #f1f1ed;
  --frame-glass: rgba(18, 14, 10, 0.55);

  /* Type */
  --serif: ui-serif, "New York", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Rhythm & touch */
  --btn: 60px;
  --btn-hero: 64px;
  --radius-card: 8px;
  --radius-ui: 8px;
  --page-pad: 20px;
  --chapter-gap: clamp(44px, 7vh, 64px);
  --content-max: 640px;
}

/* ---------- base ---------- */

* {
  box-sizing: border-box;
}

html {
  /* Dynamic Type hook: -apple-system-body makes 1rem track iOS "Larger Text".
     Must live on the root (not body) so rem units scale with it. */
  font: -apple-system-body;
  font-family: var(--serif);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

img {
  display: block;
}

a {
  color: var(--jay);
  text-underline-offset: 3px;
}

button {
  appearance: none;
  border: none;
  margin: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--jay);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: no-preference) {
  .pressable {
    transition: transform 120ms cubic-bezier(0.23, 1, 0.32, 1), box-shadow 120ms cubic-bezier(0.23, 1, 0.32, 1);
  }
  .pressable:active {
    transform: scale(0.98);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 40;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--radius-ui);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 22px;
  max-width: var(--content-max);
  margin: 56px auto 0;
  padding: 24px var(--page-pad) calc(env(safe-area-inset-bottom) + 32px);
  border-top: 1px solid var(--feather-line-soft);
  font-family: var(--sans);
  font-size: 0.9375rem;
}

.site-legal a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--bark);
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--content-max);
  margin: 0 auto 18px;
  padding: calc(env(safe-area-inset-top) + 14px) var(--page-pad) 0;
}

.masthead-mark {
  width: 38px;
  height: 38px;
}

.masthead-title h1 {
  font-family: var(--serif);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
}

.masthead-sub {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 400;
  color: var(--bark);
  margin-top: 2px;
}

.sample-note {
  margin: -8px 0 20px;
  padding: 12px var(--page-pad);
  background: var(--paper-deep);
  border-block: 1px solid var(--feather-line-soft);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--bark);
  text-align: center;
  text-wrap: pretty;
}

.sample-note[hidden] {
  display: none;
}

/* ---------- the book ---------- */

.book {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 24px);
}

.chapter {
  margin-block-start: var(--chapter-gap);
}

.chapter:first-child,
#today {
  margin-block-start: 0;
}

.chapter-body {
  padding: 0 var(--page-pad);
}

.kicker {
  font-family: var(--sans);
  font-size: 1rem; /* the 16px floor holds even for kickers */
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--cardinal);
  padding: 0 var(--page-pad);
}

.kicker.goldfinch {
  color: var(--goldfinch-ink);
}

.dateline-title {
  font-family: var(--serif);
  font-size: clamp(2.125rem, 9vw, 2.75rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0;
  text-wrap: balance;
  color: var(--ink);
  margin: 6px 0 0;
  padding: 0 var(--page-pad);
}

.deck {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.45;
  color: var(--bark);
  text-wrap: pretty;
  margin-top: 10px;
  padding: 0 var(--page-pad);
}

/* who came by today — a compact field-guide index */

.today-birds {
  margin: 20px var(--page-pad) 4px;
  border-block: 1px solid var(--feather-line-soft);
}

.today-birds-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0 11px;
}

.today-birds-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
}

.today-birds-head span {
  flex: none;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--bark);
  font-variant-numeric: tabular-nums;
}

.faces {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 16px;
}

.face {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 76px;
  padding: 10px 0;
  border-top: 1px solid var(--feather-line-soft);
  color: inherit;
  text-decoration: none;
}

.face-portrait {
  display: grid;
  place-items: center;
  width: 48px;
  height: 54px;
  border-radius: 999px 999px 9px 9px;
  object-fit: cover;
  border: 1.5px solid var(--feather-line);
  background: var(--paper-deep);
}

.face-portrait.is-mystery {
  border-style: dashed;
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--bark);
}

.face-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.face-label {
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  text-wrap: pretty;
}

.face-count {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--bark);
  font-variant-numeric: tabular-nums;
}

.face-open {
  color: var(--cardinal);
  font-family: var(--sans);
  font-size: 1.5rem;
  line-height: 1;
}

/* ---------- moment cards ---------- */

.moment {
  margin-top: 20px;
}

.moment + .moment {
  margin-top: 24px;
}

.moment-media {
  position: relative;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--frame-dark);
  border-block: 1px solid var(--feather-line-soft);
}

.play-cover {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
}

.play-cover img {
  width: 100%;
  height: auto; /* beat the width/height attributes so aspect-ratio wins */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--frame-dark);
}

.play-cover.ratio-4x3 img {
  aspect-ratio: 4 / 3;
}

.play-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: none;
  border-radius: inherit;
}

.moment-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px var(--page-pad) 0;
}

.moment-species {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
}

.moment-meta {
  display: block;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.play-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.play-circle svg {
  width: 22px;
  height: 22px;
  margin-left: 3px; /* optical centering */
  fill: #ffffff;
}

.moment-media video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--frame-dark);
}

.moment-media.ratio-4x3 video {
  aspect-ratio: 4 / 3;
}

/* replay overlay after a clip ends */

.after-clip {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  background: rgba(18, 14, 10, 0.55);
  overflow: auto;
}

.after-clip .btn {
  width: min(240px, 100%);
  min-height: 48px;
}

.story {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--bark);
  text-wrap: pretty;
  margin: 12px var(--page-pad) 0;
}

.moment-datestamp {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  margin: 10px var(--page-pad) 0;
}

/* ---------- buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--btn);
  padding: 12px 20px;
  border-radius: var(--radius-ui);
  background: var(--paper-deep);
  border: 1.5px solid var(--feather-line);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.1875rem;
  font-weight: 600;
  text-wrap: balance;
}

.btn-cardinal {
  background: var(--cardinal);
  border-color: var(--cardinal);
  color: var(--cardinal-button-text);
}

.btn-cardinal:active {
  background: var(--cardinal-press);
}

.btn[disabled] {
  cursor: default;
  opacity: 0.55;
}

/* ---------- chapter footer / honest tally ---------- */

.tally-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: calc(100% - 24px);
  margin: 24px 12px 0;
  min-height: var(--btn-hero);
  padding: 12px 18px;
  border-radius: var(--radius-ui);
  background: var(--paper-deep);
  border: 1px solid var(--feather-line);
  text-align: left;
}

.tally-count {
  font-family: var(--sans);
  font-size: 1.125rem;
  color: var(--ink);
}

.tally-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--cardinal);
  white-space: nowrap;
}

.tally-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: rotate 200ms ease;
}

.tally-row[aria-expanded="true"] .tally-action svg {
  rotate: 180deg;
}

/* the ledger — every visit, chronological, no filters ever */

.ledger {
  margin: 12px 12px 0;
  border: 1px solid var(--feather-line);
  border-radius: var(--radius-ui);
  overflow: hidden;
}

.ledger-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 5px 12px 5px 5px;
  text-align: left;
  background: var(--paper);
}

.ledger-row:nth-child(even) {
  background: var(--paper-deep);
}

.ledger-row img {
  width: 104px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--frame-dark);
}

.ledger-row img.ledger-species-portrait {
  object-position: center;
}

.ledger-mystery {
  display: grid;
  place-items: center;
  width: 104px;
  height: 58px;
  border: 1px dashed var(--feather-line);
  border-radius: 8px;
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--bark);
}

.ledger-name {
  font-family: var(--sans);
  font-size: 1.125rem;
  color: var(--ink);
  line-height: 1.3;
}

.ledger-time {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  font-variant-numeric: tabular-nums;
}

.ledger-unavailable {
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--bark);
  text-align: center;
}

.ledger-play {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1.5px solid var(--feather-line);
  display: grid;
  place-items: center;
}

.ledger-play svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
  fill: var(--bark);
}

.ledger-player {
  padding: 10px;
  background: var(--paper-deep);
}

.ledger-player .moment-media {
  margin: 0;
}

.ledger-note {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  padding: 10px 14px;
  background: var(--paper);
}

/* ---------- day chapters ---------- */

.dateline {
  display: flex;
  flex-wrap: wrap; /* narrow screens: the tally drops to its own line */
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  min-height: 44px;
  padding: 8px var(--page-pad) 0;
}

.dateline-day {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--ink);
}

.feather-stamp {
  width: 20px;
  height: 20px;
  flex: none;
}

.feather-stamp path {
  fill: var(--cardinal);
}

.dateline-tally {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}


/* older days compress to a 2-up spread */

.spread {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin: 20px 0 0;
}

.spread-item {
  text-align: left;
}

.spread-item .play-cover img,
.spread-item .poster-missing {
  aspect-ratio: 16 / 9;
  border-radius: 0;
}

.spread-item .moment-media {
  margin: 0;
  border-radius: 0;
}

.spread-item .play-circle {
  width: 56px;
  height: 56px;
}

.spread-item .play-circle svg {
  width: 22px;
  height: 22px;
}

.spread-caption {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  line-height: 1.35;
  margin: 9px var(--page-pad) 0;
  font-variant-numeric: tabular-nums;
}

.spread-caption strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.spread-player {
  grid-column: 1 / -1;
}

.spread-player .moment-media {
  margin: 0;
}

/* quiet day */

.quiet-day {
  padding: 8px var(--page-pad) 0;
}

.quiet-art {
  width: 96px;
  height: 72px;
  margin-top: 14px;
}

.quiet-art * {
  fill: none;
  stroke: var(--bark);
  stroke-width: 2;
  stroke-linecap: round;
}

.quiet-line {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
  margin-top: 12px;
}

.meanwhile {
  font-family: var(--serif);
  font-size: 1.0625rem;
  color: var(--bark);
  margin: 14px var(--page-pad) 0;
}

/* turn back more pages */

.turn-back {
  width: calc(100% - 24px);
  margin: var(--chapter-gap) 12px 0;
}

.book-end {
  font-family: var(--serif);
  font-size: 1.125rem;
  color: var(--bark);
  text-align: center;
  margin: var(--chapter-gap) var(--page-pad) 0;
}

/* ---------- live card ---------- */

.live-card {
  margin: 16px var(--page-pad) 0;
  padding: 18px 0;
  border-radius: 0;
  background: transparent;
  border-block: 1px solid var(--feather-line-soft);
}

#live-slot .kicker {
  padding: 0;
}

#live-slot {
  margin-block-start: 40px;
  padding: 0 0;
}

#live-slot .live-kicker {
  padding: 0 var(--page-pad);
}

.live-title {
  font-family: var(--serif);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--ink);
  margin-top: 10px;
  text-wrap: balance;
}

.live-line {
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--bark);
  margin-top: 6px;
  text-wrap: pretty;
  font-variant-numeric: tabular-nums;
}

.live-art {
  display: none;
}

.live-art * {
  fill: none;
  stroke: var(--bark);
  stroke-width: 2;
  stroke-linecap: round;
}

.live-card .btn {
  margin-top: 16px;
}

.live-card .btn + .btn {
  margin-top: 12px;
}

.live-card .btn-hero {
  min-height: var(--btn-hero);
}

.live-video-wrap {
  position: relative;
  margin-top: 16px;
  border-radius: var(--radius-ui);
  overflow: hidden;
  background: var(--frame-dark);
}

.live-video-wrap video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.live-pill {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(18, 14, 10, 0.6);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--cardinal);
}

/* ---------- the regulars ---------- */

#regulars {
  margin-block-start: var(--chapter-gap);
}

.regulars-title {
  font-family: var(--serif);
  font-size: 1.875rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink);
  margin: 6px 0 0;
  padding: 0 var(--page-pad);
}

.roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 12px;
  margin: 24px 12px 0;
}

.roster-tile {
  display: block;
  text-align: center;
  padding: 0;
  color: inherit;
  text-decoration: none;
}

.portrait-frame {
  display: block;
  position: relative;
  width: min(100%, 190px);
  margin: 0 auto;
}

.portrait {
  display: block; /* the no-poster fallback is a span */
  width: 100%;
  height: auto;
  aspect-ratio: 7 / 8;
  object-fit: cover;
  border-radius: 999px 999px 14px 14px;
  border: 2px solid var(--feather-line);
  background: var(--paper-deep);
}

.portrait.mystery-portrait {
  display: grid;
  place-items: center;
  border-style: dashed;
  font-family: var(--serif);
  font-size: 4rem;
  color: var(--bark);
}

.roster-tile.is-cardinal .portrait {
  border-color: var(--cardinal);
}

.roster-tile.is-mystery .portrait {
  border-style: dashed;
}

.mystery-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--paper);
  border: 1.5px dashed var(--feather-line);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--bark);
}

.tile-stamp {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--feather-line-soft);
  display: grid;
  place-items: center;
}

.tile-stamp svg {
  width: 17px;
  height: 17px;
}

.roster-name {
  display: block;
  font-family: var(--sans);
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 12px;
  line-height: 1.25;
}

.roster-sub {
  display: block;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  margin-top: 3px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.roster-open {
  display: block;
  margin-top: 8px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--cardinal);
}






/* ---------- colophon ---------- */

.colophon {
  margin-block-start: var(--chapter-gap);
  padding: 0 var(--page-pad) 96px;
  text-align: center;
}

.colophon img {
  width: 56px;
  height: 56px;
  margin: 0 auto;
}

.colophon-end {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
  margin-top: 14px;
}

.colophon-note {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------- states ---------- */

.skeleton {
  padding: 0 var(--page-pad);
}

.skeleton-bar,
.skeleton-card {
  background: var(--paper-deep);
  border-radius: 10px;
}

.skeleton-kicker {
  width: 72px;
  height: 16px;
}

.skeleton-headline {
  width: 62%;
  height: 38px;
  margin-top: 12px;
}

.skeleton-deck {
  width: 90%;
  height: 48px;
  margin-top: 12px;
}

.skeleton-card {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-card);
  margin-top: 18px;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton > * {
    animation: pulse 1.2s ease-in-out infinite alternate;
  }
  @keyframes pulse {
    from {
      opacity: 1;
    }
    to {
      opacity: 0.55;
    }
  }
}

.loading-note {
  font-family: var(--serif);
  font-size: 1.125rem;
  color: var(--bark);
  padding: 16px var(--page-pad) 0;
}

.book-error {
  padding: 48px var(--page-pad);
  text-align: center;
}

.book-error h2 {
  font-family: var(--serif);
  font-size: 1.375rem;
  font-weight: 500;
}

.book-error .btn {
  max-width: 320px;
  margin: 20px auto 0;
}

.poster-missing {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--paper-deep);
}

.poster-missing svg {
  width: 28px;
  height: 28px;
}

.poster-missing path {
  fill: var(--feather-line);
}

/* image fade-in */

@media (prefers-reduced-motion: no-preference) {
  .fade-img {
    opacity: 0;
    transition: opacity 250ms ease-out;
  }
  .fade-img.is-loaded {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-img {
    opacity: 1;
  }
}

/* ---------- wider screens: the book stays a book ---------- */

@media (min-width: 720px) {
  :root {
    --page-pad: 24px;
  }

  .book,
  .masthead {
    max-width: 680px;
  }

  .moment-media,
  .tally-row,
  .ledger,
  .live-card,
  .roster,
  .spread,
  .turn-back {
    margin-left: var(--page-pad);
    margin-right: var(--page-pad);
    width: auto;
  }

  .roster {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .faces {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bird-grid {
    grid-template-columns: 1fr 1fr;
  }

  .moment-media,
  .spread-item .moment-media,
  .spread-item .play-cover img,
  .spread-item .poster-missing {
    border-radius: var(--radius-card);
  }
}

@media (min-width: 520px) and (max-width: 719px) {
  .faces {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- book nav (slim, icon + word) ---------- */

.book-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  max-width: var(--content-max);
  margin: 0 auto 24px;
  padding: 0 10px;
  border-bottom: 1px solid var(--feather-line-soft);
}

.nav-link span,
.nav-link {
  white-space: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bark);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

.nav-link .ic {
  width: 17px;
  height: 17px;
  fill: var(--bark);
}

/* ---------- inline icons ---------- */

.ic {
  width: 16px;
  height: 16px;
  flex: none;
  fill: currentColor;
  vertical-align: -2px;
}

.kicker .ic {
  width: 15px;
  height: 15px;
  margin-right: 2px;
}

/* ---------- signal tags & species chips ---------- */

.moment-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 8px var(--page-pad) 0;
}

.ledger-player .moment-tags,
.spread-player .moment-tags {
  margin: 10px 4px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bark);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
}

.tag.gold {
  color: var(--goldfinch-ink);
  border-color: currentColor;
}

.species-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px 8px 5px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.species-chip img {
  width: 26px;
  height: 30px;
  border-radius: 999px 999px 8px 8px;
  object-fit: cover;
  background: var(--paper);
}

/* ---------- hearts & comments ---------- */

.social-row {
  display: none;
  gap: 8px;
}

.social-on .social-row {
  display: inline-flex;
}

.social-btn {
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--feather-line);
  border-radius: 999px;
}

.social-btn .count {
  font-variant-numeric: tabular-nums;
  min-width: 0.6em;
}

.heart-btn.is-on {
  color: var(--cardinal); /* hearts share the cardinal budget: love is love */
  border-color: currentColor;
}

.spread-hearts {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(18, 14, 10, 0.6);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.spread-hearts .ic {
  width: 13px;
  height: 13px;
}

.comments-panel {
  margin: 10px var(--page-pad) 0;
  border: 1px solid var(--feather-line);
  border-radius: var(--radius-ui);
  background: var(--paper-deep);
  padding: 14px;
}

.ledger-player .comments-panel,
.spread-player .comments-panel {
  margin: 10px 4px 0;
}

.comment {
  padding: 8px 0;
  border-bottom: 1px solid var(--feather-line-soft);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

.comment:last-child {
  border-bottom: none;
}

.comment-name {
  font-weight: 700;
  color: var(--ink);
  margin-right: 6px;
}

.comment-source {
  display: inline-block;
  margin-left: 8px;
  color: var(--bark);
  font-size: 0.75rem;
  font-weight: 500;
}

.comment-text {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.comment-when {
  display: inline-block;
  margin-left: 6px;
  color: var(--bark);
  font-variant-numeric: tabular-nums;
}

.comments-empty {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
}

.comment-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  border: 1px solid var(--feather-line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem; /* ≥16px so iOS Safari never zoom-jumps on focus */
  padding: 10px 12px;
}

.comment-form textarea {
  resize: vertical;
}

.comment-post {
  min-height: 48px;
  justify-self: end;
  width: auto;
  padding: 10px 26px;
}

/* ---------- bird pages ---------- */

/* ---------- pages ---------- */

.page[hidden] {
  display: none;
}

.page-title {
  font-family: var(--serif);
  font-size: 1.875rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink);
  margin: 6px 0 0;
  padding: 0 var(--page-pad);
}

#days-page .kicker,
#best-page .kicker {
  display: block;
}

.nav-link.is-active {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 -2px var(--cardinal);
}

.nav-link.is-active .ic {
  fill: var(--cardinal);
}

/* home doors — big labeled entrances to the other pages */

.doors {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: var(--chapter-gap) 12px 0;
}

.door {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 84px;
  padding: 14px 8px;
  border: 1px solid var(--feather-line);
  border-radius: var(--radius-ui);
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}

.door .ic {
  width: 24px;
  height: 24px;
  fill: var(--bark);
}

#bird-page {
  padding-top: 4px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 0 var(--page-pad);
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bark);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
}

.bird-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 20px var(--page-pad) 0;
}

.bird-head .portrait-frame {
  width: 132px;
  flex: none;
}

.bird-head-copy {
  min-width: 0;
}

.bird-title {
  font-family: var(--serif);
  font-size: 1.875rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.15;
  text-wrap: balance;
}

.bird-stats {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bark);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  text-wrap: pretty;
}

.bird-note {
  font-family: var(--serif);
  font-size: 1.0625rem;
  color: var(--bark);
  margin-top: 4px;
}

.sort-row {
  display: flex;
  gap: 20px;
  margin: 20px var(--page-pad) 0;
  border-bottom: 1px solid var(--feather-line-soft);
}

.sort-btn {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--bark);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
}

.sort-btn[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 -2px var(--cardinal);
}

#bird-more {
  margin-top: 16px;
}

#bird-more .btn {
  width: calc(100% - 24px);
  margin: 0 12px;
}

@media (min-width: 720px) {
  #bird-more .btn {
    width: auto;
    margin: 0 var(--page-pad);
  }
}

.comment-label {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: -2px;
}

.comment-error {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--cardinal);
}

.comment-error[hidden] {
  display: none;
}

/* ---------- polish pass (revision 4) ---------- */

/* Dark scrollbars and native controls on the black theme */
html {
  color-scheme: dark;
}

::selection {
  background: rgba(224, 90, 78, 0.4);
  color: var(--ink);
}

/* Share button (native sheet on phones, copies the link elsewhere) */
.share-note {
  font-family: var(--sans);
  font-size: 1rem;
}

.share-note:empty {
  display: none;
}

.share-btn.is-copied {
  color: var(--goldfinch-ink);
  border-color: rgba(217, 165, 33, 0.5);
}

/* Shared-clip landing page (?clip=…) */
.shared-title {
  margin-top: 4px;
}

.shared-kicker {
  display: block;
  margin-top: 16px;
}

#shared-clip .bird-stats {
  padding: 0 var(--page-pad);
  margin-top: 2px;
}

/* Typography niceties */
.live-title,
.page-title,
.bird-title {
  text-wrap: balance;
}

.live-line,
.quiet-line {
  text-wrap: pretty;
}

.comment-text-input {
  resize: vertical;
}

.spread-hearts {
  font-variant-numeric: tabular-nums;
}

/* The masthead and navigation keep one calm reading axis on every screen. */
@media (min-width: 720px) {
  .site-head {
    max-width: 680px;
    margin: 0 auto;
  }

  .site-head .masthead {
    margin-bottom: 18px;
  }

  .site-head .book-nav {
    margin-bottom: 28px;
  }
}

/* Desktop: reading pages stay a book column; galleries open wide */
@media (min-width: 1080px) {
  .book {
    max-width: none;
  }

  .page {
    max-width: 680px;
    margin-inline: auto;
  }

  #best-page,
  #birds-page,
  #bird-page {
    max-width: 1024px;
  }

  .bird-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 28px 14px;
  }

  .roster {
    grid-template-columns: repeat(4, 1fr);
    gap: 34px 18px;
  }

  .bird-head {
    gap: 28px;
  }
}

/* Hover craft — mouse users only; motion respects reduced-motion */
@media (hover: hover) and (pointer: fine) {
  .nav-link:hover,
  .door:hover,
  .tally-row:hover,
  .btn:hover:not(:disabled):not(.btn-cardinal),
  .sort-btn[aria-pressed="false"]:hover,
  .social-btn:hover,
  a.species-chip:hover {
    border-color: rgba(255, 255, 255, 0.34);
  }

  .nav-link:hover:not(.is-active),
  .door:hover {
    background: transparent;
    color: var(--ink);
  }

  .btn-cardinal:hover:not(:disabled) {
    background: var(--cardinal-press);
  }

  .heart-btn:hover {
    color: var(--cardinal);
  }

  a.species-chip:hover span,
  .face:hover .face-label,
  .roster-tile:hover .roster-name,
  .back-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .roster-tile:hover .portrait {
    border-color: rgba(255, 255, 255, 0.4);
  }

  .roster-tile.is-cardinal:hover .portrait {
    border-color: var(--cardinal);
  }

  .ledger-row:hover {
    background: var(--paper-deep);
  }

  .play-cover:hover .play-circle {
    background: rgba(18, 14, 10, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
  }

  @media (prefers-reduced-motion: no-preference) {
    .play-circle {
      transition:
        transform 160ms cubic-bezier(0.23, 1, 0.32, 1),
        background-color 160ms cubic-bezier(0.23, 1, 0.32, 1),
        border-color 160ms cubic-bezier(0.23, 1, 0.32, 1);
    }

    .play-cover:hover .play-circle {
      transform: scale(1.07);
    }

    .door,
    .nav-link,
    .roster-tile {
      transition:
        transform 140ms cubic-bezier(0.23, 1, 0.32, 1),
        background-color 140ms cubic-bezier(0.23, 1, 0.32, 1),
        border-color 140ms cubic-bezier(0.23, 1, 0.32, 1);
    }

    .door:hover,
    .roster-tile:hover {
      transform: translateY(-2px);
    }
  }
}
