/* Crossmoji home: Nocturne Stage. Builds on site.css (tokens, ground, brand, footer).
   Frames in Figma: phone 950:5050 / 950:5653, desktop 950:5263 / 950:5867.
   The board is the app's board: its tiles are ported from crossmoji-ios (TileMetrics.swift,
   Tile.swift, Palette.swift), and site.js moves them on the app's timing sheet (BoardMotion.swift). */

:root {
  --aura-strong: rgba(121, 108, 191, 0.2);
  --grad-a: #6755c2;
  --grad-b: #5a4aa8;

  /* the app's ground, light (Palette.ground): the board card is the app's screen, so its tiles
     sit on what they sit on in the app */
  --ground-center: #e4e7f5;
  --ground-edge: #cfd3e5;
  /* the app's tile palette is in site.css, which the 404's tiles share */
  --app-accent: #796cbf;
  --clue-label: #4f4590; /* the accent's hue, dark enough for small text on the well */

  --chip-bg: rgba(121, 108, 191, 0.07);
  --chip-edge: rgba(93, 82, 148, 0.22);
  --chip-text: rgba(41, 43, 49, 0.78);
  --chip-hover-bg: rgba(121, 108, 191, 0.12);
  --chip-on-bg: rgba(121, 108, 191, 0.16);
  --chip-on-edge: rgba(93, 82, 148, 0.55);
  --chip-on-text: #1f2128;
  --resume-hover-bg: rgba(121, 108, 191, 0.26);
  --home-foot: rgba(41, 43, 49, 0.78);
  --home-foot-copy: rgba(41, 43, 49, 0.78);
  --badge-glow: 0 10px 26px rgba(31, 33, 40, 0.2);
  --well-inset: inset 0 2px 6px rgba(0, 0, 0, 0.08);
  --emoji-glow: drop-shadow(0 6px 14px rgba(121, 108, 191, 0.25));
}

@media (prefers-color-scheme: dark) {
  :root {
    --aura-strong: rgba(121, 108, 191, 0.26);
    --grad-a: #c9bfff;
    --grad-b: #9a89ee;

    --ground-center: #20233a;
    --ground-edge: #161826;
    --app-accent: #9184d9;
    --clue-label: var(--label);

    --chip-bg: rgba(14, 16, 26, 0.56);
    --chip-edge: rgba(233, 233, 237, 0.16);
    --chip-text: rgba(207, 210, 228, 0.86);
    --chip-hover-bg: rgba(145, 132, 217, 0.12);
    --chip-on-bg: rgba(145, 132, 217, 0.2);
    --chip-on-edge: rgba(212, 208, 255, 0.6);
    --chip-on-text: #ffffff;
    --resume-hover-bg: rgba(145, 132, 217, 0.32);
    --home-foot: rgba(207, 210, 228, 0.68);
    --home-foot-copy: rgba(207, 210, 228, 0.62);
    --badge-glow: 0 10px 30px rgba(184, 174, 253, 0.22);
    --well-inset: none;
    --emoji-glow: drop-shadow(0 6px 14px rgba(184, 174, 253, 0.3));
  }
}

/* A tile's four colours, registered as colours so one animation can blend a tile from one look to
   another (they inherit, so the tile's edge, face, ring and letter all read them). Without
   @property the looks still show; changes just don't blend. */
@property --face { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --edge { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --ring { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --ink { syntax: "<color>"; inherits: true; initial-value: transparent; }

/* ---------- Frame ---------- */

/* the reading pages set their text in SF Pro; the home page stays in SF Pro Rounded throughout */
body.home { font-family: var(--font-display); }

.wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: min(1072px, calc(100% - 48px));
  margin: 0 auto;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 42px;
}
.home-header .back { display: none; }

.hero {
  flex: 1;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "copy" "board" "cta";
  align-content: center;
  justify-items: center;
  row-gap: 22px;
  padding: 4px 0 8px;
  text-align: center;
}
/* the soft lavender glow behind the board */
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  top: 50%;
  left: 50%;
  width: min(660px, 100vw);
  height: min(660px, 100vw);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--aura-strong), transparent);
}

