/* site/site.css: the landing page. Page-only, never shipped.
   It sits on top of the library bundle (../divot.css), which supplies the
   palette and the buttons. Everything below is for this page alone. */

/* --- page tokens ------------------------------------------------------ */
/* Type, and the hairlines the page draws. The button reads none of these. */
:root {
  --font-ui: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  --font-size-micro: 10px;
  --font-size-meta: 11px;
  --font-size-mono: 12px;
  --font-size-ui: 13px;
  --font-size-body: 14px;
  --font-size-title: 15px;
  --label-tracking: 0.12em;
}

/* Same three theme selectors as the library palette, so they stay in step. */
:root,
[data-theme="light"] {
  --border: #c9c3b1;
  --border-strong: #8e8977;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --border: #2a2521;
    --border-strong: #4c443d;
  }
}

[data-theme="dark"] {
  --border: #2a2521;
  --border-strong: #4c443d;
}

/* --- base ------------------------------------------------------------- */
/* The tokens leave color-scheme alone on :root, so the page opts in itself:
   follow the OS until the theme toggle sets [data-theme]. */
:root:not([data-theme]) {
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-inline: 16px;
  padding-block: 0 72px;
  background: var(--background);
  color: var(--ink);
  font: var(--font-size-body)/1.55 var(--font-ui);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h2 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 {
  font-size: clamp(20px, 2.6vw, 26px);
  line-height: 1.2;
}

p {
  margin: 0;
  max-width: 56ch;
}

a {
  color: inherit;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: var(--ink);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

pre {
  margin: 0;
  font: var(--font-size-mono)/1.6 var(--font-mono);
  white-space: pre;
  overflow-x: auto;
}

.divot {
  font: var(--font-size-ui)/1.3 var(--font-ui);
}

a.divot {
  display: inline-block;
  text-decoration: none;
}

/* --- shared pieces ---------------------------------------------------- */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
}

/* A full-bleed band escapes the body gutter, then re-applies it inside. */
.bleed {
  margin-inline: calc(50% - 50vw);
  padding-inline: max(16px, calc(50vw - 540px));
}

.band-surface {
  background: var(--surface);
  --divot-ground: var(--surface);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.eyebrow {
  font: 500 var(--font-size-meta)/1 var(--font-mono);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--ink-dim);
}

.lab {
  font: var(--font-size-micro)/1.3 var(--font-mono);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--ink-dim);
}

.dim {
  color: var(--ink-dim);
}

section {
  display: grid;
  gap: 24px;
  padding-block: 56px;
}

.sec-head {
  display: grid;
  gap: 10px;
}

.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}

/* Cells that share one hairline grid. */
.sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.sheet > div {
  display: grid;
  gap: 12px;
  justify-items: start;
  align-content: start;
  min-height: 80px;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.sheet .cap {
  font-size: var(--font-size-mono);
  line-height: 1.4;
  color: var(--ink-dim);
}

/* --- syntax colouring for the snippets -------------------------------- */
:root {
  --syntax-string: #7a5a24;
  --syntax-attribute: #5b6a52;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --syntax-string: #c8a570;
    --syntax-attribute: #9aab8e;
  }
}

[data-theme="dark"] {
  --syntax-string: #c8a570;
  --syntax-attribute: #9aab8e;
}

pre.hl .p { color: var(--ink-faint); }
pre.hl .t { color: var(--ink); font-weight: 500; }
pre.hl .a { color: var(--syntax-attribute); }
pre.hl .s { color: var(--syntax-string); }

/* --- masthead --------------------------------------------------------- */
.mast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
}

.mast .word {
  font: 500 var(--font-size-title)/1 var(--font-ui);
}

.mast nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.mast nav a {
  padding: 6px 8px;
  font: var(--font-size-ui)/1 var(--font-ui);
  color: var(--ink-dim);
  text-decoration: none;
}

.mast nav a:hover {
  color: var(--ink);
}

.mast .theme {
  margin-left: 8px;
  gap: 4px;
}

.mast .theme .divot {
  --divot-padding-y: 6px;
  --divot-padding-x: 7px;
}

.mast .theme svg {
  display: block;
}

/* --- hero ------------------------------------------------------------- */
.hero-band {
  background: var(--surface);
  --divot-ground: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 4vw, 56px);
  align-items: center;
  padding-block: clamp(32px, 5vw, 64px);
}

.hero .t {
  display: grid;
  gap: 20px;
  align-content: center;
}

.hero h1 {
  font-size: clamp(48px, 8.5vw, 120px);
  line-height: 0.92;
  letter-spacing: -0.035em;
  margin-left: -0.045em;
}

.hero .ver {
  margin-bottom: -6px;
  font-size: var(--font-size-ui);
  text-transform: none;
}

.hero .sub {
  max-width: 44ch;
  font-size: clamp(15px, 1.6vw, 19px);
  line-height: 1.45;
  color: var(--ink-dim);
  text-wrap: balance;
}

.hero .row .divot {
  --divot-padding-y: 8px;
  --divot-padding-x: 18px;
}

