/* =====================================================================
   Day 27/30 — Vibe check
   The page owns no colour. The mood brings it.

   Before a result the field is a dusky, near-neutral drift. The palette
   the model returns floods the whole screen and that transition is the
   moment the build is built around.
   ===================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

:root {
  /* Type */
  --display: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  --ui:      'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --label:   'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --ground: #0b0d10;

  /* The resting palette. Dusky and cool rather than grey, so the loading
     bloom has real saturation to lift. Replaced by the model's four. */
  --c1: #4a5768;
  --c2: #35485a;
  --c3: #545d6b;
  --c4: #1f252e;

  /* Field dials, moved per state rather than per element. Resting is low
     but never off: an invisible field has nowhere to bloom from, and the
     first screen would just be a black rectangle. */
  --blob-o: 0.72;
  --sat: 0.5;
  --bright: 0.92;
  --blur: clamp(26px, 6vw, 58px);

  --veil-a: 0.30;

  --pad: clamp(1.5rem, 6vw, 5.5rem);

  /* Exponential ease-out. Everything on the page leaves from a fast start
     and settles, which is what makes a slow duration feel calm and not slow. */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Ink flips with the palette's luminance so type never dies on a pastel. */
body[data-lum="dark"] {
  --ink:   #f4f2ee;
  --ink-2: rgba(244, 242, 238, 0.90);
  --ink-3: rgba(244, 242, 238, 0.62);
  --veil:  8, 9, 12;
  --veil-line: 244, 242, 238;
  /* A light blob can drift under the corner even on a dark palette, so the
     dark pool has to be deep enough for that phase, not the average one.
     On a dark field it reads as an ordinary vignette. */
  --day-pool: 0.66;
}

body[data-lum="light"] {
  --ink:   #14161b;
  --ink-2: rgba(20, 22, 27, 0.88);
  --ink-3: rgba(20, 22, 27, 0.60);
  --veil:  255, 253, 250;
  --veil-line: 20, 22, 27;
  /* Dark ink over a pale field clears 4.5:1 with far less help, and a
     heavy white pool would read as a smudge in the corner. */
  --day-pool: 0.34;
}

/* ------------------------------------------------------------------ *
   THE FIELD
 * ------------------------------------------------------------------ */

.field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  /* Set from the palette on a result, so the gaps between blobs read as
     part of the weather rather than as a hole punched in it. */
  background: var(--ground);
  transition: background-color 1700ms var(--ease);
}

/* A solid colour behind a soft radial mask, rather than a background-image
   gradient. background-color interpolates, background-image does not, so
   the palette can cross-fade into place instead of cutting. */