.hero-copy { grid-area: copy; }
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 7.7vw, 44px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.hero h1 .line { display: block; }
.grad {
  color: var(--accent);
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sub {
  display: none;
  margin: 18px auto 0;
  max-width: 24em;
  font-size: 18px;
  line-height: 1.5;
  color: var(--text-muted);
}

.cta { grid-area: cta; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 51px;
  margin: 0;
  padding: 12px clamp(20px, 6vw, 32px);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  box-shadow: var(--badge-glow);
  text-decoration: none;
  font: 600 clamp(14px, 4.1vw, 16px)/1.2 ui-rounded, -apple-system, system-ui, sans-serif;
  text-align: center;
  text-wrap: balance;
}
.cta-sub { margin: 14px 0 0; font-size: 14px; font-weight: 600; }
.cta-sub a { text-decoration: none; }
.cta-sub a:hover { text-decoration: underline; }

/* ---------- Board card ---------- */

.board-wrap {
  grid-area: board;
  container-type: inline-size;
  width: min(459px, max(calc(100vw - 90px), 288px));
}

.board-card {
  --u: calc(100cqw / 459); /* 1 design pixel of the 459px desktop card */
  --pad-top: max(calc(25 * var(--u)), 16px);
  --pad-x: calc(29 * var(--u));
  --well-h: max(calc(98 * var(--u)), 92px);
  position: relative;
  padding: var(--pad-top) var(--pad-x) max(calc(26 * var(--u)), 18px);
  border-radius: calc(30 * var(--u));
  /* Palette.ground: an elliptical wash from the centre that ends at 0.75 of each side */
  background: radial-gradient(ellipse 75% 75% at 50% 50%, var(--ground-center), var(--ground-edge));
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: max(calc(21 * var(--u)), 18px);
  text-align: center;
}
.board-card::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1.25px;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--card-edge-from), var(--card-edge-to));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

