/* =========================================================================
   brey.xyz — José Brey · career timeline
   "Quiet luxury editorial": near-monochrome, vast whitespace, one warm accent.
   Mobile-first. Fraunces (display) + Hanken Grotesk (body), self-hosted.
   ========================================================================= */

/* ---- Self-hosted webfonts (latin, wght-only variable, no opsz) ---------- */
@font-face {
  font-family: 'Fraunces';
  src: url('/assets/fonts/fraunces-latin-var.woff2') format('woff2');
  font-weight: 340 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Hanken Grotesk';
  src: url('/assets/fonts/hanken-grotesk-latin-var.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched fallbacks (computed) so the swap doesn't shift layout (CLS). */
@font-face {
  font-family: 'Fraunces Fallback';
  src: local('Georgia');
  size-adjust: 110.26%;
  ascent-override: 88.70%;
  descent-override: 23.13%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Hanken Fallback';
  src: local('Arial');
  size-adjust: 123.47%;
  ascent-override: 80.99%;
  descent-override: 24.54%;
  line-gap-override: 0%;
}

/* ---- Dusk-transitionable theme tokens (registered so they interpolate) --- */
@property --bg      { syntax: '<color>'; inherits: true; initial-value: #101114; }
@property --bg-2    { syntax: '<color>'; inherits: true; initial-value: #16171b; }
@property --ink     { syntax: '<color>'; inherits: true; initial-value: #ECEAE3; }
@property --muted   { syntax: '<color>'; inherits: true; initial-value: #9A9AA2; }
@property --faint   { syntax: '<color>'; inherits: true; initial-value: #6E6F77; }
@property --line    { syntax: '<color>'; inherits: true; initial-value: #2A2B31; }
@property --accent  { syntax: '<color>'; inherits: true; initial-value: #D9B36C; }

:root {
  --bg: #101114;  --bg-2: #16171b;  --ink: #ECEAE3;  --muted: #9A9AA2;
  --faint: #6E6F77;  --line: #2A2B31;  --accent: #D9B36C;

  --font-display: 'Fraunces', 'Fraunces Fallback', Georgia, 'Times New Roman', serif;
  --font-body: 'Hanken Grotesk', 'Hanken Fallback', Arial, system-ui, sans-serif;

  --maxw: 64rem;
  --pad: clamp(1.25rem, 5vw, 6rem);
  --bar-h: 4rem;
}

/* Forced light + no-JS system-light */
:root[data-theme="light"],
:root:not([data-theme]) {
  /* default stays dark unless overridden below */
}
:root[data-theme="light"] {
  --bg: #F4F0E8;  --bg-2: #FBF8F2;  --ink: #1B1B1E;  --muted: #5C5C64;
  --faint: #8A8A92;  --line: #DAD3C4;  --accent: #9A6A1F;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #F4F0E8;  --bg-2: #FBF8F2;  --ink: #1B1B1E;  --muted: #5C5C64;
    --faint: #8A8A92;  --line: #DAD3C4;  --accent: #9A6A1F;
  }
}

/* Enable the dusk crossfade only after first paint (set by main.js) so the
   initial theme application doesn't animate. */
:root[data-theme-ready] {
  transition: --bg .7s ease, --bg-2 .7s ease, --ink .7s ease,
              --muted .7s ease, --faint .7s ease, --line .7s ease, --accent .7s ease;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; }
:where(a, button) { transition: color .2s ease, opacity .2s ease; }

/* Visible focus for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: fixed; top: .5rem; left: .5rem; z-index: 100;
  background: var(--bg-2); color: var(--ink);
  padding: .6rem 1rem; border: 1px solid var(--line); border-radius: 8px;
  transform: translateY(-150%); transition: transform .2s ease;
}
.skip-link:focus { transform: translateY(0); }

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 70; /* stays above the menu overlay so the toggle is reachable */
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  padding: .85rem var(--pad);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 500; font-size: 1.15rem; letter-spacing: .01em;
  text-decoration: none; margin-right: auto;
}
.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.theme-toggle, .menu-toggle {
  font-family: var(--font-body);
  background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer;
}
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 2.4rem; height: 2.4rem; padding: 0;
}
.theme-toggle:hover, .menu-toggle:hover { border-color: var(--accent); color: var(--accent); }
.menu-toggle {
  display: none; /* shown only with JS */
  padding: .5rem 1.1rem; font-size: .95rem; letter-spacing: .02em;
}
/* sun in light, moon in dark */
.icon-sun { display: none; } .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun { display: block; }
  :root:not([data-theme]) .icon-moon { display: none; }
}

/* ---- Menu (base = visible list for no-JS, sits under the bar) ----------- */
.site-menu { padding: .5rem var(--pad) .9rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.menu-inner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1.4rem;
  padding-top: .35rem;
}
.menu-label {
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--faint); flex-basis: 100%;
}
.menu-list {
  list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.2rem;
}
.menu-list a, .menu-link {
  font-family: var(--font-body); font-size: 1rem; color: var(--muted);
  text-decoration: none; background: none; border: 0; padding: .15rem 0;
  cursor: pointer; border-bottom: 1px solid transparent;
}
.menu-list a:hover, .menu-link:hover { color: var(--ink); border-bottom-color: var(--accent); }

/* JS: collapse menu into a toggled full-screen overlay */
.js .menu-toggle { display: inline-flex; }
.js .site-menu {
  position: fixed; inset: 0; z-index: 60;
  flex-basis: auto;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: grid; align-content: start; justify-items: start;
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--bar-h) + 1.75rem) var(--pad) 2.5rem;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .4s ease, visibility .4s ease;
}
@media (min-width: 48rem) { .js .site-menu { align-content: center; } }
.js .site-menu[data-open] { opacity: 1; visibility: visible; pointer-events: auto; }
.js .menu-inner {
  flex-wrap: nowrap; /* base layout is wrap; column + wrap would spill into off-screen columns */
  flex-direction: column; align-items: flex-start; gap: 1.1rem;
  max-width: var(--maxw); width: 100%; margin-inline: auto;
}
.js .menu-label { flex-basis: auto; }
.js .menu-list { flex-direction: column; gap: .4rem; flex-basis: auto; width: 100%; }
.js .menu-list a, .js .menu-link {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 7vw, 3rem); font-weight: 400; line-height: 1.05;
  color: var(--ink);
}
.js .menu-list a:hover, .js .menu-link:hover { color: var(--accent); border-bottom-color: transparent; }
.js .menu-label { font-size: .8rem; margin-top: .5rem; }

/* ---- Hero --------------------------------------------------------------- */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--bar-h) var(--pad) clamp(4rem, 12vh, 9rem);
  max-width: calc(var(--maxw) + 8rem);
}
.hero-kicker {
  font-size: .8rem; letter-spacing: .26em; text-transform: uppercase;
  color: var(--accent); margin-bottom: clamp(1rem, 4vh, 2.5rem);
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 420; font-size: clamp(3.2rem, 15vw, 10rem);
  line-height: .94; letter-spacing: -0.015em;
}
.hero-tagline {
  font-size: clamp(1.15rem, 3.4vw, 1.7rem); color: var(--muted);
  margin-top: clamp(1.2rem, 3vh, 2rem); max-width: 30ch;
}
.scroll-cue {
  margin-top: clamp(2.5rem, 9vh, 6rem);
  display: inline-flex; align-items: center; gap: .7rem;
  text-decoration: none; color: var(--faint);
  font-size: .82rem; letter-spacing: .16em; text-transform: uppercase;
}
.scroll-cue:hover { color: var(--ink); }
.scroll-cue-chev {
  font-size: 1.1rem; line-height: 1;
  animation: cue-bob 2.4s ease-in-out infinite;
}
@keyframes cue-bob { 0%, 100% { transform: translateY(-3px); opacity: .5; } 50% { transform: translateY(4px); opacity: 1; } }

