/* ==========================================================================
   Mulberry Door — waiting-list page
   styles.css

   Contents
     1. Design tokens
     2. Base
     3. Page and fixed scene
     4. Logo, orbiting words and copy block
     5. Sign-up form
     6. Corner text (scroll cue and footer strip)
     7. Accessibility helpers
     8. Short screens
     9. Reduced motion

   How the page works: .page is a tall empty block that gives the browser
   something to scroll. .scene is pinned to the viewport and never moves.
   main.js reads the scroll position and animates everything inside the scene.
   ========================================================================== */


/* 1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  --ink: #542033;          /* body text, deep mulberry */
  --berry: #76233b;        /* button and error text */
  --berry-dark: #5f1b30;   /* button hover */
  --teal: #07545a;         /* tagline, thank-you text, focus ring */
  --paper: #f8f6ef;        /* page background, also the veil behind the copy */
  --muted: #68645b;

  /* Form colours, chosen for contrast (checked against WCAG AA):
     typed text 18:1 on white, placeholder 7.9:1, fine print 6.3:1.
     The field border is 3.5:1 against the paper, which meets the 3:1
     rule for the edge of a control. */
  --field-text: #1f1218;
  --field-placeholder: #5d4d54;
  --field-border: #8a8174;
  --fine-print: #5f5a50;

  /* Corner text stays quiet but readable: about 6:1 on the paper colour. */
  --corner-text: rgba(84, 32, 51, .78);
}


/* 2. BASE
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, serif;
}


/* 3. PAGE AND FIXED SCENE
   -------------------------------------------------------------------------- */

/* The scroll track. 320svh means "three and a bit screens of scrolling" to
   travel from the opening view to the sign-up form. */
.page {
  position: relative;
  width: 100%;
  height: 320svh;
  min-height: 320svh;
}

/* Everything the visitor sees lives here, pinned to the viewport. */
.scene {
  position: fixed;
  inset: 0;
  height: 100svh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.4vh, 26px) 18px;
}

/* The garden: two canvases stacked on top of each other and drawn by main.js
   (plants and roots underneath, drifting specks on top). */
.garden {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.garden canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}


/* 4. LOGO, ORBITING WORDS AND COPY BLOCK
   -------------------------------------------------------------------------- */
.center {
  position: relative;
  z-index: 2;
  isolation: isolate;
  width: min(100%, 510px);
  max-height: calc(100svh - 24px);
  padding: clamp(13px, 2.2vh, 26px) clamp(20px, 4vw, 54px) clamp(16px, 2.4vh, 28px);
  text-align: center;
  will-change: transform;
}

/* A soft paper-coloured glow behind the content so text stays readable
   where garden lines pass underneath it. */
.center::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -150px -190px;
  pointer-events: none;
  /* main.js shrinks the glow vertically (--veil-scale) as the logo settles.
     Scaling is done by the graphics chip, so it never has to be repainted. */
  transform: scaleY(var(--veil-scale, 1));
  will-change: transform;
  background: radial-gradient(ellipse at center,
    rgba(248, 246, 239, .84) 0%,
    rgba(248, 246, 239, .70) 43%,
    rgba(248, 246, 239, 0) 76%);
}

.logo-stack {
  /* --logo-w is the one number the logo and the orbit ring are both sized
     from, so they always stay in proportion. */
  --logo-w: min(clamp(300px, 46vh, 460px), 72vw);   /* the 72vw cap keeps the whole ring of words on narrow phones */
  position: relative;
  width: 100%;
  height: clamp(320px, 52vh, 520px);   /* main.js fixes this to the opening height; it never changes while scrolling */
  display: grid;
  place-items: center;
  perspective: 900px;
}

/* The ring is centred on the logo's circle (not on the image box) and sized
   from the logo radius, so all three words share one concentric track.
   The .0068 / .0763 / 1.204 factors were measured from the logo artwork. */
