/* Palette: chart paper, navy ink, chart blue, airspace magenta */
:root {
  --paper: #F3F6F9;
  --panel: #FFFFFF;
  --ink: #13243A;
  --muted: #4E5F73;
  --line: #CCD6E0;
  --blue: #1E6FD9;
  --magenta: #A3246E;
  --tag: #E4ECF4;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 1080px;
}
/* Dark theme: follows the system unless the visitor picks light or dark with the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1B2B;
    --panel: #15253A;
    --ink: #E6EDF5;
    --muted: #9FB0C3;
    --line: #2A3C53;
    --blue: #6AA8FF;
    --magenta: #E070AE;
    --tag: #1C2F47;
  }
}
:root[data-theme="dark"] {
  --paper: #0F1B2B;
  --panel: #15253A;
  --ink: #E6EDF5;
  --muted: #9FB0C3;
  --line: #2A3C53;
  --blue: #6AA8FF;
  --magenta: #E070AE;
  --tag: #1C2F47;
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; font-size: 1.125rem; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.nav { display: flex; gap: 22px; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; font-size: 0.95rem; }
.nav a:hover { color: var(--blue); }
.nav__cta { border: 1.5px solid var(--ink); padding: 6px 14px; border-radius: 999px; }
.nav__cta:hover { border-color: var(--blue); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; padding: 0; }
.theme-toggle:hover { border-color: var(--blue); color: var(--blue); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (max-width: 760px) {
  .nav li:not(.nav__keep) { display: none; }
}

/* Hero */
.hero { padding: 72px 0 40px; }
.hero__grid { display: grid; grid-template-columns: 1fr 260px; gap: 48px; align-items: center; }
.hero__name { font-size: clamp(3rem, 9vw, 6.75rem); font-weight: 700; letter-spacing: -0.035em; line-height: 0.95; }
.hero__role { font-size: clamp(1.25rem, 2.4vw, 1.6rem); font-weight: 500; color: var(--muted); margin: 14px 0 0; }
.route { width: min(100%, 560px); height: 40px; margin: 18px 0 6px; overflow: visible; }
.route__path { fill: none; stroke: var(--magenta); stroke-width: 2.5; stroke-dasharray: 8 7; }
.route__wpt { fill: var(--paper); stroke: var(--magenta); stroke-width: 2.5; }
.route__wpt--end { fill: var(--magenta); }
.hero__lede { max-width: 60ch; font-size: 1.15rem; margin: 6px 0 28px; }
.hero__links { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-block; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.95rem; background: var(--panel); }
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn--solid { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn--solid:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn--solid { color: #0F1B2B; } }
:root[data-theme="dark"] .btn--solid { color: #0F1B2B; }

/* Compass dial around the photo: the page's one signature element */
.dial { position: relative; margin: 0; width: 260px; aspect-ratio: 1; }
.dial__ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.dial__outer { fill: none; stroke: var(--line); stroke-width: 1.5; }
.dial__ticks line { stroke: var(--muted); stroke-width: 1.2; }
.dial__ticks line.major { stroke: var(--ink); stroke-width: 2; }
.dial__card { font: 600 13px var(--font); fill: var(--magenta); text-anchor: middle; }
.dial__photo { position: absolute; inset: 22%; width: 56%; height: 56%; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 4px var(--paper), 0 0 0 5.5px var(--ink); }
@media (max-width: 760px) {
  .hero { padding-top: 40px; }
  .hero__grid { grid-template-columns: 1fr; gap: 28px; }
  .dial { width: 180px; order: -1; }
}

/* Load moment: the route draws once */
@media (prefers-reduced-motion: no-preference) {
  .route__path { stroke-dasharray: 700; stroke-dashoffset: 700; animation: fly 1.6s ease-out 0.2s forwards; }
  .route__wpt--end { opacity: 0; animation: arrive 0.3s ease-out 1.7s forwards; }
  @keyframes fly { to { stroke-dashoffset: 0; stroke-dasharray: 8 7; } }
  @keyframes arrive { to { opacity: 1; } }
}

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 56px 0 0; border-top: 1px solid var(--line); }
.facts div { padding: 18px 20px 0 0; }
.facts dt { font-size: 0.85rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
@media (max-width: 760px) { .facts { grid-template-columns: 1fr; } .facts div { padding-right: 0; } }

/* Sections */
.section { padding: 72px 0; border-top: 1px solid var(--line); }
.two-col { display: grid; grid-template-columns: 220px 1fr; gap: 40px; }
.two-col > h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; position: sticky; top: 92px; align-self: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; gap: 20px; } .two-col > h2 { position: static; } }
@media (max-width: 760px) { .section { padding: 52px 0; } }
.prose p { max-width: 66ch; margin: 0 0 1em; }
.prose p:last-child { margin-bottom: 0; }

/* Experience as a flight route: each job is a waypoint on one line */
.flightlog { position: relative; padding-left: 32px; }
.flightlog::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; border-left: 2px dashed var(--line); }
.leg { position: relative; padding-bottom: 40px; }
.leg:last-child { padding-bottom: 0; }
.leg::before { content: ""; position: absolute; left: -32px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 2.5px solid var(--magenta); }
.leg--current::before { background: var(--magenta); }
.leg__head h3 { font-size: 1.25rem; font-weight: 600; }
.leg__org { margin: 4px 0 0; font-weight: 500; color: var(--blue); }
.leg__when { margin: 2px 0 12px; color: var(--muted); font-size: 0.95rem; }
.leg__notes { list-style: disc; padding-left: 1.1em; max-width: 68ch; }
.leg__notes li { margin: 0 0 6px; }
.leg__notes li::marker { color: var(--muted); }
.leg--compact .leg__notes li { color: var(--muted); }

