/* css/design-system.css — Sam Ngo Universal Design System overrides for Folio.
   Loaded AFTER folio.css so it wins specificity ties without !important.
   See /design.md for the binding spec; this file implements §5 (navbar),
   §6 (hero), §7 (section), §8 (buttons), §10 (motion), §11 (grain + canvas),
   §17 (skip link). The palette + fonts live in folio-tokens.css. */

/* ── Skip link (design.md §17) ─────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--accent);
  color: #0a0a0f;
  font: 600 var(--t-meta)/1 var(--font-body);
  z-index: 100000;
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Decorative grain overlay (design.md §11) ─────────────────── */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  background-image: radial-gradient(circle, var(--ink-muted) 0.5px, transparent 0.5px);
  background-size: 24px 24px;
}

/* ── Hero particle canvas (design.md §6 + §11) ────────────────── */
.hero-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 0;
  opacity: 0;                           /* JS fades in once a hero mounts */
  transition: opacity 600ms var(--ease-out);
}
.hero-canvas.is-active { opacity: 1; }

/* ── Navbar (design.md §5 + canonical site-header layout) ─────── */
.navbar.topbar {
  position: fixed;               /* canonical: fixed (was sticky in folio.css) */
  top: 0; left: 0; right: 0;
  z-index: 1000;                 /* canonical: 1000 (was 50) */
  background: var(--nav-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid transparent;
  padding: 0 32px;               /* canonical: 0 32px (was 0 24px) */
  min-height: var(--nav-h);      /* canonical: 60px */
  display: block;                /* override folio.css flex on .topbar */
  transition: border-color var(--t-mid) var(--ease-out),
              box-shadow var(--t-mid) var(--ease-out);
}
.navbar.topbar > .topbar-inner {
  max-width: 1100px;             /* canonical: 1100px centered inner */
  margin: 0 auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--s-4);
}
@media (max-width: 768px) {
  .navbar.topbar { padding: 0 20px; }
  /* Room for the library search box on a phone (folio.css keeps it visible). */
  .navbar.topbar > .topbar-inner { gap: var(--s-2); }
  .about-link { padding-left: var(--s-2); padding-right: var(--s-2); }
}
/* No hardware keyboard on a phone → the keyboard-shortcuts button only takes
   room from the search box. */
@media (max-width: 768px) and (pointer: coarse) {
  .shortcuts-btn { display: none; }
}

/* Fixed navbar overlays content — push everything down by its height so
   the first paragraph isn't hidden under it. Hero already accounts for
   this via padding-top: 140px (design.md §6); other views need the bump. */
body { padding-top: var(--nav-h); }
.lib-hero.hero-mounted { margin-top: calc(-1 * var(--nav-h)); }   /* let hero bleed under nav, hero's own 140px top padding pushes content past */
.navbar.scrolled {
  border-bottom-color: var(--paper-rule);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}
[data-theme="light"] .navbar.scrolled {
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
}

.nav-brand {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: var(--s-3);
}
.nav-brand .brand-mark { color: var(--accent); }
/* Hide any residual brand word — canonical brand is monogram-only. */
.nav-brand .brand-word { display: none; }

/* About link — canonical nav-link pattern with active 1.5px accent underline. */
.about-link {
  position: relative;
  font: 500 0.92rem/1 var(--font-body);     /* 16.56px at 18px base — matches canonical */
  color: var(--nav-text);
  opacity: 0.65;
  letter-spacing: 0.01em;
  text-decoration: none;
  padding: var(--s-2) var(--s-3);
  transition: opacity var(--t-fast) var(--ease-out);
}
.about-link:hover,
.about-link.active {
  opacity: 1;
  background: transparent;          /* override folio-tokens.css hover background */
  color: var(--nav-text);
}
.about-link.active::after {
  content: '';
  position: absolute;
  left: var(--s-3);
  right: var(--s-3);
  bottom: -4px;
  height: 1.5px;
  background: var(--accent);
}

/* ── Hero (design.md §6) ──────────────────────────────────────── */
.lib-hero.hero-mounted {
  position: relative;
  overflow: hidden;
  padding: 140px var(--s-8) var(--s-16);     /* 140px top clears fixed nav */
  margin: calc(-1 * var(--s-12)) calc(-1 * var(--s-8)) var(--s-16);
  background: var(--hero-bg);
  isolation: isolate;
}
@media (max-width: 768px) {
  .lib-hero.hero-mounted {
    padding: 110px var(--s-6) var(--s-12);
    margin: calc(-1 * var(--s-12)) calc(-1 * var(--s-6)) var(--s-8);
  }
}
@media (max-width: 720px) {
  /* .lib's side padding drops to --s-4 at this width (folio.css). The bleed
     must match it exactly — bleeding --s-6 made the whole page 8px wider than
     a phone screen, so it wobbled sideways under a thumb. */
  .lib-hero.hero-mounted {
    margin-left: calc(-1 * var(--s-4));
    margin-right: calc(-1 * var(--s-4));
  }
}

