/*
 * Tactile UI — the shared studio.
 *
 * A dark, warm surface where every object brings its own light. Two voices:
 * Instrument Sans (display and text) and Sligoil Micro (the engraved plate:
 * labels, figures, specifications). One accent, signal vermilion, for index
 * marks, the founder dot and active states — never for headings.
 */
@font-face { font-family: 'Instrument Sans'; src: url('/app/fonts/instrument-sans/InstrumentSans-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/app/fonts/instrument-sans/InstrumentSans-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/app/fonts/instrument-sans/InstrumentSans-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Sligoil'; src: url('/app/fonts/sligoil/Sligoil-Micro.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Sligoil'; src: url('/app/fonts/sligoil/Sligoil-MicroMedium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Sligoil'; src: url('/app/fonts/sligoil/Sligoil-MicroBold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root, [data-finish] {
  /* The site is drawn with the kit it sells: every surface is a kit token,
     so the finish switch (aluminium / graphite) restyles all of it. */
  --bg: var(--tui-desk);
  --bg-2: var(--tui-face);
  --bg-3: var(--tui-well);
  --ink: var(--tui-ink);
  --ink-2: color-mix(in oklab, var(--tui-ink) 72%, var(--tui-ink-2));
  --ink-3: var(--tui-ink-2);
  --ink-4: var(--tui-ink-3);
  --line: var(--tui-rule);
  --line-2: color-mix(in oklab, var(--tui-ink) 20%, transparent);
  /* No brand colour: colour only means a lamp is on. */
  --signal: var(--tui-green);
  --curve: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  /* Printing on the panel: the grotesk, small and tracked, like a Braun label. */
  --plate: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --code: 'Geist Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --max: 1320px;
  --gut: clamp(16px, 4vw, 48px);
  --r: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--bg, #0e0f10); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(100%, var(--max)); margin: 0 auto; padding: 0 var(--gut); }
[hidden] { display: none !important; }
/* A preview's own stage fills whatever frame the page gives it. */
.fill > :first-child { height: 100% !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------- voices */
.plate {
  font: 600 10.5px/1.3 var(--plate);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.plate b, .plate strong { color: var(--ink); font-weight: 500; }
.fig { font-family: var(--plate); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.display {
  font: 700 clamp(44px, 6.9vw, 104px)/0.94 var(--sans);
  letter-spacing: -0.043em;
  margin: 0;
  text-wrap: balance;
}
.h2 {
  font: 700 clamp(34px, 4.4vw, 62px)/1 var(--sans);
  letter-spacing: -0.038em;
  margin: 0;
  text-wrap: balance;
}
.h3 { font: 700 22px/1.15 var(--sans); letter-spacing: -0.02em; margin: 0; }
.lede { font-size: clamp(18px, 1.6vw, 21px); line-height: 1.5; color: var(--ink-2); max-width: 36em; margin: 0; text-wrap: pretty; }
.muted { color: var(--ink-3); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 6px 1px rgb(63 163 77 / 0.5); vertical-align: 0.1em; }

/* ---------------------------------------------------------------- controls */
/* Buttons are the kit's keys: a cap on a skirt; pressing takes the skirt away
   and the plate's edge shades the cap. One contrast key per surface. */
.btn {
  --skirt: 2px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 44px; padding: 0 20px;
  border: 0; border-radius: 8px;
  color: var(--tui-ink);
  font: 600 14.5px/1 var(--sans);
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--tui-hl), transparent 60%),
    linear-gradient(var(--tui-face-hi), color-mix(in oklab, var(--tui-face-hi) 92%, rgb(var(--tui-sh))));
  box-shadow:
    inset 0 1px 0 var(--tui-hl),
    0 var(--skirt) 0 var(--tui-skirt),
    0 calc(var(--skirt) + 1px) 2px rgb(var(--tui-sh) / calc(var(--tui-sh-a) * 1.4)),
    0 calc(var(--skirt) + 6px) 12px -6px rgb(var(--tui-sh) / var(--tui-sh-a));
  transition: transform 70ms var(--tui-ease), box-shadow 70ms var(--tui-ease);
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(var(--skirt)); filter: brightness(0.97); box-shadow: var(--tui-pressed); }
.btn.primary {
  color: var(--tui-cap-ink); font-weight: 700;
  --tui-skirt: var(--tui-cap-skirt);
  --tui-hl: var(--tui-cap-hl);
  background:
    radial-gradient(120% 90% at 50% 0%, rgb(255 255 255 / 0.1), transparent 60%),
    linear-gradient(var(--tui-cap-hi), var(--tui-cap));
}
.btn.small { --skirt: 1.5px; height: 34px; padding: 0 14px; font-size: 13.5px; border-radius: 7px; }
.btn .fig { font-size: 13px; opacity: 0.8; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.linkish {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  color: var(--ink-2); font: 500 14px/1 var(--sans);
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 5px;
}
.linkish:hover { color: var(--ink); text-decoration-color: var(--ink-3); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--line-2);
  font: 500 10.5px/1 var(--plate); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2);
}
.chip[data-access='free'] { color: var(--ink); border-color: var(--ink-3); }

/* ---------------------------------------------------------------- header */
.bar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in oklab, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.4s var(--curve);
}
.bar[data-scrolled='true'] { border-bottom-color: var(--line); }
.bar .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.mark svg { width: 20px; height: 20px; }
.mark span { font: 700 14px/1 var(--sans); letter-spacing: 0.3em; margin-right: -0.3em; }
.bar nav { display: flex; gap: 24px; margin-left: auto; }
.bar nav a { text-decoration: none; color: var(--ink-2); font: 500 14.5px/1 var(--sans); }
.bar nav a:hover { color: var(--ink); }
.account { display: flex; align-items: center; gap: 14px; }
.tier {
  font: 500 10.5px/1 var(--plate); letter-spacing: 0.14em; text-transform: uppercase;
  padding: 7px 10px; border-radius: 999px; background: var(--ink); color: var(--bg);
}
.tier::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); margin-right: 7px; vertical-align: 0.05em; }
@media (max-width: 860px) {
  .bar nav { display: none; }
  .account { margin-left: auto; }
}
@media (max-width: 520px) {
  .account .linkish { display: none; }
  .bar .wrap { gap: 12px; }
}

/* ---------------------------------------------------------------- footer */
.foot { border-top: 1px solid var(--line); margin-top: clamp(80px, 12vw, 160px); padding: 56px 0 40px; }
.foot .cols { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.foot h4 { margin: 0 0 14px; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.foot a { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.foot a:hover { color: var(--ink); }
.foot .word {
  margin-top: 64px;
  /* Sized so the ten letters of the name span the page, no wider. */
  font: 700 calc((min(100vw, var(--max)) - 2 * var(--gut)) / 6.1)/0.74 var(--sans);
  letter-spacing: -0.06em;
  color: var(--bg-3);
  user-select: none;
  white-space: nowrap;
  margin-bottom: -0.05em;
}
.foot .small { margin-top: 18px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
@media (max-width: 760px) { .foot .cols { grid-template-columns: 1fr 1fr; } .foot .cols > :first-child { grid-column: 1 / -1; } }

/* ---------------------------------------------------------------- licence dialog (account.mjs) */
dialog.licence {
  width: min(520px, calc(100vw - 32px));
  border: 0; border-radius: 16px;
  background: var(--bg-2); color: var(--ink);
  box-shadow: inset 0 1px 0 var(--tui-hl), 0 30px 60px -20px rgb(var(--tui-sh) / calc(var(--tui-sh-a) * 2.4));
  padding: 28px;
}
dialog.licence::backdrop { background: rgb(4 4 5 / 0.72); }
dialog.licence h2 { margin: 0 0 8px; font: 700 24px/1.1 var(--sans); letter-spacing: -0.03em; }
dialog.licence p { margin: 0 0 16px; color: var(--ink-2); font-size: 15px; }
dialog.licence label { display: block; margin-bottom: 8px; font: 500 11px/1 var(--plate); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
dialog.licence textarea {
  width: 100%; resize: vertical; min-height: 84px;
  background: var(--tui-well-fill) var(--tui-well); color: var(--ink);
  border: 0; box-shadow: var(--tui-inset); border-radius: 8px; padding: 12px;
  font: 400 13px/1.45 var(--code); letter-spacing: 0.02em;
}
dialog.licence textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.licence-error { color: #ff9b86 !important; margin: 10px 0 0 !important; }
.licence-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------------------------------------------------------------- the ghost hand's caption */
.ghost-note {
  position: absolute; left: 50%; top: 14px; translate: -50% 0; z-index: 21; margin: 0; pointer-events: none; white-space: nowrap;
  padding: 7px 11px; border-radius: 999px; background: rgb(12 12 13 / 0.72); color: var(--ink) !important;
  animation: ghost-in 0.4s var(--curve);
}
@keyframes ghost-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------------------------------------------------------------- search button (bar) */
.search-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px 0 12px; border-radius: 999px;
  border: 0; background: var(--tui-well-fill) var(--tui-well); box-shadow: var(--tui-inset); color: var(--ink-3); cursor: pointer;
  font: 500 13.5px/1 var(--sans);
}
.search-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.search-btn kbd { font: 500 10.5px/1 var(--code); letter-spacing: 0.06em; padding: 4px 6px; border-radius: 6px; background: var(--bg-3); color: var(--ink-2); }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .search-btn .label { display: none; }
  .search-btn { padding: 0 10px; }
}

/* ---------------------------------------------------------------- library shell */
.lib { display: grid; grid-template-columns: 264px minmax(0, 1fr); width: min(100%, 1560px); margin: 0 auto; }
.side {
  position: sticky; top: 64px; height: calc(100dvh - 64px); overflow: auto; padding: 26px 18px 40px 22px;
  border-right: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.side-group { display: grid; gap: 2px; margin-bottom: 26px; }
.side-head { margin: 0 0 8px 10px; font: 500 10.5px/1.3 var(--plate); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); }
.side-link {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: baseline; gap: 6px;
  padding: 7px 10px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font: 500 14.5px/1.3 var(--sans);
  transition: background-color 0.2s var(--curve), color 0.2s var(--curve);
}
.side-link.is-doc { grid-template-columns: 1fr; }
.side-link:hover { background: color-mix(in oklab, var(--tui-face-hi) 55%, transparent); color: var(--ink); }
.side-link[aria-current='page'] { background: var(--tui-well-fill) var(--tui-well); color: var(--ink); box-shadow: var(--tui-inset); }
.side-link.is-block { padding-left: 20px; font-size: 13.5px; color: var(--ink-3); }
.side-link.is-block .side-no { font-size: 10px; }
.side-no { font: 500 11px/1 var(--plate); letter-spacing: 0.06em; color: var(--ink-4); }
.side-link[aria-current='page'] .side-no { color: var(--ink); }
.side-free { font: 500 9.5px/1 var(--plate); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); padding: 3px 6px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-2); }
.lib-main { min-width: 0; padding: 0 clamp(16px, 3vw, 44px) 0; }
@media (max-width: 1100px) {
  .lib { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .side {
    position: fixed; z-index: 40; top: 64px; left: 0; bottom: 0; width: min(320px, 86vw); height: auto;
    background: var(--bg); border-right: 1px solid var(--line-2); transform: translateX(-102%);
    transition: transform 0.35s var(--curve); box-shadow: 30px 0 60px rgb(0 0 0 / 0.5);
  }
  .side[data-open='true'] { transform: none; }
}

/* ---------------------------------------------------------------- search palette */
dialog.palette {
  width: min(640px, calc(100vw - 24px)); margin-top: 12vh; padding: 0; border: 0; border-radius: 18px;
  background: var(--bg-2); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2), 0 40px 80px -20px rgb(0 0 0 / 0.8);
}
dialog.palette::backdrop { background: rgb(4 4 5 / 0.66); }
.palette-input {
  width: 100%; height: 58px; padding: 0 20px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink);
  font: 500 17px/1 var(--sans); outline: none;
}
.palette-input::placeholder { color: var(--ink-4); }
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: min(420px, 56vh); overflow: auto; }
.palette-list li a { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; text-decoration: none; }
.palette-list li[aria-selected='true'] a { background: var(--bg-3); }
.palette-list b { font: 700 15px/1.2 var(--sans); }
.palette-list span { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { padding: 18px 12px; color: var(--ink-3); }
.palette-foot { margin: 0; padding: 10px 18px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- page transitions */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
@media (max-width: 520px) {
  .bar .search-btn[data-search] { display: none; }
  .account .btn.small { padding: 0 12px; font-size: 13px; }
  .mark span { letter-spacing: 0.22em; }
}

/* ---------------------------------------------------------------- a block, shown as a window (app/frame.mjs) */
.vp { position: absolute; top: 0; transform-origin: 0 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(128 128 128 / 0.4) transparent; }
.vp[data-scroll='false'] { overflow: hidden; }
/* A thumbnail window centres a section shorter than itself; a taller one keeps its top. */
.vp[data-scroll='false'] .vp-page { display: flex; flex-direction: column; justify-content: safe center; }
.vp-page { container-type: inline-size; min-height: 100%; }
.vp[data-device='tablet'], .vp[data-device='phone'] { border-radius: 20px; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.1), 0 30px 60px -30px rgb(0 0 0 / 0.8); }

/* ---------------------------------------------------------------- the finish key (finish.mjs) */
.finish-key { flex: none; }
.finish-key svg { width: 15px; height: 15px; }
.finish-key[aria-pressed='true'] svg { transform: rotate(180deg); }

/* ---------------------------------------------------------------- the sidebar, by category (shell.mjs) */
.side-search {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; margin: 0 0 14px; padding: 0 10px;
  border: 0; border-radius: 9px; cursor: pointer; text-align: left;
  font: 500 13.5px/1 var(--sans); color: var(--ink-3);
  background: var(--tui-well-fill) var(--tui-well); box-shadow: var(--tui-inset);
}
.side-search span { flex: 1; }
.side-search kbd { font: 500 11px/1 var(--code); padding: 3px 6px; border-radius: 5px; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.side-search:hover { color: var(--ink); }
.side-icon { width: 17px; height: 17px; flex: none; color: var(--ink-3); }
.side-cat { display: flex; align-items: center; gap: 11px; padding: 7px 10px; }
.side-cat .side-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-count { font: 500 11.5px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink-4); }
.side-cat:hover .side-icon, .side-cat[aria-current='page'] .side-icon { color: var(--ink); }
.side-item { display: block; padding: 5px 10px 5px 38px; font-size: 13.5px; color: var(--ink-3); position: relative; }
.side-item::before { content: ''; position: absolute; left: 18px; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.side-item[aria-current='page'] { color: var(--ink); background: none; box-shadow: none; }
.side-item[aria-current='page']::after { content: ''; position: absolute; left: 15.5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--tui-green); box-shadow: 0 0 6px 1px color-mix(in oklab, var(--tui-green) 55%, transparent); }

/* ---------------------------------------------------------------- sign in (account.mjs) */
.signin-keys { display: grid; gap: 10px; margin: 18px 0 6px; }
.signin-keys .btn { justify-content: flex-start; gap: 12px; width: 100%; }
.signin-keys svg { width: 17px; height: 17px; flex: none; }
.signin .licence-actions { justify-content: space-between; align-items: center; }

/* The header's lamp (app/finish.mjs): its own ring hugs the acorn, so no box ring;
   its light fades out before the edges of its small box instead of stopping at them. */
.bar-lamp .pc:focus-visible { outline: none; }
.bar-lamp .pc-light, .bar-lamp .pc-glow, .bar-lamp .pc-shadow {
  -webkit-mask: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent), linear-gradient(to bottom, #000 70%, transparent);
  -webkit-mask-composite: source-in;
  mask: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent), linear-gradient(to bottom, #000 70%, transparent);
  mask-composite: intersect;
}
