/* ==========================================================================
   Reel & Merge — web presence
   The look is lifted straight from the game: a warm low-poly afternoon at the
   pond. Sand and cream from the shoreline, the icon's sky-blue → teal water,
   coin gold, campfire orange, and the deep board-navy the merge grid sits on.
   Light is the native, on-brand mode ("noon at the pond"); dark mode is the
   game's own night biome — campfire glow, starlit water.
   Accent colors are sampled from icon.svg and the in-game UI.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Pond palette (icon.svg + in-game UI) */
  --water-sky: #7ec8e3;   /* icon gradient top */
  --water-deep: #2e86ab;  /* icon gradient bottom */
  --coin: #ffd166;        /* coin gold */
  --fin: #f4a261;         /* fish belly orange */
  --campfire: #e76f51;    /* dorsal fin / campfire */
  --cast: #2e9277;        /* the CAST button */
  --board: #17344a;       /* merge-board navy */
  --board-cell: #1f4360;  /* a board cell */
  --ink: #1d3557;         /* the fish's eye */

  /* The water, as a reusable sweep */
  --water: linear-gradient(160deg, var(--water-sky) 0%, var(--water-deep) 100%);

  /* Semantic roles — light (native): noon at the pond */
  --bg: #f7f1e3;
  --bg-deep: #efe6d0;
  --surface: #fffdf6;
  --surface-2: #faf5e9;
  --text: #21374e;
  --muted: #67788a;
  --border: #e2d7bf;
  --hairline: #d8ccb2;
  --accent: var(--water-deep);
  --accent-ink: #1f6f92;
  --accent-strong: var(--cast);
  --gold-ink: #a97a12;
  --shadow: rgba(46, 92, 122, 0.18);
  --frame-bg: var(--board);

  --maxw: 46rem;
  --radius: 18px;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
    "Segoe UI", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto,
    Helvetica, Arial, sans-serif;
}

/* Night at the pond — the game's own after-dark biome */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f2236;
    --bg-deep: #0a1929;
    --surface: #16324b;
    --surface-2: #1a3a57;
    --text: #eaf2f8;
    --muted: #93a9bd;
    --border: #234a68;
    --hairline: #1f4460;
    --accent: var(--water-sky);
    --accent-ink: #8fd2e8;
    --accent-strong: #46b493;
    --gold-ink: #ffd166;
    --shadow: rgba(0, 0, 0, 0.45);
    --frame-bg: #0d1e30;
  }
}

/* Explicit theme overrides (viewer toggle stamps data-theme on :root) */
:root[data-theme="light"] {
  --bg: #f7f1e3;
  --bg-deep: #efe6d0;
  --surface: #fffdf6;
  --surface-2: #faf5e9;
  --text: #21374e;
  --muted: #67788a;
  --border: #e2d7bf;
  --hairline: #d8ccb2;
  --accent: var(--water-deep);
  --accent-ink: #1f6f92;
  --accent-strong: var(--cast);
  --gold-ink: #a97a12;
  --shadow: rgba(46, 92, 122, 0.18);
  --frame-bg: var(--board);
}
:root[data-theme="dark"] {
  --bg: #0f2236;
  --bg-deep: #0a1929;
  --surface: #16324b;
  --surface-2: #1a3a57;
  --text: #eaf2f8;
  --muted: #93a9bd;
  --border: #234a68;
  --hairline: #1f4460;
  --accent: var(--water-sky);
  --accent-ink: #8fd2e8;
  --accent-strong: #46b493;
  --gold-ink: #ffd166;
  --shadow: rgba(0, 0, 0, 0.45);
  --frame-bg: #0d1e30;
}

* { box-sizing: border-box; }

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

/* 100vw includes the scrollbar gutter on some platforms; the full-bleed shot
   strip may overshoot by a few px there. Clip instead of growing the page. */
body { overflow-x: clip; }

body {
  margin: 0;
  background-color: var(--bg);
  /* Sky light pooling at the top of the page, shore deepening at the foot —
     the same top-to-bottom sky → water → board read as the game screen.
     In dark mode the warm glow becomes the campfire on the left bank. */
  background-image:
    radial-gradient(120% 55% at 50% -8%, rgba(126, 200, 227, 0.22) 0%, transparent 60%),
    radial-gradient(90% 40% at 8% 102%, rgba(231, 111, 81, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, transparent 62%, var(--bg-deep) 100%);
  background-repeat: no-repeat;
  background-attachment: fixed, fixed, fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 17.5px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.15rem, 5vw, 2rem) 5rem;
}

/* Links: deep-water teal with a soft underline that darkens on hover. */
a {
  color: var(--accent-ink);
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--accent); }

/* --- Header ------------------------------------------------------------ */
.site-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding-bottom: 1.4rem;
  margin-bottom: 2.4rem;
  border-bottom: 1px solid var(--hairline);
}
.site-head .mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
  box-shadow: 0 1px 8px rgba(46, 134, 171, 0.3);
}
.brand {
  font-family: var(--round);
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}
/* The ampersand is the merge — it gets the coin. */
.brand-amp { color: var(--gold-ink); }
.site-head nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}
.site-head nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-head nav a:hover { color: var(--text); }

