/**
 * InsytAI — Shared Design System
 * Single source of truth for tokens, base, nav, footer, utilities.
 * All pages link this file. Page-specific styles go in each page's own <style> block.
 */

/* ── TOKENS ────────────────────────────────────────────────────────────────── */
:root {
  /* Colours */
  --obsidian:  #0A1518;
  --obsidian2: #0F1D22;
  --obsidian3: #152528;
  --teal:      #00897B;
  --teal2:     #00BFA5;
  --teal3:     #005449;
  --paper:     #EEE8DC;
  --paper2:    #D9D2C5;
  --dim:       rgba(238,232,220,0.75);
  --muted:     rgba(238,232,220,0.48);
  --ghost:     rgba(238,232,220,0.12);
  --rule:      rgba(0,137,123,0.15);
  --rule2:     rgba(0,137,123,0.30);
  --danger:    #E05555;
  --success:   #22C55E;
  --gold:      #C9920A;

  /* Typography */
  --fh: 'Playfair Display', Georgia, serif;
  --fm: 'IBM Plex Mono', 'Courier New', monospace;
  --fb: 'IBM Plex Sans', system-ui, sans-serif;

  /* Layout — safe padding: never less than 16px */
  --nav-h: 58px;
  --max-w: 1400px;
  --pad-x: max(16px, 4vw);
}

/* ── SKIP LINK ─────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 99999;
  padding: 8px 16px;
  background: var(--teal);
  color: var(--obsidian);
  font-family: var(--fm);
  font-size: 0.8rem;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
}

/* SEO crawl list (blog index SSR) */
.seo-post-list {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── RESET ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); }
img, video { max-width: 100%; display: block; }
button { cursor: pointer; }
a { overflow-wrap: anywhere; }

/* ── BASE ───────────────────────────────────────────────────────────────────── */
body {
  background: var(--obsidian);
  color: var(--paper);
  font-family: var(--fb);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

::selection { background: rgba(0,191,165,0.28); color: var(--paper); }

:focus-visible {
  outline: 2px solid var(--teal2);
  outline-offset: 3px;
}

/* ── SCROLLBAR ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: var(--obsidian); }
::-webkit-scrollbar-thumb { background: var(--teal); border-radius: 0; }

/* ── NOISE TEXTURE (shared atmospheric layer) ──────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 9990;
  pointer-events: none; opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ── SHARED NAV ─────────────────────────────────────────────────────────────── */
#site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--nav-h); padding: 0 var(--pad-x);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(5,12,14,0.90);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--rule);
  transition: border-color 0.3s;
}
#site-nav.lit { border-bottom-color: var(--rule2); }

.nav-logo {
  font-family: var(--fm); font-size: 0.92rem; font-weight: 600;
  letter-spacing: 4px; text-decoration: none; color: var(--paper);
}
.nav-logo span { color: var(--teal2); }

.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a {
  font-family: var(--fm); font-size: 0.66rem; font-weight: 500;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--muted); text-decoration: none; transition: color 0.2s;
  white-space: nowrap;
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute; left: 0; right: 2px; bottom: -8px;
  height: 1px; background: var(--teal2);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.22s ease;
}
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.nav-links a:hover, .nav-links a.active { color: var(--teal2); }

.nav-cta {
  font-family: var(--fm); font-size: 0.64rem; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 7px 16px; border: 1px solid var(--teal); color: var(--teal);
  text-decoration: none; transition: all 0.2s;
  min-height: 34px; display: inline-flex; align-items: center; justify-content: center;
}
.nav-cta:hover { background: var(--teal); color: var(--obsidian); }

.nav-hamburger {
  display: none; flex-direction: column; gap: 5px; cursor: pointer;
  align-items: center; justify-content: center;
  width: 42px; height: 42px; margin-right: -10px;
  border: 0; background: transparent;
}
.nav-hamburger span { width: 22px; height: 1.5px; background: var(--paper); display: block; transition: all 0.3s; }

/* ── SHARED FOOTER ──────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--rule);
  background: rgba(0,0,0,0.5);
  padding: 2.5rem var(--pad-x);
}
.foot {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1.5rem;
}
.foot-logo { font-family: var(--fm); font-size: 0.82rem; font-weight: 600; letter-spacing: 4px; color: var(--paper); }
.foot-logo span { color: var(--teal2); }
.foot-copy { font-family: var(--fm); font-size: 0.58rem; letter-spacing: 1px; color: var(--muted); }
.foot-links { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.foot-links a {
  font-family: var(--fm); font-size: 0.58rem; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--muted); text-decoration: none; transition: color 0.2s;
  white-space: nowrap;
}
.foot-links a:hover { color: var(--teal2); }

/* ── SHARED UTILITY CLASSES ─────────────────────────────────────────────────── */
/* Eyebrow label */
.eyebrow {
  font-family: var(--fm); font-size: 0.65rem; font-weight: 600;
  letter-spacing: 5px; text-transform: uppercase; color: var(--teal2);
  display: flex; align-items: center; gap: 12px; margin-bottom: 1rem;
}
.eyebrow::before { content: ''; width: 28px; height: 1px; background: var(--teal); }

