/* ===== Design tokens ===== */
:root {
  --bg: #0C0E10;
  --card: #12141670;
  --text: #DEE3E8;
  --text-muted: #8E97A0;
  --text-faint: #7E8790;
  --text-footnote: #767D84; /* bumped from #5C646C (~3.2:1) to clear WCAG AA 4.5:1 on --bg */
  --tag-text: #AEB6BE;
  --accent: #E8A63D;
  --accent-hover: #F2C275;
  --accent-line: rgba(232, 166, 61, 0.35);
  --border: rgba(222, 227, 232, 0.12);
  --border-soft: rgba(222, 227, 232, 0.09);
  --border-strong: rgba(222, 227, 232, 0.22);
  --sans: 'Archivo', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: 'Space Grotesk', var(--sans);
  --mono: 'IBM Plex Mono', "SFMono-Regular", Consolas, monospace;
  --max-width: 1240px;
}

[data-theme="light"] {
  --bg: #F2F1EC;
  --card: #FBFAF7;
  --text: #16181B;
  --text-muted: #6E7378;
  --text-faint: #6E7378;
  --text-footnote: #63686D; /* bumped from #9A9C96 (~2.45:1) to clear WCAG AA 4.5:1 on light --bg */
  --tag-text: #4E5257;
  --accent: #A66A00;
  --accent-hover: #8A5800;
  --accent-line: rgba(166, 106, 0, 0.4);
  --border: rgba(22, 24, 27, 0.14);
  --border-soft: rgba(22, 24, 27, 0.12);
  --border-strong: rgba(22, 24, 27, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }

/* ===== Nav ===== */
.nav-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.nav-links {
  display: flex;
  gap: 28px;
  margin-left: auto;
}
.nav-links a {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  transition: color 0.2s ease;
}
.nav-links a:hover,
.nav-links a.is-active { color: var(--accent); }

.theme-switch {
  position: relative;
  width: 52px;
  height: 26px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  padding: 3px;
}
/* Explicit, narrow exception to the Transform-Free Interaction Rule: this
   dot is fully isolated from the project-card/flagship-swap elements that
   rule exists to protect, and transform is the only compositor-friendly
   way to slide it — see DESIGN.md's Elevation & Depth section. */
.theme-switch-dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(0);
  transition: transform 0.2s ease;
}
[data-theme="light"] .theme-switch-dot { transform: translateX(24px); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
}
.nav-toggle span { width: 22px; height: 1.5px; background: var(--text); display: block; }

/* ===== Hero ===== */
.hero {
  position: relative;
  overflow: hidden;
  padding: 110px 48px 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.field-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 30px; max-width: 900px; }

.typed-line {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 0;
  min-height: 1.2em;
}
.cursor-blink { animation: blink 1s step-end infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.hero-name { margin: 0; display: flex; flex-direction: column; align-items: center; }
.line-wrap { overflow: hidden; display: block; }
.hero-line {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(3.2rem, 11vw, 11rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.hero-line-outline {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--text);
}

.subtext { font-size: 19px; line-height: 1.65; color: var(--text-muted); max-width: 560px; margin: 0 auto; }

.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }

.hero-stats {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-footnote);
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 16px 30px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 13px 24px; font-size: 12.5px; }

.text-link {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
  display: inline-block;
  margin-top: 4px;
}
.text-link:hover { color: var(--accent-hover); }
.skills-cert-link { margin-top: 32px; }

/* ===== Sections ===== */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 88px 48px;
  border-top: 1px solid var(--border-soft);
  position: relative;
  z-index: 1;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 48px;
  flex-wrap: wrap;
}
.section-label { font-family: var(--mono); font-size: 13px; letter-spacing: 0.14em; }
.section-meta { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

/* ===== About ===== */
.about-grid { display: grid; grid-template-columns: 280px 1fr; gap: 64px; align-items: start; }
.bracket-frame { position: relative; padding: 12px; }
.bracket-frame::before,
.bracket-frame::after,
.bracket-frame > .corner-bl,
.bracket-frame > .corner-br { content: ""; }
.bracket-frame { border: none; }
.bracket-frame {
  --c: 16px;
}
.bracket-frame::before {
  position: absolute; top: 0; left: 0; width: var(--c); height: var(--c);
  border-top: 1px solid var(--accent); border-left: 1px solid var(--accent);
}
.bracket-frame::after {
  position: absolute; bottom: 0; right: 0; width: var(--c); height: var(--c);
  border-bottom: 1px solid var(--accent); border-right: 1px solid var(--accent);
}
.avatar-placeholder {
  width: 256px;
  height: 310px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border-soft);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 1.4rem;
}
.avatar { width: 256px; height: 310px; object-fit: cover; display: block; }

.about-content { display: flex; flex-direction: column; gap: 48px; }
.about-lead {
  font-family: var(--display);
  font-weight: 500;
  font-size: 28px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  max-width: 880px;
  margin: 0;
}
.timeline { display: flex; flex-direction: column; max-width: 880px; }
.timeline li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 15.5px;
  color: var(--tag-text);
  align-items: baseline;
}
.timeline li:last-child { border-bottom: 1px solid var(--border-soft); }
.timeline li span { font-family: var(--mono); font-size: 13px; color: var(--accent); }

/* ===== Projects ===== */
.flagship {
  position: relative;
  border: 1px solid var(--accent-line);
  overflow: hidden;
}
/* align-items: flex-start keeps the CTA button hugging its own text width;
   without it, the default `stretch` forces the normally inline-block .btn
   to fill the full flagship column. */
