/* site.css — the page around the tank.
 *
 * Palette and type are the app's, taken from src/renderer/shared/pixel.css and
 * src/renderer/onboarding/onboarding.css: the tank is the settings card's dark
 * field inside the same brown rim, the ink is its cream, and the accents are
 * sampled off the kelp. The one liberty is the rim's rounded corners — the
 * app's cards are hard-edged.
 *
 * Both fonts were drawn without antialiasing, on grids of their own: Yowza is
 * crisp at multiples of 26px, Lowza at multiples of 8px. Every size below is
 * one of those multiples, and `-webkit-font-smoothing: none` keeps macOS from
 * feathering edges the art doesn't have. See the app's docs/reference/panels.md.
 */

@font-face {
  font-family: 'Yowza';
  src: url('../assets/fonts/Yowza.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: 'Lowza';
  src: url('../assets/fonts/Lowza.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bar-h: 64px;
  --tank-inset: 20px;
  --rim-w: 6px;

  /* Straight from the app. */
  --tank: #122020; /* onboarding.css --panel-dark, the settings card's field */
  --edge: #71413b; /* pixel.css --edge, the rim on all three cards */
  --cream: #fef3c0; /* pixel.css --ink-cream */
  --amber: #ffd541; /* pixel.css --panel */
  --pixel-ink: #060608; /* pixel.css --ink */
  --kelp-bright: #14a02e; /* onboarding.css, sampled off the kelp */

  /* The page the cutout sits on. Cream drained most of the way to paper, so
   * the tank is the only saturated thing above the fold. */
  --paper: #efe6cf;
  --ink: #2a2119;
  --ink-soft: #6f6252;
  --line: #d8cbae;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Warmer and darker than the tank's teal, so the cutout still reads as a
     * cutout rather than blending into the page. */
    --paper: #0d0b08;
    --ink: #efe6cf;
    --ink-soft: #9b8f7c;
    --line: #322b22;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* Anchored sections clear the fixed bar. */
  scroll-padding-top: calc(var(--bar-h) + 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  /* Both fonts are ASCII-only; keep the fallback. */
  font: 16px/1.6 'Lowza', ui-sans-serif, -apple-system, BlinkMacSystemFont, sans-serif;
  text-transform: uppercase;
  -webkit-font-smoothing: none;
}

/* Prose is the one thing Lowza is wrong for: it is a small-caps pixel face
 * drawn for labels, and the app never sets a paragraph in it. */
.prose {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* -- top bar ------------------------------------------------------------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--tank-inset);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  text-decoration: none;
  font-family: 'Yowza', ui-sans-serif, sans-serif;
  font-size: 26px; /* Yowza's grid */
  line-height: 1;
}

.brand img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  border-radius: 6px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a {
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 1;
  text-decoration: none;
  color: var(--ink-soft);
}

.nav a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

/* The bar has room for FAQ and the CTA on a phone, and not much else. */
@media (max-width: 560px) {
  .nav-suggest {
    display: none;
  }
}

/* Mail links in the prose. */
.link {
  color: var(--ink);
  text-decoration-color: color-mix(in srgb, var(--ink) 40%, transparent);
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--kelp-bright);
  text-decoration-color: currentColor;
}

/* -- buttons -------------------------------------------------------------- */

/* The app's `.pixel-button`: the field's colour on the rim's, inverted so the
 * one button is the one solid shape. Rounded here to match the cutout. */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 18px;
  border: 2px solid transparent;
  border-radius: 8px;
  font: inherit;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--amber);
  color: var(--pixel-ink);
  border-color: var(--amber);
}

.btn-primary:hover {
  background: var(--cream);
  border-color: var(--cream);
}

.btn-ghost {
  background: transparent;
  color: var(--cream);
  border-color: color-mix(in srgb, var(--cream) 35%, transparent);
}

.btn-ghost:hover {
  color: var(--amber);
  border-color: var(--amber);
}

/* `.nav a` is the more specific selector, so the CTA's colours need saying
 * again here or it inherits the muted link colour. */
.nav a.btn-primary,
.nav a.btn-primary:hover {
  padding: 9px 15px;
  color: var(--pixel-ink);
  background: var(--amber);
  border-color: var(--edge);
}

/* Not on the App Store yet — the button says so rather than pretending. */
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* -- the cutout ----------------------------------------------------------- */

/* The rim lives out here. A border on #tank would push the padding box in by
 * its width and offset every absolutely-positioned sprite by the same. */
.tank-frame {
  margin: calc(var(--bar-h) + var(--tank-inset)) var(--tank-inset) var(--tank-inset);
  height: calc(100svh - var(--bar-h) - var(--tank-inset) * 2);
  /* Tall enough for the copy and the planting to both fit without meeting. A
   * short phone scrolls a little rather than stacking them on top of one
   * another. */
  min-height: 620px;
  border: var(--rim-w) solid var(--edge);
  border-radius: 26px;
  background: var(--tank);
  overflow: hidden;
}

#tank {
  position: relative;
  width: 100%;
  height: 100%;
  color: var(--cream);
  /* Nothing selectable: dragging a selection across the tank while feeding
   * looks broken. */
  user-select: none;
  -webkit-user-select: none;
}

/* The line the shrimp walks on, in the rim's own brown rather than the kelp's
 * green — it reads as the floor of the cutout, not as a seam in the water. */
#tank::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--edge);
  z-index: 0;
}

/* Nothing is drawn until the atlases have loaded and been placed once. */
#tank .dt-fade,
.planting {
  opacity: 0;
  transition: opacity 500ms ease;
}

#tank.is-ready .dt-fade,
.planting.is-ready {
  opacity: 1;
}