/* Section title */
.stitle {
  font-family: var(--fh);
  font-size: clamp(2.2rem, 4.5vw, 4rem);
  font-weight: 900; line-height: 0.97; letter-spacing: -1px;
  color: var(--paper); margin-bottom: 1.25rem;
}
.stitle em { font-style: italic; color: var(--teal2); }

/* Body text */
.sbody { font-size: 1rem; line-height: 1.85; color: var(--dim); max-width: 560px; }

/* Buttons */
.btn-p {
  font-family: var(--fm); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase;
  padding: 12px 26px; background: var(--teal); color: var(--obsidian);
  border: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; transition: background 0.2s, transform 0.2s;
}
.btn-p:hover { background: var(--teal2); transform: translateY(-1px); }

.btn-g {
  font-family: var(--fm); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase;
  padding: 12px 26px; background: transparent; color: var(--paper);
  border: 1px solid var(--ghost); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; transition: border-color 0.2s, color 0.2s;
}
.btn-g:hover { border-color: var(--teal); color: var(--teal2); }

/* Section padding */
.pad { padding: 110px var(--pad-x); }
.inner { max-width: var(--max-w); margin: 0 auto; }

/* Rule divider */
.s-rule { border-top: 1px solid var(--rule); }

/* Scroll margin for all anchor targets */
[id] { scroll-margin-top: calc(var(--nav-h) + 8px); }

/* Reveal animations */
.rv   { opacity: 0; transform: translateY(32px); transition: opacity 0.9s ease, transform 0.9s ease; }
.rv-l { opacity: 0; transform: translateX(-32px); transition: opacity 0.9s ease, transform 0.9s ease; }
.rv-r { opacity: 0; transform: translateX(32px);  transition: opacity 0.9s ease, transform 0.9s ease; }
.rv.in, .rv-l.in, .rv-r.in { opacity: 1; transform: translate(0); }

/* Entry animation (loader sequence) */
.entry { opacity: 0; transform: translateY(18px); }
.entry.in { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.7s ease; }

/* ── SHARED CARD COMPONENT ──────────────────────────────────────────────────── */
.card-base {
  background: var(--obsidian2);
  border: 1px solid var(--rule);
  padding: 2rem;
  transition: background 0.3s, border-color 0.3s;
}
.card-base:hover { background: rgba(0,137,123,0.05); border-color: var(--rule2); }

/* Grid gap system */
.grid-flush { display: grid; gap: 2px; background: var(--rule); border: 1px solid var(--rule); }
.grid-flush > * { background: var(--obsidian); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.filter-select {
  width: 100%;
  min-height: 44px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--teal2) 50%) calc(100% - 18px) 18px/6px 6px no-repeat,
    linear-gradient(135deg, var(--teal2) 50%, transparent 50%) calc(100% - 12px) 18px/6px 6px no-repeat,
    rgba(0,137,123,0.06);
  border: 1px solid var(--rule2);
  color: var(--paper);
  font-family: var(--fm);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  padding: 12px 38px 12px 14px;
  outline: none;
}
.filter-select:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(0,137,123,0.18); }
.filter-select option { background: #0F1D22; color: var(--paper); }

/* ── RESPONSIVE SHARED ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #site-nav { height: var(--nav-h); }
  .nav-links, .nav-cta { display: none !important; }
  .nav-hamburger { display: flex !important; }
  .pad { padding: 80px var(--pad-x); }
  /* Mobile menu drop-down (breakpoint matches nav hide) */
  #nav-links-list.open {
    display: flex !important;
    position: absolute;
    top: var(--nav-h); left: 0; right: 0;
    flex-direction: column;
    background: rgba(10,21,24,0.98);
    border-bottom: 1px solid rgba(0,137,123,0.2);
    padding: 1rem 5vw 1.5rem;
    gap: 0;
    backdrop-filter: blur(20px);
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  }
  #nav-links-list.open li { border-bottom: 1px solid rgba(0,137,123,0.08); }
  #nav-links-list.open a {
    display: block;
    padding: 14px 0;
    font-size: 0.82rem;
    line-height: 1.25;
  }
}
@media (max-width: 600px) {
  :root { --pad-x: max(16px, 5vw); }
  .nav-logo { font-size: 0.84rem; letter-spacing: 3px; }
  .pad { padding: 60px var(--pad-x); }
  .inner { overflow-x: hidden; }
  /* Prevent any child from bleeding past the viewport */
  .inner > * { max-width: 100%; }
  .btn-p, .btn-g, .nav-cta { max-width: 100%; text-align: center; white-space: normal; }
  .foot { align-items: flex-start; flex-direction: column; }
  .foot-links { gap: 0.9rem 1.2rem; }
}
