/* =========================================================
   Design tokens - "Clean white + Navy"
   Every color on the site comes from these variables.
   ========================================================= */
:root {
  --bg: #FFFFFF;            /* page background */
  --surface: #F5F6F8;       /* cards, alternate sections, tags, badges */
  --surface-hover: #EEF0F3; /* card hover background */
  --border: #E4E7EB;        /* all borders and dividers */
  --text: #0F172A;          /* headings and main text */
  --text-muted: #5B6472;    /* paragraphs, descriptions, labels */
  --text-light: #8A92A0;    /* non-text details only (3.1:1 fails AA for text) */
  --accent: #1E3A8A;        /* navy, the only accent color */
  --accent-hover: #172E6E;  /* darker navy for hover */
  --accent-soft: #E8EDF8;   /* light navy for tag/badge backgrounds */
  --on-accent: #FFFFFF;     /* text on navy */
  --success: #16A34A;       /* "Open to work" dot only */
  --band: #1E3A8A;          /* call-to-action band background */
  --on-band: #FFFFFF;       /* text on the band */
  --band-muted: #E8EDF8;    /* secondary text on the band */

  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

[x-cloak] { display: none !important; }

/* =========================================================
   Base
   ========================================================= */
html { -webkit-font-smoothing: antialiased; scroll-padding-top: 88px; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
}

h1, h2, h3, h4 { color: var(--text); font-family: "Inter", system-ui, sans-serif; }
.font-mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

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

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

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 500;
}
.skip-link:focus { top: 16px; }

.profile-headshot { object-fit: cover; object-position: center top; }

/* =========================================================
   Layout
   ========================================================= */
.container-x { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 24px; }

.section { padding-block: 72px; background: var(--bg); }
.section-alt { background: var(--surface); }
@media (min-width: 768px) { .section { padding-block: 112px; } }

/* Page header for inner pages */
.page-header { padding-block: 64px 48px; background: var(--surface); border-bottom: 1px solid var(--border); }
@media (min-width: 768px) { .page-header { padding-block: 96px 64px; } }

/* =========================================================
   Typography helpers
   ========================================================= */
.label {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.h-hero { font-size: 38px; font-weight: 700; line-height: 1.08; letter-spacing: -0.02em; color: var(--text); }
@media (min-width: 768px) { .h-hero { font-size: 60px; } }
.h-page { font-size: 36px; font-weight: 700; line-height: 1.12; letter-spacing: -0.02em; }
@media (min-width: 768px) { .h-page { font-size: 48px; } }
.h-section { font-size: 30px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; margin-top: 8px; }
@media (min-width: 768px) { .h-section { font-size: 36px; } }
.lead { font-size: 17px; line-height: 1.65; color: var(--text-muted); max-width: 65ch; }
.text-body { color: var(--text-muted); line-height: 1.65; }
.measure { max-width: 65ch; }

.link-accent { color: var(--accent); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; transition: color 0.2s; }
.link-accent:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

/* Arrow icons slide right on hover of their link/button */
.arrow { display: inline-block; transition: transform 0.2s var(--ease); }
a:hover .arrow, button:hover .arrow { transform: translateX(3px); }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500; line-height: 1.2;
  border: 1px solid transparent;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface); border-color: var(--text-light); }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn-invert { background: var(--on-accent); color: var(--accent); }
.btn-invert:hover { background: var(--accent-soft); }
.btn:disabled { opacity: 0.7; cursor: wait; transform: none; }

/* =========================================================
   Cards
   ========================================================= */
.card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card-hover { transition: transform 0.25s var(--ease), border-color 0.25s, background-color 0.25s; }
.card-hover:hover { transform: translateY(-4px); border-color: var(--accent); }
.card-surface { background: var(--surface); box-shadow: none; }
.card-surface.card-hover:hover { background: var(--surface-hover); }

.card-media { overflow: hidden; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.card-media img { transition: transform 0.35s var(--ease); }
.card-hover:hover .card-media img { transform: scale(1.03); }

.icon-box {
  display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent);
}