/* ---- Timeline ----------------------------------------------------------- */
.timeline {
  list-style: none; padding: 0;
  position: relative;
  margin: clamp(2rem, 8vh, 7rem) 0 0;
  padding-left: clamp(2.25rem, 9vw, 3.5rem);
  padding-right: var(--pad);
  max-width: calc(var(--maxw) + 8rem);
}
/* the continuous thread: now (accent, top) → past (faint, bottom) */
.timeline::before {
  content: ''; position: absolute; top: .4rem; bottom: 0;
  left: clamp(.7rem, 3.2vw, 1.1rem); width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--line) 32%, var(--line));
}
/* scroll-linked "travelled" fill, layered over the thread (created by main.js) */
.thread-progress {
  position: absolute; top: .4rem; bottom: 0;
  left: clamp(.7rem, 3.2vw, 1.1rem); width: 2px;
  background: var(--accent);
  transform-origin: top center; transform: scaleY(0);
  pointer-events: none;
}
.role {
  position: relative;
  padding: clamp(3rem, 11vh, 8rem) 0;
  scroll-margin-top: 5rem;
}
.role:first-child { padding-top: clamp(1rem, 4vh, 3rem); }
.role::before { /* node */
  content: ''; position: absolute; top: clamp(3.4rem, 11.6vh, 8.5rem);
  left: calc(-1 * clamp(2.25rem, 9vw, 3.5rem) + clamp(.7rem, 3.2vw, 1.1rem) - 4px);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--faint); border: 2px solid var(--bg);
}
.role:first-child::before { padding: 0; top: clamp(1.4rem, 4.6vh, 3.5rem); }
.role--present::before {
  background: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
}
.role-when {
  font-family: var(--font-body); font-size: .8rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .9rem;
}
.role-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.9rem, 6vw, 3.6rem); line-height: 1.04;
  letter-spacing: -0.01em;
}
.role-org { display: block; color: var(--muted); font-style: italic; margin-top: .2rem; }
.role-detail {
  margin-top: 1.1rem; color: var(--muted);
  font-size: clamp(1.05rem, 2.4vw, 1.25rem); max-width: 42ch;
}
.role--present .role-title { font-size: clamp(2.3rem, 8vw, 4.6rem); }
.role--present .role-detail { color: var(--ink); max-width: 46ch; }
.role--compressed .role-title { font-size: clamp(1.5rem, 4.5vw, 2.4rem); }
.role--compressed .role-detail { font-size: 1.05rem; color: var(--faint); }

