/* ---------- Tokens: light box on / off ---------- */
:root {
  --glass: #E8EDF3;
  --sheet: #F6F8FB;
  --ink: #15202E;
  --muted: #5A6677;
  --rule: #C9D2DD;
  --cobalt: #2346D8;
  --marker: #F4B22E;
  --film: #0F1B2B;
  --glow: rgba(120, 170, 255, .55);

  --step--1: .875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3125rem;
  --step-2: 1.75rem;
  --step-name: clamp(3rem, 9vw, 7.25rem);

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1180px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --glass: #0E1622; --sheet: #152031; --ink: #E6ECF3; --muted: #94A1B3;
    --rule: #263247; --cobalt: #7E98FF; --film: #050A12; --glow: rgba(140, 180, 255, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --glass: #0E1622; --sheet: #152031; --ink: #E6ECF3; --muted: #94A1B3;
  --rule: #263247; --cobalt: #7E98FF; --film: #050A12; --glow: rgba(140, 180, 255, .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--glass);
  color: var(--ink);
  font-family: "Readex Pro", system-ui, sans-serif;
  font-size: var(--step-0);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2.5px solid var(--cobalt); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; inset-inline-start: 12px; top: -60px; background: var(--ink); color: var(--glass); padding: 8px 14px; border-radius: 6px; z-index: 10; }
.skip:focus { top: 12px; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: color-mix(in srgb, var(--glass) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  text-decoration: none; font-weight: 600; font-size: 1.15rem;
}
.bar-nav { display: flex; align-items: center; gap: clamp(14px, 3vw, 28px); font-size: var(--step--1); font-weight: 400; }
.bar-nav a { text-decoration: none; padding: 6px 0; border-bottom: 1.5px solid transparent; }
.bar-nav a:hover { border-color: var(--ink); }
.theme {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--rule); border-radius: 50%; background: transparent; cursor: pointer;
}
.theme:hover { border-color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  max-width: var(--max); margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) var(--gutter) clamp(56px, 9vw, 112px);
  display: grid;
  grid-template-columns: minmax(240px, 380px) 1fr;
  gap: clamp(28px, 6vw, 88px);
  align-items: center;
}

/* The film: a hung X-ray on the light box */
.film { margin: 0; position: relative; padding: 14px; background: var(--film); border-radius: 6px; }
.reg { position: absolute; width: 14px; height: 14px; border-color: var(--marker); border-style: solid; border-width: 0; }
.reg-a { top: -7px; inset-inline-start: -7px; border-top-width: 2px; border-inline-start-width: 2px; }
.reg-b { top: -7px; inset-inline-end: -7px; border-top-width: 2px; border-inline-end-width: 2px; }
.reg-c { bottom: -7px; inset-inline-start: -7px; border-bottom-width: 2px; border-inline-start-width: 2px; }
.reg-d { bottom: -7px; inset-inline-end: -7px; border-bottom-width: 2px; border-inline-end-width: 2px; }