/* --- Typography -------------------------------------------------------- */
h1, h2, h3 { text-wrap: balance; font-family: var(--round); }

h1 {
  font-weight: 800;
  font-size: clamp(2.1rem, 6.4vw, 3.2rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  margin: 0 0 0.6rem;
}
h2 {
  font-weight: 700;
  font-size: clamp(1.3rem, 3vw, 1.55rem);
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 2.8rem 0 0.7rem;
  /* Each section opens with a little bobber on its line. */
  padding-top: 1.6rem;
  position: relative;
}
h2::before {
  content: "";
  position: absolute;
  top: 0.1rem;
  left: 0;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--campfire) 0%, var(--campfire) 48%, #fffdf6 52%, #fffdf6 100%);
  box-shadow: 0 2px 6px var(--shadow);
}
h2::after {
  content: "";
  position: absolute;
  top: 0.48rem;
  left: 1.25rem;
  width: 2.6rem;
  height: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}
h3 {
  font-weight: 700;
  font-size: 1.1rem;
  margin: 1.6rem 0 0.35rem;
}

.meta {
  color: var(--muted);
  font-size: 0.94rem;
  letter-spacing: 0.01em;
  margin: 0 0 2rem;
}

p { margin: 0.75rem 0; }
ul { margin: 0.7rem 0; padding-left: 0; list-style: none; }
li {
  position: relative;
  margin: 0.5rem 0;
  padding-left: 1.35rem;
}
/* A little coin instead of a default bullet. */
li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.58em;
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  background: var(--coin);
  border: 1.5px solid color-mix(in srgb, var(--gold-ink) 70%, transparent);
  box-shadow: 0 1px 3px var(--shadow);
}
strong { font-weight: 700; color: var(--text); }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
  background: var(--surface-2);
  color: var(--accent-ink);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

.lede {
  font-size: clamp(1.12rem, 2.4vw, 1.32rem);
  line-height: 1.55;
  color: var(--muted);
  font-weight: 450;
  margin: 0.4rem 0 0;
}

/* --- Callout ----------------------------------------------------------- */
.callout {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem 1.25rem 1.55rem;
  margin: 1.6rem 0 0.5rem;
  box-shadow: 0 2px 10px var(--shadow);
  overflow: hidden;
}
/* Water edge instead of a flat colored border. */
.callout::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--water);
}
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout p:first-child strong { font-family: var(--round); font-size: 1.05rem; }

/* --- Hero (index) ------------------------------------------------------ */
.hero { padding: 1.5rem 0 0.5rem; }
.eyebrow {
  display: block;
  font-family: var(--round);
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 0.9rem;
}
.hero-mark {
  width: clamp(104px, 26vw, 148px);
  height: clamp(104px, 26vw, 148px);
  border-radius: 23%; /* iOS-style superellipse approximation */
  display: block;
  margin-bottom: 1.2rem;
  box-shadow: 0 16px 44px -10px rgba(46, 134, 171, 0.5),
    0 4px 14px var(--shadow);
}
/* The pond ripples out from under the icon, like under the bobber. */
.hero-ripple {
  width: clamp(104px, 26vw, 148px);
  height: 14px;
  margin: -4px 0 1.6rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: transparent;
  opacity: 0.8;
}
/* Deep water runs through the headline itself. */
.water-text {
  background: var(--water);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pill {
  display: inline-block;
  font-family: var(--round);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  margin-bottom: 1.4rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.1rem;
  margin: 2rem 0 1.6rem;
}
/* Apple's badge artwork is the one sanctioned non-game graphic on the site. */
.store-badge {
  display: inline-block;
  border-radius: 10px;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.store-badge img { display: block; height: 50px; width: auto; }
.store-badge:hover {
  transform: translateY(-1px);
  filter: drop-shadow(0 4px 16px rgba(46, 134, 171, 0.4));
}
.store-badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
/* The secondary button is the CAST button. */
.btn {
  display: inline-block;
  text-decoration: none;
  font-family: var(--round);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
  padding: 0.68rem 1.5rem;
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-cast {
  color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cast) 88%, #fff) 0%, var(--cast) 100%);
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--cast) 70%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-cast:hover { transform: translateY(-1px); filter: brightness(1.05); }

/* --- The loop, as a strip of board cells (index) ------------------------ */
.loop-board {
  background: var(--frame-bg);
  border-radius: calc(var(--radius) + 4px);
  padding: clamp(0.9rem, 3vw, 1.3rem);
  margin: 2rem 0 0.6rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.5rem, 2vw, 0.9rem);
  box-shadow: 0 10px 30px -12px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.loop-cell {
  background: var(--board-cell);
  border-radius: 14px;
  padding: 0.85rem 0.5rem 0.8rem;
  text-align: center;
  position: relative;
}
.loop-cell .loop-emoji {
  display: block;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  line-height: 1;
  margin-bottom: 0.45rem;
}
.loop-cell .loop-word {
  display: block;
  font-family: var(--round);
  font-weight: 800;
  font-size: clamp(0.72rem, 2.2vw, 0.88rem);
  letter-spacing: 0.09em;
  color: #ecf4f9;
}
.loop-cell .loop-sub {
  display: block;
  font-size: clamp(0.62rem, 1.9vw, 0.74rem);
  color: #9db8cb;
  margin-top: 0.15rem;
}
/* Merge arrows between the cells. */
.loop-cell:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: calc(clamp(0.5rem, 2vw, 0.9rem) * -0.5 - 0.32em);
  top: 50%;
  transform: translateY(-50%);
  color: var(--coin);
  font-weight: 800;
  font-size: 0.9rem;
}
.loop-note {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.9rem;
}

/* --- Life at the pond: the shot strip (index) --------------------------- */
/* A full-bleed strip of game moments; resting position aligns with the
   reading column, but the frames slide out to the viewport edges. */
.shots {
  --bleed: calc(max((100vw - var(--maxw)) / 2, 0px) + clamp(1.15rem, 5vw, 2rem));
  display: flex;
  gap: 1.1rem;
  margin: 1.9rem 0 0.4rem;
  margin-inline: calc(var(--bleed) * -1);
  padding-inline: var(--bleed);
  padding-block: 0.5rem 1rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--bleed);
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
}
.shots:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.shot {
  flex: 0 0 auto;
  width: clamp(186px, 62vw, 246px);
  margin: 0;
  scroll-snap-align: start;
}
/* Frames read like board cells: navy, chunky radius, warm shadow. */
.shot-frame {
  aspect-ratio: 720 / 1280;
  border-radius: 22px;
  overflow: hidden;
  background: var(--frame-bg);
  border: 1px solid color-mix(in srgb, var(--board) 30%, var(--border));
  box-shadow: 0 14px 34px -14px var(--shadow), 0 2px 10px var(--shadow);
  transform: translateZ(0);
}
.shot-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.shot figcaption {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 0.7rem;
  padding-inline: 0.2rem;
}
.shot figcaption strong {
  font-family: var(--round);
  font-weight: 700;
  display: block;
  color: var(--text);
}
/* The pond bobs gently: each frame drifts a little, out of phase, like
   boats at their moorings. Stills stay fully visible without it. */
