/* Layout and component styles. Values come from tokens.css; nothing here hard-codes a colour or font. */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--size-body);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Reset every control's default styling (UX spec, Build notes) */
button, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
}
button { cursor: pointer; }

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

:focus-visible { outline: 3px solid var(--color-text-secondary); outline-offset: 3px; }
textarea:focus-visible { outline: none; }

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

/* Background waves: slow, layered, transform-only */
.waves { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.wave {
  position: absolute; left: 0; bottom: 0;
  width: 200%;
  animation: roll var(--motion-wave) linear infinite;
}
.wave path { fill: currentColor; }
.wave-1 { height: 70vh; color: var(--color-wave-1); }
.wave-2 { height: 52vh; color: var(--color-wave-2); opacity: 0.55; animation-duration: calc(var(--motion-wave) * 1.4); animation-direction: reverse; }
.wave-3 { height: 36vh; color: var(--color-wave-3); opacity: 0.35; animation-duration: calc(var(--motion-wave) * 1.9); }
.wave-4 { height: 82vh; color: var(--color-wave-coral); opacity: 0.12; animation-duration: calc(var(--motion-wave) * 1.2); animation-direction: reverse; }
@keyframes roll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Sample cards on a slowly turning ring (decorative). Sizes and angles are set from config.js.
   The ring is seen from outside: near-side cards face the viewer, side cards turn away. */
.drift {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden;
  perspective: var(--ring-perspective);
  opacity: var(--ring-opacity);
  -webkit-mask-image: linear-gradient(to right, transparent, black 14%, black 86%, transparent);
  mask-image: linear-gradient(to right, transparent, black 14%, black 86%, transparent);
}
.ring {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--ring-r) * -1)) rotateX(var(--ring-tilt));
}
.spin {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  animation: turn var(--ring-turn) linear infinite;
  will-change: transform;
}
@keyframes turn { from { transform: rotateY(0deg); } to { transform: rotateY(-360deg); } }
.ring-card {
  position: absolute;
  width: var(--card-w); height: var(--card-h);
  margin: calc(var(--card-h) / -2) 0 0 calc(var(--card-w) / -2);
  transform: rotateY(var(--angle)) translateZ(var(--ring-r)) translateY(var(--dy));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.ring-inner {
  width: 100%; height: 100%;
  padding: calc(22px * var(--card-scale)) calc(20px * var(--card-scale));
  display: flex; align-items: center; justify-content: center;
  border-radius: calc(var(--radius-card) * var(--card-scale));
  background: var(--color-card);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: calc(var(--size-card-thought) * var(--card-scale));
  line-height: 1.45;
  text-align: center;
  position: relative;
  --mood-color: var(--color-accent-deep);
}
.tone-deep .ring-inner { background: var(--color-card-deep); --mood-color: var(--color-text); }
.tone-coral .ring-inner { background: var(--color-card-coral); }
.ring-inner .mood {
  position: absolute; right: calc(20px * var(--card-scale)); bottom: calc(16px * var(--card-scale));
  font-family: var(--font-sans); font-size: max(10px, calc(var(--size-small) * var(--card-scale))); font-weight: 500;
  color: var(--mood-color);
}

/* A soft pale veil behind the page content, so text stays readable over the cards */
.veil {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse 30% 66% at 50% 44%, var(--color-veil) 58%, var(--color-veil-clear) 100%);
}

/* Page: always fits one screen, so the button is never below the fold */
.page {
  position: relative; z-index: 3;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 2dvh, 20px);
  padding: clamp(12px, 3dvh, 32px) 16px;
}

.hero { flex: 0 0 auto; text-align: center; }
.hero h1 { margin: 0; }
.logo { display: block; height: clamp(84px, 24dvh, 250px); width: auto; max-width: 70vw; margin: 0 auto; }
.sub { margin: 4px 0 0; font-family: var(--font-serif); font-style: italic; color: var(--color-text-secondary); font-size: clamp(14px, 2.2dvh, 17px); }

.concept { flex: 0 0 auto; margin: 0; max-width: 28em; text-align: center; color: var(--color-text-secondary); font-size: clamp(14px, 2.2dvh, 17px); line-height: 1.45; }

/* Compose card: shrinks to fit, the text box takes up the slack */
.compose {
  width: min(100%, 520px);
  flex: 0 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: clamp(12px, 2.4dvh, 20px);
  border-radius: var(--radius-card);
  background: var(--color-card);
  box-shadow: var(--shadow-card);
}
.compose textarea {
  display: block; width: 100%; resize: none;
  flex: 1 1 150px; min-height: 64px; max-height: 240px;
  padding: clamp(12px, 2dvh, 18px);
  border-radius: var(--radius-void);
  background: var(--color-void);
  box-shadow: var(--shadow-void);
  font-family: var(--font-serif);
  font-size: var(--size-thought);
  line-height: 1.5;
  color: var(--color-text);
  caret-color: var(--color-accent-deep);
  transition: background var(--motion-fast);
}
.compose textarea:focus { background: var(--color-void-shadow); }
.compose textarea::placeholder { color: var(--color-text-placeholder); opacity: 1; }