/* the clue well: five stacked clues, one shows at a time (.on); site.js slides or fades between them */
.clue-well {
  position: relative;
  overflow: hidden;
  height: var(--well-h);
  border-radius: calc(18 * var(--u));
  background: var(--well);
  border: 1px solid var(--well-edge);
  box-shadow: var(--well-inset);
}
.clue {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(6 * var(--u));
  opacity: 0;
}
.clue.on { opacity: 1; }
.clue-meta {
  font-size: max(calc(11.5 * var(--u)), 11.5px);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clue-label);
}
.clue-emoji {
  font-size: max(calc(50 * var(--u)), 38px);
  line-height: 1.05;
  filter: var(--emoji-glow);
}
/* every word solved: the app's check, "Solved" and the count (ClueBar.swift) */
.clue-solved {
  display: inline-flex;
  align-items: center;
  gap: calc(7 * var(--u));
  font: 600 max(calc(22.7 * var(--u)), 18px)/1.2 -apple-system, system-ui, sans-serif;
  color: var(--text);
}
.clue-solved svg {
  width: 1.2em;
  height: 1.2em;
  color: var(--app-accent);
}
.clue-count {
  font-size: max(calc(13.6 * var(--u)), 12px);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* ---------- The board: the app's tiles ----------
   Every size is a ratio of the cell --s, as in TileMetrics.swift: gap 3/28, corner 0.12 (3 px at
   least), lip 0.07 (2 px at least), letter 0.65, number 0.25. Seven cells and six gaps fill the
   400-unit board, so --s is 400 / (7 + 6 x 3/28) units and six rows come to 342. */
.board {
  --s: calc(400 * var(--u) / 7.642857);
  --pitch: calc(var(--s) * 31 / 28);
  --lip: max(2px, calc(var(--s) * 0.07));
  --corner: max(3px, calc(var(--s) * 0.12));
  /* The app's two fixed sizes, the solved ring (1.5 pt) and the glow's shadow radius (7.5 pt), as
     ratios of the 39 pt cell an iPhone board has, so this board is the phone's board at another
     scale. A SwiftUI shadow radius is the blur's standard deviation: a CSS filter blur of the
     same length, and a box-shadow blur of twice it. */
  --ring-w: max(1px, calc(var(--s) * 1.5 / 39));
  --glow-r: calc(var(--s) * 7.5 / 39);
  position: relative;
  width: calc(400 * var(--u));
  height: calc(342 * var(--u));
  margin: 0 auto;
}

/* A tile, drawn in the app's order (Tile.swift). The edge colour fills the rounded square; the
   face is the same rounded shape, a lip shorter, over it from the top, so the lip shows as a
   crescent that follows the face's corners; the ring is drawn inside the shape, over both. A
   solved tile is hollow: no face, no lip, only the ring. Under them all is a pop's glow, the
   shadow of the tile's shape, which shows through a tile as it fades to hollow. site.js adds the
   face (.f) and the glow (.g): the resting solved board needs neither. */
.tile {
  position: absolute;
  z-index: 0;
  left: calc(var(--x) * var(--pitch));
  top: calc(var(--y) * var(--pitch));
  width: var(--s);
  height: var(--s);
  border-radius: var(--corner);
  font-style: normal;
  -webkit-user-select: none;
  user-select: none;
  --face: var(--plain-face);
  --edge: var(--plain-edge);
  --ring: transparent;
  --ink: var(--tile-ink);
}
.tile::before,
.tile::after,
.tile > .f,
.tile > .g {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}
.tile::before { background: var(--edge); }
.tile > .f { bottom: var(--lip); background: var(--face); }
.tile::after { border: var(--ring-w) solid var(--ring); }
.tile > .g { z-index: -1; background: var(--cur-glow); filter: blur(var(--glow-r)); opacity: 0; }
.tile.word { --face: var(--word-face); --edge: var(--word-edge); }
.tile.cursor { z-index: 1; --face: var(--cur-face); --edge: var(--cur-edge); --ink: var(--cur-ink); }
.tile.solved { --face: transparent; --edge: transparent; --ring: var(--solved-ring); --ink: var(--solved-ink); }
.board-card.live .tile { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Letter and number carry the app's hairline, outside the glyph and in the opposite polarity to
   the theme: a stroke twice the visible width, painted under the fill. The letter is centred in
   the face below the number band (0.17 of the cell from the top, down to the lip). */
.l, .n {
  position: absolute;
  z-index: 1;
  line-height: 1;
  paint-order: stroke fill;
  pointer-events: none;
}
.l {
  left: 0;
  right: 0;
  top: calc((var(--s) * 1.17 - var(--lip)) / 2);
  translate: 0 -50%;
  text-align: center;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: calc(var(--s) * 0.65);
  font-weight: 600;
  color: var(--ink);
  -webkit-text-stroke: 0.055em var(--glyph-outline);
}
.tile.empty .l { opacity: 0; }
.n {
  left: calc(var(--s) * 0.07);
  top: calc(var(--s) * 0.0542); /* the app's 0.03 inset to the line box, for a line of 1 */
  font-family: -apple-system, system-ui, sans-serif;
  font-size: calc(var(--s) * 0.25);
  font-weight: 500;
  color: var(--tile-num);
  -webkit-text-stroke: calc(var(--s) * 0.03) var(--glyph-outline);
}
/* Where the browser can trim a line to its capitals, centre and inset by the capitals themselves,
   so a font with other metrics than San Francisco still lands where the app's letter does. */
@supports (text-box: trim-both cap alphabetic) {
  .l, .n { text-box: trim-both cap alphabetic; }
  .n { top: calc(var(--s) * 0.0918); }
}

/* The cursor's glow, a layer under the tiles so it can glide between cells: only the glow outside
   the tile's shape. site.js adds it, moves the outer box and breathes the inner one in step with the cursor tile. */
.glow-at {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--s);
  height: var(--s);
  pointer-events: none;
}
.glow {
  position: absolute;
  inset: 0;
  border-radius: var(--corner);
  box-shadow: 0 0 calc(var(--glow-r) * 2) var(--cur-glow);
}

/* ---------- Clue chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--chip-edge);
  background: var(--chip-bg);
  color: var(--chip-text);
  font: 600 11px/1 ui-rounded, -apple-system, system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out,
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.chip-emoji { font-size: 13px; letter-spacing: 0; }
/* a 44px tap height from the 36px pill (4px above and below), and 3px into each side's gap:
   clear of the next chip (6px apart on a phone; the narrowest card's rule is below), the board
   above and the card's edge. The insets count from inside the 1px border. */
.chip { position: relative; }
.chip::after { content: ""; position: absolute; inset: -5px -4px; }
.chip:hover {
  background: var(--chip-hover-bg);
  border-color: var(--chip-on-edge);
  color: var(--chip-on-text);
}
.chip:active { transform: scale(0.97); }
/* 2 px out and 2 px wide: clear of the next chip across the gap */
.chip:focus-visible { outline-offset: 2px; }
.chip[aria-pressed="true"] {
  background: var(--chip-on-bg);
  border-color: var(--chip-on-edge);
  color: var(--chip-on-text);
}

/* The play button, over the right end of the clue well while a word is picked (site.js shows
   it). It lets go of the word. It is outside the well, which is hidden from assistive tech. */
.resume {
  --d: max(calc(34 * var(--u)), 30px);
  position: absolute;
  z-index: 1;
  top: calc(var(--pad-top) + (var(--well-h) - var(--d)) / 2);
  right: calc(var(--pad-x) + max(calc(14 * var(--u)), 9px));
  display: grid;
  place-items: center;
  width: var(--d);
  height: var(--d);
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--chip-on-edge);
  background: var(--chip-on-bg);
  color: var(--chip-on-text);
  cursor: pointer;
  transition: background-color 160ms ease-out, transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.resume[hidden] { display: none; }
/* a 44 px target around the smaller circle */
.resume::after { content: ""; position: absolute; inset: calc((var(--d) - 44px) / 2); }
.resume svg {
  width: 62%;
  height: 62%;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
/* it already wears the picked chip's look, so hover deepens it */
.resume:hover { background: var(--resume-hover-bg); }
.resume:active { transform: scale(0.94); }

@media (max-width: 480px) {
  .chips { gap: 6px; flex-wrap: nowrap; }
  .chip { padding: 0 7px; gap: 3px; letter-spacing: 0; white-space: nowrap; }
  .chip-emoji { font-size: 12px; }
}
/* The narrowest card (288px, up to a 378px window): the three chips are wider than its content, so
   the row takes the card's side padding too and the pills draw closer, which keeps them 10px or
   more inside the card's edge. The tap areas reach 2px into each gap, so neighbours still meet. */
@container (max-width: 299px) {
  .chips { gap: 4px; margin-inline: calc(-1 * var(--pad-x)); }
  .chip { padding: 0 4px; }
  .chip::after { inset: -5px -3px; }
}

@media (prefers-reduced-motion: reduce) {
  .chip, .resume { transition: none; }
  .chip:active, .resume:active { transform: none; }
}

/* ---------- Footer ---------- */

.home-footer { padding-top: 24px; }
.home-footer a { color: var(--home-foot); }
.home-footer small { color: var(--home-foot-copy); }
/* only where the footer is one row: stacked (899 and below), the pulled-up link would touch the
   copyright, and on a phone site.css already gives the links their 44px tap height */
@media (min-width: 900px) {
  .home-footer nav a { padding: 8px 0; margin: -8px 0; }
}
/* the four links stay on one line down to 320 (site.css hides the dots at this width) */
@media (max-width: 360px) {
  .home-footer nav { gap: 0 16px; }
  .home-footer nav a { padding-inline: 0; }
}

/* ---------- Ground, phone: the reading-page ground hides its right cluster and parks both
   pulse tiles behind the card. Here both clusters stay, and the tiles sit around the board
   as in the phone frames (950:5050 / 950:5653). ---------- */

@media (max-width: 720px) {
  html::before,
  body::before,
  body::after {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }
  html::before {
    top: 8px;
    left: 108px;
    box-shadow:
      -50px 50px 0 var(--tile), 0 50px 0 var(--tile), 50px 50px 0 var(--tile), 100px 50px 0 var(--tile),
      0 100px 0 var(--tile), 0 150px 0 var(--tile), 0 200px 0 var(--tile), 50px 200px 0 var(--tile), 100px 200px 0 var(--tile),
      -100px 350px 0 var(--tile), -50px 350px 0 var(--tile), 0 350px 0 var(--tile), 50px 350px 0 var(--tile), 100px 350px 0 var(--tile),
      -50px 300px 0 var(--tile), -50px 400px 0 var(--tile), -50px 450px 0 var(--tile), -50px 500px 0 var(--tile),
      0 500px 0 var(--tile), 50px 500px 0 var(--tile), 100px 500px 0 var(--tile),
      100px 450px 0 var(--tile), 100px 550px 0 var(--tile), 100px 600px 0 var(--tile), 100px 650px 0 var(--tile),
      50px 650px 0 var(--tile), 100px 700px 0 var(--tile);
  }
  body::before {
    display: block;
    top: 58px;
    left: auto;
    right: 90px;
    box-shadow:
      0 50px 0 var(--tile), 0 100px 0 var(--tile), 0 150px 0 var(--tile), 0 200px 0 var(--tile), 0 250px 0 var(--tile),
      50px 150px 0 var(--tile), 0 450px 0 var(--tile), 50px 450px 0 var(--tile),
      50px 600px 0 var(--tile), 0 600px 0 var(--tile);
  }
  /* pulse tiles: the left margin beside the board, and one in each top corner. All three are
     above y = 410, where the footer never is on a phone, so no link is read over one. */
  body::after {
    top: 358px;
    left: 8px;
    box-shadow: 0 -300px 0 var(--tile-pulse), calc(100vw - 90px) -350px 0 var(--tile-pulse);
  }
  html::after {
    background: radial-gradient(ellipse 52% 26% at 50% 34%, var(--fade) 0%, var(--fade) 40%, transparent 100%);
  }
}

/* ---------- Tablet and up: copy and badge on the left, board on the right ---------- */

@media (min-width: 600px) {
  .sub { display: block; }
  .hero h1 { font-size: clamp(36px, 6.4vw, 44px); }
}

@media (min-width: 900px) {
  .home-header { justify-content: space-between; }
  .home-header .back { display: inline; }
  .hero {
    grid-template-columns: minmax(0, 1fr) 459px;
    grid-template-areas: "copy board" "cta board";
    grid-template-rows: auto 1fr;
    column-gap: 48px;
    row-gap: 0;
    justify-items: start;
    text-align: left;
    padding: 20px 0 8px;
  }
  .hero-copy { align-self: start; margin-top: 70px; }
  .hero h1 { font-size: 50px; letter-spacing: -0.025em; }
  .sub { margin: 24px 0 0; max-width: 400px; }
  .cta { align-self: start; margin-top: 38px; }
  .board-wrap { justify-self: end; align-self: center; grid-row: 1 / span 2; width: 459px; }
  .hero::before { left: auto; right: -24px; transform: translate(0, -50%); }
  .home-footer {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: min(1072px, calc(100% - 48px));
    margin: 0 auto;
    padding: 24px 0 44px;
  }
  .home-footer small { margin: 0; }
}