.film-window { position: relative; aspect-ratio: 4 / 5; overflow: hidden; border-radius: 2px; background: #1a2638; }
.photo {
  position: absolute; inset: 0;
  background-size: cover; background-position: center 25%;
  display: grid; place-items: center;
}
.photo-neg { filter: grayscale(1) invert(1) contrast(1.25) brightness(.95) sepia(.25) hue-rotate(170deg); }
.photo-pos { clip-path: inset(0 0 0 0); transition: clip-path .9s cubic-bezier(.6, 0, .2, 1); }
.photo .initials {
  font-weight: 200; font-size: clamp(5rem, 14vw, 9rem); line-height: 1;
  color: #DCE6F5;
}
.photo-pos .initials { color: #DCE6F5; }
.photo-pos:not(.has-img) { background: linear-gradient(160deg, #24395E, #12203A); }
.photo-neg:not(.has-img) { background: #0b1220; }

.scanline {
  position: absolute; inset-inline: 0; top: 0; height: 2px;
  background: #CFE0FF;
  box-shadow: 0 0 18px 4px var(--glow);
  opacity: 0; pointer-events: none;
}

/* the one orchestrated moment: scan the film into a photo */
.is-scanning .photo-pos { animation: reveal 1.9s cubic-bezier(.55, .05, .25, 1) .35s both; }
.is-scanning .scanline { animation: sweep 1.9s cubic-bezier(.55, .05, .25, 1) .35s both; }
@keyframes reveal { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes sweep {
  0% { top: 0; opacity: 1; }
  92% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}
.film.xray .photo-pos { clip-path: inset(100% 0 0 0); }

.film-caption {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 12px; color: #9FB0C8; font-size: var(--step--1);
}
.xray-toggle {
  background: transparent; color: #DCE6F5; cursor: pointer;
  border: 1px solid #3A4A63; border-radius: 999px; padding: 4px 14px; font-size: var(--step--1);
  white-space: nowrap;
}
.xray-toggle:hover { border-color: #DCE6F5; }
.xray-toggle[aria-pressed="true"] { background: #DCE6F5; color: var(--film); border-color: #DCE6F5; }

.hero-text { min-width: 0; }
.role { margin: 0 0 10px; color: var(--muted); font-size: var(--step-1); font-weight: 300; line-height: 1.4; }
.name {
  margin: 0; font-size: var(--step-name); line-height: 1.02; letter-spacing: -.025em;
  display: flex; flex-wrap: wrap; column-gap: .28em;
}
.name .w {
  font-weight: var(--w, 340);
  transition: font-weight .25s ease-out;
}
.intro { margin: 22px 0 0; max-width: 34em; font-size: var(--step-1); line-height: 1.75; }

/* Contact */
.contact { list-style: none; padding: 0; margin: 32px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.contact a, .contact button {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 18px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: transparent;
  text-decoration: none; font-weight: 400; font-size: var(--step--1); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.contact a:hover, .contact button:hover { background: var(--ink); color: var(--glass); }
.contact li:first-child > * { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.contact li:first-child > *:hover { background: var(--ink); border-color: var(--ink); color: var(--glass); }
.contact svg { width: 17px; height: 17px; flex: none; }

/* ---------- Projects ---------- */
.projects { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) clamp(72px, 10vw, 128px); }
.projects-head {
  display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 18px;
  padding-bottom: 20px; border-bottom: 1.5px solid var(--ink);
}
.projects-head h2 { margin: 0; font-size: var(--step-2); font-weight: 500; line-height: 1.2; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  border: 1px solid var(--rule); background: transparent; border-radius: 999px;
  padding: 5px 14px; font-size: var(--step--1); cursor: pointer;
}
.filters button:hover { border-color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--glass); }
.filters .count { color: var(--muted); margin-inline-start: 4px; }
.filters button[aria-pressed="true"] .count { color: inherit; opacity: .7; }

.index { list-style: none; margin: 0; padding: 0; }
.item { border-bottom: 1px solid var(--rule); }
.item-head {
  width: 100%; display: grid; align-items: baseline; text-align: start;
  grid-template-columns: 1fr auto auto 22px;
  gap: 8px 28px; padding: 22px 0; background: none; border: 0; cursor: pointer;
}
.item-title { font-size: var(--step-2); font-weight: 400; line-height: 1.3; transition: font-weight .2s; }
.item-sum { grid-column: 1; color: var(--muted); font-size: var(--step-0); max-width: 40em; }
.item-cat { grid-row: 1; grid-column: 2; font-size: var(--step--1); color: var(--muted); white-space: nowrap; }
.item-year { grid-row: 1; grid-column: 3; font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; }
.item-head:hover .item-title { font-weight: 600; }
.plus { grid-row: 1 / span 2; grid-column: 4; align-self: center; width: 22px; height: 22px; position: relative; }
.plus::before, .plus::after { content: ""; position: absolute; inset: 10px 0 auto; height: 1.5px; background: var(--ink); transition: transform .3s; }
.plus::after { transform: rotate(90deg); }
.item.open .plus::after { transform: rotate(0deg); }

.item-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s cubic-bezier(.4, 0, .2, 1); }
.item.open .item-body { grid-template-rows: 1fr; }
.item-inner { overflow: hidden; }
.item-content {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(20px, 4vw, 48px);
  padding: 4px 0 32px;
}
.item-content.no-img { grid-template-columns: 1fr; }
.item-details { margin: 0; padding: 0; list-style: none; max-width: 36em; }
.item-details li { position: relative; padding-inline-start: 20px; margin-bottom: 10px; }
.item-details li::before {
  content: ""; position: absolute; inset-inline-start: 0; top: .78em;
  width: 8px; height: 8px; border: 1.5px solid var(--marker); border-radius: 50%;
}
.stack { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; }
.stack li { font-size: var(--step--1); padding: 2px 10px; border-radius: 4px; background: var(--sheet); border: 1px solid var(--rule); direction: ltr; }
.links { display: flex; gap: 16px; margin-top: 18px; }
.links a { color: var(--cobalt); font-weight: 500; text-underline-offset: 4px; }

.shot { margin: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.shot img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; object-position: top; }
.shot.contain { display: grid; place-items: center; padding: 36px; min-height: 220px; background: #F6F8FB; }
.shot.contain img { object-fit: contain; max-height: 160px; width: auto; }

.empty { color: var(--muted); padding: 28px 0; }

/* ---------- Certificates ---------- */
.certs { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) clamp(72px, 10vw, 128px); }
.cert-list { list-style: none; margin: 0; padding: 0; }
.cert {
  display: grid; grid-template-columns: minmax(220px, 420px) 1fr;
  gap: clamp(20px, 4vw, 56px); align-items: center;
  padding: 32px 0; border-bottom: 1px solid var(--rule);
}
/* the certificate hangs on the light box like the portrait film */
.cert-shot {
  display: block; padding: 10px; background: var(--film); border-radius: 6px;
  transition: transform .25s ease-out;
}
.cert-shot img { border-radius: 2px; width: 100%; height: auto; background: #fff; }
.cert-shot:hover { transform: translateY(-3px); }
.cert-title { margin: 0; font-size: var(--step-2); font-weight: 400; line-height: 1.3; }
.cert-issuer { margin: 8px 0 0; font-size: var(--step-0); }
.cert-note { margin: 4px 0 0; color: var(--muted); font-size: var(--step--1); }
.cert-meta { display: flex; flex-wrap: wrap; gap: 8px 36px; margin: 20px 0 0; }
.cert-meta dt { color: var(--muted); font-size: var(--step--1); }
.cert-meta dd { margin: 0; font-weight: 400; }
.cert-link { display: inline-block; margin-top: 20px; color: var(--cobalt); font-weight: 500; text-underline-offset: 4px; }

.cert-plain { grid-template-columns: 1fr; padding: 24px 0; }
.cert-plain .cert-meta { margin-top: 12px; }

/* ---------- Project results ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 12px 40px; margin: 0 0 24px; }
.stats div { display: flex; flex-direction: column; }
.stats dd { margin: 0; font-size: var(--step-2); font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats dt { color: var(--muted); font-size: var(--step--1); }

/* ---------- Experience: a timeline, newest first ---------- */
.exp-list { list-style: none; margin: 0; padding: 0; }
.exp {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 8px clamp(20px, 4vw, 56px);
  padding: 28px 0; border-bottom: 1px solid var(--rule);
}
.exp-when { margin: 0; color: var(--muted); font-size: var(--step--1); padding-top: .4em; font-variant-numeric: tabular-nums; }
.exp-title { margin: 0; font-size: var(--step-1); font-weight: 500; line-height: 1.35; }
.exp-org { margin: 2px 0 14px; color: var(--muted); }

/* ---------- Awards ---------- */
.award-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.award { padding: 28px clamp(0px, 2vw, 28px) 28px 0; border-bottom: 1px solid var(--rule); }
.award-title { margin: 0; font-size: var(--step-1); font-weight: 500; line-height: 1.35; }
.award-detail { margin: 8px 0 0; color: var(--muted); font-size: var(--step-0); }
.award-year { margin: 12px 0 0; font-size: var(--step--1); color: var(--muted); }

/* ---------- Footer ---------- */
.foot {
  max-width: var(--max); margin: 0 auto; padding: clamp(48px, 8vw, 88px) var(--gutter) 40px;
  border-top: 1.5px solid var(--ink);
}
.foot-line { margin: 0; font-size: var(--step-2); font-weight: 300; line-height: 1.35; max-width: 20em; }
.contact-foot { margin-top: 24px; }
.foot-meta { margin: 48px 0 0; color: var(--muted); font-size: var(--step--1); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 16px);
  background: var(--ink); color: var(--glass); padding: 10px 20px; border-radius: 999px;
  font-size: var(--step--1); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .hero { padding-top: 20px; gap: 24px; }
  .film { width: 62%; max-width: 240px; padding: 10px; }
  .film-window { aspect-ratio: 1 / 1; }
  #filmLabel { display: none; }
  .film-caption { justify-content: flex-start; padding-top: 10px; }
  .intro { margin-top: 14px; }
  .contact { margin-top: 22px; }
  .item-head { grid-template-columns: 1fr auto 22px; }
  .item-cat { display: none; }
  .item-year { grid-column: 2; }
  .plus { grid-column: 3; }
  .item-title { font-size: var(--step-1); }
  .item-content { grid-template-columns: 1fr; }
  .cert { grid-template-columns: 1fr; }
  .exp { grid-template-columns: 1fr; }
  .exp-when { padding-top: 0; }
  .bar-nav a[href="#experience"], .bar-nav a[href="#certificates"] { display: none; }
  .contact a, .contact button { padding: 9px 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
