/* Hinge, LidSound's design language, for the web (docs/DESIGN.md).
   Black is hardware. White type at three strengths. One red glow, only for
   what is sounding. Capsule controls. Lowercase monospaced legends. */

:root {
  color-scheme: dark;

  --island: #000;
  --primary: #fff;
  --secondary: rgba(255, 255, 255, 0.6);
  --tertiary: rgba(255, 255, 255, 0.36);
  --fill: rgba(255, 255, 255, 0.09);
  --fill-raised: rgba(255, 255, 255, 0.18);
  --keyline: rgba(255, 255, 255, 0.08);
  --ember: #e01729;
  --flare: #ff594d;
  --glow: linear-gradient(135deg, var(--flare), var(--ember));

  --rounded: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Springs from Hinge.Motion. app.js replaces these with linear() curves
     sampled from the real springs where the browser supports them. */
  --spring-open: cubic-bezier(0.32, 1.25, 0.6, 1);
  --spring-pop: cubic-bezier(0.3, 1.45, 0.55, 1);
  --spring-close: cubic-bezier(0.3, 0.9, 0.3, 1);
  --spring-control: cubic-bezier(0.32, 1.15, 0.6, 1);
  --dur-open: 0.6s;
  --dur-pop: 0.6s;
  --dur-close: 0.5s;
  --dur-control: 0.42s;

  --column: 640px;
  --gutter: 22px;
}

* { box-sizing: border-box; }

html {
  background: var(--island);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--island);
  color: var(--primary);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration-color: var(--tertiary); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--primary); }

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

::selection { background: rgba(255, 255, 255, 0.24); }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--primary); color: var(--island);
  padding: 8px 14px; border-radius: 999px; z-index: 100;
}
.skip:focus { left: 16px; top: 16px; }

.column { max-width: var(--column); margin-inline: auto; }

/* ---------- Legends: engraved, lowercase, monospaced, never bold ---------- */

