/* Shared styles for every page. Home-only layout lives in home.css.
   The site is dark-only (see CLAUDE.md section 2). */
:root {
  color-scheme: dark;

  /* Brand */
  --primary: #2563eb;          /* fills: buttons, timeline line (white text passes AA) */
  --primary-text: #60a5fa;     /* text/icons on dark surfaces */
  --secondary: #3b82f6;
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --glow: rgba(59, 130, 246, 0.35);

  /* Surfaces */
  --background: #070b14;       /* page */
  --surface: #0d1424;          /* cards, nav */
  --surface-2: #131c30;        /* raised / hover */
  --footer: #04070d;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --grid: rgba(96, 165, 250, 0.05);
  --chip: #f1f5f9;             /* light chip behind logos that are dark-on-transparent */

  /* Text */
  --heading: #f1f5f9;
  --text: #cbd5e1;
  --text-light: #94a3b8;
  --white: #ffffff;

  /* Type */
  --sans: 'Inter', system-ui, sans-serif;
  --display: 'Space Grotesk', 'Inter', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow: 0 8px 24px -8px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.7);
  --card-radius: 1rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --transition: all 0.3s var(--ease);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--sans);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
}

/* Blueprint grid with a soft glow at the top. A fixed layer instead of
   background-attachment: fixed, which repaints on every scroll on phones. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.18), transparent 70%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
}

::selection {
  background: rgba(96, 165, 250, 0.35);
  color: var(--white);
}

img {
  max-width: 100%;
}

a {
  color: var(--primary-text);
  text-underline-offset: 3px;
}

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

h1, h2, h3 {
  font-family: var(--display);
  line-height: 1.15;
  color: var(--heading);
  letter-spacing: -0.01em;
}

.mono {
  font-family: var(--mono);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Navbar: floating glass pill ---------- */
.navbar {
  position: fixed;
  top: 1rem;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0 1rem;
  pointer-events: none;
  transition: transform 0.4s var(--ease);
}

/* nav.js: hidden while scrolling down */
.navbar.nav-hidden {
  transform: translateY(-150%);
}

.nav-content {
  pointer-events: auto;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 0.75rem 0.6rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: rgba(13, 20, 36, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 30px -12px rgb(0 0 0 / 0.7);
}

.logo {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--heading);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.04em;
}

.logo::before {
  content: '';
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 12px var(--accent);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  transition: color 0.2s ease, background 0.2s ease;
}

@media (hover: hover) {
  .nav-links a:hover {
    color: var(--heading);
    background: rgba(148, 163, 184, 0.08);
  }
}

.nav-links a.active,
.nav-links a[aria-current="page"] {
  color: var(--heading);
  background: rgba(96, 165, 250, 0.14);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.3);
}

/* Menu button (phones only; nav.js adds it and .has-toggle to the navbar) */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0 1rem;
  font: 500 0.78rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--heading);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
}

.nav-toggle-icon {
  position: relative;
  width: 16px;
  height: 10px;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.25s var(--ease), top 0.25s var(--ease);
}

.nav-toggle-icon::before { top: 0; }
.nav-toggle-icon::after { top: 8px; }

.menu-open .nav-toggle-icon::before { top: 4px; transform: rotate(45deg); }
.menu-open .nav-toggle-icon::after { top: 4px; transform: rotate(-45deg); }

/* ---------- Buttons ---------- */
.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border-radius: 0.65rem;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.primary-button {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.25) inset, 0 8px 24px -8px var(--glow);
}

.primary-button:hover {
  background: #1d4ed8;
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.35) inset, 0 12px 32px -8px var(--glow);
}

.secondary-button {
  background: rgba(148, 163, 184, 0.06);
  color: var(--heading);
  border: 1px solid var(--border-strong);
}

.secondary-button:hover {
  border-color: var(--primary-text);
  background: rgba(96, 165, 250, 0.08);
}