.orbit-svg {
  position: absolute;
  z-index: 3;
  left: calc(50% - var(--logo-w) * .0068);
  top: calc(50% + var(--logo-w) * .0763);
  width: calc(var(--logo-w) * 1.204);
  height: calc(var(--logo-w) * 1.204);
  aspect-ratio: 1 / 1;
  overflow: visible;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.orbit-svg text {
  fill: rgba(7, 84, 90, .85);
  font: 600 30px Arial, sans-serif;
  letter-spacing: 9px;
  text-transform: uppercase;
}

.orbit-label {
  opacity: 1;
  transform-box: view-box;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

/* Opening view: the logo symbol on its own. */
.logo-symbol-mask {
  position: absolute;
  width: var(--logo-w);
  /* Height is stated outright (width / .94), not left to aspect-ratio alone:
     iPhone browsers ignored aspect-ratio here, so the crop never happened and
     the whole logo, wordmark included, showed in the opening view. */
  height: calc(var(--logo-w) / .94);
  aspect-ratio: .94 / 1;
  overflow: hidden;
}

.logo-symbol {
  display: block;
  width: 100%;
  height: auto;
  /* Second, independent crop: cut the image off below the symbol (everything
     under width / .94 is the wordmark). Belt and braces with the box above. */
  clip-path: inset(0 0 calc(100% - var(--logo-w) / .94) 0);
}

/* Final view: the full logo, faded in by main.js as the symbol fades out. */
.brand-final {
  position: absolute;
  display: block;
  width: clamp(112px, 13vh, 145px);
  height: auto;
  opacity: 0;
}

/* Tagline, intro and form. Hidden until the visitor has scrolled far enough. */
.copy {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: -16px;
  opacity: 0;
  transform: translateY(26px);
  pointer-events: none;
  /* Tells the browser this block will slide and fade, so it prepares it on
     the graphics chip and the movement stays smooth. */
  will-change: transform, opacity;
}

.tag {
  margin: 7px 0 4px;   /* small on purpose: keeps the gap to the line below equal to the gap inside the pair */
  color: var(--teal);
  font: 400 clamp(13px, 1.9vh, 16px)/1.3 Arial, sans-serif;
  letter-spacing: .26em;
}

/* A soft halo in the page colour behind the copy, so a garden line or leaf that
   drifts underneath never muddies the letters. */
.tag, .intro, .fine, .privacy, #thanks {
  text-shadow:
    0 0 3px var(--paper), 0 0 7px var(--paper), 0 0 12px var(--paper), 0 0 18px var(--paper);
}

/* The name comes first and is the strongest line on the page. */
.tag-name {
  display: block;
  font-size: clamp(15px, 2.4vh, 20px);
  font-weight: 700;
  letter-spacing: .22em;
}

/* Second line under the name, the quieter tagline, tucked just below it. */
.tag-pair {
  display: block;
  margin-top: .6em;
}

.intro {
  max-width: 400px;
  margin: 0 auto clamp(16px, 2.4vh, 28px);
  color: var(--ink);
  font: clamp(15px, 2.2vh, 19px)/1.5 Georgia, serif;
}


/* 5. SIGN-UP FORM
   -------------------------------------------------------------------------- */
form {
  display: grid;
  gap: 8px;
  max-width: 330px;
  margin: auto;
}

input, button {
  width: 100%;
  height: 46px;
  border-radius: 0;
}

input {
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--field-border);
  color: var(--field-text);
  font: 15px Arial, sans-serif;
}

input::placeholder {
  color: var(--field-placeholder);
  opacity: 1;
}

input:focus {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-color: var(--teal);
}

.name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  border: 0;
  background: var(--berry);
  color: #fff;
  cursor: pointer;
  font: 10px Arial, sans-serif;
  letter-spacing: .2em;
  text-transform: uppercase;
}

button:hover { background: var(--berry-dark); }
button:disabled { opacity: .6; cursor: default; }

/* After a successful sign-up the button becomes a calm confirmation. */
button.done:disabled { opacity: 1; background: var(--teal); }

/* Make the hidden attribute always win, even over rules like form { display: grid }. */
[hidden] { display: none !important; }

/* Honeypot: a field real visitors never see. Bots fill it in, and the
   server quietly ignores any submission where it has a value.
   It is moved off-screen rather than display:none, because some bots skip
   fields that are display:none. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Small print and messages under the form */
.fine {
  max-width: 360px;
  margin: 11px auto 0;
  color: var(--fine-print);
  font: 12px/1.4 Arial, sans-serif;
}

.privacy {
  max-width: 360px;
  margin: 4px auto 0;
  color: var(--fine-print);
  font: 12px/1.4 Arial, sans-serif;
}

#thanks {
  margin: 11px 0 0;
  color: var(--teal);
  font: 13px/1.5 Arial, sans-serif;
}

#error {
  max-width: 330px;
  margin: 11px auto 0;
  color: var(--berry);
  font: 11px Arial, sans-serif;
}


/* 6. CORNER TEXT
   -------------------------------------------------------------------------- */

/* Footer strip: brand at the left, "Scroll to enter the garden" in the middle
   (it fades out once scrolling starts), place at the right. */
.hud {
  position: absolute;
  z-index: 2;
  left: 28px;
  right: 28px;
  bottom: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  color: var(--corner-text);
  font: 9px Arial, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  pointer-events: none;
}

.hud span {
  white-space: nowrap;
  /* Same soft halo as the other text, so vines passing behind the corners stay out of the letters. */
  text-shadow: 0 0 3px var(--paper), 0 0 7px var(--paper), 0 0 12px var(--paper);
}
#scroll-cue { will-change: opacity; }
.hud-start  { justify-self: start; }
.hud-middle { justify-self: center; text-align: center; }
.hud-end    { justify-self: end; }

/* On narrow screens three items do not fit side by side, so the scroll hint
   moves to its own line above the brand and the place. */
@media (max-width: 560px) {
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
  .hud-middle { grid-column: 1 / -1; grid-row: 1; }
  .hud-start, .hud-end { grid-row: 2; }
}


/* 7. ACCESSIBILITY HELPERS
   -------------------------------------------------------------------------- */