/* =========================================================
   Tags, badges, chips
   ========================================================= */
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 6px;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; line-height: 1.5;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
a.tag:hover { border-color: var(--accent); color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 9999px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Filter pills (projects, certifications, achievements, skills) */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 9999px;
  font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  white-space: nowrap; cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.chip:hover { color: var(--text); border-color: var(--text-light); }
.chip-active, .chip-active:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Status dots */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 9999px; flex-shrink: 0; background: var(--accent); }
.dot-muted { background: var(--text-light); }
.dot-success { background: var(--success); position: relative; }
.dot-success::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--success);
  animation: soft-pulse 2.4s ease-out infinite;
}
@keyframes soft-pulse { 0% { transform: scale(1); opacity: 0.45; } 70%, 100% { transform: scale(2.4); opacity: 0; } }

/* =========================================================
   Forms
   ========================================================= */
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--text-light); }
.input:hover { border-color: var(--text-light); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input {
  appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235B6472' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.field-error { margin-top: 6px; font-size: 14px; color: var(--text); font-weight: 500; }
.field-error::before { content: "! "; color: var(--accent); font-weight: 700; }

/* =========================================================
   Navigation
   ========================================================= */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.site-nav.is-scrolled { border-bottom-color: var(--border); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06); }

.nav-link {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding-block: 6px;
  font-size: 14.5px; font-weight: 500; color: var(--text-muted);
  transition: color 0.2s;
}
.nav-link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.25s var(--ease);
}
.nav-link:hover { color: var(--text); }
.nav-link:hover::after { transform: scaleX(1); background: var(--border); }
.nav-link.is-active { color: var(--accent); }
.nav-link.is-active::after { transform: scaleX(1); background: var(--accent); }

.dropdown {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06); padding: 6px;
}
.dropdown a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; font-size: 14px; color: var(--text-muted); }
.dropdown a:hover { background: var(--surface); color: var(--text); }
.dropdown a.is-active { color: var(--accent); background: var(--accent-soft); }

.mobile-link { display: block; padding: 12px 4px; font-weight: 500; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.mobile-link:hover { color: var(--text); }
.mobile-link.is-active { color: var(--accent); }

.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text-muted); background: var(--bg);
  transition: color 0.2s, border-color 0.2s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* =========================================================
   Home-page pieces
   ========================================================= */
/* Stats separated by thin vertical dividers */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.stat { padding: 28px 24px; }
.stat:nth-child(odd) { border-right: 1px solid var(--border); }
.stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
@media (min-width: 768px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat { border-bottom: 0 !important; border-right: 1px solid var(--border); }
  .stat:last-child { border-right: 0; }
}
.stat-number { font-size: 40px; font-weight: 700; line-height: 1; color: var(--accent); letter-spacing: -0.02em; }
.stat-label { margin-top: 8px; font-size: 14px; color: var(--text-muted); }

/* Skills ticker */
.marquee { overflow: hidden; }
.marquee-track { display: flex; gap: 12px; width: max-content; animation: marquee 40s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee .tag { font-size: 13px; padding: 8px 14px; }
@keyframes marquee { to { transform: translateX(calc(-50% - 6px)); } }

/* Progress bars */
.bar { height: 6px; border-radius: 9999px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* Timeline */
.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 5px; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding-left: 36px; }
.timeline-dot { position: absolute; left: 0; top: 7px; width: 11px; height: 11px; border-radius: 9999px; background: var(--accent); box-shadow: 0 0 0 4px var(--bg); }
.section-alt .timeline-dot { box-shadow: 0 0 0 4px var(--surface); }
.timeline-date { font-size: 13px; color: var(--text-muted); } /* --text-light fails AA contrast for text */

/* Full-width navy call-to-action */
.cta-band { background: var(--band); color: var(--on-band); }
.cta-band h2 { color: var(--on-band); }
.cta-band p { color: var(--band-muted); }
.btn-on-band { color: var(--on-band); border-color: var(--band-muted); }
.btn-on-band:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--on-band); }

