/* ==========================================================================
   SEBIV — GLOBAL SHELL + DESIGN TOKENS
   sebiv.css · loaded by every page, before that page's own <style> block.
   Page-level styles may override anything here. Nothing in this file is
   allowed to dictate the look of a section's content, only the frame
   around it: header, menu, sub-nav, footer, and shared primitives.
   ========================================================================== */

:root {
  /* Palette (legacy names kept so existing page CSS keeps working) */
  --bg: #131211;
  --bg2: #1c1b19;
  --bg3: #232220;
  --border: #2e2c29;
  --text: #f0ede8;
  --text-muted: #888580;
  --purple: #9B6FC6;
  --green: #77B777;
  --white: #f0ede8;

  /* sv- aliases: what the shell itself uses */
  --sv-bg: var(--bg);
  --sv-bg2: var(--bg2);
  --sv-bg3: var(--bg3);
  --sv-border: var(--border);
  --sv-text: var(--text);
  --sv-muted: var(--text-muted);
  --sv-accent: var(--purple);
  --sv-accent-dim: rgba(155, 111, 198, 0.4);
  --sv-accent-wash: rgba(155, 111, 198, 0.09);

  /* Type scale */
  --sv-font: Helvetica, Arial, sans-serif;
  --sv-meta: 11px;      /* eyebrows, labels, tiny metadata */
  --sv-small: 13px;
  --sv-body: 16px;
  --sv-lead: clamp(17px, 1.4vw, 19px);
  --sv-h3: clamp(20px, 2.4vw, 26px);
  --sv-h2: clamp(28px, 4vw, 44px);
  --sv-h1: clamp(38px, 7vw, 72px);
  --sv-display: clamp(48px, 11vw, 120px);
  --sv-track-wide: 0.25em;   /* uppercase metadata */
  --sv-track-tight: -0.02em; /* large headings */

  /* Space scale */
  --sv-1: 4px;  --sv-2: 8px;  --sv-3: 12px; --sv-4: 16px;
  --sv-5: 24px; --sv-6: 32px; --sv-7: 48px; --sv-8: 64px;
  --sv-9: 96px; --sv-10: 128px;

  /* Measure */
  --sv-gutter: clamp(20px, 5vw, 48px);
  --sv-w-page: 1100px;
  --sv-w-prose: 680px;

  /* Shell */
  --sv-header-h: 72px;
  --sv-safe-t: env(safe-area-inset-top, 0px);
  --sv-safe-b: env(safe-area-inset-bottom, 0px);
  --sv-safe-l: env(safe-area-inset-left, 0px);
  --sv-safe-r: env(safe-area-inset-right, 0px);

  /* Motion */
  --sv-t-fast: 140ms;
  --sv-t: 220ms;
  --sv-t-slow: 380ms;
  --sv-ease: cubic-bezier(0.2, 0.6, 0.2, 1);

  /* Layering. One place. Nothing else in the site may exceed these. */
  --sv-z-content: 1;
  --sv-z-sticky: 40;
  --sv-z-header: 300;
  --sv-z-scrim: 400;
  --sv-z-drawer: 500;
}

@media (max-width: 768px) {
  :root { --sv-header-h: 60px; }
}

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sv-font);
  /* Fixed header means every in-page anchor needs clearance. */
}

/* Anchor targets never land underneath the fixed header. */
:target,
[id] { scroll-margin-top: calc(var(--sv-header-h) + var(--sv-safe-t) + 16px); }

/* Keyboard users get a real focus ring everywhere. */
:focus-visible {
  outline: 2px solid var(--sv-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Page entry. Fast, once, never blocks reading. */
body.sv-enter > *:not(.sv-header):not(.sv-drawer):not(.sv-scrim) {
  animation: sv-fade-up var(--sv-t-slow) var(--sv-ease) both;
}
@keyframes sv-fade-up {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   GLOBAL HEADER — identical on every page, every breakpoint
   -------------------------------------------------------------------------- */

.sv-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--sv-z-header);
  height: calc(var(--sv-header-h) + var(--sv-safe-t));
  padding: var(--sv-safe-t) calc(var(--sv-gutter) + var(--sv-safe-r)) 0 calc(var(--sv-gutter) + var(--sv-safe-l));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sv-4);
  background: rgba(19, 18, 17, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--sv-border);
  transition: background var(--sv-t) var(--sv-ease), border-color var(--sv-t) var(--sv-ease);
}

/* Over a full-bleed hero the header floats until you scroll. */
.sv-header.is-top[data-transparent="true"] {
  background: linear-gradient(to bottom, rgba(10,9,8,0.55), rgba(10,9,8,0));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom-color: transparent;
}