/* Skills */
.skills { display: grid; gap: 24px; }
.skills__group h3 { font-size: 1rem; font-weight: 600; margin-bottom: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags li { background: var(--tag); padding: 5px 12px; border-radius: 6px; font-size: 0.93rem; }

/* Projects */
.projects { display: grid; gap: 4px; }
.project { display: grid; grid-template-columns: 72px 1fr; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.project:last-child { border-bottom: 0; }
.project img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; background: var(--panel); }
.project--noimg { grid-template-columns: 1fr; padding-left: 90px; }
.project h3 { font-size: 1.1rem; font-weight: 600; }
.project h3 a { color: var(--ink); }
.project h3 a:hover { color: var(--blue); }
.project p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }
@media (max-width: 760px) { .project--noimg { padding-left: 0; } }

/* Writing */
.articles li { border-bottom: 1px solid var(--line); }
.articles a { display: block; padding: 12px 0; color: var(--ink); text-decoration: none; font-weight: 500; }
.articles a:hover { color: var(--blue); }
.more { margin: 18px 0 0; font-weight: 600; }

/* Education */
.edu { display: grid; gap: 18px; }
.edu h3 { font-size: 1.1rem; font-weight: 600; }
.edu p { margin: 2px 0 0; color: var(--muted); }

/* Footer */
.footer { background: var(--ink); color: var(--paper); padding: 72px 0 40px; }
.footer h2 { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 700; letter-spacing: -0.02em; }
.footer__lede { max-width: 56ch; color: color-mix(in srgb, var(--paper) 75%, var(--ink)); margin: 12px 0 18px; }
.footer a { color: var(--paper); }
.footer__mail { font-size: clamp(1.15rem, 3vw, 1.6rem); font-weight: 600; }
.footer__links { display: flex; flex-wrap: wrap; gap: 20px; margin: 28px 0 0; }
.footer__fine { margin: 48px 0 0; font-size: 0.85rem; color: color-mix(in srgb, var(--paper) 60%, var(--ink)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .footer { background: #091320; color: var(--ink); }
  :root:not([data-theme="light"]) .footer a { color: var(--ink); }
  :root:not([data-theme="light"]) .footer__lede, :root:not([data-theme="light"]) .footer__fine { color: var(--muted); }
}
:root[data-theme="dark"] .footer { background: #091320; color: var(--ink); }
:root[data-theme="dark"] .footer a { color: var(--ink); }
:root[data-theme="dark"] .footer__lede, :root[data-theme="dark"] .footer__fine { color: var(--muted); }

/* Easter eggs */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); max-width: min(92vw, 560px); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 500; font-size: 0.95rem; box-shadow: 0 8px 24px rgba(19, 36, 58, 0.25); z-index: 20; transition: transform 0.3s ease; pointer-events: none; }
.toast--show { transform: translate(-50%, 0); }
.dial { cursor: pointer; }
.dial__ring { transition: transform 1.6s cubic-bezier(.2,.7,.2,1); transform-origin: 50% 50%; }
.plane { position: fixed; top: 30%; left: -60px; color: var(--magenta); z-index: 20; pointer-events: none; animation: plane-fly 3.2s ease-in-out forwards; }
@keyframes plane-fly {
  0% { transform: translate(0, 0) rotate(90deg); }
  50% { transform: translate(55vw, -12vh) rotate(80deg); }
  100% { transform: translate(115vw, -4vh) rotate(100deg); }
}
.barrel-roll body { animation: barrel 1.3s ease-in-out; }
@keyframes barrel { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .toast, .dial__ring { transition: none; }
}
/* Night-flying cockpit mode: red instrument lighting that protects night vision */
:root[data-cockpit] {
  --paper: #0A0606; --panel: #140B0B; --ink: #FF6B5A; --muted: #C9564A; --line: #3A1A17;
  --blue: #FF8A70; --magenta: #FFB199; --tag: #1F0F0E; color-scheme: dark;
}
:root[data-cockpit] .dial__photo { filter: sepia(1) saturate(4) hue-rotate(-30deg) brightness(.8); }
:root[data-cockpit] .btn--solid { color: #0A0606; }
:root[data-cockpit] .footer { background: #050303; color: var(--ink); }
:root[data-cockpit] .footer a { color: var(--ink); }
.logbook { background: var(--panel); border-top: 2px dashed var(--magenta); border-bottom: 2px dashed var(--magenta); padding: 48px 0; }
.logbook h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 10px; }
.logbook ul { list-style: disc; padding-left: 1.2em; margin: 12px 0 22px; max-width: 66ch; }
.logbook li { margin-bottom: 6px; }
.logbook:focus { outline: none; }