.legend {
  font: 400 11px/1.4 var(--mono);
  letter-spacing: 0.07em;
  text-transform: lowercase;
  color: var(--tertiary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* A lamp lights only when something is alive: here, the section on screen. */
.lamp {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fill-raised);
  transition: background 0.6s ease, box-shadow 0.6s ease;
  flex: none;
}
.is-lit > .legend .lamp,
.is-lit .lamp.self { background: var(--primary); box-shadow: 0 0 8px rgba(255, 255, 255, 0.45); }

/* ---------- The notch island ---------- */

.island {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 50;
  width: 185px;
  height: 32px;
  transform: translateX(-50%);
  margin-top: env(safe-area-inset-top, 0px);
  background: var(--island);
  border-radius: 0 0 12px 12px;
  box-shadow: inset 0 -1px 0 var(--keyline), inset 1px 0 0 var(--keyline), inset -1px 0 0 var(--keyline);
  transition:
    width var(--dur-close) var(--spring-close),
    height var(--dur-close) var(--spring-close),
    border-radius var(--dur-close) var(--spring-close);
  color: var(--primary);
}

/* The concave flares where the island melts into the top edge. */
.island::before,
.island::after {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 8px;
  pointer-events: none;
}
.island::before { right: 100%; background: radial-gradient(circle at 0 100%, transparent 7.5px, var(--island) 8px); }
.island::after { left: 100%; background: radial-gradient(circle at 100% 100%, transparent 7.5px, var(--island) 8px); }

.island[data-mode="live"] {
  width: 305px;
  border-radius: 0 0 14px 14px;
  transition:
    width var(--dur-open) var(--spring-open),
    height var(--dur-open) var(--spring-open),
    border-radius var(--dur-open) var(--spring-open);
}
.island[data-mode="event"] {
  width: 313px;
  height: 76px;
  border-radius: 0 0 22px 22px;
  transition:
    width var(--dur-pop) var(--spring-pop),
    height var(--dur-pop) var(--spring-pop),
    border-radius var(--dur-pop) var(--spring-pop);
}

.island-wing {
  position: absolute;
  top: 0;
  width: 54px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  filter: blur(6px);
  transition: opacity 0.14s ease-out, filter 0.14s ease-out;
}
.island-wing.left { left: 6px; }
.island-wing.right { right: 6px; }
.island-glyph { width: 39px; height: 24px; }
.island-angle {
  font: 500 12px/1 var(--rounded);
  font-variant-numeric: tabular-nums;
}

.island-event {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 38px;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  filter: blur(8px);
  transform: scale(0.86);
  transform-origin: 50% 0;
  transition: opacity 0.14s ease-out, filter 0.14s ease-out, transform 0.14s ease-out;
}
.island-event .symbol { width: 18px; height: 18px; flex: none; }
.island-caption {
  font: 600 13px/1 var(--rounded);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.island-bars { width: 26px; height: 14px; flex: none; }

.island[data-mode="live"] .island-wing,
.island[data-mode="event"] .island-wing,
.island[data-mode="event"] .island-event {
  opacity: 1;
  filter: none;
  transform: none;
  transition: opacity 0.35s ease 0.06s, filter 0.35s ease 0.06s, transform 0.35s ease 0.06s;
}

@media (max-width: 360px) {
  .island { transform: translateX(-50%) scale(0.86); transform-origin: 50% 0; }
}

/* ---------- Top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  margin-top: calc(10px + env(safe-area-inset-top, 0px));
  max-width: 1080px;
  margin-inline: auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font: 600 15px/1 var(--rounded);
}
.brand img { width: 28px; height: 28px; }
.bar nav { display: flex; gap: 18px; }
.bar nav a {
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.07em;
  color: var(--secondary);
  text-decoration: none;
}
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--primary); }

@media (max-width: 520px) {
  .brand span { display: none; }
  .bar nav { gap: 12px; }
  .bar nav .wide { display: none; }
}

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

.hero { text-align: center; padding-block: 72px 36px; }
.hero .icon { width: 128px; height: 128px; margin: 0 auto 28px; }
.hero .legend { justify-content: center; }
.hero h1 {
  font: 300 clamp(38px, 8vw, 64px)/1.04 var(--rounded);
  letter-spacing: -0.02em;
  margin: 16px 0 18px;
}
.hero .lede {
  color: var(--secondary);
  font-size: 18px;
  line-height: 1.5;
  max-width: 34em;
  margin: 0 auto;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: center;
  margin-top: 30px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  border: 0;
  font: 600 14px/1 var(--rounded);
  text-decoration: none;
  cursor: pointer;
}
.pill.solid { background: var(--primary); color: var(--island); }
.pill.quiet { background: var(--fill); color: var(--secondary); cursor: default; }
.cta .note { color: var(--tertiary); font: 400 12px/1.4 var(--mono); letter-spacing: 0.04em; }

/* ---------- The instrument: the window set down on the page ---------- */

.instrument {
  padding-block: 28px 8px;
  touch-action: pan-y;
}
.instrument-head { display: flex; justify-content: space-between; align-items: center; }
.instrument-head .hint { color: var(--tertiary); font: 400 11px/1 var(--mono); letter-spacing: 0.07em; }

.stage {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-top: 18px;
}
.lid {
  width: min(416px, 100%);
  aspect-ratio: 26 / 16;
  cursor: ns-resize;
  touch-action: none;
}
.readout {
  font: 300 64px/1 var(--rounded);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin: 4px 0 0;
}
.readout .deg { color: var(--tertiary); }
.last-event {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font: 600 13px/1 var(--rounded);
}
.last-event .symbol { width: 18px; height: 18px; }
.last-event .bars { width: 26px; height: 14px; }
.last-event .symbol, .last-event .bars { opacity: 0; transition: opacity 0.3s ease; }
.last-event.has-event .symbol, .last-event.has-event .bars { opacity: 1; }
.last-event.is-fresh { color: var(--primary); }

.travel { margin-top: 26px; }
.scale { width: 100%; height: 14px; display: block; margin-top: 12px; }
.scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--tertiary);
  font: 400 10px/1 var(--mono);
  letter-spacing: 0.07em;
}

