/* ============================================================
   Verilith — design system primitives
   Colour is expressed entirely through tokens so that the whole
   product (marketing + IDE) stays in one monochromatic system.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; }
img, video, svg { max-width: 100%; height: auto; }

/* ---------- tokens: light (warm white) ---------- */
:root {
  --bg:            #f4f4f2;
  --bg-2:          #ececea;
  --elev:          #ffffff;
  --glass:         rgba(255, 255, 255, 0.72);
  --glass-strong:  rgba(255, 255, 255, 0.88);
  --surface:       rgba(18, 20, 22, 0.025);
  --surface-2:     rgba(18, 20, 22, 0.05);
  --surface-3:     rgba(18, 20, 22, 0.08);
  --border:        rgba(18, 20, 22, 0.10);
  --border-2:      rgba(18, 20, 22, 0.18);
  --text:          #15181b;
  --text-2:        #565c62;
  --text-3:        #858b91;
  --scrim-1:       rgba(244, 244, 242, 0.62);
  --scrim-2:       rgba(244, 244, 242, 0.94);
  --shadow-1:      0 1px 2px rgba(16, 18, 20, 0.06);
  --shadow-2:      0 20px 44px -28px rgba(16, 18, 20, 0.35);
  --shadow-3:      0 28px 60px -30px rgba(16, 18, 20, 0.40);
  --success:       #16a34a;   /* green-600: vivid on light surfaces */
  --scroll-thumb:  rgba(18, 20, 22, 0.20);
  --scroll-thumb-hover: rgba(18, 20, 22, 0.34);
  color-scheme: light;
}

/* ---------- tokens: dark (near black / graphite) ---------- */
.dark {
  --bg:            #07080a;
  --bg-2:          #0a0b0d;
  --elev:          #101315;
  --glass:         rgba(20, 23, 26, 0.62);
  --glass-strong:  rgba(16, 19, 21, 0.86);
  --surface:       rgba(255, 255, 255, 0.035);
  --surface-2:     rgba(255, 255, 255, 0.062);
  --surface-3:     rgba(255, 255, 255, 0.095);
  --border:        rgba(255, 255, 255, 0.085);
  --border-2:      rgba(255, 255, 255, 0.16);
  --text:          #e8ebed;
  --text-2:        #a0a7ad;
  --text-3:        #6c7378;
  --scrim-1:       rgba(7, 8, 10, 0.55);
  --scrim-2:       rgba(7, 8, 10, 0.94);
  --shadow-1:      0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2:      0 20px 44px -26px rgba(0, 0, 0, 0.85);
  --shadow-3:      0 30px 70px -32px rgba(0, 0, 0, 0.9);
  --success:       #4ade80;   /* green-400: unmistakable pass state */
  --scroll-thumb:  rgba(148, 156, 163, 0.22);
  --scroll-thumb-hover: rgba(170, 178, 185, 0.42);
  color-scheme: dark;         /* native controls + scrollbars never render light */
}

/* ---------- status + code tokens (shared, deliberately muted) ---------- */
:root, .dark {
  --sage:   #86a683;
  --amber:  #c3a065;
  --brick:  #b3766d;
  --info:   #7e929f;

  /* The editor and console stay dark in both themes — an EDA
     convention, and it keeps syntax contrast predictable. */
  --code-bg:        #0a0c0e;
  --code-bg-2:      #0d1013;
  --code-border:    rgba(255, 255, 255, 0.07);
  --code-text:      #d7dbde;
  --code-gutter:    #565d63;
  --code-gutter-on: #9aa1a7;
  --code-active:    rgba(255, 255, 255, 0.035);
  --code-kw:        #9fb2c4;
  --code-type:      #a7b8a4;
  --code-num:       #c3a065;
  --code-dir:       #9a93b5;
  --code-com:       #5e666c;
  --code-punct:     #8b9298;

  --ease:     cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-io:  cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  transition: background-color 400ms var(--ease), color 400ms var(--ease);
}

.font-mono, code, pre, .mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-feature-settings: "zero" 1;
}

/* ---------- surfaces ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  backdrop-filter: blur(16px) saturate(130%);
  border: 1px solid var(--border);
}
.glass-strong {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--border);
}
.panel {
  background: var(--elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.hairline { background: var(--border); }

.lift {
  transition: transform 260ms var(--ease), border-color 260ms var(--ease),
              background-color 260ms var(--ease), box-shadow 260ms var(--ease);
  will-change: transform;
}
.lift:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow-2); }

.press { transition: transform 150ms var(--ease), background-color 200ms var(--ease), border-color 200ms var(--ease), opacity 200ms var(--ease); }
.press:active { transform: translateY(1px) scale(0.995); }

/* ---------- scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  filter: blur(6px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease), filter 700ms var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; filter: none; }

/* ---------- nav indicator ---------- */
.nav-link { position: relative; transition: color 240ms var(--ease), opacity 240ms var(--ease); }
.nav-link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: center;
  transition: transform 300ms var(--ease), opacity 300ms var(--ease); opacity: 0.5;
}
.nav-link:hover::after { transform: scaleX(0.6); }
.nav-link[data-active="true"]::after { transform: scaleX(1); opacity: 1; }