.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  opacity: var(--blob-o);
  filter: blur(var(--blur)) saturate(var(--sat)) brightness(var(--bright));
  -webkit-mask-image: radial-gradient(closest-side, #000 0%, rgba(0,0,0,0.86) 38%, transparent 74%);
          mask-image: radial-gradient(closest-side, #000 0%, rgba(0,0,0,0.86) 38%, transparent 74%);
  will-change: transform;
  transition:
    background-color 1700ms var(--ease),
    opacity          1700ms var(--ease),
    filter           1700ms var(--ease);
}

/* Sizes and paths are deliberately unequal. The loops share no common
   multiple, so the composition never returns to a frame you have seen. */
.blob-1 { width: 96vmax; height: 74vmax; left: -26vmax; top: -22vmax;
          background: var(--c1); animation: drift-1 43s linear infinite; }

.blob-2 { width: 78vmax; height: 98vmax; right: -24vmax; top: -30vmax;
          background: var(--c2); animation: drift-2 37s linear infinite; }

.blob-3 { width: 104vmax; height: 82vmax; left: -30vmax; bottom: -34vmax;
          background: var(--c3); animation: drift-3 53s linear infinite; }

.blob-4 { width: 70vmax; height: 90vmax; right: -22vmax; bottom: -28vmax;
          background: var(--c4); animation: drift-4 31s linear infinite; }

/* The fifth carries a mid tone back across the centre so the middle of the
   screen never reads as the flat place where four edges meet. */
.blob-5 { width: 86vmax; height: 86vmax; left: 12vmax; top: 6vmax;
          background: var(--c2); opacity: calc(var(--blob-o) * 0.7);
          animation: drift-5 61s linear infinite; }

/* Translate and rotate only. Nothing scales, so the blurred layer is
   rasterised once and the drift stays a pure composite. */
@keyframes drift-1 {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  33%  { transform: translate3d(14vmax, 9vmax, 0) rotate(52deg); }
  66%  { transform: translate3d(5vmax, 18vmax, 0) rotate(154deg); }
  100% { transform: translate3d(0, 0, 0) rotate(360deg); }
}

@keyframes drift-2 {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  33%  { transform: translate3d(-12vmax, 14vmax, 0) rotate(-64deg); }
  66%  { transform: translate3d(-19vmax, 3vmax, 0) rotate(-186deg); }
  100% { transform: translate3d(0, 0, 0) rotate(-360deg); }
}

@keyframes drift-3 {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  33%  { transform: translate3d(17vmax, -11vmax, 0) rotate(76deg); }
  66%  { transform: translate3d(7vmax, -21vmax, 0) rotate(212deg); }
  100% { transform: translate3d(0, 0, 0) rotate(360deg); }
}

@keyframes drift-4 {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  33%  { transform: translate3d(-15vmax, -8vmax, 0) rotate(-48deg); }
  66%  { transform: translate3d(-4vmax, -19vmax, 0) rotate(-168deg); }
  100% { transform: translate3d(0, 0, 0) rotate(-360deg); }
}

@keyframes drift-5 {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  33%  { transform: translate3d(-18vmax, 12vmax, 0) rotate(84deg); }
  66%  { transform: translate3d(13vmax, 20vmax, 0) rotate(198deg); }
  100% { transform: translate3d(0, 0, 0) rotate(360deg); }
}

/* ------------------------------------------------------------------ *
   VEIL + GRAIN
 * ------------------------------------------------------------------ */

/* Type sits in a soft pool rather than on the raw gradient. The pool is
   strongest under the text column and gone by the far edge, so the palette
   still owns most of the screen. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(78vmax 62vmax at 22% 52%,
      rgba(var(--veil), var(--veil-a)) 0%,
      rgba(var(--veil), calc(var(--veil-a) * 0.55)) 42%,
      rgba(var(--veil), 0) 76%),
    linear-gradient(to right,
      rgba(var(--veil), calc(var(--veil-a) * 0.75)) 0%,
      rgba(var(--veil), 0) 68%);
  transition: background 1700ms var(--ease), opacity 1700ms var(--ease);
}

/* Fixed and pointer-events none, so the noise never repaints with scroll.
   Its real job is killing the banding a large smooth gradient always has. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ *
   STAGE + PANELS
 * ------------------------------------------------------------------ */

.stage {
  position: relative;
  z-index: 3;
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding:
    max(4.5rem, calc(env(safe-area-inset-top) + 3rem)) var(--pad)
    max(4.5rem, calc(env(safe-area-inset-bottom) + 3.5rem));
}

.panel {
  grid-area: 1 / 1;
  width: 100%;
  max-width: 34rem;
  display: none;
}

body[data-state="ask"]     #panel-ask,
body[data-state="loading"] #panel-load,
body[data-state="vibe"]    #panel-vibe,
body[data-state="care"]    #panel-care { display: block; }

/* One authored entrance, shared. Enters from an already-visible default:
   nothing starts at zero, so a slow reveal never reads as a page still loading. */
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); filter: blur(7px); }
  to   { opacity: 1; transform: none;                    filter: blur(0); }
}

.panel > * { animation: rise 900ms var(--ease) both; }

/* ------------------------------------------------------------------ *
   ASK
 * ------------------------------------------------------------------ */

.wordmark {
  margin: 0 0 clamp(2rem, 7vh, 3.25rem);
  font-family: var(--display);
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.ask { margin: 0; }

.ask-q {
  display: block;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.9rem, 8vw, 2.9rem);
  font-weight: 200;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.ask-hint {
  margin: 0.75rem 0 clamp(1.75rem, 5vh, 2.5rem);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-3);
}

.mood {
  display: block;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0.75rem 0;
  border: 0;
  border-bottom: 1px solid rgba(var(--veil-line), 0.28);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.25rem;   /* 16px floor, and above it, so iOS never zooms */
  font-weight: 300;
  letter-spacing: -0.01em;
  transition: border-color 220ms var(--ease);
}

.mood::placeholder { color: var(--ink-3); opacity: 1; }
.mood:hover { border-bottom-color: rgba(var(--veil-line), 0.44); }

.mood:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.go {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 1.5rem;
  padding: 0.9rem 1.5rem;
  border: 1px solid rgba(var(--veil-line), 0.30);
  border-radius: 999px;
  background: rgba(var(--veil-line), 0.07);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition:
    background-color 200ms var(--ease),
    border-color     200ms var(--ease),
    transform        120ms var(--ease);
}

.go:hover  { background: rgba(var(--veil-line), 0.13); border-color: rgba(var(--veil-line), 0.46); }
.go:active { transform: translateY(1px); }