/* Thumbless capsule slider (HingeSlider). */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --value: 0%;
}
.slider::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, rgba(255,255,255,0.82) var(--value), var(--fill) var(--value));
  transition: height 0.2s ease;
}
.slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, rgba(255,255,255,0.82) var(--value), var(--fill) var(--value));
}
.slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 1px; height: 5px; background: transparent; border: 0; }
.slider::-moz-range-thumb { width: 1px; height: 5px; background: transparent; border: 0; }
.slider:hover::-webkit-slider-runnable-track, .slider:active::-webkit-slider-runnable-track, .slider:focus-visible::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(to right, #fff var(--value), var(--fill) var(--value));
}
.slider:hover::-moz-range-track, .slider:active::-moz-range-track { height: 8px; }
.slider:focus-visible { outline-offset: 4px; }

.lid-control { margin-top: 18px; }
.lid-control label, .setting label { display: block; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 0;
  background: var(--fill);
  color: var(--secondary);
  font: 500 12px/1 var(--sans);
  cursor: pointer;
  transition: transform 0.2s var(--spring-control), opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.chip:hover { color: var(--primary); }
.chip:active { transform: scale(0.94); opacity: 0.7; }

/* Pack switcher: every pack as a capsule, a highlight that slides. */
.packs { margin-top: 34px; }
.pack-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 520px) {
  .pack-grid { display: flex; flex-wrap: wrap; }
  .pack { padding: 0 15px; flex: 1 0 auto; }
}

.pack {
  position: relative;
  z-index: 1;
  height: 34px;
  border-radius: 999px;
  border: 0;
  background: var(--fill);
  color: var(--secondary);
  font: 600 13px/1 var(--rounded);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
  transition: color 0.25s ease, background 0.25s ease, transform 0.2s ease;
}
.pack .plus-tag { font: 400 9px/1 var(--mono); letter-spacing: 0.08em; margin-left: 6px; opacity: 0.55; }
.pack:hover { color: var(--primary); }
.pack:active { transform: scale(0.96); }
.pack[aria-checked="true"] { color: var(--island); background: transparent; }
.pack-highlight {
  position: absolute;
  z-index: 0;
  left: 0; top: 0;
  height: 34px;
  border-radius: 999px;
  background: var(--primary);
  transition:
    transform var(--dur-control) var(--spring-control),
    width var(--dur-control) var(--spring-control);
  pointer-events: none;
}
.pack-tagline { color: var(--tertiary); font-size: 13px; margin: 12px 0 0; min-height: 1.5em; }

/* Sound rows, one per event. */
.sounds { margin-top: 30px; }
.rows { list-style: none; margin: 10px 0 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 22px 1fr auto 32px;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--keyline);
}
.row:last-child { border-bottom: 1px solid var(--keyline); }
.row .symbol { width: 20px; height: 20px; color: var(--tertiary); transition: color 0.2s ease; }
.row .what { min-width: 0; }
.row .event { font: 600 14px/1.2 var(--rounded); display: block; }
.row .when { color: var(--tertiary); font-size: 12px; display: block; margin-top: 2px; }
/* Up to two lines, so an event with several takes can name all of them. */
.row .plays { color: var(--secondary); font-size: 13px; line-height: 1.3; text-align: right; max-width: 15em; text-wrap: balance; }
.play {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--fill);
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
.play svg { width: 12px; height: 12px; }
.play:active { transform: scale(0.92); opacity: 0.7; }
.play:disabled { opacity: 0.35; cursor: default; }
.row.is-sounding .symbol { color: var(--flare); }
.row.is-sounding .play { background: var(--glow); }
.pack-note { color: var(--tertiary); font-size: 12px; margin: 10px 0 0; min-height: 1.4em; }

/* Settings: volume and the follow sound, in one ink. */
.settings {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px 28px;
  align-items: end;
  margin-top: 30px;
}
.setting .legend { margin-bottom: 8px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  color: var(--secondary);
  font: 500 12px/1 var(--sans);
  padding: 0;
  cursor: pointer;
}
.toggle .track {
  position: relative;
  width: 34px; height: 20px;
  border-radius: 999px;
  background: var(--fill-raised);
  transition: background 0.25s ease;
}
.toggle .knob {
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--secondary);
  transition: transform var(--dur-control) var(--spring-control), background 0.25s ease;
}
.toggle[aria-checked="true"] .track { background: var(--primary); }
.toggle[aria-checked="true"] .knob { background: var(--island); transform: translateX(14px); }

