/* ─────────────────────────────────────────────────────────
   bettercallhtm — style.css
   follows the system theme; [data-theme] on <html> overrides it
   ───────────────────────────────────────────────────────── */

/* ── fonts (self-hosted; latin + latin-ext, greek for μ/σ in mono) ── */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/jetbrains-mono-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/space-grotesk-600-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/space-grotesk-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── tokens ──────────────────────────────────────────── */
:root {
  --bg:           #F6F4EF;
  --bg-rgb:       246, 244, 239;
  --bg-2:         #EFECE5;
  --surface:      #FFFFFF;
  --surface-2:    #F8F6F2;
  --text:         #15141A;
  --text-muted:   #5C5A68;
  --text-dim:     #6E6C78;
  --border:       rgba(20, 18, 30, 0.10);
  --border-strong:rgba(20, 18, 30, 0.18);
  --accent:       #5B4DE8;
  --on-accent:    #FFFFFF;
  --accent-2:     #E0457F;
  --up:           #16935C;
  --down:         #D6405A;
  --sq-a:         #E6E1F2;
  --sq-b:         #FFFFFF;
  --orb-a:        rgba(106, 92, 240, 0.10);
  --orb-b:        rgba(244, 93, 154, 0.08);

  /* code window + terminal stay dark in both themes */
  --win-bg:       #111218;
  --win-bar:      #171820;
  --win-text:     #D9D8E2;
  --win-dim:      #8A899B;
  --win-border:   rgba(255, 255, 255, 0.08);
  --win-accent:   #8EDDB8;

  --font-sans:    'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius:       18px;
  --ease:         cubic-bezier(.2, .7, .2, 1);
  --header-h:     61px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0E0F14;
    --bg-rgb:       14, 15, 20;
    --bg-2:         #121319;
    --surface:      #16171F;
    --surface-2:    #1C1D26;
    --text:         #ECEAE4;
    --text-muted:   #9C9BAD;
    --text-dim:     #858496;
    --border:       rgba(255, 255, 255, 0.07);
    --border-strong:rgba(255, 255, 255, 0.14);
    --accent:       #9A8FFF;
    --on-accent:    #0E0F14;
    --accent-2:     #F07AA8;
    --up:           #5FCF98;
    --down:         #F0677F;
    --sq-a:         #232433;
    --sq-b:         #16171F;
    --orb-a:        rgba(143, 132, 255, 0.13);
    --orb-b:        rgba(244, 93, 154, 0.09);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:           #0E0F14;
  --bg-rgb:       14, 15, 20;
  --bg-2:         #121319;
  --surface:      #16171F;
  --surface-2:    #1C1D26;
  --text:         #ECEAE4;
  --text-muted:   #9C9BAD;
  --text-dim:     #858496;
  --border:       rgba(255, 255, 255, 0.07);
  --border-strong:rgba(255, 255, 255, 0.14);
  --accent:       #9A8FFF;
  --on-accent:    #0E0F14;
  --accent-2:     #F07AA8;
  --up:           #5FCF98;
  --down:         #F0677F;
  --sq-a:         #232433;
  --sq-b:         #16171F;
  --orb-a:        rgba(143, 132, 255, 0.13);
  --orb-b:        rgba(244, 93, 154, 0.09);
  color-scheme: dark;
}

/* ── reset / base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .3s;
}

a { color: var(--accent); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
button { font: inherit; color: inherit; }
img, svg, canvas { display: block; max-width: 100%; }
kbd {
  font-family: var(--font-mono);
  font-size: .72rem;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
}
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }

.mono { font-family: var(--font-mono); }
.wrap { max-width: 1180px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 40px); }

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
}
.skip:focus { top: 12px; }

/* ── background fx ───────────────────────────────────── */
/* two soft, static colour washes — same idea as the original site */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(640px circle at 10% 6%,  var(--orb-a), transparent 60%),
    radial-gradient(600px circle at 90% 22%, var(--orb-b), transparent 60%);
}

/* ── header ──────────────────────────────────────────── */
.top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(var(--bg-rgb), .72);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
          backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

/* nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6A5CF0, #F45D9A);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  transition: transform .3s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-8deg); }
@keyframes blink { 50% { opacity: 0; } }

.nav-right { display: flex; align-items: center; gap: 18px; }
.nav-links { list-style: none; display: flex; gap: 6px; }
.nav-links a {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: .86rem;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.lang-opt {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 5px 11px;
  transition: background .18s, color .18s;
}
.lang-opt[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.switch {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .2s;
}
.switch:hover { border-color: var(--accent); }
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(20px);
  transition: transform .25s var(--ease);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .switch-knob { transform: translateX(0); }
}
:root[data-theme="dark"] .switch-knob { transform: translateX(0); }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: .8;
}

/* ── buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px;
  border-radius: 12px;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s, background .25s, border-color .25s, color .25s;
  will-change: transform;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -12px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn-ghost {
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.btn-ghost .mono { color: var(--accent); font-weight: 700; }

/* ── hero ────────────────────────────────────────────── */
.hero { padding-block: clamp(48px, 8vw, 96px) 0; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}

.hero-headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: -.03em;
  text-wrap: balance;
  max-width: 21ch;
  margin-bottom: 22px;
  color: var(--text);
}

.hero-id {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin-bottom: 18px;
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -.01em;
}
.hero-role {
  font-family: var(--font-mono);
  font-size: .88rem;
  color: var(--text-muted);
  text-wrap: balance;
}
.role-ps { color: var(--accent); }
.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.hero-bio {
  font-size: 1.06rem;
  color: var(--text-muted);
  max-width: 58ch;
  line-height: 1.7;
  margin-bottom: 30px;
}
.hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; }

.hero-side { min-width: 0; }

