/* Layout: flat and light. Sticky bar, split hero, dated timeline, tinted bands
   for alternate sections, dark contact block. */
:root {
  --bg: #e8edf2;
  --surface: #f7f9fb;
  --band: #dce4ec;
  --fg: #0f1e2e;
  --muted: #4a5868;
  --line: #c8d3de;
  --accent: #1d5a8a;
  --accent-ink: #ffffff;
  --accent-soft: #cfdeeb;
  --navy: #13293f;
  --ink-block: #0b1b2b;
  --ink-fg: #e8eef3;
  --ink-muted: #9fb0bf;
  --ink-accent: #8cc9f2;
  --ink-line: #253a4f;

  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1721;
    --surface: #152231;
    --band: #121e2b;
    --fg: #e6edf3;
    --muted: #9aa9b7;
    --line: #26384a;
    --accent: #6cb6e8;
    --accent-ink: #08131d;
    --accent-soft: #17344a;
    --ink-block: #08111a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; }
p { margin: 0 0 .9rem; text-wrap: pretty; }
.muted { color: var(--muted); }
code { font: 400 .88em var(--font-mono); background: var(--accent-soft); padding: .05em .35em; border-radius: 3px; }

.backdrop { display: none; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

.wrap {
  max-width: 1080px; margin-inline: auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.panel .wrap, .open .wrap { padding-block: 4.5rem; }
#about, #videos { background: var(--band); border-block: 1px solid var(--line); }

/* Navy bands: the same components re-tinted by scoping the tokens. */
.bar, .hero, #ai {
  --bg: var(--navy);
  --surface: #1a344f;
  --band: #1a344f;
  --fg: #eaf1f7;
  --muted: #a8bbcc;
  --line: #2b4661;
  --accent: #8cc9f2;
  --accent-ink: #08131d;
  --accent-soft: #24496b;
  background: var(--navy);
  color: var(--fg);
}
.hero { border-bottom: 1px solid #0d1f31; }

/* ---------- Top bar ---------- */
.bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; }
.mark { flex: none; display: inline-flex; align-items: center; min-height: 44px; font: 600 1.35rem var(--font-display); color: var(--fg); text-decoration: none; letter-spacing: .02em; }
.mark span { color: var(--accent); }
.bar nav { display: flex; align-items: center; gap: .15rem; font-size: .93rem; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.bar nav::-webkit-scrollbar { display: none; }
.bar nav a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding-inline: .7rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.bar nav a:hover { color: var(--fg); }
.bar nav a[aria-current="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.bar nav .nav-cta { min-height: 36px; margin-left: .4rem; color: var(--accent); font-weight: 600; border: 1px solid var(--accent); border-radius: 4px; }
.bar nav .nav-cta:hover { background: var(--accent); color: var(--accent-ink); }
.menu-toggle { display: none; align-items: center; justify-content: center; width: 44px; height: 44px; margin-right: -.5rem; padding: 0; background: none; border: 0; color: var(--fg); cursor: pointer; }
.menu-toggle .m-close, .menu-toggle[aria-expanded="true"] .m-open { display: none; }
.menu-toggle[aria-expanded="true"] .m-close { display: inline; }
.lang { display: flex; align-items: center; margin-left: .6rem; }
.lang button { display: grid; place-items: center; width: 40px; height: 44px; padding: 0; background: none; border: 0; cursor: pointer; opacity: .6; transition: opacity .15s; }
.lang button:hover, .lang button[aria-pressed="true"] { opacity: 1; }
.lang svg { display: block; width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.lang button[aria-pressed="true"] svg { box-shadow: 0 0 0 2px var(--accent); }
@media (max-width: 839px) {
  .menu-toggle { display: inline-flex; order: 3; }
  .lang { order: 2; margin-left: auto; }
  .bar nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; padding: .5rem 20px 1rem; overflow: visible; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px rgba(0, 0, 0, .12); }
  .bar.menu-open nav { display: flex; }
  .bar nav a { border-bottom: 1px solid var(--line); padding-inline: 0; font-size: 1.05rem; }
  .bar nav a[aria-current="true"] { border-bottom-color: var(--accent); }
  .bar nav .nav-cta { justify-content: center; margin: .9rem 0 0; padding-inline: 1rem; border: 1px solid var(--accent); }
}

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; min-height: 44px; padding: .55rem 1.2rem; border: 1px solid var(--line); border-radius: 4px; color: var(--fg); background: var(--surface); text-decoration: none; font-weight: 500; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.1); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.dl { position: relative; }
.dl-toggle { cursor: pointer; font: inherit; font-weight: 500; }
.dl-toggle .caret { margin-left: .5em; transition: transform .2s ease; }
.dl-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.btn:active { transform: translateY(1px); }
.dl-menu { position: absolute; z-index: 15; top: calc(100% + .45rem); left: 0; width: max(100%, 17.5rem); max-width: calc(100vw - 40px); margin: 0; padding: .35rem; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 16px 36px rgba(0, 0, 0, .4);
  opacity: 0; visibility: hidden; transform: translateY(-6px); transform-origin: top left; transition: opacity .16s ease, transform .16s ease, visibility 0s .16s; }
.dl-toggle[aria-expanded="true"] + .dl-menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.dl-menu a { display: flex; align-items: center; gap: .85rem; min-height: 56px; padding: .45rem .75rem; color: var(--fg); text-decoration: none; border-radius: 4px; }
.dl-menu .fi { flex: none; color: var(--accent); }
.dl-menu .t { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.dl-menu b { font-weight: 600; }
.dl-menu small { color: var(--muted); font-size: .82rem; }
.dl-menu .go { flex: none; color: var(--muted); opacity: 0; transform: translateY(-3px); transition: opacity .15s, transform .15s; }
.dl-menu a:hover, .dl-menu a:focus-visible { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.dl-menu a:hover .go, .dl-menu a:focus-visible .go { opacity: 1; transform: none; color: var(--accent); }
.dl-menu a:focus-visible { outline-offset: -2px; }
@media (hover: none) { .dl-menu .go { opacity: .7; transform: none; } }

/* ---------- Hero ---------- */
.hero { padding-block: 4rem 4.5rem; }
.hero-grid { display: grid; grid-template-columns: 1fr; gap: 2.5rem; align-items: center; }
@media (min-width: 840px) { .hero-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 4rem; } }
.hero-text { min-width: 0; }
.eyebrow { font: 500 .8rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 1rem; }
.hero h1 { font: 600 clamp(2.3rem, 5.5vw, 3.7rem)/1.05 var(--font-display); letter-spacing: -.02em; margin-bottom: 1.25rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 40em; margin-bottom: 1.75rem; }
.lead b { color: var(--fg); font-weight: 600; }
.facts { display: flex; flex-wrap: wrap; gap: 1.25rem 3rem; margin: 2.25rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.facts dt { font: 500 .72rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: .15rem 0 0; font-weight: 500; }
.portrait-frame { justify-self: start; max-width: 300px; width: 100%; }
@media (max-width: 839px) { .portrait-frame { max-width: 200px; order: -1; } }
@media (min-width: 840px) { .portrait-frame { justify-self: end; } }
.portrait { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); box-shadow: 14px 14px 0 var(--accent-soft); }

/* ---------- Section headings ---------- */
.section-head { margin-bottom: 2rem; }
.kicker { font: 500 .75rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: .4rem; }
h2 { font: 600 clamp(1.7rem, 3vw, 2.2rem)/1.15 var(--font-display); letter-spacing: -.01em; }
.section-head p { color: var(--muted); max-width: 62ch; margin: .75rem 0 0; }

/* ---------- Experience timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { display: grid; grid-template-columns: 1fr; gap: .25rem 2.5rem; padding-block: 1.6rem; border-top: 1px solid var(--line); }
.timeline > li:last-child, .timeline > li:has(+ li[hidden]) { border-bottom: 1px solid var(--line); }
.timeline > li[hidden] { display: none; }
@media (min-width: 760px) { .timeline > li { grid-template-columns: 11rem minmax(0, 1fr); } }
.when { font: 400 .83rem/1.5 var(--font-mono); color: var(--muted); margin: .25rem 0 0; font-variant-numeric: tabular-nums; }
.job { min-width: 0; }
.job h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: .1rem; }
.org { color: var(--accent); font-weight: 500; margin: 0 0 .6rem; }
.points { margin: 0 0 .7rem; padding-left: 1.1rem; max-width: 66ch; }
.points li { margin-bottom: .3rem; padding-left: .15rem; }
.points li::marker { color: var(--muted); }
.stack { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; }
.stack span { font: 400 .76rem var(--font-mono); color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: .05rem .45rem; }

/* ---------- AI section ---------- */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 2rem 3rem; }
.topic { border-top: 2px solid var(--accent); padding-top: .9rem; min-width: 0; }
.topic .ic { display: block; width: 22px; height: 22px; margin-bottom: .6rem; color: var(--accent); }
.topic .ic svg { width: 22px; height: 22px; }
.topic h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.topic p { color: var(--muted); font-size: .95rem; margin: 0; }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 2rem 3rem; }
.skill-group h3 { font: 500 .78rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .75rem; }
.tags { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; }
.tags > * { display: inline-flex; align-items: center; min-height: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: .15rem .65rem; font-size: .9rem; color: var(--fg); text-decoration: none; transition: border-color .15s, color .15s; }
.tags > a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1fr; gap: 2.5rem; }
@media (min-width: 840px) { .about { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 4rem; } }
.prose p { max-width: 62ch; }
.facts-list h3 { font: 500 .78rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .45rem; }
.facts-list > div + div { margin-top: 1.5rem; }
.facts-list p, .facts-list li { font-size: .95rem; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.sub { font: 600 1.4rem var(--font-display); margin: 3.5rem 0 1.25rem; }

/* ---------- Cards and repos ---------- */
.cards, .repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 1.25rem; }
.card, .repo { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; transition: border-color .15s; }
.card:hover, .repo:hover { border-color: var(--accent); }
.card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-bottom: 1px solid var(--line); }
.card-body, .repo { padding: 1.1rem 1.2rem 1.2rem; }
.card-body { display: flex; flex-direction: column; flex: 1; }
.card h4, .repo h4 { font-size: 1rem; margin-bottom: .45rem; line-height: 1.3; }
.repo h4 { font-family: var(--font-mono); font-weight: 500; overflow-wrap: anywhere; }
/* The title link stretches over the whole card, so any click opens the repo. */
.repo { position: relative; cursor: pointer; }
.repo h4 a { text-decoration: none; }
.repo h4 a::after { content: ""; position: absolute; inset: 0; }
.repo:hover h4 a { text-decoration: underline; }
.repo:has(a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.repo h4 a:focus-visible { outline: none; }
.card p, .repo p { font-size: .93rem; color: var(--muted); }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.card .go { margin-top: auto; font-weight: 500; font-size: .93rem; }
.repo .meta { margin: auto 0 0; padding-top: .4rem; font: 400 .78rem var(--font-mono); color: var(--muted); display: flex; gap: 1rem; }
/* "Show more" control: a centered button sitting on a divider line. */
.more { display: flex; align-items: center; gap: 1rem; margin: 2rem 0 0; }
.more::before, .more::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.more[hidden] { display: none; }
.more-toggle { display: inline-flex; align-items: center; gap: .6rem; min-height: 44px; padding: .5rem .9rem .5rem 1.1rem; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; font: 500 .93rem var(--font-body); cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.more-toggle:hover { border-color: var(--accent); color: var(--accent); }
.more-toggle:active { background: var(--band); }
.more-count { font: 500 .75rem var(--font-mono); padding: .1rem .45rem; border-radius: 3px; background: var(--accent-soft); color: var(--accent); }
.more-count[hidden] { display: none; }
.caret { flex: none; transition: transform .2s ease; }
.more-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.repo[hidden], .card[hidden] { display: none; }
.extra { animation: reveal .25s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Video cards: the whole card is one play button */
.card.video { position: relative; cursor: pointer; }
.thumb { position: relative; }
.play-icon { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(11, 27, 43, .78); transition: background .15s, transform .15s; }
.play-icon::after { content: ""; position: absolute; left: 22px; top: 17px; border-style: solid; border-width: 11px 0 11px 17px; border-color: transparent transparent transparent #fff; }
.card.video:hover .play-icon { background: var(--accent); transform: scale(1.06); }
.play { position: absolute; inset: 0; width: 100%; background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: inherit; }
.play:focus-visible { outline-offset: -3px; }

/* Floating video player */
.video-dialog { width: min(960px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); overflow: hidden; }
.video-dialog::backdrop { background: rgba(6, 12, 20, .78); }
.video-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem .5rem .5rem 1.1rem; border-bottom: 1px solid var(--line); }
.video-head h3 { font-size: 1rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-close { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.video-close:hover { background: var(--band); color: var(--fg); }
.video-frame { aspect-ratio: 16 / 9; background: #000; }
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ---------- Contact (dark block) ---------- */
#contact { background: var(--ink-block); color: var(--ink-fg); }
.contact-card { display: grid; grid-template-columns: 1fr; gap: 2.5rem; }
@media (min-width: 840px) { .contact-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4rem; } }
.contact-card .kicker { color: var(--ink-accent); }
.contact-card h2 { color: var(--ink-fg); margin-bottom: .75rem; }
.contact-card p { color: var(--ink-muted); max-width: 48ch; margin-bottom: 1.5rem; }
.contact-card .btn { background: transparent; color: var(--ink-fg); border-color: var(--ink-line); }
.contact-card .btn:hover { border-color: var(--ink-accent); }
.contact-card .btn.primary { background: var(--ink-accent); color: #08131d; border-color: var(--ink-accent); }
.details { margin: 0; display: grid; gap: 1.1rem; align-content: start; }
.details dt { font: 500 .72rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.details dd { margin: .1rem 0 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.details a { color: var(--ink-accent); }
.details > div { display: grid; grid-template-columns: 22px 1fr; column-gap: .85rem; align-items: start; }
.details .i { grid-row: 1 / span 2; width: 22px; height: 22px; margin-top: .1rem; color: var(--ink-accent); }
.btn .i { width: 1.1em; height: 1.1em; margin-right: .5em; vertical-align: -.18em; }
#contact :focus-visible, footer :focus-visible { outline-color: var(--ink-accent); }

footer { background: var(--ink-block); color: var(--ink-muted); border-top: 1px solid var(--ink-line); font-size: .88rem; }
footer a { color: var(--ink-muted); }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding-block: 1.5rem; }

/* ---------- Print: one clean column ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --band: #fff; --fg: #000; --muted: #333; --line: #bbb; --accent: #000; --ink-block: #fff; --ink-fg: #000; --ink-muted: #333; --ink-accent: #000; }
  .bar, .skip, .actions, #ai .topics, #projects, #videos, .sub, .cards, footer, .portrait-frame { display: none !important; }
  .panel .wrap, .open .wrap { padding-block: 1rem; }
  .hero { padding-block: 0 1rem; }
  .hero-grid { grid-template-columns: 1fr; }
  .timeline > li { break-inside: avoid; padding-block: .8rem; }
  .timeline > li[hidden] { display: grid; }
  #experience-more { display: none !important; }
  a { color: inherit; text-decoration: none; }
}

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