.sv-header__home {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-right: var(--sv-3);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.sv-header__home img {
  height: 26px;
  width: auto;
  display: block;
  object-fit: contain;
  transition: opacity var(--sv-t-fast) var(--sv-ease);
}
.sv-header__home:hover img { opacity: 0.75; }

/* Menu button: 44x44 minimum target, same position on every page. */
.sv-menu-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  color: var(--sv-muted);
  -webkit-tap-highlight-color: transparent;
}
.sv-menu-btn img {
  height: 20px;
  width: auto;
  opacity: 0.7;
  transition: opacity var(--sv-t-fast) var(--sv-ease);
  pointer-events: none;
}
.sv-menu-btn:hover img,
.sv-menu-btn[aria-expanded="true"] img { opacity: 1; }
.sv-menu-btn:active img { opacity: 1; }

/* --------------------------------------------------------------------------
   DRAWER
   -------------------------------------------------------------------------- */

.sv-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--sv-z-scrim);
  background: rgba(8, 7, 6, 0.62);
  opacity: 0;
  visibility: hidden;               /* no invisible tap-eater when closed */
  pointer-events: none;
  transition: opacity var(--sv-t) var(--sv-ease), visibility 0s linear var(--sv-t);
}
.sv-scrim.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--sv-t) var(--sv-ease), visibility 0s;
}

.sv-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: var(--sv-z-drawer);
  width: min(340px, 86vw);
  height: 100%;
  height: 100dvh;                   /* Safari toolbar-safe */
  background: var(--sv-bg);
  border-left: 1px solid var(--sv-border);
  padding: calc(var(--sv-header-h) + var(--sv-safe-t) + var(--sv-5)) var(--sv-7)
           calc(var(--sv-7) + var(--sv-safe-b));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transform: translate3d(101%, 0, 0);
  visibility: hidden;
  transition: transform var(--sv-t) var(--sv-ease), visibility 0s linear var(--sv-t);
}
.sv-drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform var(--sv-t) var(--sv-ease), visibility 0s;
}

.sv-drawer__close {
  position: absolute;
  top: calc(var(--sv-safe-t) + 14px);
  right: var(--sv-5);
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--sv-muted);
  font-family: var(--sv-font);
  font-size: 18px;
  line-height: 1;
  transition: color var(--sv-t-fast) var(--sv-ease);
}
.sv-drawer__close:hover { color: var(--sv-accent); }

.sv-drawer__label {
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--sv-muted);
  margin-bottom: var(--sv-5);
}

.sv-drawer__nav ul { list-style: none; margin: 0; padding: 0; }
.sv-drawer__nav li { border-bottom: 1px solid rgba(46, 44, 41, 0.6); }
.sv-drawer__nav li:first-child { border-top: 1px solid rgba(46, 44, 41, 0.6); }

.sv-drawer__nav a {
  display: flex;
  align-items: center;
  gap: var(--sv-3);
  min-height: 52px;                 /* generous touch target */
  padding: var(--sv-3) 0;
  text-decoration: none;
  color: var(--sv-text);
  font-size: var(--sv-small);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: color var(--sv-t-fast) var(--sv-ease), padding-left var(--sv-t-fast) var(--sv-ease);
  -webkit-tap-highlight-color: transparent;
}
.sv-drawer__nav a:hover,
.sv-drawer__nav a:active { color: var(--sv-accent); padding-left: 6px; }

.sv-drawer__nav a[aria-current] {
  color: var(--sv-accent);
  padding-left: 12px;
  box-shadow: inset 2px 0 0 var(--sv-accent);
}

.sv-drawer__nav .sv-mark { flex-shrink: 0; opacity: 0.75; }

.sv-drawer__foot {
  margin-top: auto;
  padding-top: var(--sv-7);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sv-3) var(--sv-4);
}
.sv-drawer__foot a {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--sv-muted);
  text-decoration: none;
  transition: color var(--sv-t-fast) var(--sv-ease);
}
.sv-drawer__foot a:hover { color: var(--sv-accent); }

/* Scroll lock. Position is restored exactly by sebiv.js. */
body.sv-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   CONTEXTUAL SUB-NAV — lives UNDER the global header, never replaces it
   -------------------------------------------------------------------------- */

