/* ============================================================
   SPARQIO — design tokens + base
   Dark mode is primary. Tokens switch on :root[data-theme].
   Gold is an accent, never body text on light backgrounds.
   ============================================================ */

/* ---------- Fonts (self-hosted, variable) ---------- */
@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/space-grotesk.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --gold: #d0ab0a;
  --gold-soft: rgba(208, 171, 10, 0.14);
  --gold-line: rgba(208, 171, 10, 0.35);
  --ink: #231f20;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --container: 1200px;
  --container-wide: 1360px;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme='dark'] {
  --bg: #1a1718;
  --bg-elev: #231f20;
  --panel: #231f20;
  --panel-border: rgba(188, 190, 192, 0.14);
  --text: #f1eee8;
  --heading: #ffffff;
  --muted: #bcbec0;
  --accent-text: #d0ab0a;      /* gold may carry small text on dark */
  --glow: rgba(208, 171, 10, 0.20);
  --grain-opacity: 0.05;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* Day mode: "Cobalt Engraving Editorial" re-skin (11-09-26). Cream paper
   ground, one cobalt ink. The shared accent tokens (--gold, --ink, ...)
   are re-pointed here so every component that reads them turns cobalt
   without touching the dark rules. Previous day mode: repo tag
   pre-daymode-reskin-20260911 / backups/day-mode-2026-09-11. */
:root[data-theme='light'] {
  --bg: #F6F1E4;
  --bg-elev: #F3EBDD;
  --panel: #F3EBDD;
  --panel-border: rgba(30, 74, 115, 0.22);
  --text: #163A5C;
  --heading: #0F2740;
  --muted: #2F5F8A;            /* 5.4:1 on the paper ground */
  --accent-text: #1E4A73;      /* labels, links, small accent text */
  --gold: #2F5F8A;             /* accent: rules, borders, glyphs, toggle */
  --gold-soft: rgba(47, 95, 138, 0.12);
  --gold-line: rgba(47, 95, 138, 0.40);
  --ink: #1A365D;              /* solid button fill */
  --glow: rgba(91, 127, 166, 0.22);
  --grain-opacity: 0.07;
  --shadow: 0 10px 30px rgba(22, 58, 92, 0.10);
  color-scheme: light;
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body.sq {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  margin: 0;
  overflow-x: hidden;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

/* film grain / dot grid texture over the canvas */
body.sq::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: radial-gradient(rgba(188, 190, 192, 0.55) 0.5px, transparent 0.5px);
  background-size: 26px 26px;
  opacity: var(--grain-opacity);
}

.sq h1, .sq h2, .sq h3, .sq h4 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  font-weight: 600;
  text-transform: capitalize; /* operator rule: headings title-cased */
}
.sq h1 { font-size: clamp(2.6rem, 6.5vw, 4.9rem); }
.sq h2 { font-size: clamp(2rem, 4.4vw, 3.3rem); }
.sq h3 { font-size: clamp(1.35rem, 2.4vw, 1.8rem); }
.sq p  { margin: 0 0 1.1em; }
.sq a  { color: inherit; }

.sq .gold { color: var(--accent-text); }
.sq .muted { color: var(--muted); }

/* mono labels — section numbers, tags, technical accents */
.sq-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-text);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

/* the io-node glyph — gold ring with dot centre, the recurring brand mark */
.io-node {
  width: 14px; height: 14px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  position: relative;
  display: inline-block;
  flex: none;
}
.io-node::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--gold);
  border-radius: 50%;
}

/* ---------- Layout ---------- */
.sq-container { max-width: var(--container); margin: 0 auto; padding: 0 clamp(20px, 4vw, 44px); position: relative; }
/* anchored sections (footer links to /services/#sos-desk etc.) clear the
   fixed header instead of landing underneath it */
.sq-section[id] { scroll-margin-top: 96px; }
.sq-container--wide { max-width: var(--container-wide); }
.sq-section { padding: clamp(70px, 10vw, 130px) 0; position: relative; z-index: 2; }

/* the page thread — thin gold line drawing down the page (desktop only:
   on stacked mobile layouts it would cut through content) */
.sq-thread {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(var(--gold-line), transparent);
  transform-origin: top;
  z-index: 0;
  pointer-events: none;
}
@media (max-width: 900px) { .sq-thread { display: none; } }

