/* ============================================================
   base.css — tokens, reset, typography, cursor, utilities
   Adam Yee — portfolio site
   ============================================================ */

/* ---------- Design tokens (frozen contract) ---------- */
:root {
  --bg: #0A1633;
  --bg-2: #0E1E42;
  --ink: #F2F5FF;
  --muted: #8FA3C8;
  --pop: #C6F53F; /* electric lime — the single accent */

  --font-display: 'Clash Display', 'Arial Black', sans-serif;
  --font-body: 'Satoshi', 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-mono: 'Sometype Mono', 'Courier New', monospace;
}

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

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

ul,
ol {
  list-style: none;
}

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

::selection {
  background: var(--pop);
  color: var(--bg);
}

/* ---------- Typography scale ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Oversized display utilities — up to ~10vw */
.display-xl {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3rem, 10vw, 12rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.display-lg {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 7vw, 8rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.display-md {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.text-muted { color: var(--muted); }
.text-pop   { color: var(--pop); }

/* ---------- Accent type: serif italic + mono labels ---------- */
/* Instrument Serif italic — the editorial counterpoint to Clash Display.
   Loaded via Google Fonts in index.html; degrades to a plain italic serif. */
.font-serif-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

/* Sometype Mono microcopy — eyebrows, pills, metadata. */
.mono-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.6875rem; /* 11px */
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Section eyebrow: hairline dash + mono label, sits above a headline.
   Usage: <div class="eyebrow"><span class="mono-label">[ 01 ✦ NAME ]</span></div>
   Wrap the ✦ in .text-pop for the lime accent. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: clamp(1rem, 2vh, 1.5rem);
  line-height: 1;
  text-shadow: none; /* eyebrows may nest inside heads carrying shadows */
}

.eyebrow::before {
  content: '';
  flex: none;
  width: 2rem;
  height: 1px;
  background: linear-gradient(to right, rgba(143, 163, 200, 0.6), rgba(143, 163, 200, 0.1));
}

/* ---------- SPECIMEN utilities ----------
   The whisper layer (igloo-grade): mono specimen labels, hairlines,
   data readouts, callout stubs, and the medium type scale that replaces
   oversized display type inside section content.
   Mark static mono labels with data-scramble — js/fx.js (window.SCRAMBLE)
   decode-scrambles them in when present; they render plain without it. */

/* Mono specimen label: codenames, HUD corners, status chrome. */
.spec-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.625rem; /* 10px */
  letter-spacing: 0.25em;
  text-transform: uppercase;
  line-height: 1.6;
  color: var(--muted);
}

/* 1px hairline divider, --muted at 18% (the .glass border alpha). */
.spec-rule {
  display: block;
  width: 100%;
  height: 1px;
  border: 0;
  background: rgba(143, 163, 200, 0.18);
}

/* Mono data readout: key rows with lime values via .text-pop spans.
   Usage: <div class="spec-data">
            <span>NODES: <span class="text-pop">8</span> / EDGES: <span class="text-pop">10</span></span>
          </div> */
.spec-data {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.6875rem; /* 11px */
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.8;
  color: var(--muted);
}

/* Hairline callout with an elbow stub — pair with a .spec-label/.spec-data
   for 3D projection callouts (see .sb-tag in css/sections/projects.css).
   The ::before stub ticks up from the line's anchor end. */
.spec-callout {
  position: relative;
  display: block;
  width: 3rem;
  height: 1px;
  background: rgba(143, 163, 200, 0.4);
}

.spec-callout::before {
  content: '';
  position: absolute;
  left: 0;
  top: -5px;
  width: 1px;
  height: 6px;
  background: inherit;
}

/* Medium headline scale — the loudest type inside a section.
   Spec weight is Clash 500, but Fontshare only ships 600/700 for
   Clash Display (see index.html) — 600 is the medium voice here. */
.h-medium {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
}

/* ---------- Links & buttons ---------- */
a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.25s ease;
}

a:hover {
  color: var(--pop);
}

/* Underline-sweep link utility */
.link-line {
  position: relative;
  display: inline-block;
}

.link-line::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--pop);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}

.link-line:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.9em 1.8em;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--bg);
  background: var(--pop);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.25s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn--ghost {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--muted);
}

.btn--ghost:hover {
  border-color: var(--pop);
  color: var(--pop);
}

/* Mono pill — quiet hairline outline button. Hover swaps the border for a
   lime→teal gradient ring via the two-background trick (solid fill clipped
   to padding-box over a border-box gradient, under a transparent border). */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5rem 1.25rem;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.6875rem; /* 11px */
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(143, 163, 200, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease;
}

.pill-btn:hover {
  color: var(--pop);
  border-color: transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(90deg, #C6F53F, #3FC1C9) border-box;
}

/* ---------- Custom cursor (dot + ring) ---------- */
/* Elements are injected by js/main.js only on fine-pointer devices. */
.cursor,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  border-radius: 50%;
  z-index: 9999;
  will-change: transform;
}

.cursor {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--pop);
  box-shadow: 0 0 10px rgba(198, 245, 63, 0.55);
}

.cursor-ring {
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 1px solid var(--pop);
  opacity: 0.5;
  box-shadow:
    0 0 14px rgba(198, 245, 63, 0.30),
    inset 0 0 10px rgba(198, 245, 63, 0.10);
  transition: width 0.25s ease, height 0.25s ease, margin 0.25s ease, opacity 0.25s ease;
}