/* shared window chrome */
.win-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding-inline: 14px;
  background: var(--win-bar);
  border-bottom: 1px solid var(--win-border);
}
.win-bar > i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #FF5F57;
}
.win-bar > i:nth-child(2) { background: #FEBC2E; }
.win-bar > i:nth-child(3) { background: #28C840; }
.win-title {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--win-dim);
  margin-left: 10px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.code-win {
  background: var(--win-bg);
  border: 1px solid var(--win-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 50px -36px rgba(10, 8, 30, .5);
}
.code-body {
  margin: 0;
  padding: 14px 14px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--win-text);
  overflow-x: auto;
  scrollbar-width: thin;
}
.code-body .ln {
  display: inline-block;
  width: 2ch;
  margin-right: 12px;
  text-align: right;
  color: #4A5262;
  user-select: none;
}
.t-k { color: #C792EA; }
.t-v { color: #F2F5F9; }
.t-p { color: #82AAFF; }
.t-s { color: #C3E88D; }
.t-n { color: #F78C6C; }
.t-f { color: #FFCB6B; }
.t-o { color: #89DDFF; }
.t-c { color: #5E6878; font-style: italic; }
/* ── section scaffolding ─────────────────────────────── */
.sec { padding-top: clamp(64px, 9vw, 104px); }
.sec-tight { padding-top: clamp(48px, 6vw, 72px); }
.sec-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 24px;
}
.sec-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  letter-spacing: -.03em;
  line-height: 1.1;
}
.sec-rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); align-self: center; }
.sec-note { font-family: var(--font-mono); font-size: .8rem; color: var(--text-muted); }

/* ── product cards ───────────────────────────────────── */
/* the promo cover is the card's main image; the text column sits beside it */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.card {
  --c: var(--accent);
  display: grid;
  grid-template-columns: clamp(120px, 38%, 210px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 18, 30, .04);
  transition: border-color .2s;
}
.card:hover { border-color: var(--border-strong); }

.card-main { display: flex; flex-direction: column; min-width: 0; padding: 8px 8px 6px 0; align-self: stretch; }
.card-cat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card-cat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 10px 0 10px;
}
.card-name a { color: var(--text); }
.card-name a:hover { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.card-desc { font-size: .92rem; color: var(--text-muted); line-height: 1.65; }
.card-tag { font-style: italic; font-size: .88rem; color: var(--text-muted); margin-top: 12px; }

/* opening the product: a plain outlined button, distinct from the play cover */
.card-open {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.2;
  transition: border-color .2s, background .2s;
}
.card-main > :nth-last-child(2) { margin-bottom: 18px; }
.card-open:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); }

.card-video {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  border: 0;
  position: relative;
  display: block;
  cursor: pointer;
  padding: 0;
  background: color-mix(in srgb, var(--c) 30%, #06060a);
}
.video-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
.video-poster {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, .72), rgba(0, 0, 0, 0) 34%);
  transition: background .2s;
}
/* play + label sit together at the bottom, so the cover itself stays readable */
.video-cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  color: #14141d;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .2s;
}
.card-video:hover .video-cta { transform: scale(1.04); }
.play {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #14141d;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .62rem;
  padding-left: 2px;
}

.card-next {
  grid-template-columns: minmax(0, 1fr);
  padding: 22px;
  border-style: dashed;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  box-shadow: none;
}
.card-next .card-main { padding: 0; }
.next-code { font-family: var(--font-mono); font-size: .86rem; color: var(--text-muted); }

/* home: link to the full portfolio + quiet list of the other pages */
.more-link { margin-top: 22px; }
.more-link a {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-weight: 600;
  color: var(--accent);
}
.more-link a:hover > span:first-child { text-decoration: underline; text-underline-offset: 4px; }
.more-sub { font-weight: 400; font-size: .9rem; color: var(--text-muted); }

.links { list-style: none; border-top: 1px solid var(--border); }
.links li { border-bottom: 1px solid var(--border); }
.links a {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr) auto;
  gap: 4px 20px;
  align-items: baseline;
  padding: 16px 4px;
  color: var(--text);
}
.links-path { font-family: var(--font-mono); font-weight: 700; font-size: .86rem; color: var(--accent); }
.links-desc { color: var(--text-muted); font-size: .94rem; line-height: 1.6; }
.links-go { color: var(--text-dim); transition: transform .2s, color .2s; }
.links a:hover .links-go { color: var(--accent); transform: translateX(3px); }
.links a:hover .links-path { text-decoration: underline; text-underline-offset: 4px; }

/* ── stack ───────────────────────────────────────────── */
.stack-list { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  font-size: .92rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color .2s;
}
.pill:hover { border-color: var(--border-strong); }
.pill i { width: 8px; height: 8px; border-radius: 2px; background: var(--p); }
.pill i.mono-dot { background: var(--text); }

/* ── lab ─────────────────────────────────────────────── */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.lab-tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  min-width: 0;
}
.lab-tile.wide { grid-column: 1 / -1; }
.lab-head { display: flex; justify-content: space-between; align-items: center; }
.lab-tag {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 4px 11px;
  border-radius: 999px;
}
.lab-title { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; letter-spacing: -.02em; line-height: 1.2; }
.lab-desc { color: var(--text-muted); font-size: .92rem; line-height: 1.65; max-width: 720px; }

