:root {
  --bg: #F7F5F0;
  --ink: #1E1D1A;
  --ink-soft: #4A4943;
  --muted: #6B6A63;
  --hairline: #E1DED4;
  --accent: #D4537E;
  --accent-deep: #993556;
  --accent-badge-bg: #4B1528;
  --accent-badge-text: #F4C0D1;
  --surface: #FFFFFF;
  --surface-alt: #FFF9FB;
  --shadow: rgba(30, 29, 26, 0.16);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1712;
    --ink: #F2EAE0;
    --ink-soft: #C7BBAE;
    --muted: #8F8377;
    --hairline: #362E26;
    --accent: #E68EA8;
    --accent-deep: #F2A9BE;
    --accent-badge-bg: #3D1B28;
    --accent-badge-text: #F2A9BE;
    --surface: #241D16;
    --surface-alt: #2B2119;
    --shadow: rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --bg: #1C1712;
  --ink: #F2EAE0;
  --ink-soft: #C7BBAE;
  --muted: #8F8377;
  --hairline: #362E26;
  --accent: #E68EA8;
  --accent-deep: #F2A9BE;
  --accent-badge-bg: #3D1B28;
  --accent-badge-text: #F2A9BE;
  --surface: #241D16;
  --surface-alt: #2B2119;
  --shadow: rgba(0, 0, 0, 0.45);
}

html { transition: none; }
body, .nav, .project-card, .tag, .popup-card, button.tag-popup {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 3px;
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem clamp(1.5rem, 6vw, 4rem);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline);
}

.nav-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
}

.nav-links a {
  text-decoration: none;
  font-size: 14px;
  color: var(--ink-soft);
}

.nav-links a:hover { color: var(--accent-deep); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: clamp(0.5rem, 2vw, 1rem);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.theme-toggle:hover { border-color: var(--accent-deep); color: var(--accent-deep); }

.theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: inline; }
}

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(3rem, 10vw, 6rem) clamp(1.5rem, 6vw, 4rem) clamp(3rem, 8vw, 5rem);
}

.hero-triangle {
  position: absolute;
  top: 0;
  right: 0;
  width: min(45vw, 420px);
  height: min(45vw, 420px);
  background: var(--accent);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  opacity: 0.9;
}

.hero-inner {
  position: relative;
  max-width: 640px;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.08;
  margin: 0 0 1.25rem;
}

.hero-name {
  font-size: clamp(2.8rem, 8vw, 4.8rem);
}

.badge {
  display: inline-block;
  background: var(--accent-badge-bg);
  color: var(--accent-badge-text);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.hero-position {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 0.75rem;
}

.hero-bio {
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 520px;
  margin: 0 0 2rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}

.btn-primary:hover { background: var(--accent-deep); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn-secondary:hover { border-color: var(--accent-deep); color: var(--accent-deep); }

/* Sections */
.section {
  padding: clamp(3rem, 8vw, 5rem) clamp(1.5rem, 6vw, 4rem);
  border-top: 1px solid var(--hairline);
  max-width: 980px;
  margin: 0 auto;
}

.section-label {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 2rem;
}

/* Experience timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--hairline);
}

.timeline-item:last-child { border-bottom: none; padding-bottom: 0; }

.timeline-when {
  font-size: 13px;
  color: var(--muted);
  padding-top: 3px;
}

.timeline-role {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 0.75rem;
}

.timeline-org {
  font-weight: 400;
  color: var(--ink-soft);
}

.timeline-body ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.timeline-body li { margin-bottom: 0.4rem; }

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 420px));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 1.75rem;
}

.project-card h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 0.75rem 0 0.75rem;
}

.project-desc {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 1rem;
}

.project-stack {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 1rem;
}

.project-link {
  display: inline-block;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--accent-deep);
  border-bottom: 1px solid transparent;
}

.project-link:hover { border-bottom-color: var(--accent-deep); }

.status-badge {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius);
}

.status-progress {
  background: #FAEEDA;
  color: #854F0B;
}

.project-card-placeholder {
  background: transparent;
  border: 1px dashed var(--hairline);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
}

.project-card-placeholder h3 {
  color: var(--muted);
  margin-top: 0;
}

.project-card-placeholder .project-desc {
  color: var(--muted);
  margin: 0;
}

.earlier-label {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 1rem;
}

.earlier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.earlier-item {
  border-top: 1px solid var(--hairline);
  padding-top: 1rem;
}

.earlier-title {
  font-size: 14.5px;
  font-weight: 500;
  margin: 0 0 0.4rem;
}

.earlier-desc {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0;
}

/* Elsewhere */
.elsewhere-intro {
  font-size: 15px;
  color: var(--ink-soft);
  margin: -1rem 0 1.75rem;
}

.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 1.5rem;
}

.tags-plain {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
}

.tag-icon { font-size: 14px; line-height: 1; }

button.tag-popup {
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  padding: 13px 24px;
  border: 1.5px solid var(--accent);
  background: var(--surface-alt);
  color: var(--accent-deep);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

button.tag-popup .tag-icon { font-size: 17px; }

.tag-group:hover .tag-popup,
.tag-group:focus-within .tag-popup {
  border-color: var(--accent-deep);
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(212, 83, 126, 0.22);
}

.tag-plain {
  background: var(--bg);
  color: var(--ink-soft);
  cursor: default;
}

.tag-group {
  position: relative;
  display: inline-flex;
}

/* Small always-hoverable strip directly under the tag, exactly its width, so the
   mouse never leaves .tag-group while crossing into the popup below. Kept narrow
   (14px) and pinned to the tag's own width so it can't shadow neighboring tags
   or anything further down the page. */
.tag-group::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 14px;
}

/* Invisible bridge: keeps :hover alive across the gap between the tag and the popup below it. */
.tag-popup-panel {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 50%;
  width: 320px;
  padding-top: 14px;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s;
}

.tag-popup-panel-right {
  left: auto;
  right: 0;
  transform: none;
}

.tag-popup-panel-wide {
  width: 460px;
}

.tag-group:hover .tag-popup-panel,
.tag-group:focus-within .tag-popup-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.popup-card {
  position: relative;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: 0 20px 40px var(--shadow);
  transform: translateY(-6px);
  transition: transform 0.18s ease;
}

.tag-group:hover .popup-card,
.tag-group:focus-within .popup-card {
  transform: translateY(0);
}

.popup-card::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  border-top: 1px solid var(--hairline);
  transform: translateX(-50%) rotate(45deg);
}