.sound-state { color: var(--tertiary); font: 400 11px/1.4 var(--mono); letter-spacing: 0.05em; margin: 22px 0 0; }

/* ---------- Story sections ---------- */

.section {
  padding-block: 44px;
  border-top: 1px solid var(--keyline);
}
.section:first-of-type { border-top: 0; }
.section h2 {
  font: 300 clamp(26px, 5vw, 34px)/1.15 var(--rounded);
  letter-spacing: -0.01em;
  margin: 14px 0 12px;
}
.section p { color: var(--secondary); margin: 0 0 12px; }
.section p strong { color: var(--primary); font-weight: 600; }

.facts { list-style: none; margin: 18px 0 0; padding: 0; }
.facts li {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: 16px;
  padding: 11px 0;
  border-top: 1px solid var(--keyline);
  color: var(--secondary);
  font-size: 15px;
}
.facts li span:first-child { color: var(--tertiary); font: 400 11px/1.9 var(--mono); letter-spacing: 0.07em; }
@media (max-width: 520px) {
  .facts li { grid-template-columns: 1fr; gap: 2px; }
}

/* The live Dock icon, tilting with the demo lid. */
.dock-demo {
  display: flex;
  justify-content: center;
  padding: 24px 0 8px;
}
.dock-demo img {
  width: 112px; height: 112px;
  transform: perspective(500px) rotateX(calc(var(--tilt, 0) * 1deg));
  transform-origin: 50% 85%;
  transition: transform 0.15s linear;
}

/* ---------- Documents (support, privacy, terms) ---------- */

.doc { padding-block: 64px 24px; }
.doc h1 { font: 300 clamp(34px, 7vw, 48px)/1.1 var(--rounded); letter-spacing: -0.02em; margin: 14px 0 8px; }
.doc .updated { color: var(--tertiary); font: 400 11px/1.4 var(--mono); letter-spacing: 0.07em; margin: 0 0 36px; }
.doc h2 { font: 600 17px/1.3 var(--rounded); margin: 38px 0 10px; }
.doc h3 { font: 600 15px/1.35 var(--rounded); margin: 22px 0 6px; }
.doc p, .doc li { color: var(--secondary); }
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 12px; padding-left: 1.2em; }
.doc li { margin: 4px 0; }
.doc strong { color: var(--primary); font-weight: 600; }
.doc .lead { font-size: 18px; color: var(--secondary); }
.doc .contact {
  margin: 26px 0 8px;
  padding: 18px 0;
  border-top: 1px solid var(--keyline);
  border-bottom: 1px solid var(--keyline);
}
.doc .contact a { font: 600 18px/1.3 var(--rounded); color: var(--primary); }
.doc details { border-top: 1px solid var(--keyline); padding: 14px 0; }
.doc details:last-of-type { border-bottom: 1px solid var(--keyline); }
.doc summary { cursor: pointer; font: 600 15px/1.35 var(--rounded); color: var(--primary); list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.doc summary::-webkit-details-marker { display: none; }
.doc summary::after { content: "+"; color: var(--tertiary); font-weight: 400; }
.doc details[open] summary::after { content: "\2212"; }
.doc details p { margin: 10px 0 0; }

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

.footer {
  border-top: 1px solid var(--keyline);
  margin-top: 24px;
  padding-block: 28px calc(36px + env(safe-area-inset-bottom, 0px));
  color: var(--tertiary);
  font-size: 13px;
}
.footer .links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 12px; padding: 0; list-style: none; }
.footer .links a { color: var(--secondary); text-decoration: none; font: 400 11px/1.6 var(--mono); letter-spacing: 0.07em; }
.footer .links a:hover { color: var(--primary); }
.footer p { margin: 4px 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.2s !important;
    transition-timing-function: ease-in-out !important;
    transition-delay: 0s !important;
  }
}
