/* Shared components: preloader, navbar, section dots, cursor, buttons, chips,
   badges, cards, spotlight, toasts. Overlays (drawer, palette, terminal,
   lightbox, video player) are at the end. */

/* ---------- preloader: first visit only, at most ~1.2 s ---------- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: var(--z-preloader);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--bg);
  transition: transform 0.7s var(--ease-in-out), opacity 0.7s var(--ease-in-out);
  /* safety net: gone after 3 s even if the script never runs */
  animation: preloader-bail 0.4s linear 3s forwards;
}
.seen .preloader, .preloader.is-done { transform: translateY(-100%); pointer-events: none; }
.seen .preloader { display: none; }
@keyframes preloader-bail { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.preloader__name { font-family: var(--display); font-weight: 650; font-size: var(--step-3); letter-spacing: 0.02em; }
.preloader__count { color: var(--accent); font-size: var(--step--1); letter-spacing: 0.2em; }

/* ---------- navbar: a floating glass pill ---------- */
.nav {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: var(--z-nav);
  width: min(calc(100% - 2 * var(--gutter)), 1100px);
  transform: translateX(-50%);
}
.nav__bar {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(18, 18, 18, 0.62);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 10px 40px -18px rgba(0, 0, 0, 0.8);
}
.nav__logo { display: flex; align-items: center; gap: 10px; min-width: 0; font-family: var(--display); font-weight: 700; }
.nav__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 13px;
  letter-spacing: -0.02em;
}
/* the hero name docks here as you scroll */
.nav__name { font-size: 15px; letter-spacing: 0.04em; white-space: nowrap; opacity: 0; transform: translateY(6px); transition: opacity var(--base) var(--ease-out), transform var(--base) var(--ease-out); }
.is-docked .nav__name { opacity: 1; transform: none; }
.nav__links { display: flex; gap: 2px; margin-left: auto; }
.nav__links a {
  position: relative;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 550;
  line-height: 18px;
  transition: color var(--fast), background var(--fast);
}
.nav__links a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav__links a[aria-current="true"] { color: var(--text); }
.nav__links a[aria-current="true"]::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}
.nav__cmd {
  flex: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  transition: color var(--fast), border-color var(--fast);
}
.nav__cmd:hover { color: var(--text); border-color: var(--accent); }
.nav__progress { position: absolute; left: 22px; right: 22px; bottom: -1px; height: 2px; overflow: hidden; border-radius: 2px; }
.nav__progress span { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* side section dots, desktop only */
.dots {
  position: fixed;
  right: 18px;
  top: 50%;
  z-index: var(--z-nav);
  display: grid;
  gap: 6px;
  transform: translateY(-50%);
}
.dots a { position: relative; display: grid; place-items: center; width: 22px; height: 22px; }
.dots a::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); transition: background var(--fast), transform var(--base) var(--ease-spring); }
.dots a:hover::before { background: var(--muted); }
.dots a[aria-current="true"]::before { background: var(--accent); transform: scale(1.6); }
.dots span {
  position: absolute;
  right: 28px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(6px);
  pointer-events: none;
  transition: opacity var(--fast), transform var(--fast);
}
.dots a:hover span, .dots a:focus-visible span { opacity: 1; transform: none; }
@media (max-width: 1100px) { .dots { display: none; } }
@media (max-width: 860px) { .nav__links { display: none; } .nav__cmd { margin-left: auto; } }