/* ---------- Buttons — gold-box lockup: solid gold fill, ink text ---------- */
.sq-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  text-transform: capitalize; /* operator rule: button words title-cased */
  padding: 0.95rem 1.9rem;
  border-radius: 10px;
  border: 2px solid var(--gold);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background-color 0.25s var(--ease), color 0.25s var(--ease);
  /* no will-change here: a promoted button layer inside the fixed header
     gets painted BEHIND the header's backdrop-blur layer in Safari after a
     scroll (operator: "button hiding behind after scrolling back up") */
}
/* compound selectors so button text beats the `.sq a` inherit rule.
   Standardized to the hero theme (operator, CC097.12): ink body, gold text,
   inverting to gold/ink on hover. --solid and --ink are now the same look. */
.sq-btn.sq-btn--solid { background: var(--ink); color: var(--gold); }
.sq-btn--solid:hover { background: var(--gold); color: var(--ink); box-shadow: 0 8px 30px var(--glow); transform: translateY(-2px); }
.sq-btn.sq-btn--ghost { background: transparent; color: var(--accent-text); }
.sq-btn--ghost:hover { background: var(--gold-soft); transform: translateY(-2px); }
/* ink variant: black button, gold text (hero primary CTA) */
.sq-btn.sq-btn--ink { background: var(--ink); color: var(--gold); }
.sq-btn--ink:hover { background: var(--gold); color: var(--ink); box-shadow: 0 8px 30px var(--glow); transform: translateY(-2px); }
.sq-btn:active { transform: translateY(0) scale(0.98); }
.sq-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* a button that follows body text gets clear air above it (operator rule);
   card buttons keep their own flex-driven placement via the more-specific rule */
.sq p + .sq-btn { margin-top: 1.1rem; }

/* gold ripple on press (driven by JS) */
.sq-btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  animation: sq-ripple 0.55s var(--ease) forwards;
  pointer-events: none;
}
@keyframes sq-ripple { to { transform: scale(3.4); opacity: 0; } }

/* ---------- Header ---------- */
.sq-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  transition: box-shadow 0.3s var(--ease), padding 0.3s var(--ease);
  padding: 20px 0;
}
/* Scrolled backdrop lives on a ::before layer BEHIND the nav content:
   backdrop-filter directly on the fixed header makes Safari glitch the
   children (the Start A Conversation button) while scrolling. */