/* Orbit rings — non-negotiable per design.md §6 rule 3 */
.lib-hero.hero-mounted::before,
.lib-hero.hero-mounted::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--hero-orbit);
  pointer-events: none;
  z-index: 0;
}
.lib-hero.hero-mounted::before {
  top: -120px; right: -80px;
  width: 400px; height: 400px;
  animation: folio-orbit 25s linear infinite;
}
.lib-hero.hero-mounted::after {
  bottom: -200px; left: -100px;
  width: 500px; height: 500px;
  border-color: var(--hero-orbit-lg);
  animation: folio-orbit 35s linear infinite reverse;
}
@keyframes folio-orbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.lib-hero .hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-w-lib);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-12);
  align-items: center;
}
@media (max-width: 900px) {
  .lib-hero .hero-inner {
    grid-template-columns: 1fr;
    gap: var(--s-8);
  }
  .lib-hero .hero-photo { order: -1; }       /* photo above on mobile */
}

.lib-hero .hero-text { min-width: 0; }

/* Eyebrow label with the signature 24px dash (design.md §6 rule 2) */
.lib-hero .hero-label {
  font: 500 0.72rem/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: var(--s-4);
  display: inline-flex; align-items: center; gap: 10px;
}
.lib-hero .hero-label::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--accent);
}

/* H1 — Space Mono 900, em italic accent (design.md §3) */
.lib-hero .lib-title {
  font: 900 clamp(2.8rem, 6vw, 4.2rem)/1.05 var(--font-display);
  letter-spacing: -0.03em;
  color: var(--hero-text);
  margin: 0 0 var(--s-4);
}
.lib-hero .lib-title em {
  font-style: italic;
  color: var(--accent);
}

.lib-hero .headline {
  font: 400 1.1rem/1.6 var(--font-body);
  color: var(--hero-muted);
  max-width: 440px;
  margin: 0 0 var(--s-3);
}

.lib-hero .lib-sub {
  font: 500 0.78rem/1.4 var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  margin: 0 0 var(--s-6);
}

.lib-hero .header-actions {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
}

/* Hero photo slot — filled by library.js with a 6-cover collage. */
.lib-hero .hero-photo {
  display: flex; align-items: center; justify-content: center;
  min-width: 280px;
}
.hero-collage {
  display: grid;
  grid-template-columns: repeat(3, 80px);
  grid-template-rows: repeat(2, 116px);
  gap: 8px;
  padding: 14px;
  background: var(--paper-soft);
  border: 1px solid var(--paper-rule);
  border-radius: var(--r-sm);
  box-shadow: var(--hero-pic-shadow);
  transition: transform var(--t-sheet) var(--ease-out), box-shadow var(--t-sheet) var(--ease-out);
}
.hero-collage:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: var(--hero-pic-shadow-hover);
}
.hero-collage-cell {
  background: var(--paper-soft2);
  border-radius: 2px;
  background-size: cover;
  background-position: center;
}
.hero-collage-empty {
  font: 500 0.72rem/1.4 var(--font-mono);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: var(--s-6);
  text-align: center;
}

/* ── Buttons (design.md §8) ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px;
  border-radius: var(--r-md);
  font: 600 0.85rem/1 var(--font-body);
  letter-spacing: 0.01em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.btn-primary {
  background: var(--accent);
  color: #0a0a0f;                              /* near-black — passes WCAG on orange */
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #0a0a0f;
  box-shadow: 0 4px 20px rgba(255, 107, 0, 0.3);
}
.btn-outline {
  background: transparent;
  color: var(--hero-text);
  border-color: var(--hero-btn-border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  /* Match canonical Sam-Personal-Profile style.css L455 — 0.06 alpha,
     softer than --accent-glow (0.15) which felt too punchy on hover. */
  background: rgba(255, 107, 0, 0.06);
}

/* ── Section H2 "// " marker (design.md §7) ─────────────────── */
.continue-title::before,
.section-h2::before {
  content: '// ';
  color: var(--accent);
  font-weight: 400;
}
.continue-title {
  font: 700 var(--t-h2)/1.2 var(--font-display);
  letter-spacing: -0.02em;
}

/* ── Scroll-revealed sections (design.md §10) ─────────────────── */
.fade-in {
  opacity: 0.15;
  transform: translateY(12px);
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-slow) var(--ease-out);
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered hero reveal */
.hero-reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
}
.hero-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.hero-text > .hero-reveal:nth-child(1) { transition-delay: 0ms; }
.hero-text > .hero-reveal:nth-child(2) { transition-delay: 80ms; }
.hero-text > .hero-reveal:nth-child(3) { transition-delay: 160ms; }
.hero-text > .hero-reveal:nth-child(4) { transition-delay: 240ms; }
.hero-text > .hero-reveal:nth-child(5) { transition-delay: 320ms; }
.hero-photo.hero-reveal { transition-delay: 200ms; }

/* ── Focus visible (design.md §17) ────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-md);
}