@media (prefers-reduced-motion: no-preference) {
  .shot { animation: bob 7s ease-in-out infinite alternate; }
  .shot:nth-child(2) { animation-delay: -1.4s; }
  .shot:nth-child(3) { animation-delay: -2.8s; }
  .shot:nth-child(4) { animation-delay: -4.2s; }
  .shot:nth-child(5) { animation-delay: -5.6s; }
  @keyframes bob {
    from { transform: translateY(0); }
    to { transform: translateY(-6px); }
  }
}

/* --- Feature rows (index) ---------------------------------------------- */
.feature {
  display: grid;
  gap: 1.7rem;
  align-items: center;
  margin: 2.6rem 0;
}
.feature h2 { margin-top: 0; }
.feature-text p { margin-bottom: 0; }
.feature-shot {
  width: min(62vw, 236px);
  flex: none;
  scroll-snap-align: none;
  animation: none;
}
@media (min-width: 640px) {
  .feature {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2.4rem;
  }
  .feature-flip { grid-template-columns: auto minmax(0, 1fr); }
  .feature-flip .feature-media { order: -1; }
}

/* --- Ripple divider: the water line under the bobber -------------------- */
.ripple-line {
  border: 0;
  height: 12px;
  margin: 2.4rem 0;
  background: none;
  position: relative;
}
.ripple-line::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Three nested ripples, like the icon's rings. */
  background:
    radial-gradient(50% 100% at 50% 0%, transparent 62%, color-mix(in srgb, var(--accent) 30%, transparent) 63%, transparent 70%) center / 5rem 200% no-repeat,
    linear-gradient(90deg, transparent, var(--hairline) 26%, var(--hairline) 40%, transparent 47%) center left / 50% 1px no-repeat,
    linear-gradient(90deg, transparent 53%, var(--hairline) 60%, var(--hairline) 74%, transparent) center right / 50% 1px no-repeat;
  background-position: center top, left center, right center;
}

/* --- Footer ------------------------------------------------------------ */
footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: center;
}
.footer-links { margin-left: auto; display: flex; gap: 1.2rem; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

.disclaimer {
  font-size: 0.96rem;
  color: var(--muted);
  line-height: 1.55;
}

/* --- Entrance motion: one calm, staggered settle on load --------------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal > * {
    opacity: 0;
    transform: translateY(10px);
    animation: settle 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }
  .reveal > *:nth-child(1) { animation-delay: 0.02s; }
  .reveal > *:nth-child(2) { animation-delay: 0.09s; }
  .reveal > *:nth-child(3) { animation-delay: 0.16s; }
  .reveal > *:nth-child(4) { animation-delay: 0.23s; }
  .reveal > *:nth-child(5) { animation-delay: 0.30s; }
  .reveal > *:nth-child(6) { animation-delay: 0.37s; }
  .reveal > *:nth-child(7) { animation-delay: 0.44s; }
  .reveal > *:nth-child(8) { animation-delay: 0.51s; }
  @keyframes settle {
    to { opacity: 1; transform: none; }
  }
}