.sq-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: transparent;
  transition: background-color 0.3s var(--ease);
  transform: translateZ(0); /* own layer, deterministically beneath the nav */
}
.sq-header.is-scrolled {
  box-shadow: 0 1px 0 var(--panel-border);
  padding: 10px 0;
}
.sq-header.is-scrolled::before {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.sq-header .sq-container { display: flex; align-items: center; gap: 2rem; z-index: 1; /* nav content explicitly above the ::before blur layer */ }
.sq-logo { display: flex; align-items: center; text-decoration: none; }
/* one logo size everywhere: header and footer match */
.sq-logo svg { height: 54px; width: auto; display: block; }
@media (max-width: 560px) { .sq-logo svg { height: 44px; } }
/* logo theming: .s0 = "sparq", .s1 = the gold "io" (never changes) */
:root[data-theme='dark'] .sq-logo svg .s0 { fill: #f1eee8; }
:root[data-theme='light'] .sq-logo svg .s0 { fill: #0F2740; }
/* day-mode component skin: navy solid buttons with cream text (the shared
   ink/gold pair reads poorly as blue-on-navy), cobalt ghost buttons, blue
   paper grain */
:root[data-theme='light'] .sq-btn.sq-btn--solid,
:root[data-theme='light'] .sq-btn.sq-btn--ink { background: #1A365D; color: #F6F1E4; border-color: #1A365D; }
:root[data-theme='light'] .sq-btn--solid:hover,
:root[data-theme='light'] .sq-btn--ink:hover { background: #2F5F8A; color: #F6F1E4; border-color: #2F5F8A; box-shadow: 0 8px 24px rgba(22, 58, 92, 0.18); }
:root[data-theme='light'] .sq-btn.sq-btn--ghost { color: #1E4A73; border-color: #2F5F8A; }
:root[data-theme='light'] .sq-btn--ghost:hover { background: rgba(47, 95, 138, 0.10); }
:root[data-theme='light'] body.sq::before { background-image: radial-gradient(rgba(30, 74, 115, 0.5) 0.5px, transparent 0.5px); }
.sq-logo svg .s1 { fill: var(--gold); }

.sq-nav { display: flex; align-items: center; gap: 1.7rem; margin-left: auto; }
.sq-nav a {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  position: relative;
  padding: 4px 0;
}
.sq-nav a:not(.sq-btn)::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 100%; height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}
.sq-nav a:not(.sq-btn):hover::after, .sq-nav a[aria-current='page']::after { transform: scaleX(1); }
.sq-nav .sq-btn { padding: 0.55rem 1.2rem; font-size: 0.9rem; }

/* theme toggle */
.sq-toggle {
  background: transparent;
  border: 1.5px solid var(--panel-border);
  border-radius: 999px;
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
  flex: none;
}
.sq-toggle:hover { border-color: var(--gold); transform: rotate(15deg); }
.sq-toggle svg { width: 18px; height: 18px; }
.sq-toggle .ico-sun { display: none; }
:root[data-theme='dark'] .sq-toggle .ico-sun { display: block; }
:root[data-theme='dark'] .sq-toggle .ico-moon { display: none; }

/* mobile nav */
.sq-burger {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  width: 42px; height: 42px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  margin-left: auto;
}
.sq-burger span { display: block; height: 2px; background: var(--heading); border-radius: 2px; transition: transform 0.3s var(--ease), opacity 0.3s var(--ease); }

@media (max-width: 900px) {
  .sq-burger { display: flex; margin-left: 0; position: relative; z-index: 56; }
  .sq-toggle { margin-left: auto; position: relative; z-index: 56; }
  .sq-nav {
    /* explicit viewport sizing: the header's backdrop-filter makes it the
       containing block for fixed children, so inset:0 would collapse the
       menu to a floating header-height strip */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: var(--bg);
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    transform: translateY(-102%);
    transition: transform 0.45s var(--ease);
    margin: 0;
    z-index: 55;
    overflow-y: auto;
  }
  .sq-nav a { font-size: 1.5rem; }
  body.nav-open .sq-nav { transform: translateY(0); }
  body.nav-open .sq-burger span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  body.nav-open .sq-burger span:nth-child(2) { opacity: 0; }
  body.nav-open .sq-burger span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
  body.nav-open { overflow: hidden; }
}

/* ---------- Footer ---------- */
.sq-footer {
  border-top: 1px solid var(--panel-border);
  padding: clamp(50px, 7vw, 80px) 0 40px;
  position: relative;
  z-index: 2;
}
.sq-footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2.5rem; margin-bottom: 3rem; }
.sq-footer h4 { font-size: 0.95rem; margin-bottom: 1rem; }
.sq-footer ul { list-style: none; margin: 0; padding: 0; }
.sq-footer li { margin-bottom: 0.55rem; }
.sq-footer a { text-decoration: none; color: var(--muted); font-size: 0.95rem; transition: color 0.2s; }
.sq-footer a:hover { color: var(--accent-text); }
.sq-footer-base {
  display: flex; flex-wrap: wrap; gap: 1rem;
  justify-content: space-between;
  border-top: 1px solid var(--panel-border);
  padding-top: 1.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}
@media (max-width: 800px) { .sq-footer-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Motion opt-in defaults ----------
   Content is visible by default; GSAP's fromTo hides and reveals it at
   runtime (immediateRender). No JS / reduced motion / any script failure
   ⇒ everything simply shows. Never hide content in CSS. */
.reduced-motion [data-anim] { opacity: 1 !important; transform: none !important; }

/* focus visibility everywhere */
/* keyboard focus ring for interactive elements only. Anchor jumps
   (footer links to /services/#sos-desk etc.) hand focus to the target
   <section>; a universal :focus-visible ring on it painted a full-width
   gold line at the section's top edge (operator report). */
.sq :is(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
/* tabindex="-1" is set at runtime by the parent theme's skip-link focus
   script on anchor targets; programmatic focus never needs a ring */
.sq [tabindex="-1"]:focus, .sq [tabindex="-1"]:focus-visible, .sq section:focus, .sq section:focus-visible { outline: none; }

/* footer social icons */
.sq-social { display: flex; gap: 1.1rem; margin-top: 1.2rem; }
.sq-social a {
  color: var(--muted);
  display: inline-flex;
  transition: color 0.25s var(--ease), transform 0.25s var(--ease);
}
.sq-social a:hover { color: var(--accent-text); transform: translateY(-2px); }
.sq-social svg { width: 20px; height: 20px; }

/* back-to-top: floating gold node, appears after scrolling */
.sq-totop {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), background-color 0.25s, color 0.25s;
}
.sq-totop.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sq-totop:hover { background: var(--gold); color: var(--ink); }
.sq-totop svg { width: 19px; height: 19px; }

/* skip link */
.sq-skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--gold); color: var(--ink);
  padding: 10px 18px; z-index: 100; border-radius: 0 0 8px 0;
  font-family: var(--font-display); font-weight: 600; text-decoration: none;
}
.sq-skip:focus { left: 0; }
