/* ============================================================
   ALIFY — base.css
   Reset, design tokens, shared primitives. Loaded on every page.
   ============================================================ */

/* ---------- 1 · Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

html.menu-open,
html.popup-open { overflow: hidden; }

/* ---------- ambient aurora (site-wide depth layer) ---------- */
.ambient {
  position: fixed; inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.ambient span { position: absolute; border-radius: 50%; will-change: transform; }
.ambient span:nth-child(1) {
  width: 58vw; height: 58vw; top: -20vw; right: -12vw;
  background: radial-gradient(circle, rgba(56, 65, 102, .55), transparent 65%);
  animation: amb1 26s ease-in-out infinite alternate;
}
.ambient span:nth-child(2) {
  width: 44vw; height: 44vw; bottom: -16vw; left: -12vw;
  background: radial-gradient(circle, rgba(11, 115, 95, .34), transparent 62%);
  animation: amb2 33s ease-in-out infinite alternate;
}
.ambient span:nth-child(3) {
  width: 30vw; height: 30vw; top: 34%; left: 55%;
  background: radial-gradient(circle, rgba(12, 220, 42, .13), transparent 62%);
  animation: amb3 21s ease-in-out infinite alternate;
}
@keyframes amb1 { to { transform: translate(-6vw, 8vw) scale(1.12); } }
@keyframes amb2 { to { transform: translate(8vw, -7vw) scale(1.09); } }
@keyframes amb3 { to { transform: translate(-8vw, -6vw) scale(.88); } }

body {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
ul[role="list"], ol[role="list"] { list-style: none; }
table { border-collapse: collapse; width: 100%; }
:target { scroll-margin-top: 100px; }

/* ---------- 2 · Design tokens ---------- */
:root {
  color-scheme: dark; /* dark native controls: scrollbars, dropdowns, autofill */

  /* palette (§2.1 of master plan) */
  --green:   #0CDC2A;
  --navy:    #384166;
  --navy-2:  #2B3252;
  --teal:    #0B735F;
  --teal-2:  #41A98F;   /* lighter teal for text/borders on dark */
  --sage:    #639D75;
  --sage-2:  #9CC4A6;   /* lighter sage for text on dark */
  --sand:    #E3DBA9;
  --white:   #FFFFFF;
  --black:   #000000;
  --ink:     #0D0D0D;
  --ink-2:   #111111;
  --off:     #F7F7F5;
  --off-2:   #FAFAF8;

  /* semantic */
  --bg:      var(--ink);
  --panel:   #14151D;
  --panel-2: #191B26;
  --text:    #ECECE4;
  --muted:   rgba(236, 236, 228, .62);
  --faint:   rgba(236, 236, 228, .38);
  --line:    rgba(236, 236, 228, .10);
  --line-2:  rgba(236, 236, 228, .20);

  /* type */
  --ff-display: 'Clash Display', 'Space Grotesk', system-ui, sans-serif;
  --ff-body:    'General Sans', 'Space Grotesk', system-ui, sans-serif;
  --ff-mono:    'Space Grotesk', ui-monospace, 'SF Mono', monospace;
  --ff-accent:  'Playfair Display', Georgia, serif;

  /* 8px space scale */
  --s1: .5rem; --s2: 1rem; --s3: 1.5rem; --s4: 2rem;
  --s5: 3rem; --s6: 4rem; --s8: 6rem; --s10: 8rem;

  --container: 1320px;
  --container-w: 1440px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section: clamp(4rem, 9vw, 7.5rem);
  --r: 3px;
  --header-h: 76px;

  /* z-index map */
  --z-grain: 940;
  --z-header: 1000;
  --z-menu: 1100;
  --z-modal: 1160;
  --z-chat: 1180;
  --z-cookie: 1200;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
}

/* ---------- 3 · Focus / selection / scrollbar ---------- */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 2px;
}

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

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: #2B2E3C; border-radius: 6px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: var(--navy); }

/* ---------- 4 · Accessibility helpers ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: .75rem; left: .75rem;
  z-index: 1300;
  background: var(--green);
  color: var(--ink);
  font-family: var(--ff-mono);
  font-size: .8rem; font-weight: 600; letter-spacing: .06em;
  padding: .75rem 1.25rem;
  border-radius: var(--r);
  text-decoration: none;
  transform: translateY(-300%);
  transition: transform .3s ease;
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---------- 5 · Grain overlay (§2.6 — one reusable layer) ---------- */
.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: .05;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* ---------- 6 · Layout primitives ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide { max-width: var(--container-w); }

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

/* every tinted section uses several palette colors, never flat B/W */
.section--navy {
  background:
    radial-gradient(110% 90% at 0% 0%, rgba(12, 220, 42, .07), transparent 55%),
    radial-gradient(90% 90% at 100% 100%, rgba(11, 115, 95, .16), transparent 60%),
    var(--navy);
}
.section--ink2 { background: linear-gradient(180deg, #111114, #0F1016); }
.section--panel { background: var(--panel); }
.section--sand {
  background: linear-gradient(160deg, #E9E1B8, var(--sand) 55%, #D8CF9C);
  color: #17170E;
}
.section--rule {
  border-top: 1px solid transparent;
  border-image: linear-gradient(90deg, rgba(12, 220, 42, .38), rgba(65, 169, 143, .22) 38%, rgba(236, 236, 228, .07) 78%) 1;
}

/* section header pattern — editorial kicker + oversized title */
.section__head { display: grid; gap: 1.5rem; margin-bottom: clamp(2.5rem, 6vw, 4.5rem); }
@media (min-width: 1024px) {
  .section__head { grid-template-columns: repeat(12, 1fr); align-items: end; gap: 1.5rem; }
  .section__head-main { grid-column: 1 / 9; }
  .section__head-side { grid-column: 9 / 13; justify-self: end; text-align: right; }
}
.section__head-main h2 { margin-top: 1.5rem; }
.section__head-side .muted { max-width: 32ch; }

/* ---------- 7 · Square media (§2.7) ---------- */
.square { aspect-ratio: 3 / 2; width: 100%; object-fit: cover; }  /* wide editorial media (3:2) */

.media-frame {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--panel);
  position: relative;
}
/* brand-tinted image treatment — unifies all imagery with the palette */
.media-frame::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(56, 65, 102, .14), transparent 38%, rgba(13, 13, 13, .3));
  pointer-events: none;
}
.media-frame img {
  filter: saturate(.93) contrast(1.05);
  transition: transform .8s cubic-bezier(.22, .61, .36, 1);
}
.media-frame:hover img { transform: scale(1.045); }

.media-caption {
  font-family: var(--ff-mono);
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
  margin-top: .85rem;
  display: flex; justify-content: space-between; gap: 1rem;
}

/* ---------- 8 · Shared patterns used across pages ---------- */

/* chips / tags */
.chip {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--ff-mono);
  font-size: .72rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase;
  padding: .5em 1em;
  border: 1px solid; border-radius: 99px;
  white-space: nowrap;
}
.chip--green { color: var(--green); border-color: rgba(12, 220, 42, .4); background: rgba(12, 220, 42, .07); }
.chip--teal  { color: var(--teal-2); border-color: rgba(65, 169, 143, .4); background: rgba(11, 115, 95, .16); }
.chip--sage  { color: var(--sage-2); border-color: rgba(99, 157, 117, .45); background: rgba(99, 157, 117, .12); }
.chip--sand  { color: var(--sand); border-color: rgba(227, 219, 169, .35); background: rgba(227, 219, 169, .08); }
.chip--ink   { color: #17170E; border-color: rgba(23, 23, 14, .5); background: rgba(23, 23, 14, .06); }
.tags { display: flex; flex-wrap: wrap; gap: .5rem; }

/* editorial index number */
.idx {
  font-family: var(--ff-mono);
  font-size: .75rem; letter-spacing: .12em;
  color: var(--teal-2);
}

/* process steps — broken/offset grid */
.process { display: grid; gap: 2.25rem; }
@media (min-width: 1024px) {
  .process { grid-template-columns: repeat(4, 1fr); gap: 1.75rem; }
  .process__step:nth-child(2) { margin-top: 3rem; }
  .process__step:nth-child(3) { margin-top: 6rem; }
  .process__step:nth-child(4) { margin-top: 9rem; }
}
.process__step { border-top: 2px solid var(--teal); padding-top: 1.5rem; }
.process__num {
  font-family: var(--ff-display);
  font-size: clamp(2.75rem, 4.5vw, 3.5rem);
  font-weight: 600; line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(236, 236, 228, .4);
  display: block; margin-bottom: 1.25rem;
}
.process__title { margin-bottom: .75rem; }
.process__text { color: var(--muted); font-size: .95rem; line-height: 1.65; }

/* stats band */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border-block: 1px solid var(--line);
}
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--bg); padding: clamp(1.75rem, 3.5vw, 3rem); }
.section--navy .stat, .section--ink2 .stat { background: transparent; }
.stat__num {
  font-family: var(--ff-display);
  font-size: clamp(2.6rem, 4.5vw, 3.75rem);
  font-weight: 600; line-height: 1; color: var(--off);
  display: block;
}
.stat__num sup { font-size: .45em; color: var(--green); font-weight: 600; margin-left: .1em; }
.stat__label {
  display: block; margin-top: 1rem;
  font-family: var(--ff-mono); font-size: .75rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

/* giant outline watermark */
.wm {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: clamp(5rem, 19vw, 17rem);
  line-height: .82;
  letter-spacing: .02em;
  text-align: center;
  color: transparent;
  -webkit-text-stroke: 1px rgba(236, 236, 228, .09);
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
}

.w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .12em; margin-bottom: -.12em; }
.wi { display: inline-block; will-change: transform; }