.sv-subnav {
  position: sticky;
  top: calc(var(--sv-header-h) + var(--sv-safe-t));
  margin-top: calc(var(--sv-header-h) + var(--sv-safe-t));
  z-index: var(--sv-z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sv-3);
  min-height: 46px;
  padding: 0 calc(var(--sv-gutter) + var(--sv-safe-r)) 0 calc(var(--sv-gutter) + var(--sv-safe-l));
  background: rgba(19, 18, 17, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--sv-border);
  font-size: var(--sv-meta);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--sv-muted);
  overflow: hidden;
}
.sv-subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--sv-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--sv-t-fast) var(--sv-ease);
}
.sv-subnav a:hover { color: var(--sv-accent); }
.sv-subnav__here {
  color: var(--sv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.sv-subnav__sep { opacity: 0.45; flex-shrink: 0; }

/* Pages with a sub-nav need extra clearance for anchors. */
.sv-has-subnav [id] { scroll-margin-top: calc(var(--sv-header-h) + var(--sv-safe-t) + 62px); }

/* --------------------------------------------------------------------------
   SHARED PRIMITIVES
   -------------------------------------------------------------------------- */

.sv-eyebrow {
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--sv-muted);
}

.sv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 var(--sv-7);
  background: var(--sv-text);
  color: var(--sv-bg);
  border: 0;
  font-family: var(--sv-font);
  font-size: var(--sv-meta);
  font-weight: 600;
  letter-spacing: var(--sv-track-wide);
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--sv-t-fast) var(--sv-ease), color var(--sv-t-fast) var(--sv-ease);
}
.sv-btn:hover { background: var(--sv-accent); color: var(--sv-text); }
.sv-btn[disabled] { opacity: 0.25; pointer-events: none; }

.sv-btn--ghost {
  background: none;
  color: var(--sv-text);
  border: 1px solid var(--sv-border);
}
.sv-btn--ghost:hover { border-color: var(--sv-accent); color: var(--sv-accent); background: none; }

/* Inline links inside prose read as links without shouting. */
.sv-link {
  color: var(--sv-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--sv-accent-dim);
  transition: border-color var(--sv-t-fast) var(--sv-ease);
}
.sv-link:hover { border-bottom-color: var(--sv-accent); }

/* External links get a consistent, quiet marker. */
a[target="_blank"]:not(.sv-no-mark)::after {
  content: "↗";
  font-size: 0.75em;
  margin-left: 0.35em;
  opacity: 0.6;
  vertical-align: super;
}

/* Section gate (18+, etc). Inline, dismissible, never a full-screen trap. */
.sv-gate {
  border: 1px solid var(--sv-border);
  border-left: 2px solid var(--sv-accent);
  background: var(--sv-bg2);
  padding: var(--sv-6);
}
.sv-gate__title {
  font-size: var(--sv-h3);
  font-weight: 300;
  color: var(--sv-text);
  margin-bottom: var(--sv-3);
}
.sv-gate__sub {
  font-size: var(--sv-small);
  color: var(--sv-muted);
  line-height: 1.8;
  margin-bottom: var(--sv-5);
  max-width: 46ch;
}
.sv-gate__check {
  display: flex;
  align-items: center;
  gap: var(--sv-3);
  margin-bottom: var(--sv-5);
  min-height: 44px;
  cursor: pointer;
  font-size: var(--sv-small);
  color: var(--sv-muted);
}
.sv-gate__check input { width: 18px; height: 18px; accent-color: var(--sv-accent); cursor: pointer; }

/* --------------------------------------------------------------------------
   GLOBAL FOOTER
   -------------------------------------------------------------------------- */

.sv-footer {
  background: #0a0908;
  border-top: 1px solid var(--sv-border);
  padding: var(--sv-8) calc(var(--sv-gutter) + var(--sv-safe-r))
           calc(var(--sv-7) + var(--sv-safe-b)) calc(var(--sv-gutter) + var(--sv-safe-l));
}
.sv-footer__inner {
  max-width: var(--sv-w-page);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sv-6);
}
.sv-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sv-2) var(--sv-5);
}
.sv-footer__links a {
  font-size: var(--sv-meta);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--sv-muted);
  text-decoration: none;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  transition: color var(--sv-t-fast) var(--sv-ease);
}
.sv-footer__links a:hover { color: var(--sv-accent); }
.sv-footer__copy {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--sv-muted);
  opacity: 0.8;
}

/* --------------------------------------------------------------------------
   MOTION PREFERENCES
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .sv-drawer { transition: none; }
}

/* --------------------------------------------------------------------------
   PRINT
   -------------------------------------------------------------------------- */

@media print {
  .sv-header, .sv-drawer, .sv-scrim, .sv-subnav { display: none !important; }
  body { padding-top: 0 !important; }
}
