:root {
  /* Surfaces and ink */
  --bg: #f4f0e6;
  --bg-rgb: 244 240 230;
  --surface: #fbf8f1;
  --ink: #1f2e2e;
  --muted: #55645f;
  --accent: #2f6e68;
  --accent-soft: rgb(47 110 104 / 0.12);
  --border: #ded8c9;
  --rule: #777f7a;
  --focus: #2f6e68;

  /* Ocean palettes: the single source of truth, read by ocean.js */
  --p-tidal-accent: #2f6e68;
  --p-tidal-deep: #17332f;
  --p-indigo-accent: #3d5c93;
  --p-indigo-deep: #1b2a47;
  --p-kelp-accent: #5e7a34;
  --p-kelp-deep: #22301a;
  --p-dusk-accent: #8a5670;
  --p-dusk-deep: #34202c;

  /* Space */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  /* Type */
  --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-text: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t--1: 0.75rem;
  --t-0: 1rem;
  --t-1: 1.0625rem;
  --t-2: clamp(1.375rem, 2.1vw, 1.75rem);
  --t-3: clamp(2.35rem, 6.1vw, 4.6rem);

  /* Shape */
  --r-sm: 8px;
  --r-lg: 14px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgb(31 46 46 / 0.06), 0 8px 24px -14px rgb(31 46 46 / 0.22);
  --shadow-2: 0 2px 6px rgb(31 46 46 / 0.08), 0 24px 48px -24px rgb(31 46 46 / 0.3);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--t-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

p,
h1 {
  margin: 0;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

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

.skip-link {
  position: absolute;
  top: var(--s2);
  left: var(--s2);
  z-index: 20;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--t--1);
  text-decoration: none;
  transform: translateY(-200%);
}

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

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

.app {
  display: grid;
  /* Header, ocean and dock share the viewport, so the controls never fall
     below the fold on a short screen. */
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% 0%, rgb(255 253 247 / 0.7), transparent 70%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) clamp(var(--s4), 4vw, var(--s7)) var(--s3);
}

.wordmark {
  font-family: var(--font-display);
  font-size: var(--t-1);
  letter-spacing: 0.005em;
}

.topbar__note {
  font-size: var(--t--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  display: grid;
  min-height: 0;
  overflow: hidden;
  padding: clamp(var(--s4), 2.5vw, var(--s6)) clamp(var(--s4), 5vw, var(--s8));
  isolation: isolate;
}

.sea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}

.sea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -7px;
  border-radius: var(--r-lg);
}

.hero__copy {
  position: relative;
  z-index: 1;
  align-self: center;
  max-width: 38rem;
  padding: clamp(var(--s2), 2vw, var(--s5));
  pointer-events: none;
  transition: opacity 320ms ease, transform 320ms ease, visibility 320ms;
}

.hero__copy .btn {
  pointer-events: auto;
}

.hero__copy::before {
  content: "";
  position: absolute;
  inset: -8% -22% -8% -14%;
  z-index: -1;
  background: radial-gradient(78% 72% at 26% 48%, rgb(var(--bg-rgb) / 0.98) 34%, rgb(var(--bg-rgb) / 0.86) 58%, rgb(var(--bg-rgb) / 0) 86%);
  pointer-events: none;
}

.hero__copy.is-hidden {
  opacity: 0;
  transform: translateY(-10px);
  visibility: hidden;
  pointer-events: none;
}

.hero__copy.is-collapsed {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  pointer-events: none;
}

.hero__copy.is-collapsed::before {
  content: none;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
  font-size: var(--t--1);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow__rule {
  width: 32px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.display {
  font-family: var(--font-display);
  font-size: var(--t-3);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.028em;
  text-wrap: balance;
  max-width: 18ch;
}

.lede {
  margin-top: var(--s5);
  max-width: 48ch;
  font-size: var(--t-1);
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4) var(--s5);
  margin-top: var(--s6);
}

.hero__hint {
  font-size: var(--t--1);
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.btn--primary {
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-1);
}

.btn--primary:hover {
  background: var(--accent);
}

.btn--primary:active {
  transform: translateY(1px);
}

.btn--solid {
  background: var(--accent-soft);
  border-color: rgb(47 110 104 / 0.35);
  color: var(--ink);
}

.btn--solid:hover {
  background: rgb(47 110 104 / 0.2);
}

.btn--ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink);
}

.btn--ghost:hover {
  background: rgb(31 46 46 / 0.06);
  border-color: var(--ink);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Dock ---------- */

.dock {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s5) clamp(var(--s5), 4vw, var(--s7));
  padding: var(--s4) clamp(var(--s4), 4vw, var(--s7)) var(--s5);
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgb(var(--bg-rgb) / 0.75), var(--bg) 55%);
}

.group {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.group__label {
  padding: 0;
  font-size: var(--t--1);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.group--colour {
  border: 0;
  margin: 0;
  padding: 0;
}

.group--colour .group__label {
  margin-bottom: var(--s2);
}

.swatches {
  display: flex;
  gap: var(--s1);
  margin: 0 calc(var(--s2) * -1);
}

.swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s1);
  min-width: 52px;
  min-height: 44px;
  padding: var(--s1) var(--s2);
  border-radius: var(--r-sm);
  cursor: pointer;
}

.swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch__dot {
  pointer-events: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(31 46 46 / 0.18);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.swatch__name {
  pointer-events: none;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 160ms ease;
}

.swatch:hover .swatch__dot {
  transform: scale(1.08);
}

.swatch input:checked ~ .swatch__dot {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--swatch),
    inset 0 0 0 1px rgb(31 46 46 / 0.14);
}

.swatch input:checked ~ .swatch__name {
  color: var(--ink);
}

.swatch input:focus-visible ~ .swatch__dot {
  outline: 2px solid var(--focus);
  outline-offset: 5px;
}

.swatch[data-p="tidal"] { --swatch: var(--p-tidal-accent); }
.swatch[data-p="indigo"] { --swatch: var(--p-indigo-accent); }
.swatch[data-p="kelp"] { --swatch: var(--p-kelp-accent); }
.swatch[data-p="dusk"] { --swatch: var(--p-dusk-accent); }

.group--height {
  min-width: 168px;
  flex: 1 1 200px;
  max-width: 320px;
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent) var(--fill, 55%), var(--rule) var(--fill, 55%));
}

.range::-moz-range-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent) var(--fill, 55%), var(--rule) var(--fill, 55%));
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-1);
  transition: transform 140ms ease, background-color 140ms ease;
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-1);
}

.range:hover::-webkit-slider-thumb {
  transform: scale(1.08);
}

.range:focus-visible {
  outline: none;
}

.range:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.range:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.range__value {
  font-size: var(--t--1);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.group--buttons {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-left: auto;
}

.dock__hint {
  flex-basis: 100%;
  max-width: 76ch;
  font-size: var(--t--1);
  line-height: 1.5;
  color: var(--muted);
}

.dock__note {
  flex-basis: 100%;
  max-width: 66ch;
  padding: var(--s2) var(--s3);
  border-left: 2px solid var(--accent);
  font-size: var(--t--1);
  line-height: 1.5;
  color: var(--ink);
  background: rgb(47 110 104 / 0.07);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.dock__note[hidden],
.group[hidden] {
  display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .hero {
    min-height: 0;
    padding: var(--s5) var(--s5) 0;
  }

  .hero__copy {
    align-self: start;
    padding: var(--s2) 0 var(--s4);
  }

  .hero__copy::before {
    inset: -14% -14% 0 -14%;
    background: linear-gradient(180deg, rgb(var(--bg-rgb) / 0.98) 0%, rgb(var(--bg-rgb) / 0.96) 56%, rgb(var(--bg-rgb) / 0.6) 82%, rgb(var(--bg-rgb) / 0) 100%);
  }

  .display {
    max-width: 20ch;
  }

  .dock {
    gap: var(--s3) var(--s4);
    padding: var(--s3) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom, 0px));
  }

  .dock__hint {
    font-size: 0.75rem;
    line-height: 1.45;
  }

  .group--height {
    flex: 1 1 100%;
    max-width: none;
  }

  .group--buttons {
    flex: 1 1 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .group--buttons .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 420px) {
  .topbar__note {
    display: none;
  }

  .hero__actions {
    gap: var(--s3);
    margin-top: var(--s5);
  }

  .btn {
    padding: 0 var(--s4);
  }

  .swatch {
    min-width: 46px;
    padding-inline: var(--s1);
  }
}

/* Short viewports share the frame with the dock, so the copy steps down a size
   instead of being clipped by the hero's overflow. */
@media (max-height: 780px) {
  .hero__copy {
    padding: var(--s1) 0 var(--s2);
  }

  .eyebrow {
    margin-bottom: var(--s2);
  }

  .display {
    font-size: clamp(1.6rem, min(6.6vw, 4.6vh), 2.4rem);
    max-width: 26ch;
  }

  .lede {
    margin-top: var(--s3);
    font-size: clamp(0.8125rem, 2.1vh, 0.9375rem);
    line-height: 1.45;
  }

  .hero__actions {
    margin-top: var(--s3);
    gap: var(--s3);
  }
}

/* Very short phones (iPhone SE and up): the decorative tagline steps aside so
   the headline, lede and primary action all stay above the fold. */
@media (max-height: 668px) {
  .hero {
    padding-top: var(--s3);
  }

  .hero__copy {
    padding-bottom: var(--s1);
  }

  .display {
    font-size: clamp(1.45rem, 6.2vw, 1.9rem);
    max-width: 28ch;
  }

  .lede {
    line-height: 1.4;
  }

  .hero__actions {
    margin-top: var(--s2);
  }

  .hero__hint {
    display: none;
  }
}

/* Landscape phones are too short to hold header, ocean and dock at once: let
   the page scroll rather than crushing the hero to nothing. */
@media (max-height: 470px) {
  .app {
    height: auto;
  }

  .hero {
    min-height: 62dvh;
    padding-bottom: var(--s4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