/* ---------- the custom cursor ---------- */
.has-cursor, .has-cursor * { cursor: none !important; }
.has-cursor input, .has-cursor textarea { cursor: text !important; }
.cursor { position: fixed; inset: 0; z-index: var(--z-cursor); pointer-events: none; opacity: 0; transition: opacity var(--base); }
.cursor.is-shown { opacity: 1; }
.cursor__dot, .cursor__ring { position: fixed; left: 0; top: 0; will-change: transform; }
.cursor__dot { width: 0; height: 0; }
.cursor__dot::before { content: ''; position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); transition: transform var(--fast) var(--ease-out); }
.cursor__ring { width: 0; height: 0; }
.cursor__ring::before {
  content: '';
  position: absolute;
  left: -18px;
  top: -18px;
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(245, 245, 244, 0.55);
  border-radius: 999px;
  transition: all var(--base) var(--ease-spring);
}
.cursor__label {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  display: grid;
  place-items: center;
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--fast);
}
.cursor[data-state="link"] .cursor__ring::before { left: -28px; top: -28px; width: 56px; height: 56px; border-color: var(--accent); background: var(--accent-soft); }
.cursor[data-state="link"] .cursor__dot::before,
.cursor[data-state="view"] .cursor__dot::before,
.cursor[data-state="play"] .cursor__dot::before,
.cursor[data-state="pause"] .cursor__dot::before,
.cursor[data-state="drag"] .cursor__dot::before,
.cursor[data-state="copy"] .cursor__dot::before,
.cursor[data-state="text"] .cursor__dot::before { transform: scale(0); }
.cursor[data-state="view"] .cursor__ring::before,
.cursor[data-state="play"] .cursor__ring::before,
.cursor[data-state="pause"] .cursor__ring::before,
.cursor[data-state="copy"] .cursor__ring::before { left: -40px; top: -40px; width: 80px; height: 80px; border-color: var(--accent); background: var(--accent); }
.cursor[data-state="drag"] .cursor__ring::before { left: -40px; top: -40px; width: 80px; height: 80px; border-color: var(--info); background: var(--info); }
.cursor[data-state="view"] .cursor__label, .cursor[data-state="play"] .cursor__label, .cursor[data-state="pause"] .cursor__label,
.cursor[data-state="copy"] .cursor__label, .cursor[data-state="drag"] .cursor__label { opacity: 1; }
.cursor[data-state="drag"] .cursor__label { color: #fff; }
.cursor[data-state="drag"] .cursor__label::before { content: '← '; }
.cursor[data-state="drag"] .cursor__label::after { content: ' →'; }
.cursor[data-state="text"] .cursor__ring::before { left: -1.5px; top: -14px; width: 3px; height: 28px; border: 0; border-radius: 2px; background: var(--accent); }
.cursor[data-state="hide"] { opacity: 0; }
.cursor.is-down .cursor__ring::before { transform: scale(0.82); }
/* over the hero name the ring inverts what's beneath it */
.cursor.is-blend .cursor__ring { mix-blend-mode: difference; }
.cursor.is-blend .cursor__ring::before { left: -44px; top: -44px; width: 88px; height: 88px; border: 0; background: #fff; }
.cursor__ripple {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}
.cursor__ripple::before {
  content: '';
  position: absolute;
  left: -20px;
  top: -20px;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  animation: ripple 0.55s var(--ease-out) forwards;
}
@keyframes ripple { from { transform: scale(0.4); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform var(--base) var(--ease-out), border-color var(--fast), background var(--fast), color var(--fast);
}
.btn:hover { border-color: var(--text); }
.btn--primary { border-color: var(--accent); background: var(--accent); color: var(--bg); }
.btn--primary:hover { border-color: #FF8640; background: #FF8640; }
.btn--small { height: 36px; padding: 0 14px; font-size: var(--step--2); }
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.is-magnet { transition: transform 0.15s linear, border-color var(--fast), background var(--fast), color var(--fast); }

/* ---------- chips, badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 550;
  transition: color var(--fast), border-color var(--fast), background var(--fast);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--text); border-color: var(--text); }
.chip__n { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.badge--strong { color: var(--accent); } .badge--strong::before { background: var(--accent); }
.badge--comfortable { color: var(--muted); } .badge--comfortable::before { background: var(--muted); }
.badge--learning { color: #8DB6F9; } .badge--learning::before { background: var(--info); }

/* ---------- cards, spotlight, tilt ---------- */
.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  isolation: isolate;
}
/* a soft light follows the pointer (--mx / --my are set by spotlight.js) */
.spot::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, -999px) var(--my, -999px), rgba(255, 106, 19, 0.11), transparent 60%);
  opacity: 0;
  transition: opacity var(--slow);
}
.spot::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(300px circle at var(--mx, -999px) var(--my, -999px), rgba(255, 106, 19, 0.7), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--slow);
}
.spot:hover::before, .spot:hover::after, .spot:focus-within::before { opacity: 1; }
.tilt { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.5s var(--ease-out); will-change: transform; }
.tilt.is-tilting { transition: transform 0.08s linear; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; z-index: var(--z-toast); display: grid; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.9);
  font-size: var(--step--1);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: opacity var(--base) var(--ease-out), transform var(--base) var(--ease-spring);
}
.toast.is-in { opacity: 1; transform: none; }
.toast__icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--bg); font-size: 12px; font-weight: 800; }

