/* =============================================================
   leptium.dev — Richard E. Salvatierra-Ube
   Stylesheet
   -------------------------------------------------------------
   Structure:
   1. Design tokens (CSS custom properties)
   2. Theme: light / dark
   3. Reset & base
   4. Typography
   5. Layout primitives (container, sections, grid)
   6. Components (nav, hero, cards, badges, footer, etc.)
   7. Utilities & animations
   8. Responsive (mobile-first; min-width queries scale up)
   9. Accessibility (focus, reduced motion)
   ============================================================= */

/* 1. DESIGN TOKENS ------------------------------------------- */
:root {
  /* 8-point spacing scale */
  --space-1: 0.5rem;   /*  8px */
  --space-2: 1rem;     /* 16px */
  --space-3: 1.5rem;   /* 24px */
  --space-4: 2rem;     /* 32px */
  --space-5: 3rem;     /* 48px */
  --space-6: 4rem;     /* 64px */
  --space-7: 6rem;     /* 96px */
  --space-8: 8rem;     /* 128px */

  /* Layout */
  --container-max: 1240px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

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

  /* Type scale */
  --fs-xs: 0.78rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.875rem;
  --fs-2xl: 2.5rem;
  --fs-3xl: clamp(2.5rem, 6vw, 4rem);

  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-base: 1.65;

  /* Brand accent (stable across themes) */
  --accent: #1f9cf0;          /* electric blue */
  --accent-strong: #0c7fd1;
  --accent-soft: rgba(31, 156, 240, 0.12);

  --transition: 180ms ease;
}

/* 2. THEME --------------------------------------------------- */
/* Light theme is the default. Dark theme applies via [data-theme].
   The no-JS fallback uses prefers-color-scheme. */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-subtle: #f5f7fa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;          /* slate-900 */
  --text-muted: #475569;    /* slate-600 */
  --text-faint: #64748b;    /* slate-500 */
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06),
            0 8px 24px rgba(15, 23, 42, 0.06);
  --nav-bg: rgba(255, 255, 255, 0.82);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1220;            /* deep navy-charcoal */
  --bg-subtle: #0f1830;
  --bg-elevated: #121c34;
  --surface: #121c34;
  --border: #233152;
  --border-strong: #324468;
  --text: #e8eef7;
  --text-muted: #a4b3cc;
  --text-faint: #7d8eab;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4),
            0 12px 32px rgba(0, 0, 0, 0.4);
  --nav-bg: rgba(11, 18, 32, 0.8);
  color-scheme: dark;
}

/* No-JS / system-preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1220;
    --bg-subtle: #0f1830;
    --bg-elevated: #121c34;
    --surface: #121c34;
    --border: #233152;
    --border-strong: #324468;
    --text: #e8eef7;
    --text-muted: #a4b3cc;
    --text-faint: #7d8eab;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4),
              0 12px 32px rgba(0, 0, 0, 0.4);
    --nav-bg: rgba(11, 18, 32, 0.8);
    color-scheme: dark;
  }
}

/* 3. RESET & BASE -------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--transition), color var(--transition);
}

img { max-width: 100%; display: block; }

a {
  color: var(--accent-strong);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent); }

ul { margin: 0; padding: 0; list-style: none; }

/* 4. TYPOGRAPHY ---------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}

p { margin: 0 0 var(--space-2); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}

.lead {
  font-size: var(--fs-md);
  color: var(--text-muted);
  line-height: var(--lh-base);
}

/* 5. LAYOUT PRIMITIVES --------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

.section {
  padding-block: var(--space-6);
  border-top: 1px solid var(--border);
}
.section:first-of-type { border-top: none; }

.section-head {
  margin-bottom: var(--space-4);
  max-width: 60ch;
}
.section-head h2 {
  font-size: var(--fs-xl);
  margin-top: var(--space-2);
}
.section-head p { margin-top: var(--space-2); }

.grid { display: grid; gap: var(--space-3); }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* 6. COMPONENTS ---------------------------------------------- */

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  background: var(--accent);
  color: #fff;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top var(--transition);
}
.skip-link:focus { top: var(--space-2); color: #fff; }

/* Header / Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--text); }
.brand .brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
}
.brand .brand-dim { color: var(--text-faint); font-weight: 400; }

.nav-links {
  display: none;
  align-items: center;
  gap: var(--space-1);
}
.nav-links a {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text);
  background: var(--bg-subtle);
}

.nav-actions { display: flex; align-items: center; gap: var(--space-1); }

/* Theme toggle */
.theme-toggle,
.menu-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}
.theme-toggle:hover,
.menu-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg,
.menu-toggle svg { width: 18px; height: 18px; }
/* Show correct icon per theme */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-moon { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-sun { display: none; }
}