/* Text for screen readers only. Visually hidden but still read aloud. */
.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;
}

/* "Skip to the sign-up form". Invisible until a keyboard user tabs to it. */
.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--berry);
  color: #fff;
  font: 13px Arial, sans-serif;
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* The thank-you message receives focus after a successful sign-up so screen
   readers announce it. It is not interactive, so no ring is needed. */
#thanks:focus { outline: none; }


/* 8. SHORT SCREENS
   -------------------------------------------------------------------------- */
@media (max-height: 640px) {
  .scene { min-height: 0; }
  .center { padding-block: 10px 14px; }
  .logo-stack { height: 300px; }
  .intro { margin-bottom: 13px; }
  input, button { height: 42px; }
  .brand-final { width: clamp(72px, 11vh, 112px); }
  .fine { margin-top: 8px; }
}

/* Very narrow phones: slightly tighter headline lettering so it stays on two lines. */
@media (max-width: 350px) {
  .tag { letter-spacing: .14em; }
  .tag-name { letter-spacing: .12em; }
}

/* Phones (touch screen, small display): no drifting specks. main.js stops drawing
   them; this also removes the empty layer. Same test as phoneScreen in main.js. */
@media (pointer: coarse) and (max-width: 500px), (pointer: coarse) and (max-height: 500px) {
  #particle-canvas { display: none; }
}

/* Phones only (same test as phoneScreen in main.js): the garden stays visible but
   sits further back, and a feathered paper-coloured backing sits behind the headline,
   tagline, form and privacy line so they stand out. Laptops and iPads are untouched.
   The backing is part of .copy, so it fades in and out together with the text. */
@media (pointer: coarse) and (max-width: 500px), (pointer: coarse) and (max-height: 500px) {
  .garden, html.compact .garden { opacity: .72; }
  .copy::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -14px -8px -10px;
    border-radius: 26px;
    pointer-events: none;
    background: rgba(248, 246, 239, .72);
    box-shadow: 0 0 22px 20px rgba(248, 246, 239, .72);
  }
}

/* Phones held sideways: very little height, so tighten everything further. */
@media (max-height: 460px) {
  .tag { margin: 2px 0 6px; }
  .intro { margin-bottom: 8px; font-size: 14px; line-height: 1.35; }
  form { gap: 6px; }
  input, button { height: 36px; }
  .fine { display: none; }
  .privacy { margin-top: 6px; }
}


/* 9. REDUCED MOTION
   --------------------------------------------------------------------------
   Visitors who ask their device to reduce motion get the finished page at
   once: no scroll track, no animation. main.js draws the garden in its final
   state a single time. */
@media (prefers-reduced-motion: reduce) {
  .page { height: 100svh; min-height: 100svh; }
  .garden { opacity: .75; }
}

/* Privacy link under the form */
.privacy a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.privacy a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }


/* 10. COMPACT FALLBACK
   --------------------------------------------------------------------------
   Windows too small for the animated scene (very short, very narrow, or a
   page zoomed to 400%). main.js adds class "compact" to <html>; the content
   then simply stacks and scrolls like an ordinary page, so the form is always
   reachable. Same test as compactScreen in main.js. */
html.compact .page { height: auto !important; min-height: 0 !important; }
html.compact .scene { position: relative !important; height: auto !important; min-height: 100svh; overflow: visible !important; display: block !important; padding: 16px 14px 28px !important; }
html.compact .garden { position: fixed !important; opacity: .55; }
html.compact .hud, html.compact .orbit-svg, html.compact .logo-symbol-mask, html.compact .skip-link { display: none !important; }
html.compact .center { transform: none !important; max-height: none !important; margin: 0 auto !important; padding: 8px 12px !important; }
html.compact .center::before { transform: none !important; inset: -20px -12px; }
html.compact .logo-stack { height: auto !important; display: flex; justify-content: center; }
html.compact .brand-final { position: static !important; opacity: 1 !important; transform: none !important; width: clamp(110px, 40vw, 190px) !important; height: auto !important; }
html.compact .copy { opacity: 1 !important; transform: none !important; pointer-events: auto !important; }
html.compact .fine { display: block; }
html.compact, html.compact body { height: auto !important; min-height: 0 !important; }
html.compact body { overflow: visible !important; }

.privacy a { display: block; width: fit-content; margin: 2px auto 0; padding: 4px 10px; font-size: 12.5px; white-space: nowrap; }


/* 11. WHEN SPACE RUNS OUT
   --------------------------------------------------------------------------
   main.js adds these classes when the small print would otherwise touch the
   footer line (for example when a browser enlarges text or shows big toolbars). */
html.no-fine #fine { display: none; }
html.no-hud .hud-start, html.no-hud .hud-end, html.no-hud .hud-middle { visibility: hidden; }

/* Stop iPhone browsers enlarging the text on their own, which breaks the line
   breaks we chose. (A visitor's own Text Size setting still applies.) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Keep two-line headings and the intro evenly balanced, never one orphan word. */
.tag-pair, .intro { text-wrap: balance; }