/* Rich text from the |rich_text filter */
.prose-rich { max-width: 70ch; }
.prose-rich p { color: var(--text-muted); line-height: 1.7; margin-bottom: 16px; }
.prose-rich h4 { font-size: 16px; font-weight: 600; color: var(--text); margin: 24px 0 8px; }
.prose-rich ul { margin: 0 0 16px; display: grid; gap: 8px; }
.prose-rich li { position: relative; padding-left: 20px; color: var(--text-muted); line-height: 1.65; }
.prose-rich li::before { content: ""; position: absolute; left: 4px; top: 11px; width: 5px; height: 5px; border-radius: 9999px; background: var(--accent); }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); }
.footer-link { color: var(--text-muted); font-size: 14px; transition: color 0.2s; }
.footer-link:hover { color: var(--accent); }

/* HTMX loading state */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
#project-results.htmx-request { opacity: 0.55; transition: opacity 0.2s; }

/* Toasts */
.toast { animation: toast-in 0.3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* Spinner */
.spinner { width: 16px; height: 16px; border-radius: 9999px; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.btn-primary .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: var(--on-accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Elements GSAP animates start hidden only when JS is running,
   so content stays visible without JavaScript. */
.js [data-reveal], .js [data-stagger] > *, .js [data-hero-item] { opacity: 0; }

/* =========================================================
   Reduced motion: no movement, keep simple fades (handled in site.js)
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; flex-wrap: wrap; width: auto; }
  .dot-success::after { animation: none; }
  .btn:hover, .card-hover:hover { transform: none; }
  .card-hover:hover .card-media img, a:hover .arrow, button:hover .arrow { transform: none; }
  .nav-link::after { transition: none; }
}

/* Profile photos: fill the frame and keep the face in view */
.profile-headshot { object-fit: cover; object-position: center top; }

/* =========================================================
   Opening name reveal: shown once per tab (class "intro" on <html>,
   set in base.html). Flat white, navy line, no gradients or glow.
   ========================================================= */
.intro-screen { display: none; }
html.intro .intro-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); cursor: pointer;
  /* Failsafe: hide itself after 4s even if the script never runs. */
  animation: intro-failsafe 0s linear 4s forwards;
}
@keyframes intro-failsafe { to { visibility: hidden; pointer-events: none; } }
.intro-screen { overflow: hidden; }
/* Hand-sketched code doodles: pencil handwriting, far fainter than the name */
.intro-sketch { position: absolute; inset: 0; pointer-events: none; filter: url(#pencil); }
.intro-sketch span {
  position: absolute; left: 0; top: 0;  /* position, tilt, size and faintness are set at random in site.js */
  font-family: "Caveat", "Segoe Print", cursive; font-weight: 500;
  line-height: 1; white-space: nowrap; color: var(--text);
}
.intro-inner { position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 24px; text-align: center; }
.intro-name {
  overflow: hidden;              /* letters slide up from behind this edge */
  padding-bottom: 0.08em;
  font-size: clamp(2.5rem, 9vw, 5.5rem);
  font-weight: 700; letter-spacing: -0.03em; line-height: 1.05;
  color: var(--text);
}
.intro-name .intro-char { display: inline-block; white-space: pre; }
.intro-line {
  display: block; width: min(220px, 50vw); height: 2px; margin-top: 18px;
  background: var(--accent); transform: scaleX(0); transform-origin: left center;
}
.intro-role { margin-top: 16px; font-size: 14px; font-weight: 500; letter-spacing: 0.02em; color: var(--text-muted); opacity: 0; }

/* =========================================================
   Page transitions (View Transitions API, pure CSS).
   Pages cross-fade and the nav stays put. Browsers without
   support simply navigate normally.
   ========================================================= */
@view-transition { navigation: auto; }
.site-nav { view-transition-name: site-nav; }
::view-transition-old(root) { animation: page-out 0.18s ease both; }
::view-transition-new(root) { animation: page-in 0.32s var(--ease) both; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