.timeline-end {
  text-align: left; color: var(--faint);
  padding: 1rem 0 6rem clamp(2.25rem, 9vw, 3.5rem);
  font-size: .8rem; letter-spacing: .22em; text-transform: uppercase;
  max-width: calc(var(--maxw) + 8rem);
}

/* ---- Footer ------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: clamp(2rem, 6vh, 3.5rem) var(--pad) clamp(3rem, 8vh, 5rem);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.footer-mark { font-family: var(--font-display); font-size: 1.1rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.footer-links a, .footer-links .menu-link {
  font-size: .92rem; color: var(--muted); text-decoration: none;
}
.footer-links a:hover, .footer-links .menu-link:hover { color: var(--accent); }

/* ---- Skills dialog ------------------------------------------------------ */
.skills {
  width: min(46rem, 92vw); border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg-2); color: var(--ink); padding: 0;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
}
.skills::backdrop { background: rgba(8,8,10,.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.skills-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.4rem clamp(1.4rem, 4vw, 2.2rem); border-bottom: 1px solid var(--line);
}
.skills-head h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; }
.skills-close {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  width: 2.1rem; height: 2.1rem; color: var(--muted); cursor: pointer; font-size: 1rem;
}
.skills-close:hover { color: var(--ink); border-color: var(--accent); }
.skills-body { padding: clamp(1.4rem, 4vw, 2.2rem); display: grid; gap: 1.8rem; }
.skills-body h3 {
  font-size: .76rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .8rem; font-weight: 600;
}
.skills-grid, .skills-stack { list-style: none; padding: 0; display: grid; gap: .5rem; }
.skills-grid li, .skills-stack li { color: var(--ink); }
.skills-grid { grid-template-columns: 1fr; }

/* ========================= Larger screens =============================== */
@media (min-width: 48rem) {
  :root { --bar-h: 4.5rem; }
  .skills-grid { grid-template-columns: 1fr 1fr; gap: .6rem 2rem; }
  .role-detail { font-size: clamp(1.1rem, 1.6vw, 1.3rem); }
}
@media (min-width: 64rem) {
  .hero, .timeline, .timeline-end { margin-left: clamp(0rem, 6vw, 7rem); }
}

/* ========================= Reduced motion =============================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-cue-chev { animation: none; }
  :root[data-theme-ready] { transition-duration: .001s; }
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