.hero .art {
  position: relative;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

canvas.ascii {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

canvas.ascii:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

/* --- why -------------------------------------------------------------- */
#why .two {
  gap: clamp(48px, 8vw, 112px);
}

.why {
  display: grid;
  gap: 14px;
  max-width: 62ch;
}

.why .sec-head {
  margin-bottom: 10px;
}

.why .eyebrow {
  font-size: var(--font-size-meta);
  line-height: 1;
}

.why p {
  max-width: none;
  font-size: var(--font-size-title);
  line-height: 1.6;
  color: var(--ink-dim);
}

svg.fig {
  display: block;
  width: 100%;
  height: auto;
}

/* --- gallery ---------------------------------------------------------- */
.elev {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.elev .sheet {
  border: 0;
}

.elev .sheet > div {
  box-shadow: -1px -1px 0 var(--border);
}

/* --- customize -------------------------------------------------------- */
/* Copy and code on the left, the lamp dial on the right. */
.cust {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  align-items: stretch;
  border: 1px solid var(--border);
  background: var(--background);
  --divot-ground: var(--background);
}

.cust .info {
  display: grid;
  gap: 24px;
  align-content: start;
  padding: clamp(24px, 3.5vw, 40px);
}

.cust .info .body {
  display: grid;
  gap: 20px;
}

.cust .info .body p {
  margin-bottom: 20px;
  max-width: 62ch;
  font-size: var(--font-size-title);
  line-height: 1.6;
  color: var(--ink-dim);
}

.cust .stage {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  padding: clamp(40px, 5vw, 56px) clamp(24px, 3vw, 32px);
  border-left: 1px solid var(--border);
}

.cust .stage .lframe {
  max-width: 240px;
}

.cust .tools {
  position: absolute;
  top: 10px;
  right: 10px;
  gap: 6px;
}

.cust .tool {
  --divot-padding-y: 3px;
  --divot-padding-x: 8px;
  font: var(--font-size-mono)/1.3 var(--font-mono);
}

.cust .scale {
  min-width: 4ch;
}

.lcode {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}

.lcode pre {
  flex: 1 1 auto;
  padding: 6px 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface);
}

/* The dial: a square frame the lamp orbits, sized in cqw so it scales. */
.lframe {
  position: relative;
  width: 100%;
  max-width: 290px;
  aspect-ratio: 1;
  container-type: inline-size;
  justify-self: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.lframe.grab {
  cursor: grabbing;
}

.lframe .ring {
  position: absolute;
  inset: 4%;
  border: 1px dashed var(--border-strong);
  border-radius: 50%;
}

.lframe .ray {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 46cqw;
  border-left: 1px dashed var(--ink-dim);
  transform-origin: 0 0;
  transform: rotate(calc(var(--divot-light-angle) + 180deg));
}

/* The button in the middle: a stock .divot with every dimension doubled. */
.lframe .mag {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
  font: calc(var(--font-size-ui) * 2)/1.3 var(--font-ui);
  letter-spacing: normal;
  border-width: 2px;
  --divot-inner-width: 2px;
  --divot-press-offset: 0.5px;
  --divot-padding-y: 10px;
  --divot-padding-x: 24px;
}

.lframe .zoom {
  position: absolute;
  left: 50%;
  top: calc(50% + 20cqw);
  transform: translateX(-50%);
  font: var(--font-size-micro)/1 var(--font-mono);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* At 1× the button renders at actual size. */
.lframe.x1 .mag {
  font: var(--font-size-ui)/1.3 var(--font-ui);
  letter-spacing: normal;
  border-width: 1px;
  --divot-inner-width: 1px;
  --divot-press-offset: 0.25px;
  --divot-padding-y: 5px;
  --divot-padding-x: 12px;
}

.lframe.x1 .zoom {
  top: calc(50% + 8cqw);
}

.lframe .lamp {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: -11px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--background);
  transform: rotate(var(--divot-light-angle)) translateY(-46cqw) rotate(calc(-1 * var(--divot-light-angle)));
}

.lframe .lamp::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
}

.lframe .lamp::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
}

.lframe .lamp:hover,
.lframe.grab .lamp {
  box-shadow: 0 0 0 5px var(--border);
}

.lframe .lamp:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 5px;
}

/* --- cheatsheet ------------------------------------------------------- */
.cheat {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.cheat > div {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.cheat dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: var(--font-size-ui);
}

.cheat dt {
  font-family: var(--font-mono);
  font-size: var(--font-size-mono);
  white-space: nowrap;
}

.cheat dd {
  margin: 0;
  color: var(--ink-dim);
}

/* --- install ---------------------------------------------------------- */
#install {
  padding-bottom: 96px;
}

.inst-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.inst-head .divot {
  --divot-padding-y: 8px;
  --divot-padding-x: 18px;
}

.install {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.install > div {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* --- footer ----------------------------------------------------------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font: var(--font-size-mono)/1.5 var(--font-mono);
  color: var(--ink-dim);
}

.foot nav {
  display: flex;
  gap: 16px;
}

/* --- responsive ------------------------------------------------------- */
@media (max-width: 760px) {
  .hero,
  .two,
  .cust,
  .cheat,
  .install {
    grid-template-columns: 1fr;
  }

  .cust .stage {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