/* ---------- collapsible ---------- */
.disclosure { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 380ms var(--ease); }
.disclosure > * { overflow: hidden; min-height: 0; }
.disclosure[data-open="true"] { grid-template-rows: 1fr; }

/* ---------- glassmorphic scrollbars (global) ----------
   Transparent track, translucent graphite thumb that only firms up on hover.
   Applies to every scroll container, including the page itself. */
/* Firefox only: Chromium ignores ::-webkit-scrollbar whenever scrollbar-color is set. */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
  *:hover { scrollbar-color: var(--scroll-thumb-hover) transparent; }
}
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track,
::-webkit-scrollbar-track-piece,
::-webkit-scrollbar-corner { background: transparent; border: 0; box-shadow: none; }
::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb);
  border-radius: 999px;
  border: 2.5px solid transparent;          /* inset look: thumb floats inside the gutter */
  background-clip: padding-box;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background-color 200ms var(--ease);
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
::-webkit-scrollbar-thumb:active { background-color: var(--scroll-thumb-hover); border-width: 2px; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
html, body { scrollbar-gutter: auto; }

/* ---------- editor ---------- */
.code-scroll { overflow: auto; }

.code-row { transition: background-color 220ms var(--ease), box-shadow 220ms var(--ease); }
.code-row:hover { background: var(--code-active); }
.code-row[data-current="true"] { background: var(--code-active); box-shadow: inset 2px 0 0 var(--border-2); }
.code-row[data-flag="warn"] { box-shadow: inset 2px 0 0 var(--amber); background: rgba(195, 160, 101, 0.07); }
.code-row[data-flag="error"] { box-shadow: inset 2px 0 0 var(--brick); background: rgba(179, 118, 109, 0.09); }

.caret { display: inline-block; width: 7px; height: 1em; background: var(--code-gutter-on); vertical-align: -2px; animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- pipeline ---------- */
.stage-dot { transition: background-color 400ms var(--ease), box-shadow 400ms var(--ease), transform 400ms var(--ease); }
.stage-track { position: relative; overflow: hidden; }
.stage-track > i { position: absolute; inset: 0; transform-origin: left center; transition: transform 600ms var(--ease); }
@keyframes pulse-soft { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.pulse-soft { animation: pulse-soft 1.8s var(--ease-io) infinite; }

/* ---------- waveform ---------- */
.wf-grid {
  background-image: repeating-linear-gradient(to right, var(--code-border) 0 1px, transparent 1px var(--wf-tick, 60px));
}
.wf-scroll { overflow-x: auto; overflow-y: hidden; }
.wf-scroll::-webkit-scrollbar { height: 8px; }
.no-scrollbar { -ms-overflow-style: none; }
@supports not selector(::-webkit-scrollbar) { .no-scrollbar { scrollbar-width: none; } }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- elastic zoom slider (waveform) ---------- */
.zoom-range {
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
  height: 18px; width: 100%; margin: 0; --fill: 0%;
}
.zoom-range:focus { outline: none; }
.zoom-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--text-2) 0 var(--fill), var(--surface-3) var(--fill) 100%);
  box-shadow: inset 0 0 0 1px var(--border);
}
.zoom-range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border); }
.zoom-range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--text-2); }
.zoom-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -5px;
  height: 14px; width: 14px; border-radius: 999px; background: var(--text);
  border: 2px solid var(--bg-2); box-shadow: 0 0 0 1px var(--border-2), 0 2px 6px rgba(0,0,0,0.45);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.zoom-range::-moz-range-thumb {
  height: 12px; width: 12px; border-radius: 999px; background: var(--text);
  border: 2px solid var(--bg-2); box-shadow: 0 0 0 1px var(--border-2);
}
.zoom-range:hover::-webkit-slider-thumb { transform: scale(1.12); }
.zoom-range:active::-webkit-slider-thumb { transform: scale(1.22); box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 16%, transparent), 0 2px 6px rgba(0,0,0,0.45); }
.zoom-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 25%, transparent); }

/* ---------- success flash (Generate .bit) ---------- */
@keyframes tick-pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); } }
.tick-pop { animation: tick-pop 420ms var(--ease) both; }
.btn-success {
  color: var(--success) !important;
  border-color: color-mix(in srgb, var(--success) 60%, transparent) !important;
  background: color-mix(in srgb, var(--success) 14%, transparent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 14%, transparent), 0 0 18px -4px color-mix(in srgb, var(--success) 70%, transparent);
}