.flagship-body { padding: 40px 56px 56px; display: flex; flex-direction: column; align-items: flex-start; gap: 22px; }
.flagship-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
}
.flagship-body p { font-size: 16.5px; line-height: 1.7; color: var(--text-muted); max-width: 640px; margin: 0; }
/* Fixed box so multiple screenshots of different source dimensions can
   crossfade in place without the container resizing between slides. Ratio
   is tuned to Løfte's dashboard/login captures (~1.88:1, close to a
   standard browser window) since that's the shape most app screenshots
   will share. The landing page shot is a wider crop (2.25:1) — combined
   with object-fit:contain below, it just gets a thin letterbox bar instead
   of being cropped, so no screenshot ever loses real content to fit here. */
.flagship-media {
  position: relative;
  aspect-ratio: 3340 / 1778;
  border-bottom: 1px solid var(--accent-line);
  background: var(--border-soft);
  overflow: hidden;
}
.image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 12.5px;
}
.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.slide.is-active { opacity: 1; z-index: 1; }
.slide img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Caption bar under the screenshot — only rendered when a project has more
   than one image. Plain CSS opacity crossfade + this bar is the whole
   mechanism; no animation library involved. */
.media-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--accent-line);
  background: var(--border-soft);
}
.media-nav-count { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--text-faint); }
.media-nav-btns { display: flex; gap: 8px; }
.media-nav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.media-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.note { font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--text-footnote); }

.bracket-tags { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--mono); font-size: 12px; color: var(--tag-text); }
.bracket-tags-sm { font-size: 11.5px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 24px;
}
.project-card {
  border: 1px solid var(--border);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  /* The hover "lift" below uses box-shadow rather than transform, since
     transform is a common source of animation conflicts elsewhere on the
     site — keeping it off this property entirely avoids that class of bug. */
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.project-card:hover {
  border-color: var(--accent-line);
  box-shadow: 0 14px 28px -18px rgba(0, 0, 0, 0.55);
}
.project-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-line);
}
.project-index { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.project-card h3 { font-family: var(--display); font-weight: 600; font-size: 24px; margin: 0; }
.project-card p { font-size: 14.5px; line-height: 1.65; color: var(--text-muted); flex-grow: 1; margin: 0; }

/* ===== Skills ===== */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.skill-box {
  border: 1px solid var(--border);
  margin-left: -1px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.skill-box:first-child { margin-left: 0; }
.skill-box-accent { border-color: var(--accent-line); }
.skill-box-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; color: var(--text-faint); }
.skill-box-accent .skill-box-label { color: var(--accent); }
.skill-list { display: flex; flex-direction: column; gap: 2px; }
.skill-list li {
  font-family: var(--display);
  font-size: 17px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.skill-list li:last-child { border-bottom: none; }

/* ===== Certifications ===== */
.cert-list { display: flex; flex-direction: column; }
.cert-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 24px;
  align-items: baseline;
  padding: 26px 0;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.2s ease;
}
.cert-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.cert-year { font-family: var(--mono); font-size: 13px; color: var(--text-faint); }
.cert-title { font-family: var(--display); font-size: 22px; }
.cert-title em { font-family: var(--sans); font-style: normal; font-size: 15px; color: var(--text-muted); }
.cert-link { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.06em; color: var(--accent); }

/* ===== Contact ===== */
.contact-section {
  text-align: center;
  padding: 120px 48px 110px;
  position: relative;
  overflow: hidden;
}
.contact-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.contact-headline {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  max-width: 900px;
  margin: 0;
}
.contact-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* ===== Footer ===== */
.footer {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 48px;
  border-top: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-footnote);
}
.footer a { color: var(--text-footnote); }
.footer a:hover { color: var(--accent); }

/* ===== Language switch (floating, bottom-right) ===== */
.lang-switch {
  position: fixed;
  right: 32px;
  bottom: 32px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  background: var(--bg);
  border: 1px solid var(--accent-line);
  color: var(--text-muted);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.lang-btn:hover,
.lang-btn:focus-visible { border-color: var(--accent); outline: none; }
.lang-bracket { color: var(--text-faint); }
.lang-code { color: var(--accent); }
.lang-caret { color: var(--text-faint); font-size: 10px; }
.lang-switch.open .lang-caret { transform: rotate(180deg); }

.lang-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 150px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
}
.lang-menu[hidden] { display: none; }
.lang-menu li + li button { border-top: 1px solid var(--border-soft); }
.lang-menu button {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.lang-menu button:hover,
.lang-menu button:focus-visible { color: var(--text); outline: none; }
.lang-menu button[aria-selected="true"] { color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .about-grid { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .skill-box:nth-child(2) { margin-left: -1px; }
  .skill-box:nth-child(3) { margin-left: 0; }
}

@media (max-width: 700px) {
  .lang-switch { right: 16px; bottom: 16px; }
  .nav { padding: 0 20px; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .nav-links a { padding: 14px 20px; display: block; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }
  .theme-switch { order: -1; margin-left: 0; margin-right: 10px; }
  .hero { padding: 64px 20px 56px; }
  .section { padding: 56px 20px; }
  .skills-grid { grid-template-columns: 1fr; }
  .skill-box { margin-left: 0 !important; border-top: none; }
  .skill-box:first-child { border-top: 1px solid var(--border); }
  .cert-row { grid-template-columns: 1fr; gap: 6px; }
  .contact-section { padding: 64px 20px 56px; }
  .contact-actions { flex-direction: column; width: 100%; }
  .footer { padding: 18px 20px; flex-direction: column; gap: 8px; text-align: center; }
}
