/* ==========================================================================
   Ahmed Babay — Design System
   base.css : tokens, reset, typography, layout primitives
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Colour — dark is the default surface */
  --bg:            #08090c;
  --bg-2:          #0b0d12;
  --surface:       #111419;
  --surface-2:     #171b22;
  --surface-3:     #1d222b;

  --border:        rgba(255, 255, 255, 0.07);
  --border-2:      rgba(255, 255, 255, 0.12);
  --border-3:      rgba(255, 255, 255, 0.20);

  --text:          #eef1f6;
  --text-2:        #9aa4b4;
  --text-3:        #6b7486;

  --accent:        #5ef1c8;
  --accent-2:      #37d9ae;
  --accent-ink:    #04150f;
  --accent-soft:   rgba(94, 241, 200, 0.12);
  --accent-line:   rgba(94, 241, 200, 0.30);
  --accent-glow:   rgba(94, 241, 200, 0.22);

  --warm:          #ffb86b;
  --warm-soft:     rgba(255, 184, 107, 0.14);

  --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
  --shadow:     0 12px 32px -12px rgba(0,0,0,.65);
  --shadow-lg:  0 40px 80px -32px rgba(0,0,0,.8);

  /* Typography */
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-display: clamp(2.6rem, 7.2vw, 5.25rem);
  --fs-h1:      clamp(2.1rem, 4.6vw, 3.4rem);
  --fs-h2:      clamp(1.85rem, 3.4vw, 2.7rem);
  --fs-h3:      clamp(1.2rem, 1.9vw, 1.5rem);
  --fs-lede:    clamp(1.05rem, 1.5vw, 1.25rem);
  --fs-body:    1.0325rem;
  --fs-sm:      0.9125rem;
  --fs-xs:      0.8125rem;
  --fs-label:   0.7rem;

  /* Space — 4px base */
  --s-1: 0.25rem;  --s-2: 0.5rem;   --s-3: 0.75rem;  --s-4: 1rem;
  --s-5: 1.5rem;   --s-6: 2rem;     --s-7: 2.5rem;   --s-8: 3rem;
  --s-9: 4rem;     --s-10: 5.5rem;  --s-11: 7rem;    --s-12: 9rem;

  --section-y: clamp(4.5rem, 10vw, 8.5rem);
  --gutter:    clamp(1.25rem, 5vw, 3rem);
  --measure:   68ch;

  /* Shape + motion */
  --r-xs: 6px;  --r-sm: 10px; --r: 16px; --r-lg: 24px; --r-xl: 32px; --r-full: 999px;
  --ease:        cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur:         0.45s;
  --dur-fast:    0.22s;

  --nav-h: 68px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:          #f7f8fa;
  --bg-2:        #ffffff;
  --surface:     #ffffff;
  --surface-2:   #f2f4f7;
  --surface-3:   #e8ebf0;

  --border:      rgba(9, 12, 20, 0.09);
  --border-2:    rgba(9, 12, 20, 0.15);
  --border-3:    rgba(9, 12, 20, 0.26);

  --text:        #0d1017;
  --text-2:      #4c5566;
  --text-3:      #78808f;

  --accent:      #0d9488;
  --accent-2:    #0f766e;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(13, 148, 136, 0.10);
  --accent-line: rgba(13, 148, 136, 0.28);
  --accent-glow: rgba(13, 148, 136, 0.16);

  --warm:        #b45309;
  --warm-soft:   rgba(180, 83, 9, 0.10);

  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow:    0 12px 32px -14px rgba(16,24,40,.20);
  --shadow-lg: 0 40px 80px -36px rgba(16,24,40,.28);

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 1.5rem);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.65;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  overflow-x: hidden;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }

ul, ol { list-style: none; padding: 0; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border: 3px solid var(--bg);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: -0.025em; line-height: 1.25; }

p { text-wrap: pretty; }

.display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.lede {
  font-size: var(--fs-lede);
  line-height: 1.62;
  color: var(--text-2);
  max-width: 58ch;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
  opacity: 0.7;
}

.eyebrow.is-bare::before { display: none; }

.mono { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: -0.01em; }

.accent-text { color: var(--accent); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }

/* Inline link with an underline that thickens on hover */
.link {
  color: var(--text);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  padding-bottom: 1px;
  transition: background-size var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.link:hover { color: var(--accent); background-size: 100% 2px; }

/* --------------------------------------------------------------------------
   4. Layout primitives
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--wide { max-width: 1400px; }
.container--narrow { max-width: 820px; }

.section { padding-block: var(--section-y); position: relative; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-5);
  margin-bottom: var(--s-9);
}

.section-head__text { max-width: 46ch; }
.section-head .eyebrow { margin-bottom: var(--s-4); }
.section-head h2 { margin-bottom: var(--s-4); }
.section-head p { color: var(--text-2); max-width: 46ch; }

.rule { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Ambient wash — sits behind everything and follows the accent */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 12% -8%, var(--accent-glow), transparent 62%),
    radial-gradient(50rem 36rem at 92% 4%, rgba(139, 124, 246, 0.10), transparent 60%);
  opacity: 0.85;
  transition: opacity var(--dur) var(--ease);
}

:root[data-theme="light"] .ambient { opacity: 0.55; }

/* Fine grain so large flat areas do not band */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="light"] .grain { opacity: 0.05; }

#constellation {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   5. Scroll reveal
   -------------------------------------------------------------------------- */

/* Everything below is scoped to .js — set by an inline script in <head>.
   Without JavaScript the start states never apply, so the page renders as a
   complete document instead of a screen of invisible elements. */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}

.js [data-reveal].is-visible { opacity: 1; transform: none; }

/* Headline wipe — each line rises out of its own mask */
.reveal-lines span { display: block; overflow: hidden; }

/* <i> is a line wrapper here, not emphasis — it must never render italic.
   Unscoped, so this still holds when the .js animation styles are absent. */
.reveal-lines span > i { display: block; font-style: inherit; }

.js .reveal-lines span > i {
  transform: translateY(105%);
  transition: transform 0.95s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}

.js .reveal-lines.is-visible span > i { transform: none; }

/* --------------------------------------------------------------------------
   6. Accessibility
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: var(--s-3);
  left: var(--s-3);
  z-index: 1000;
  padding: var(--s-3) var(--s-5);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-sm);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease);
}

.skip-link:focus-visible { transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
  .js .reveal-lines span > i { transform: none; }
}