.tag-popup-panel-right .popup-card::before {
  left: auto;
  right: 28px;
  transform: rotate(45deg);
}

.photo-grid {
  columns: 2;
  column-gap: 8px;
}

.photo-thumb {
  position: relative;
  display: block;
  break-inside: avoid;
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--hairline);
}

.photo-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

.photo-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 8px 10px 7px;
  font-size: 12px;
  line-height: 1.3;
  color: #fff;
  background: linear-gradient(to top, rgba(15, 14, 12, 0.85), rgba(15, 14, 12, 0));
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.photo-thumb:hover .photo-caption,
.photo-thumb:focus-visible .photo-caption {
  opacity: 1;
  transform: translateY(0);
}

.photo-thumb:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

.stamp-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.stamp {
  flex: 0 0 calc(25% - 7.5px);
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px 4px 10px;
  text-align: center;
  background: var(--bg);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.stamp:nth-child(4n+1) { transform: rotate(-1.2deg); }
.stamp:nth-child(4n+2) { transform: rotate(0.8deg); }
.stamp:nth-child(4n+3) { transform: rotate(-0.5deg); }
.stamp:nth-child(4n)   { transform: rotate(1deg); }

.stamp:hover, .stamp:focus-visible {
  border-color: var(--accent);
  background: var(--surface-alt);
  transform: rotate(0deg) scale(1.06);
  box-shadow: 0 8px 18px rgba(212, 83, 126, 0.16);
  outline: none;
}

.stamp-flag {
  width: 34px;
  height: 25px;
  border-radius: 3px;
  display: block;
  margin: 0 auto 8px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px rgba(30, 29, 26, 0.1), 0 2px 4px rgba(30, 29, 26, 0.12);
}

.stamp-country {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  margin: 0;
}

.stamp:hover .stamp-country,
.stamp:focus-visible .stamp-country {
  color: var(--accent-deep);
}

.popup-caption {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  margin: 8px 0 0;
}

/* Footer */
.footer {
  padding: clamp(3rem, 8vw, 5rem) clamp(1.5rem, 6vw, 4rem) 4rem;
  border-top: 1px solid var(--hairline);
}

.footer-label {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 1rem;
}

.footer h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 1.5rem;
}

.footer-links {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.footer-links a {
  text-decoration: none;
  font-size: 15px;
  color: var(--accent-deep);
  border-bottom: 1px solid transparent;
}

.footer-links a:hover { border-bottom-color: var(--accent-deep); }

.footer-copy {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* Responsive */
@media (max-width: 720px) {
  .timeline-item { grid-template-columns: 1fr; gap: 0.5rem; }
  .nav-links { gap: 1rem; }
  .nav-links a { font-size: 13px; }

  /* Hover-to-reveal doesn't exist on touch, so the "Elsewhere" popups
     become always-open cards stacked in normal flow instead of
     absolutely-positioned overlays anchored to the trigger button. */
  .tags-wrap { flex-direction: column; align-items: stretch; gap: 0; }
  .tag-group { display: block; margin-bottom: 14px; }
  .tag-group::after { display: none; }
  button.tag-popup { width: 100%; cursor: default; }
  .tag-group:hover .tag-popup,
  .tag-group:focus-within .tag-popup { transform: none; box-shadow: none; }

  .tag-popup-panel,
  .tag-popup-panel-right,
  .tag-popup-panel-wide {
    position: static;
    width: 100%;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    padding-top: 10px;
  }

  .popup-card,
  .tag-group:hover .popup-card,
  .tag-group:focus-within .popup-card {
    transform: none;
  }

  .popup-card::before { display: none; }
  .stamp { flex-basis: calc(33.333% - 7px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn { transition: none; }
}