.cursor-ring.is-hover {
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  opacity: 1;
}

/* Hide native cursor only when the custom one is active */
.has-custom-cursor,
.has-custom-cursor a,
.has-custom-cursor button {
  cursor: none;
}

/* Never show custom cursor on touch / coarse pointers */
@media (hover: none), (pointer: coarse) {
  .cursor,
  .cursor-ring {
    display: none;
  }
}

/* ---------- Marquee utility ---------- */
/* Usage: <div class="marquee"><div class="marquee__track">
            <span>…content…</span><span aria-hidden="true">…same content…</span>
          </div></div>                                        */
.marquee {
  overflow: hidden;
  white-space: nowrap;
  width: 100%;
}

.marquee__track {
  display: inline-flex;
  align-items: center;
  gap: 2rem;
  padding-right: 2rem;
  animation: marquee-scroll 20s linear infinite;
  will-change: transform;
}

@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---------- CSS-only entrance: fade + rise ---------- */
/* For entrances without a GSAP slot; fill mode 'both' means the element
   always ends fully visible, even if the animation can't run. */
@keyframes fade-rise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-rise {
  animation: fade-rise 0.8s ease-out both;
}

/* ---------- Cosmic layering: canvas below, DOM above ---------- */
/* #universe is the fixed full-screen WebGL canvas (added by the scene agent).
   Placed correctly even before JS runs; never intercepts pointer events. */
#universe {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* All DOM content floats above the canvas. */
main {
  position: relative;
  z-index: 1;
}

/* ---------- Section shell ---------- */
section[data-section] {
  position: relative;
  min-height: 100vh;
  width: 100%;
}

.section-error {
  padding: 4rem 2rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Cosmic utilities ---------- */

/* Soft aurora-lime glow for accent text floating over the 3D scene */
.glow-pop {
  color: var(--pop);
  text-shadow:
    0 0 12px rgba(198, 245, 63, 0.45),
    0 0 36px rgba(198, 245, 63, 0.18);
}

/* Frosted panel for cards floating over the universe canvas — liquid glass:
   soft inner top-light (inset shadow) plus a gradient hairline ring drawn
   by a masked ::before (bright top edge, transparent mid, dim bottom). */
.glass {
  position: relative;
  background: rgba(14, 30, 66, 0.55); /* --bg-2 @ 55% */
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(143, 163, 200, 0.18); /* --muted @ 18% (fallback under the ring) */
  border-radius: 16px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

/* Gradient border ring: the mask composite cuts the content-box fill out of
   the border-box fill, leaving only the 1.4px padding band as a ring. */
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1.4px;
  border-radius: inherit;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.45),
    transparent 50%,
    rgba(255, 255, 255, 0.3)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Hairline divider with a small 4-point star at center.
   Usage: <hr class="star-divider"> or <div class="star-divider"></div> */
.star-divider {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  height: 14px;
  border: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1 L14.6 9.4 L23 12 L14.6 14.6 L12 23 L9.4 14.6 L1 12 L9.4 9.4 Z' fill='%23C6F53F'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}

.star-divider::before,
.star-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(143, 163, 200, 0.35), transparent);
}

/* ---------- Static universe fallback (no WebGL) ---------- */
/* Applied via <body class="universe-static"> when the 3D scene can't run.
   Pure CSS: repeating radial-gradient star tiles (two densities) plus a
   faint purple/cyan nebula. Fixed layers sit at z-index 0, below main.
   No motion beyond a 120s opacity breathe (killed by the motion guard). */
body.universe-static::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 24px 48px, rgba(242, 245, 255, 0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 150px 110px, rgba(143, 163, 200, 0.70) 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 190px, rgba(242, 245, 255, 0.90) 50%, transparent 51%),
    radial-gradient(1px 1px at 230px 250px, rgba(242, 245, 255, 0.60) 50%, transparent 51%),
    radial-gradient(1px 1px at 300px 60px, rgba(198, 245, 63, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 70px 310px, rgba(143, 163, 200, 0.75) 50%, transparent 51%),
    radial-gradient(2px 2px at 390px 180px, rgba(242, 245, 255, 0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 460px 320px, rgba(242, 245, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 520px 90px, rgba(143, 163, 200, 0.65) 50%, transparent 51%);
  background-size:
    340px 340px, 340px 340px, 340px 340px, 340px 340px,
    560px 560px, 560px 560px, 560px 560px, 560px 560px, 560px 560px;
  background-repeat: repeat;
}

body.universe-static::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 45% at 18% 12%, rgba(124, 92, 191, 0.16), transparent 70%),
    radial-gradient(ellipse 55% 42% at 82% 78%, rgba(64, 180, 200, 0.11), transparent 70%),
    radial-gradient(ellipse 40% 34% at 65% 18%, rgba(198, 245, 63, 0.05), transparent 70%);
  animation: nebula-breathe 120s ease-in-out infinite alternate;
}

@keyframes nebula-breathe {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

/* ---------- Reduced motion guard ---------- */
@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;
  }

  .marquee__track {
    animation: none;
  }

  /* CSS-only entrances render in their final (visible) state, no motion */
  .fade-rise {
    animation: none;
  }

  body.universe-static::after {
    animation: none;
  }

  .cursor,
  .cursor-ring {
    display: none;
  }
}