/* ---------- file tab close ---------- */
.tab-close { opacity: 0.45; transition: opacity 160ms var(--ease), background-color 160ms var(--ease), color 160ms var(--ease); }
[role="tab"]:hover .tab-close, [role="tab"][aria-selected="true"] .tab-close, .tab-close:focus-visible { opacity: 1; }

/* ---------- resizable split panes ---------- */
.splitter { background: transparent; touch-action: none; }
.splitter-line {
  position: absolute; background: var(--border);
  transition: background-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.splitter-line-h { left: 0; right: 0; top: 3px; height: 1px; }
.splitter-line-v { top: 0; bottom: 0; left: 3px; width: 1px; }
.splitter:hover .splitter-line,
.splitter:focus-visible .splitter-line,
.splitter.is-dragging .splitter-line { background: var(--border-2); box-shadow: 0 0 0 1px var(--border); }
.splitter.is-dragging .splitter-line-h { height: 2px; }
.splitter.is-dragging .splitter-line-v { width: 2px; }

.splitter-grip {
  position: absolute; border-radius: 999px; background: var(--border-2);
  opacity: 0; transition: opacity 200ms var(--ease);
}
.splitter-grip-h { left: 50%; top: 1px; height: 5px; width: 34px; margin-left: -17px; }
.splitter-grip-v { top: 50%; left: 1px; width: 5px; height: 34px; margin-top: -17px; }
.splitter:hover .splitter-grip,
.splitter:focus-visible .splitter-grip,
.splitter.is-dragging .splitter-grip { opacity: 0.85; }

/* ---------- editable code surface ---------- */
.code-input {
  background: transparent; color: transparent; border: 0; outline: none; resize: none;
  caret-color: var(--code-text); overflow: hidden; white-space: pre; tab-size: 4;
  font: inherit; letter-spacing: inherit; padding: 0; margin: 0; display: block;
}
.code-input::selection { background: rgba(255, 255, 255, 0.14); }

/* ---------- lattice loader (build status) ---------- */
.lattice { position: relative; display: inline-grid; flex-shrink: 0; }
.lattice-cell {
  position: relative; border-radius: 28%;
  background: currentColor; opacity: 0.16; transform: scale(0.86);
  animation: lattice-cell 1.15s var(--ease-io) infinite;
}
.lattice-halo {
  position: absolute; inset: -40%; border-radius: 35%;
  background: currentColor; opacity: 0.1; filter: blur(5px);
  animation: lattice-halo 1.15s var(--ease-io) infinite;
  pointer-events: none;
}
@keyframes lattice-cell {
  0%, 100% { opacity: 0.16; transform: scale(0.86); }
  22%      { opacity: 1;    transform: scale(1); }
  55%      { opacity: 0.42; transform: scale(0.94); }
}
@keyframes lattice-halo {
  0%, 100% { opacity: 0.06; }
  50%      { opacity: 0.16; }
}

/* ---------- capability cards: matte, glowing border on hover ---------- */
.feature-card {
  background: var(--elev);
  transition: border-color 280ms var(--ease), box-shadow 280ms var(--ease);
}
.feature-card:hover {
  border-color: color-mix(in srgb, var(--sage) 48%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--sage) 22%, transparent),
    0 0 32px -8px color-mix(in srgb, var(--sage) 38%, transparent);
}
.feature-card .feature-icon { transition: border-color 280ms var(--ease); }
.feature-card:hover .feature-icon { border-color: color-mix(in srgb, var(--sage) 40%, transparent); }

/* ---------- premium auth ---------- */
.auth-field {
  border-color: var(--border);
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease), background-color 200ms var(--ease);
}
.auth-field:hover { border-color: var(--border-2); }
.auth-field.is-focused {
  border-color: color-mix(in srgb, var(--text) 45%, transparent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 9%, transparent);
}
.auth-field.is-error {
  border-color: color-mix(in srgb, var(--brick) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brick) 12%, transparent);
}
.auth-pane { animation: auth-pane-in 320ms var(--ease) both; }
@keyframes auth-pane-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- misc ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 0.75rem; }
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tnum { font-variant-numeric: tabular-nums; }
.drawer { transition: transform 420ms var(--ease), opacity 300ms var(--ease); }
.ring-anim circle { transition: stroke-dashoffset 900ms var(--ease); }
.icon-shift { transition: transform 260ms var(--ease); }
.group:hover .icon-shift { transform: translateX(2px); }

::selection { background: var(--surface-3); }
:focus-visible { outline: 1px solid var(--border-2); outline-offset: 2px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .lattice-cell { animation: none !important; opacity: 0.45; transform: none; }
  .lattice-cell:nth-child(2), .lattice-cell:nth-child(3), .lattice-cell:nth-child(5) { opacity: 1; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; filter: none !important; transition: none !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
