/* =========================================================================
   North Lawn Live
   A screen-printed editorial illustration. Limited ink set, flat plates,
   deliberate misregistration. Type does the talking; there is no UI chrome.
   ========================================================================= */

/* --- type plates --------------------------------------------------------- */

@font-face {
  font-family: 'Fira Sans';
  src: url('fonts/FiraSans-Black.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: 'Fira Sans';
  src: url('fonts/FiraSans-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Fira Sans';
  src: url('fonts/FiraSans-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vollkorn';
  src: url('fonts/Vollkorn-VariableFont_wght.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: 'Vollkorn';
  src: url('fonts/Vollkorn-Italic-VariableFont_wght.woff2') format('woff2');
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('fonts/IBMPlexMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

/* --- ink set ------------------------------------------------------------- */

:root {
  --ink: #17293D;          /* never black — this is a navy plate */
  --ink-soft: rgb(23 41 61 / 0.55);
  --paper: #FBF6EA;        /* the stock, showing through the bubble */
  --paper-worn: #F2E7CE;
  --paper-sign: #F4EBD6;   /* weathered hillside paint */
  --tan: #E08A3C;          /* the accent — his own colour, which is the joke */
  --wood: #C79A67;
  --wood-ink: #5A3E24;
  --hill-shadow: #20493A;
  --sour: #B5533F;
  --sweet: #C98A2E;

  --font-display: 'Fira Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Vollkorn', Georgia, 'Times New Roman', serif;
  --font-data: 'Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* A single visual world, lit by its own sun. It does not invert. */
  color-scheme: light;
}

/* --- stage --------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #2B79B6;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  opacity: 0;
  transition: opacity 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
  -webkit-font-smoothing: antialiased;
}
body.is-ready { opacity: 1; }

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.13;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.16'/%3E%3C/svg%3E");
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* --- the sun ------------------------------------------------------------- */

.sun { pointer-events: auto; cursor: pointer; }

.sun__body {
  transform-box: fill-box;
  transform-origin: center;
}

/* All nine heads are stacked; the active one is faded up by the component. */
.sun__face {
  opacity: 0;
  transition: opacity 900ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sun__rays-front { --ray-front: #F7C334; --ray-ink: #C9631C; }
/* Warm, or it reads as a grey shadow rather than a second flare. */
.sun__rays-back { --ray-back: rgb(255 196 58 / 0.55); }
/* Lash line: the sprite's own line work is a warm brown, not the page ink. */
.sun__lids { pointer-events: none; --lash: #8A3E12; }

.sun__hit { cursor: pointer; }

/* --- the readout, painted onto the hillside ------------------------------ */

.readout__label {
  font-family: var(--font-data);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: 0.34em;
  fill: var(--paper-sign);
  fill-opacity: 0.62;
}

.readout__percent {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 78px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  fill: var(--paper-sign);
  fill-opacity: 0.94;
}

.readout__percent--misfit {
  fill: var(--hill-shadow);
  fill-opacity: 0.42;
}

.readout__plank {
  font-family: var(--font-data);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  fill: var(--wood-ink);
}

/* --- thought bubble ------------------------------------------------------ */

.bubble {
  position: absolute;
  top: 0;
  left: 0;
  width: min(320px, 62vw);
  will-change: transform;
  /* Set here rather than on the body so the trailing puffs, which are its
     siblings, take the same colour as the cloud's outline. */
  --bubble-edge: var(--ink);
}

.bubble[data-kind='negative'] { --bubble-edge: var(--sour); }
.bubble[data-kind='positive'] { --bubble-edge: var(--sweet); }

.bubble__body {
  position: relative;
  z-index: 2;
  /* Generous, because the copy sits inside the core box while the lobes of
     the cloud bulge out past it — the corners are where it pinches closest. */
  padding: 1.15rem 1.3rem 0.95rem;
  transition:
    opacity 300ms ease,
    transform 300ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* The cloud itself: generated in ThoughtBubble.js from the measured box, and
   allowed out of its own bounds so the lobes can hang over the edge. */
.bubble__cloud {
  position: absolute;
  z-index: -1;
  overflow: visible;
  pointer-events: none;
}

.bubble__cloud-fill {
  fill: var(--paper);
  stroke: var(--bubble-edge);
  stroke-width: 3;
  stroke-linejoin: round;
  transition: stroke 700ms ease;
}

/* A hard offset drop, no blur — the same flat shadow the signposts cast. */
.bubble__cloud-shadow {
  fill: rgb(23 41 61 / 0.13);
  transform: translateY(9px);
}

.bubble__text {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.02rem;
  line-height: 1.42;
  text-wrap: pretty;
  color: var(--ink);
}

.bubble[data-kind='status'] .bubble__text {
  font-style: italic;
  color: var(--ink-soft);
}

.bubble__source {
  margin: 0.6rem 0 0;
  font-family: var(--font-data);
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.bubble__source:empty { display: none; }

.bubble.is-swapping .bubble__body {
  opacity: 0;
  transform: translateY(7px) scale(0.985);
}

/* The trail: the little puffs that make it a thought rather than a shout. */
.bubble__tail {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  background: var(--paper);
  border: 3px solid var(--bubble-edge, var(--ink));
  border-radius: 50%;
  box-shadow: 0 5px 0 rgb(23 41 61 / 0.11);
  transition: border-color 700ms ease;
}

/* --- masthead and colophon ----------------------------------------------- */

.masthead {
  position: absolute;
  top: clamp(1.1rem, 3.4vh, 2.4rem);
  left: clamp(1.1rem, 3.2vw, 2.8rem);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.06em;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: -0.035em;
  color: var(--paper-sign);
  text-shadow: 0 2px 0 rgb(23 41 61 / 0.22);
  pointer-events: none;
}

.masthead__line {
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  text-transform: uppercase;
}
.masthead__line--wide {
  font-size: clamp(1.3rem, 2.7vw, 2.05rem);
}

.colophon {
  position: absolute;
  left: clamp(1.1rem, 3.2vw, 2.8rem);
  bottom: clamp(0.9rem, 2.6vh, 1.8rem);
  margin: 0;
  max-width: 26ch;
  font-family: var(--font-data);
  font-size: 0.64rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgb(244 235 214 / 0.5);
}
.colophon a {
  color: inherit;
  text-decoration-color: rgb(244 235 214 / 0.35);
  text-underline-offset: 3px;
  pointer-events: auto;
}
.colophon a:hover { color: rgb(244 235 214 / 0.9); }
.colophon a:focus-visible {
  outline: 2px solid var(--paper-sign);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Buy Me a Coffee widget: the script renders it inline at the bottom of the
   body, so pin it to the top-right corner instead — sits in the empty sky
   above the horizon. */
.bmc-btn-container {
  position: fixed !important;
  top: clamp(1.1rem, 3.4vh, 2.4rem) !important;
  right: clamp(1.1rem, 3.2vw, 2.8rem) !important;
  width: auto !important;
  z-index: 20;
  transform-origin: top right;
}

/* Snapshot mode: strip everything that isn't the scene, so the raw
   composition can be captured for share cards and press images. */
.snapshot-mode .bmc-btn-container,
.snapshot-mode .colophon,
.snapshot-mode .rotate-prompt { display: none !important; }

/* --- rotate-your-phone prompt (portrait mobile only) --------------------- */

.rotate-prompt {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 2rem;
  background: #1a2c3f;
  color: #f4ebd6;
  text-align: center;
}

.rotate-prompt__icon {
  width: 96px;
  height: 96px;
  animation: rotate-prompt-turn 2.4s ease-in-out infinite;
}

.rotate-prompt__text {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.4;
  max-width: 22ch;
}

@keyframes rotate-prompt-turn {
  0%, 30%   { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

@media (orientation: portrait) and (max-width: 680px) {
  .rotate-prompt { display: flex; }
}

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

/* --- narrow windows ------------------------------------------------------ */

@media (max-width: 680px) {
  .bubble { width: min(250px, 70vw); }
  .bubble__text { font-size: 0.92rem; }

  /* The BMC widget's inner button is fixed at 210×60 — shrink the whole
     thing so it doesn't dominate a small screen. */
  .bmc-btn-container { transform: scale(0.7); }

  /* Keeps the desktop bottom-left position — the top-right corner is taken
     by the Buy Me a Coffee widget on mobile, so the credit stays on the grass. */
  .colophon {
    max-width: 21ch;
    font-size: 0.55rem;
    line-height: 1.5;
  }
}

/* --- reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  body,
  .bubble__body,
  .bubble__cloud-fill,
  .bubble__tail,
  .sun__face {
    transition-duration: 1ms;
  }
}

/* --- the birds ----------------------------------------------------------- */

/* The spread wing appears only while the bird is beating it; settled, the
   body sprite's own folded wing is what you see. Snapped in fast, because a
   slow fade on a beating wing reads as a smear. */
.bird__wing {
  transition: opacity 110ms linear;
}

.bird { transform-box: view-box; }

/* --- test panel ---------------------------------------------------------- */

/* Folded into the corner and faded back: the piece isn't meant to have
   controls, so this only asserts itself once you go looking for it. */
.testpanel {
  position: absolute;
  right: clamp(0.9rem, 2.4vw, 1.8rem);
  bottom: clamp(0.9rem, 2.6vh, 1.8rem);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: auto;
  font-family: var(--font-data);
}

.testpanel__toggle {
  padding: 0.3rem 0.6rem;
  font: inherit;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgb(244 235 214 / 0.45);
  background: rgb(23 41 61 / 0.18);
  border: 1px solid rgb(244 235 214 / 0.22);
  border-radius: 999px;
  cursor: pointer;
  transition: color 200ms ease, background 200ms ease, border-color 200ms ease;
}
.testpanel__toggle:hover,
.testpanel__toggle:focus-visible {
  color: var(--paper-sign);
  background: rgb(23 41 61 / 0.34);
  border-color: rgb(244 235 214 / 0.5);
}
.testpanel.is-on .testpanel__toggle {
  color: var(--paper);
  background: var(--sour);
  border-color: transparent;
}

.testpanel__body {
  width: 190px;
  padding: 0.7rem 0.8rem 0.75rem;
  background: rgb(23 41 61 / 0.82);
  border: 1px solid rgb(244 235 214 / 0.18);
  border-radius: 12px;
  color: var(--paper-sign);
  backdrop-filter: blur(3px);
}

.testpanel__row {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.testpanel__number {
  flex: 1;
  min-width: 0;
  padding: 0.28rem 0.4rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  background: rgb(0 0 0 / 0.28);
  border: 1px solid rgb(244 235 214 / 0.22);
  border-radius: 6px;
}
.testpanel__number:focus-visible,
.testpanel__slider:focus-visible {
  outline: 2px solid var(--sweet);
  outline-offset: 2px;
}
.testpanel__unit { font-size: 0.78rem; opacity: 0.7; }

.testpanel__slider {
  width: 100%;
  margin: 0.55rem 0 0;
  accent-color: var(--sour);
}

.testpanel__date {
  margin: 0.5rem 0 0;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.6;
}

@media (max-width: 680px) {
  .testpanel__body { width: 158px; }
}