.ghost-button {
  color: var(--text);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.ghost-button:hover {
  color: var(--heading);
}

@media (hover: hover) {
  .primary-button:hover,
  .secondary-button:hover {
    transform: translateY(-2px);
  }
}

.arrow {
  display: inline-block;
  transition: transform 0.2s var(--ease);
}

a:hover > .arrow {
  transform: translateX(3px);
}

/* Section headings (gallery and home) */
.section-title {
  text-align: center;
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin-bottom: 3rem;
  color: var(--heading);
}

/* ---------- Footer (site footer only, not post footers) ---------- */
body > footer {
  position: relative;
  background: var(--footer);
  color: var(--text-light);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 2.5rem 1.5rem;
  font-size: 0.92rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.25rem;
  list-style: none;
  margin-bottom: 0.75rem;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.25rem;
  color: var(--text);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--primary-text);
}

/* ---------- Back to top ---------- */
#backToTopBtn {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  right: max(1.5rem, env(safe-area-inset-right));
  background: rgba(13, 20, 36, 0.85);
  color: var(--heading);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease), visibility 0.3s, border-color 0.2s;
  z-index: 900;
  backdrop-filter: blur(10px);
}

#backToTopBtn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#backToTopBtn:hover {
  border-color: var(--primary-text);
  color: var(--primary-text);
}

#backToTopBtn svg {
  fill: currentColor;
}

/* ---------- Content pages (Work, projects, Writing, Treks) ---------- */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 8.5rem 2rem 5rem;
  min-height: 70vh;
}

.page-header {
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: clamp(2.4rem, 6vw, 3.5rem);
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.page .hero-buttons {
  justify-content: flex-start;
}

.page-lede {
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  max-width: 65ch;
}

.breadcrumb {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.page-section {
  margin-bottom: 3.5rem;
}

.page-section h2 {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-section h2::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
}

.page-section p + p {
  margin-top: 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 1.25rem;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(19, 28, 48, 0.9), rgba(13, 20, 36, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.25s ease, transform 0.25s var(--ease), box-shadow 0.25s ease;
}

.card:hover {
  border-color: rgba(96, 165, 250, 0.4);
  box-shadow: 0 16px 40px -20px var(--glow);
}

.card h3 {
  font-size: 1.25rem;
}

.card h3 a {
  color: var(--heading);
  text-decoration: none;
}

.card h3 a:hover {
  color: var(--primary-text);
}

.card-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-link {
  margin-top: auto;
  font-weight: 600;
  text-decoration: none;
}

.card-link:hover {
  text-decoration: underline;
}

.item-list {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.item-list li {
  padding-left: 1.4rem;
  position: relative;
}

.item-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 0.6rem;
  height: 1px;
  background: var(--primary-text);
}

.item-list strong,
.skill-groups dt,
.facts dt {
  color: var(--heading);
}

.skill-groups {
  display: grid;
  gap: 1.25rem;
}

.skill-groups dt {
  font-family: var(--display);
  font-weight: 700;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}

.facts dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-light);
}

.facts dd {
  color: var(--heading);
}

.results-table {
  width: 100%;
  max-width: 420px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.results-table th,
.results-table td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.results-table th {
  color: var(--heading);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.empty-state {
  color: var(--text-light);
  font-style: italic;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .navbar {
    top: 0.6rem;
    padding: 0 0.6rem;
  }

  /* No-JS fallback: the links wrap under the logo */
  .nav-content {
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.55rem 0.6rem;
    border-radius: 1.25rem;
  }

  .nav-links {
    justify-content: center;
    gap: 0.1rem;
  }

  .nav-links a {
    min-height: 44px;
    padding: 0 0.6rem;
    font-size: 0.88rem;
  }

  /* With nav.js: a slim bar (logo + Menu); the links open as a dropdown panel */
  .has-toggle .nav-content {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.4rem 0.4rem 0.4rem 1.1rem;
    border-radius: 1.6rem;
  }

  .has-toggle .nav-toggle {
    display: inline-flex;
  }

  .has-toggle .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.15rem;
    padding: 0.5rem 0 0.35rem;
    border-top: 1px solid var(--border);
  }

  .has-toggle.menu-open .nav-links {
    display: flex;
  }

  .has-toggle .nav-links a {
    min-height: 48px;
    padding: 0 1rem;
    font-size: 1rem;
    border-radius: 0.85rem;
  }

  .has-toggle.menu-open .nav-content {
    background: rgba(13, 20, 36, 0.96);
  }

  html {
    scroll-padding-top: 5.5rem;
  }

  .page {
    padding: 7rem 1rem 4rem;
  }

  #backToTopBtn {
    width: 3rem;
    height: 3rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
  }
}

@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;
  }
}