.lab-canvas {
  width: 100%;
  height: 300px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.lab-canvas-tall { height: 340px; }
#knight-canvas { cursor: pointer; height: 380px; }
.lab-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.ctl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--text-muted);
}
.ctl input[type="range"] { width: 150px; accent-color: var(--accent); cursor: pointer; }
.ctl output { min-width: 4ch; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.lab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.lab-btn:hover { border-color: var(--accent); color: var(--accent); }
.lab-btn:disabled { opacity: .5; cursor: progress; }
.lab-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.lab-readout {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  min-height: 1.5em;
}
.lab-readout b { color: var(--text); font-weight: 700; }
.lab-readout .ok { color: var(--up); }
.lab-readout .bad { color: var(--down); }
.lab-formula {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ── terminal ────────────────────────────────────────── */
.term-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.term-chip {
  font-family: var(--font-mono);
  font-size: .76rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .2s, color .2s, transform .2s;
}
.term-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.term-chip.hot { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.term {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--win-border);
  background: var(--win-bg);
  box-shadow: 0 30px 70px -40px rgba(10, 8, 30, .55);
}
.term-body {
  height: 440px;
  overflow-y: auto;
  padding: 16px 18px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--win-text);
  cursor: text;
  scrollbar-width: thin;
  scrollbar-color: #2A313C transparent;
}
.tl { white-space: pre-wrap; word-break: break-word; }
.tl a { color: var(--win-accent); text-decoration: underline; text-underline-offset: 3px; }
.tl.dim, .tl .dim { color: var(--win-dim); }
.tl.err { color: #F0677F; }
.tl .g { color: var(--win-accent); }
.tl .v { color: #A99FFF; }
.tl .y { color: #EBC878; }
.tl .r { color: #F0677F; }
.tl .c { color: #93B4F5; }
.tl .w { color: #F2F1F6; font-weight: 700; }
.tl table { border-collapse: collapse; }
.tl td { padding: 0 18px 0 0; }
.t-ps { color: var(--win-accent); margin-right: 10px; white-space: nowrap; }
.term-line { display: flex; align-items: baseline; }
#term-in {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #F2F1F6;
  font: inherit;
  caret-color: var(--win-accent);
}
.nf { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: flex-start; }
.nf-art { color: var(--win-accent); line-height: 1.2; margin: 0; font: inherit; }
.nf-swatch { display: inline-block; width: 22px; height: 12px; margin-right: 4px; border-radius: 2px; vertical-align: middle; }

/* ── about ───────────────────────────────────────────── */
.about-grid { max-width: 720px; }
.about-copy { display: flex; flex-direction: column; gap: 18px; }
.about-text { font-size: 1.06rem; line-height: 1.8; }
.interests { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.interests li {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .88rem;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.interests b { color: var(--accent); font-family: var(--font-mono); }
.about-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-top: 12px; }
.socials { display: flex; gap: 10px; flex-wrap: wrap; }
.social {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.social:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.social svg { width: 18px; height: 18px; fill: currentColor; }

/* a small, light aside — a joke, not a dashboard */
.charsheet {
  max-width: 340px;
  margin-top: 6px;
  padding: 14px 16px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-family: var(--font-mono);
}
.cs-title { font-size: .72rem; color: var(--text-dim); margin-bottom: 10px; }
.cs-body { display: flex; flex-direction: column; gap: 7px; }
.cs-row { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 3.4em; gap: 10px; align-items: center; font-size: .74rem; }
.cs-row > span { color: var(--text-muted); }
.cs-row b { text-align: right; color: var(--text); font-weight: 600; }
.cs-row b em { font-style: normal; color: var(--up); }
.bar { height: 4px; border-radius: 99px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; }
.bar i {
  display: block;
  height: 100%;
  width: calc(var(--v) * 1%);
  border-radius: inherit;
  background: var(--accent);
}
.cs-row.low .bar i { background: var(--down); }
.cs-note { font-size: .68rem; color: var(--text-dim); margin-top: 4px; }

/* ── footer ──────────────────────────────────────────── */
.footer {
  margin-top: clamp(72px, 10vw, 120px);
  padding-top: 34px;
  padding-bottom: 44px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.foot-top, .foot-bottom, .foot-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
}
.foot-clock { font-family: var(--font-mono); font-size: .78rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 10px; }
.foot-clock b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.foot-clock span { color: var(--text-dim); }
.footer-sig { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; letter-spacing: -.02em; }
.footer-links { list-style: none; display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { font-size: .86rem; color: var(--text-muted); transition: color .2s; }
.footer-links a:hover { color: var(--accent); }
.foot-meta { font-family: var(--font-mono); font-size: .7rem; color: var(--text-dim); }

/* ── lightbox ────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 8, .86); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.lb-content { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lb-frame {
  /* height drives the 9:16 box; capped so the width never exceeds the viewport */
  height: min(80vh, 640px, calc((100vw - 40px) * 16 / 9));
  aspect-ratio: 9 / 16;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .08);
}
.lb-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.lb-yt { color: #fff; font-family: var(--font-mono); font-size: .8rem; font-weight: 700; }
.lb-close {
  position: absolute;
  top: -46px;
  right: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-close:hover { background: rgba(255, 255, 255, .18); }

/* ── matrix + toast ──────────────────────────────────── */
.matrix { position: fixed; inset: 0; z-index: 130; width: 100%; height: 100%; opacity: 0; transition: opacity .5s; cursor: pointer; }
.matrix.on { opacity: 1; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 140;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--win-bg);
  color: #F2F1F6;
  border: 1px solid var(--win-border);
  font-family: var(--font-mono);
  font-size: .84rem;
  font-weight: 700;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .6);
  transition: opacity .3s, transform .3s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── reveal ──────────────────────────────────────────── */
html.js .rv {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--d, 0ms);
}
html.js .rv.in { opacity: 1; transform: none; }

/* ── sub pages ───────────────────────────────────────── */
.page-head { padding-top: clamp(44px, 7vw, 84px); }
.crumb {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.crumb a { color: var(--accent); }
.crumb a:hover { text-decoration: underline; text-underline-offset: 3px; }
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.02;
  letter-spacing: -.04em;
  margin-bottom: 16px;
}
.page-lead { color: var(--text-muted); font-size: 1.06rem; line-height: 1.75; max-width: 640px; }
.page-body { padding-top: clamp(32px, 5vw, 52px); }
.sec-sub { padding-top: clamp(56px, 8vw, 88px); }
.sec-title-sm { font-size: clamp(1.4rem, 2.6vw, 1.8rem); }

/* ── lab extras ──────────────────────────────────────── */
.lab-hint { font-family: var(--font-mono); font-size: .7rem; color: var(--text-dim); }
.ctl-check { cursor: pointer; user-select: none; }
.ctl-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
#ulam-canvas { height: 340px; cursor: crosshair; }
#bs-canvas { height: 300px; cursor: crosshair; }
#queens-canvas { height: 380px; }

/* local video in the lightbox */
.lb-frame video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.lb-frame video[hidden], .lb-frame iframe[hidden], .lb-yt[hidden] { display: none; }

/* ── responsive ──────────────────────────────────────── */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  /* the config window is a desktop detail; on smaller screens the products come first */
  .hero-side { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  /* pages move to a bottom tab bar. The header's backdrop-filter would make it the
     containing block for position:fixed children, so it goes opaque instead. */
  .top { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(var(--bg-rgb), .95); }
  .nav-links {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    justify-content: space-around;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(var(--bg-rgb), .9);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid var(--border);
  }
  .nav-links li { flex: 1; display: flex; }
  .nav-links a { flex: 1; justify-content: center; padding: 10px 4px; font-size: .82rem; font-weight: 500; }
  .nav-links a[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .lab-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  :root { --header-h: 55px; }
  .nav { height: 54px; gap: 10px; }
  .nav-right { gap: 10px; }
  .hero { padding-top: 36px; }
  .hero-bio { font-size: 1rem; }
  /* stacked card: the cover leads, cropped to 4:5 so it doesn't swallow the screen */
  .card { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 12px; }
  .card-video { aspect-ratio: 4 / 5; }
  .card-main { padding: 0 6px 6px; }
  .links a { grid-template-columns: minmax(0, 1fr) auto; }
  .links-desc { grid-column: 1; }
  .links-go { grid-row: 1; grid-column: 2; }
  .lab-tile { padding: 16px; }
  .lab-canvas { height: 260px; }
  .lab-canvas-tall { height: 280px; }
  #knight-canvas { height: 320px; }
  .ctl input[type="range"] { width: 110px; }
  .term-body { height: 380px; font-size: 12px; padding: 14px; }
  /* close button sits above the video instead of over the player's own controls */
  .lb-content { align-items: stretch; gap: 10px; }
  .lb-close { position: static; align-self: flex-end; }
  .lb-frame { height: min(calc(100svh - 150px), 640px, calc((100vw - 40px) * 16 / 9)); align-self: center; }
  .lb-yt { align-self: center; }
  .foot-meta { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 370px) {
  .brand { gap: 8px; font-size: .94rem; }
  .brand-mark { width: 26px; height: 26px; }
  .lang-opt { padding: 5px 8px; }
  .switch { width: 42px; }
  .switch-knob { transform: translateX(16px); }
}

/* ── reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  html.js .rv { opacity: 1; transform: none; }
}