.go[disabled] {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

.err {
  margin: 1.25rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.disclosure {
  margin: clamp(2rem, 6vh, 3rem) 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ *
   LOADING — no spinner. The colour comes up instead.
 * ------------------------------------------------------------------ */

.load-line {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 200;
  letter-spacing: -0.02em;
  color: var(--ink-2);
}

/* The three trailing dots are the only thing that moves, and they move
   because something is genuinely still happening. */
.load-line::after {
  content: '';
  animation: dots 1500ms steps(1, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%, 100% { content: '...'; }
}

/* ------------------------------------------------------------------ *
   VIBE — the jaunty one
 * ------------------------------------------------------------------ */

.genre {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.9rem, 13vw, 6rem);
  font-weight: 200;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--ink);
  text-wrap: balance;
}

.caption {
  margin: clamp(1.25rem, 4vh, 1.85rem) 0 0;
  max-width: 22ch;
  font-family: var(--display);
  font-size: clamp(1.0625rem, 4.2vw, 1.3125rem);
  font-weight: 300;
  line-height: 1.5;
  letter-spacing: -0.005em;
  color: var(--ink-2);
  text-wrap: pretty;
}

.again {
  min-height: 48px;
  margin-top: clamp(2rem, 6vh, 3rem);
  padding: 0.8rem 1.5rem;
  border: 1px solid rgba(var(--veil-line), 0.30);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--ui);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 200ms var(--ease),
    border-color     200ms var(--ease),
    color            200ms var(--ease),
    transform        120ms var(--ease);
}

.again:hover  { color: var(--ink); border-color: rgba(var(--veil-line), 0.46); background: rgba(var(--veil-line), 0.07); }
.again:active { transform: translateY(1px); }

/* The genre and the caption arrive a beat apart. One sequence, not two
   animations: the pause is what makes it read as a reveal. */
.panel-vibe .genre   { animation-delay: 120ms; }
.panel-vibe .caption { animation-delay: 380ms; }
.panel-vibe .again   { animation-delay: 700ms; }

/* ------------------------------------------------------------------ *
   CARE — a different page, not a restyled one.
   No flood, no reveal, no genre. Slower, quieter, more room.
 * ------------------------------------------------------------------ */

.care-caption {
  margin: 0;
  max-width: 20ch;
  font-family: var(--display);
  font-size: clamp(1.6rem, 6.5vw, 2.35rem);
  font-weight: 200;
  line-height: 1.28;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

.care-line {
  margin: clamp(1.75rem, 5vh, 2.5rem) 0 0;
  max-width: 34ch;
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* Slower and further apart than the vibe sequence. The delay is the tone. */
.panel-care .care-caption { animation: rise 1400ms var(--ease) 200ms both; }
.panel-care .care-line    { animation: rise 1400ms var(--ease) 800ms both; }
.panel-care .again        { animation: rise 1400ms var(--ease) 1400ms both; }

/* ------------------------------------------------------------------ *
   FIELD STATES
 * ------------------------------------------------------------------ */

/* Waiting: the colour comes up. Saturation and presence lift while the
   drift stays exactly as slow, so the change reads as warmth, not haste. */
body[data-state="loading"] {
  --blob-o: 0.62;
  --sat: 1.05;
  --bright: 0.88;
  --veil-a: 0.34;
}

/* The result: full presence. This is the only place the field is at 100%. */
body[data-state="vibe"] {
  --blob-o: 1;
  --sat: 1.12;
  --bright: 1;
  --veil-a: 0.60;
}

/* Care: the same palette, held back. Low presence and no saturation lift,
   so four slow loops over a muted wash read as still rather than drifting. */
body[data-state="care"] {
  --blob-o: 0.5;
  --sat: 0.82;
  --bright: 0.92;
  --veil-a: 0.56;
}

/* ------------------------------------------------------------------ *
   DAY LABEL — the one element that is not a design decision
 * ------------------------------------------------------------------ */

.day {
  position: fixed;
  z-index: 4;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(0.85rem, calc(env(safe-area-inset-bottom) + 0.35rem));
  margin: 0;
  font-family: var(--label);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  /* Full ink, not the dim role. This label is the one thing every build in
     the series shares, and it has to clear 4.5:1 over any four colours a
     model can return, not just over a ground this build chose. */
  color: var(--ink);
  pointer-events: none;
  user-select: none;
}

/* It sits outside the main text pool, so it gets a pool of its own: wide
   and soft enough not to read as a blob on a pale palette, deep enough to
   hold the contrast on a mid-luminance one. */
.day::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -2.1rem -2.4rem -1.9rem -3rem;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(var(--veil), var(--day-pool)) 0%,
    rgba(var(--veil), calc(var(--day-pool) * 0.86)) 34%,
    rgba(var(--veil), calc(var(--day-pool) * 0.30)) 62%,
    rgba(var(--veil), 0) 100%);
  transition: background 1700ms var(--ease);
}

/* ------------------------------------------------------------------ *
   FOCUS + SR
 * ------------------------------------------------------------------ */

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

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

/* ------------------------------------------------------------------ *
   WIDER
 * ------------------------------------------------------------------ */

@media (min-width: 48rem) {
  .panel { max-width: 38rem; }
  .caption { max-width: 26ch; }
  .mood { font-size: 1.4rem; }

  /* The button stops being a full-width bar once it no longer needs to be
     the width of a thumb. */
  .go { width: auto; min-width: 13rem; }
}

/* ------------------------------------------------------------------ *
   REDUCED MOTION
   The gradient is the point, so it stays. It simply stops travelling.
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  .load-line::after { animation: none; content: '...'; }

  .panel > *,
  .panel-care .care-caption,
  .panel-care .care-line,
  .panel-care .again {
    animation: none;
  }

  .blob, .veil, .day::before { transition-duration: 400ms; }

  .go, .again, .mood { transition-duration: 1ms; }
}