.count { flex: 0 0 auto; margin: 6px 6px 0; text-align: right; font-size: var(--size-small); color: var(--color-text-secondary); }

.pill {
  flex: 0 0 auto;
  display: block; width: 100%; min-height: var(--button-height); margin-top: var(--space-stack);
  border-radius: 999px;
  background: var(--color-cta); color: var(--color-on-cta);
  font-weight: 500;
  transition: opacity var(--motion-fast);
}
.pill[aria-disabled="true"] { opacity: 0.6; }

.why {
  flex: 0 0 auto;
  position: relative;
  align-self: center;
  margin: var(--space-stack) 0 0;
  text-align: center;
  font-family: var(--font-serif); font-style: italic; font-weight: 400;
  font-size: var(--size-tagline); line-height: 1.4;
  color: var(--color-accent-deep);              /* same face and colour as "A place for fleeting thoughts" */
  text-decoration: none;
}
/* The tap area is 44px tall without adding visible space around the text */
.why::after { content: ""; position: absolute; inset: -9px -24px -13px; }
.why:hover { text-decoration: underline; text-underline-offset: 4px; }
.status { flex: 0 0 auto; min-height: 1.3em; margin: var(--space-stack) 0 0; text-align: center; font-size: var(--size-small); color: var(--color-text-secondary); }
.status.is-error { color: var(--color-error); }
noscript .status { position: relative; z-index: 3; }
.status:empty { min-height: 0; margin: 0; }

/* Consent strip: dark footer gradient, plain-text actions */
.consent {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 36px 16px 20px;
  background: linear-gradient(to top, var(--color-footer-dark) 55%, var(--color-footer-clear));
  color: var(--color-on-primary);
  text-align: center; font-size: var(--size-small);
}
.consent[hidden] { display: none; }
.consent p { margin: 0 0 4px; }
.consent-actions { display: flex; justify-content: center; gap: 8px; }
.plain { min-height: var(--tap-min); padding: 0 16px; color: var(--color-on-primary); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.consent :focus-visible { outline-color: var(--color-on-primary); }

/* Text pages (Why, Privacy): the logo and title stay pinned at the top while only the text scrolls */
.doc-page {
  position: relative; z-index: 3;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 16px 56px;
}
.doc-head {
  position: sticky; top: 0; z-index: 4;
  width: calc(100% + 32px); margin: 0 -16px;      /* full width, over the page padding */
  padding: 16px 16px 4px;
  background: var(--color-bg);
}
/* A soft fade under the pinned part, so the text slides away smoothly instead of being cut off */
.doc-head::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 24px; pointer-events: none;
  background: linear-gradient(to bottom, var(--color-bg), var(--color-veil-clear));
}
.doc-head-inner { width: min(100%, 38em); margin: 0 auto; }
.doc-logo { --logo-h: clamp(84px, 13.5dvh, 120px); display: block; width: fit-content; margin: 0 auto; }
/* Both sizes are set outright, so no browser has to guess the logo's size */
.doc-logo img { display: block; height: var(--logo-h); width: calc(var(--logo-h) * var(--logo-ratio)); max-width: 100%; }
.doc-head h1 { margin: 8px 0 0; font-family: var(--font-serif); font-weight: 500; font-size: var(--size-wordmark); line-height: 1.25; }
.doc { width: min(100%, 38em); margin-top: 20px; }
.doc h2 { margin: 1.6em 0 0.5em; font-family: var(--font-serif); font-weight: 500; font-size: var(--size-headline); line-height: 1.3; }
.doc h2:first-child { margin-top: 0; }
.doc p { margin: 0 0 1em; line-height: 1.65; }
.doc-closing { margin: 1.6em 0 0.5em; font-family: var(--font-serif); font-weight: 500; font-size: var(--size-headline); line-height: 1.3; }
.doc-end { margin-top: 1em; }
.doc-end a { display: inline-block; min-height: var(--tap-min); line-height: var(--tap-min); }

/* Phones: the cards become soft, out-of-focus colour fields behind the page. They add colour and
   slow movement without competing with the text, so no veil is needed. */
@media (max-width: 700px) {
  .drift { filter: blur(var(--ring-blur-small)); opacity: calc(var(--ring-opacity) + 0.2); }
  .veil { display: none; }
}

/* Very short screens (phones turned sideways): keep only what is needed */
@media (max-height: 520px) {
  .concept { display: none; }
  .logo { height: 64px; }
  .doc-head { position: static; }
  .doc-head::after { display: none; }
  .doc-logo { --logo-h: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .wave, .spin { animation: none; }
  * { transition: none !important; }
}