/* ---------- the case-study drawer ---------- */
.is-locked { overflow: hidden; }
.drawer { position: fixed; inset: 0; z-index: var(--z-drawer); }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.4s var(--ease-out); }
.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(880px, 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(22px, 4vw, 52px);
  border-left: 1px solid var(--border);
  background: var(--bg);
  outline: none;
  transform: translateX(100%);
  transition: transform 0.45s var(--ease-out);
}
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__close { float: right; }
.drawer__close kbd { color: var(--muted); font-size: 11px; }
.drawer__title { font-family: var(--display); font-size: var(--step-5); font-weight: 650; letter-spacing: -0.04em; line-height: 0.92; }
.drawer__tagline { margin-top: 14px; max-width: 54ch; color: var(--muted); font-size: var(--step-1); }
.drawer__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px 24px; margin-top: 26px; padding: 18px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.drawer__facts dt, .drawer__metrics dt { color: var(--muted); font-size: 11px; }
.drawer__facts dd { margin: 4px 0 0; font-size: var(--step--1); }
.drawer__role, .drawer__team { grid-column: 1 / -1; }
.drawer__media { margin-top: 28px; }
.drawer__illo { position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: radial-gradient(70% 70% at 50% 45%, rgba(255, 106, 19, 0.14), transparent 70%), var(--surface); }
.drawer__cover { position: absolute; inset: 0; width: 100%; height: 100%; }
.drawer__illo .mono { position: absolute; left: 14px; bottom: 12px; color: var(--muted); font-size: 11px; }
.drawer__metrics { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 22px; }
.drawer__metrics > div { flex: 1 1 160px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.drawer__metrics dd { margin: 6px 0 0; font-family: var(--display); font-size: var(--step-3); font-weight: 600; color: var(--accent); }
.drawer__metrics small { color: var(--muted); font-size: 12px; }
.cs { display: grid; gap: 28px; margin-top: 36px; }
.cs__h { margin-bottom: 10px; color: var(--accent); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.cs p, .cs__list { max-width: 68ch; color: #D4D4D2; }
.cs__list { display: grid; gap: 10px; padding-left: 1.3em; }
ul.cs__list { list-style: '→  '; }
ol.cs__list { list-style: decimal-leading-zero; }
.cs__list li::marker { color: var(--accent); font-family: var(--mono); font-size: 0.85em; }
.drawer__tech { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 32px; }
.drawer__links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.drawer__nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--border); }
.drawer__nav a { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; font-weight: 600; transition: border-color var(--fast); }
.drawer__nav a:last-child { text-align: right; }
.drawer__nav a:hover { border-color: var(--accent); }
.drawer__nav .mono { font-size: 11px; font-weight: 400; }
.code { margin-top: 28px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #0E0E0E; }
.code figcaption { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.code pre { margin: 0; padding: 18px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; }

/* ---------- video player ---------- */
.vplayer { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #000; }
.vplayer video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.vplayer__bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); }
.vplayer__btn { min-width: 32px; height: 32px; border-radius: 8px; font-size: 13px; }
.vplayer__btn:hover { background: rgba(255, 255, 255, 0.1); }
.vplayer__seek { flex: 1; accent-color: var(--accent); }
.vplayer__time { font-size: 11px; color: var(--muted); }

/* ---------- carousel + lightbox ---------- */
.carousel { margin-top: 16px; }
.carousel__track { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.carousel__item { flex: 0 0 72%; scroll-snap-align: start; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.carousel__item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.carousel__nav { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.lightbox { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: 5vw; background: rgba(0, 0, 0, 0.92); }
.lightbox__fig { display: grid; gap: 10px; max-width: 100%; max-height: 100%; }
.lightbox__fig img { max-height: 80vh; border-radius: 12px; }
.lightbox__close { position: absolute; top: 20px; right: 20px; }
.lightbox__prev, .lightbox__next { position: absolute; top: 50%; }
.lightbox__prev { left: 20px; } .lightbox__next { right: 20px; }

/* ---------- command palette ---------- */
.palette { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; justify-items: center; align-items: start; padding: 14vh 16px 16px; background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.palette__box { width: min(620px, 100%); border: 1px solid var(--border-strong); border-radius: 18px; background: rgba(22, 22, 22, 0.96); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9); overflow: hidden; animation: pop var(--base) var(--ease-spring); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(0.97); } }
.palette__search { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.palette__search > span { color: var(--accent); }
.palette__search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: var(--step-1); }
.palette__search kbd { color: var(--muted); font-size: 11px; }
.palette__list { max-height: min(52vh, 440px); overflow-y: auto; padding: 8px; }
.palette__group { padding: 10px 10px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.palette__item { display: flex; justify-content: space-between; gap: 16px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.palette__item .mono { font-size: 12px; }
.palette__item[aria-selected="true"] { background: var(--accent-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.palette__empty { padding: 16px; }

/* ---------- terminal ---------- */
.term { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.55); }
.term__win { width: min(760px, 100%); height: min(480px, 80vh); display: flex; flex-direction: column; border: 1px solid var(--border-strong); border-radius: 14px; background: #0C0C0C; box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9); overflow: hidden; animation: pop var(--base) var(--ease-spring); }
.term__bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #141414; font-size: 12px; color: var(--muted); }
.term__bar i { width: 11px; height: 11px; border-radius: 50%; background: #3A3A3A; }
.term__bar i:first-child { background: var(--accent); }
.term__bar span { margin: 0 auto; }
.term__x { color: var(--muted); font-size: 11px; }
.term__body { flex: 1; overflow-y: auto; padding: 16px 18px; font-size: 13px; line-height: 1.65; }
.term__out > div { white-space: pre-wrap; }
.term__out { color: #D4D4D2; }
.term__echo { margin-top: 8px; color: var(--text); }
.term__line { display: flex; gap: 8px; align-items: baseline; margin-top: 8px; }
.term__line input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: inherit; caret-color: var(--accent); }
.t-user { color: var(--accent); }
.t-host { color: #8DB6F9; }