/* -- the planting --------------------------------------------------------- */

/* A zero-height rail on the floor; each plant grows up out of it. Behind the
 * shrimp, so the tank never hides the thing the page is about. */
.planting {
  position: absolute;
  inset: auto 0 0 0;
  height: 0;
  z-index: 1;
  pointer-events: none;
}

.dt-plant {
  position: absolute;
  bottom: 0;
  image-rendering: pixelated;
  background-repeat: no-repeat;
}

/* -- the copy inside the tank --------------------------------------------- */

/* The block spans the tank's full width to centre the copy, so it would
 * otherwise swallow every feeding click in a band across the whole tank. The
 * text is not interactive; the controls inside it take their clicks back. */
.tank-copy {
  pointer-events: none;
  position: absolute;
  inset: 0 0 auto 0;
  top: clamp(48px, 16vh, 150px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  text-align: center;
}

.tank-copy h1 {
  margin: 0;
  font-family: 'Yowza', ui-sans-serif, sans-serif;
  font-weight: 400;
  /* Yowza's grid, stepped rather than fluid — a clamp lands glyph edges on
   * fractions and the font goes soft. */
  font-size: 52px;
  line-height: 1.05;
}

@media (min-width: 700px) {
  .tank-copy h1 {
    font-size: 78px;
  }
}

@media (min-width: 1100px) {
  .tank-copy h1 {
    font-size: 104px;
  }
}

@media (min-width: 1600px) {
  .tank-copy h1 {
    font-size: 130px;
  }
}

/* The lede is `.prose`: the two lines are sentences, not labels. */
.tank-lede {
  margin: 0;
  max-width: 46ch;
  color: color-mix(in srgb, var(--cream) 78%, transparent);
  font-size: 15px;
  line-height: 1.7;
}

.tank-actions {
  pointer-events: auto; /* see .tank-copy */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.tank-hint {
  margin: -8px 0 0;
  color: color-mix(in srgb, var(--cream) 55%, transparent);
  letter-spacing: 0.04em;
}

/* A narrow tank has no room for the desktop rhythm: the headline wraps to
 * three lines and the buttons stack, and the whole block has to land above the
 * planting. Both fonts stay on their own grids. */
@media (max-width: 560px) {
  :root {
    --tank-inset: 12px;
    --rim-w: 5px;
  }

  .tank-copy {
    top: 64px;
    gap: 16px;
    padding: 0 18px;
  }

  .tank-copy h1 {
    font-size: 26px;
  }

  .tank-lede {
    font-size: 14px;
  }

  .tank-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
    padding: 12px 16px;
  }

  .brand {
    font-size: 26px;
  }

  section h2 {
    font-size: 26px;
  }
}

/* One hint, worded for whichever input the visitor actually has. */
.hint-coarse {
  display: none;
}

@media (pointer: coarse) {
  .hint-fine {
    display: none;
  }

  .hint-coarse {
    display: inline;
  }
}

/* Top-right, out of the planting's way. */
.sound-toggle {
  position: absolute;
  z-index: 4;
  right: 14px;
  top: 14px;
  padding: 7px 12px;
  border: 2px solid color-mix(in srgb, var(--cream) 25%, transparent);
  border-radius: 999px;
  background: transparent;
  color: color-mix(in srgb, var(--cream) 65%, transparent);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.sound-toggle:hover {
  color: var(--kelp-bright);
  border-color: var(--kelp-bright);
}

/* -- the page below ------------------------------------------------------- */

section {
  max-width: 720px;
  margin: 0 auto;
  padding: 96px 24px;
}

section h2 {
  margin: 0 0 32px;
  font-family: 'Yowza', ui-sans-serif, sans-serif;
  font-weight: 400;
  font-size: 52px;
  line-height: 1;
}

.faq-item {
  padding: 24px 0;
  border-top: 2px solid var(--line);
}

.faq-item h3 {
  margin: 0 0 10px;
  font-weight: 400;
  font-size: 24px; /* Lowza's grid */
  line-height: 1.2;
}

.faq-item p {
  margin: 0;
  color: var(--ink-soft);
}

/* -- the closing panel ----------------------------------------------------- */

/* The app's card at page scale, rounded to match the cutout. It follows the
 * FAQ, which already ends in whitespace, so the section's own top padding
 * comes off — the card's rim is the separation. */
.panels {
  padding-top: 0;
}

/* The FAQ's last answer already sits above whitespace, so the full 96px
 * underneath it plus the card's own top padding reads as a hole. */
#faq {
  padding-bottom: 32px;
}

.panel-card {
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 16px;
}

.panel-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
}

.panel-card .prose {
  margin: 0 0 22px;
  color: var(--ink-soft);
}

/* On paper the amber needs the rim behind it, the way the app's buttons sit
 * on the card's field. */
.panel-card .btn-primary {
  border-color: var(--edge);
}

.panel-card .btn-primary:hover {
  background: var(--amber);
  filter: brightness(1.08);
}

/* The address itself, for anyone whose browser swallows a mailto:. Selectable,
 * unlike the rest of the chrome. */
.panel-aside {
  margin: 26px 0 0;
  color: var(--ink-soft);
  user-select: text;
  -webkit-user-select: text;
}

footer {
  border-top: 2px solid var(--line);
  padding: 28px 24px 40px;
  text-align: center;
  color: var(--ink-soft);
}

/* -- reduced motion ------------------------------------------------------- */

/* The shrimp is the point of the page, so it keeps moving. Everything the page
 * itself animates stops. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  #tank .dt-fade,
  .planting {
    transition: none;
  }
}