.u-hr { border: 0; border-top: 1px solid var(--line); }
.on-dark-deco { color: var(--sand); font-family: var(--ff-accent); font-style: italic; }

/* breadcrumb trail (used on every inner page) */
.crumbs {
  list-style: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  padding: 0; margin: 0 0 2rem;
  font-family: var(--ff-mono); font-size: .74rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
}
.crumbs li { display: inline-flex; align-items: center; }
.crumbs a { color: var(--muted); text-decoration: none; transition: color .3s; }
.crumbs a:hover { color: var(--green); }
.crumbs .sep { color: var(--teal-2); }

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

/* ---------- soft image fade-in on load (JS adds .is-loaded) ---------- */
img { opacity: 0; transition: opacity .9s ease, transform .8s cubic-bezier(.22, .61, .36, 1); }
img.is-loaded { opacity: 1; }

/* ---------- cursor-following spotlight halo on key cards ---------- */
@media (hover: hover) and (pointer: fine) {
  .price-card, .t-card, .value-card, .sv-card, .aside-card,
  .related-card, .form-panel, .cs-metric, .cap { position: relative; }
  .price-card::before, .t-card::before, .value-card::before, .sv-card::before,
  .aside-card::before, .related-card::before, .form-panel::before,
  .cs-metric::before, .cap::before {
    content: "";
    position: absolute; inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: radial-gradient(240px circle at var(--mx, -600px) var(--my, -600px), rgba(12, 220, 42, .08), transparent 65%);
    pointer-events: none;
  }
  /* keep card content above the halo */
  .price-card > *, .t-card > *, .value-card > *, .sv-card > *, .aside-card > *,
  .related-card > *, .form-panel > *, .cs-metric > *, .cap > * { position: relative; z-index: 1; }
}

/* ---------- dual cursor: green dot + trailing ring (fine pointers only) ---------- */
.cursor-dot, .cursor-ring { display: none; }
@media (hover: hover) and (pointer: fine) {
  .cursor-dot {
    display: block;
    position: fixed; top: 0; left: 0;
    z-index: 1400;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    pointer-events: none;
    transition: opacity .3s;
  }
  .cursor-ring {
    display: block;
    position: fixed; top: 0; left: 0;
    z-index: 1399;
    width: 34px; height: 34px;
    border: 1px solid rgba(236, 236, 228, .35);
    border-radius: 50%;
    pointer-events: none;
    transition: width .3s, height .3s, border-color .3s, opacity .3s;
  }
  .cursor-ring.is-active { width: 54px; height: 54px; border-color: var(--green); }
  .cursor-hidden { opacity: 0; }
}

/* needs to override cursor transitions on opacity only */
.cursor-dot, .cursor-ring { transition-property: opacity, width, height, border-color; }