/* Mobile menu */
.menu-toggle { display: inline-grid; }
.mobile-menu {
  display: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.mobile-menu.open { display: block; }
.mobile-menu ul { padding: var(--space-2) var(--space-3) var(--space-3); }
.mobile-menu a {
  display: block;
  padding: var(--space-2);
  color: var(--text-muted);
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.mobile-menu a:hover,
.mobile-menu a[aria-current="page"] {
  color: var(--text);
  background: var(--bg-subtle);
}

@media (min-width: 880px) {
  .nav-links { display: flex; }
  .menu-toggle { display: none; }
  .mobile-menu { display: none !important; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-sm);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }
.btn svg { width: 16px; height: 16px; }

/* Hero */
.hero { padding-block: var(--space-7) var(--space-6); }
.hero-status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-bottom: var(--space-3);
}
.hero-status span { display: inline-flex; align-items: center; gap: 6px; }
.hero-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}
.hero h1 {
  font-size: var(--fs-3xl);
  max-width: 18ch;
  margin-bottom: var(--space-3);
}
.hero h1 .accent { color: var(--accent); }
.hero-sub {
  font-size: var(--fs-lg);
  color: var(--text-muted);
  max-width: 56ch;
  line-height: var(--lh-snug);
  margin-bottom: var(--space-4);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Stat / fact row under hero */
.fact-row {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
@media (min-width: 700px) {
  .fact-row { grid-template-columns: repeat(3, 1fr); }
}
.fact .fact-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.fact .fact-value {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  margin-top: 2px;
}

/* Generic card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: var(--shadow);
  height: 100%;
  transition: border-color var(--transition), transform var(--transition),
              box-shadow var(--transition);
}
.card:hover { border-color: var(--border-strong); }
.card h3 { font-size: var(--fs-lg); margin-bottom: var(--space-1); }
.card p { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: 0; }

/* Service card with index marker */
.service-card { position: relative; }
.service-card .service-index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  margin-bottom: var(--space-2);
  display: block;
}

/* Project card */
.project-card { display: flex; flex-direction: column; }
.project-card:hover { transform: translateY(-3px); }
.project-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.project-card h3 { font-size: var(--fs-md); }
.project-card .project-desc {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  flex: 1;
  margin-bottom: var(--space-3);
}
.tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tech-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Status badge */
.badge {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge-active     { color: #16a34a; background: rgba(22,163,74,0.10);  border-color: rgba(22,163,74,0.25); }
.badge-dev        { color: #d97706; background: rgba(217,119,6,0.10);  border-color: rgba(217,119,6,0.25); }
.badge-research   { color: #2563eb; background: rgba(37,99,235,0.10);  border-color: rgba(37,99,235,0.25); }
.badge-community  { color: #9333ea; background: rgba(147,51,234,0.10); border-color: rgba(147,51,234,0.25); }
[data-theme="dark"] .badge-active    { color: #4ade80; }
[data-theme="dark"] .badge-dev       { color: #fbbf24; }
[data-theme="dark"] .badge-research  { color: #60a5fa; }
[data-theme="dark"] .badge-community { color: #c084fc; }

/* Two-column content (about / philosophy) */
.split {
  display: grid;
  gap: var(--space-4);
}
@media (min-width: 880px) {
  .split { grid-template-columns: 0.9fr 1.1fr; align-items: start; }
  .split-narrow { grid-template-columns: 1fr 1.4fr; }
}

/* Definition-style list for certifications */
.cert-list { display: grid; gap: var(--space-2); }
.cert-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--surface);
}
.cert-item .cert-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}
.cert-item h3 { font-size: var(--fs-md); }
.cert-item p { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: 0; }

/* Interest chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  transition: border-color var(--transition), color var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--text); }

/* Pull-quote / philosophy */
.quote {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding-left: var(--space-3);
  max-width: 52ch;
}

/* Contact block */
.contact-grid { display: grid; gap: var(--space-3); }
@media (min-width: 640px) { .contact-grid { grid-template-columns: repeat(2, 1fr); } }
.contact-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.contact-card .ci {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.contact-card .ci svg { width: 20px; height: 20px; }
.contact-card .c-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.contact-card .c-value { font-weight: 500; color: var(--text); word-break: break-word; }

/* Image placeholder */
.img-placeholder {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background:
    repeating-linear-gradient(
      45deg,
      var(--bg-subtle),
      var(--bg-subtle) 12px,
      transparent 12px,
      transparent 24px
    );
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* Page header (interior pages) */
.page-header { padding-block: var(--space-6) var(--space-4); }
.page-header h1 { font-size: var(--fs-2xl); margin-top: var(--space-2); }
.page-header p { margin-top: var(--space-2); max-width: 60ch; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding-block: var(--space-5) var(--space-4);
  margin-top: var(--space-6);
}
.footer-top {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
@media (min-width: 760px) {
  .footer-top { grid-template-columns: 1.5fr 1fr 1fr; }
}
.footer-brand p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  max-width: 40ch;
  margin-top: var(--space-2);
}
.footer-col h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: var(--space-2);
  font-weight: 500;
}
.footer-col ul { display: grid; gap: var(--space-1); }
.footer-col a { color: var(--text-muted); font-size: var(--fs-sm); }
.footer-col a:hover { color: var(--accent); }
.footer-col .future {
  color: var(--text-faint);
  font-size: var(--fs-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
}
.footer-col .future::after {
  content: "soon";
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 6px;
}
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--fs-sm);
}
.footer-bottom .motto {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* 7. UTILITIES & ANIMATIONS ---------------------------------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-3 { margin-top: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-3 { margin-bottom: var(--space-3); }
.measure-narrow { max-width: 56ch; }
.measure { max-width: 60ch; }
.accent-text { color: var(--accent); }

/* Interior page sections sit directly under the page header, so the first
   one drops its top border and padding. */
.section-flush { border-top: none; padding-top: 0; }
.no-border-top { border-top: none; }

/* "View all" link card variant centers its content. */
.card-link {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--text);
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Fade-in on scroll (JS adds .is-visible) */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms ease, transform 500ms ease;
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* 9. ACCESSIBILITY ------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

@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;
  }
  .reveal { opacity: 1; transform: none; }
}
