:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #1c1f23;
  --muted: #5b6168;
  --line: #e2dfd9;
  --accent: #c4520a;
  --accent-fill: #e8650a;
  --accent-soft: #fdeee3;
  --hero-bg: #1c1f23;
  --hero-ink: #f3f1ed;
  --hero-muted: #b4b8bd;
  --d-a: #d9dde2;
  --d-b: #c4cad1;
  --d-c: #f7c9a6;
  --d-p: #1c1f23;
  --d-p-ink: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121416;
    --surface: #1b1e21;
    --ink: #eceae6;
    --muted: #a1a6ac;
    --line: #2c3035;
    --accent: #ff8a3d;
    --accent-fill: #e8650a;
    --accent-soft: #2e2219;
    --hero-bg: #0b0c0e;
    --d-a: #3a4047;
    --d-b: #4a5159;
    --d-c: #8a4a1c;
    --d-p: #eceae6;
    --d-p-ink: #121416;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #121416; --surface: #1b1e21; --ink: #eceae6; --muted: #a1a6ac; --line: #2c3035;
  --accent: #ff8a3d; --accent-soft: #2e2219; --hero-bg: #0b0c0e;
  --d-a: #3a4047; --d-b: #4a5159; --d-c: #8a4a1c; --d-p: #eceae6; --d-p-ink: #121416; --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: 1.5rem; }
h2::after { content: ""; display: block; width: 44px; height: 4px; background: var(--accent-fill); margin-top: .6rem; border-radius: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.section { padding: 72px 20px; }
.wrap.section { padding-left: 20px; padding-right: 20px; }
.section.alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lede { font-size: 1.15rem; color: var(--ink); }
.narrow { max-width: 720px; }

/* Hero */
.hero { background: var(--hero-bg); color: var(--hero-ink); padding: 72px 0 64px; }
.hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; }
.eyebrow { font: 700 .8rem/1 "JetBrains Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: #ff8a3d; margin: 0 0 1rem; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; }
.hero .title { font-size: clamp(1.1rem, 2.4vw, 1.35rem); font-weight: 600; color: #ff8a3d; margin: .4rem 0 1.2rem; }
.hero .lede { color: var(--hero-muted); max-width: 560px; margin: 0 0 1.8rem; }
.headshot { width: 220px; height: 220px; border-radius: 50%; object-fit: cover; border: 4px solid #e8650a; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-block; padding: 12px 20px; border-radius: 8px; font-weight: 600; font-size: .95rem;
  text-decoration: none; border: 1.5px solid currentColor; color: inherit; transition: background .15s, color .15s;
}
.hero .btn { color: var(--hero-ink); border-color: #4a4f55; }
.hero .btn:hover { border-color: var(--hero-ink); }
.btn.primary, .hero .btn.primary { background: #e8650a; border-color: #e8650a; color: #fff; }
.btn.primary:hover { background: #c4520a; border-color: #c4520a; }
.contact .btn { color: var(--ink); border-color: var(--line); }
.contact .btn.primary { color: #fff; border-color: #e8650a; }

/* Stats */
.stats { background: var(--surface); border-bottom: 1px solid var(--line); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.stat { padding: 28px 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; padding-left: 0; }
.num { display: block; font: 700 2.4rem/1 "JetBrains Mono", monospace; color: var(--accent); }
.lbl { display: block; margin-top: .5rem; font-size: .9rem; color: var(--muted); line-height: 1.35; }

/* Banner */
.banner { margin: 0; position: relative; }
.banner img { width: 100%; height: clamp(260px, 42vw, 460px); object-fit: cover; object-position: center 40%; }
.banner figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 20px 14px; color: #fff; font-size: .9rem;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); text-align: center; }

/* Experience */
.job { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; margin-bottom: 20px; box-shadow: var(--shadow); }
.job-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; margin-bottom: .8rem; }
.job h3 { font-size: 1.25rem; font-weight: 700; }
.org { margin: .2rem 0 0; color: var(--muted); font-weight: 500; }
.dates { margin: 0; font: 500 .85rem/1 "JetBrains Mono", monospace; color: var(--muted); white-space: nowrap; }
.job ul { margin: 0; padding-left: 1.2rem; }
.job li { margin-bottom: .45rem; }
.job li::marker { color: var(--accent-fill); }
.job.compact p { margin: 0; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
figure { margin: 0; }
.photos img, .feature img, .small img { width: 100%; border-radius: 8px; object-fit: cover; }
.photos img { aspect-ratio: 4 / 3; }
figcaption { font-size: .82rem; color: var(--muted); margin-top: .4rem; }

/* Cycle time */
.diagram { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin-top: 28px; }
.diagram { overflow-x: auto; }
.diagram svg { width: 100%; min-width: 560px; height: auto; overflow: visible; }
.d-label { font: 600 14px Inter, sans-serif; fill: var(--muted); }
.d-t { font: 600 13px Inter, sans-serif; fill: var(--ink); }
.d-t.inv { fill: var(--d-p-ink); }
.d-a { fill: var(--d-a); } .d-b { fill: var(--d-b); } .d-c { fill: var(--d-c); } .d-p { fill: var(--d-p); }
.d-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: .6; }
.d-save { stroke: var(--accent-fill); stroke-width: 3; }
.d-save-t { font: 700 13px "JetBrains Mono", monospace; fill: var(--accent); }
.caption { font-size: .82rem; color: var(--muted); margin: 12px 0 0; }

/* Skills */
.skills-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: start; }
.skill { padding: 14px 0; border-bottom: 1px solid var(--line); }
.skill:first-child { padding-top: 0; }
.skill h4 { font-size: 1rem; font-weight: 700; }
.skill p { margin: .25rem 0 0; color: var(--muted); font-size: .95rem; }
.sub { font-size: 1.15rem; font-weight: 700; margin: 48px 0 16px; }
.certs-grid { display: grid; grid-template-columns: 1fr 200px; gap: 32px; align-items: start; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.chips li { background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; font-size: .9rem; font-weight: 500; }
.small img { aspect-ratio: 3 / 4; }

/* Homelab */
.lab-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.lab { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.lab h4 { font-size: 1rem; font-weight: 700; color: var(--accent); }
.lab p { margin: .4rem 0 0; font-size: .95rem; color: var(--muted); }

.contact { text-align: left; }
.footer { padding: 28px 20px 40px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* Phone / tablet */
@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .headshot { order: -1; width: 140px; height: 140px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat { border-left: 0; padding: 20px 0; border-top: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
  .skills-grid, .certs-grid { grid-template-columns: 1fr; }
  .certs-grid .small { max-width: 220px; }
  .lab-grid { grid-template-columns: 1fr; }
  .section, .wrap.section { padding: 56px 16px; }
  .wrap { padding: 0 16px; }
  .job { padding: 20px; }
}
@media (max-width: 480px) {
  .photos { gap: 8px; margin-top: 16px; }
  .photos figcaption { font-size: .75rem; }
  .num { font-size: 2rem; }
}

/* Cycle-time race animation (armed by JS; static diagram if JS off or reduced motion) */
.diagram .bar rect { transform-box: fill-box; transform-origin: left center; }
.diagram.armed .bar rect { transform: scaleX(0); }
.diagram.armed .bar text, .diagram.armed .fin { opacity: 0; }
.diagram.play .bar rect { transform: scaleX(1); transition: transform var(--d) linear var(--s); }
.diagram.play .bar text { opacity: 1; transition: opacity .3s ease calc(var(--s) + var(--d) * .3); }
.diagram.play .fin { opacity: 1; transition: opacity .6s ease var(--end); }
.d-head { stroke: var(--accent-fill); stroke-width: 2; opacity: 0; }
.diagram.play:not(.done) .d-head { opacity: .9; }
.diagram-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.diagram-foot .caption { margin: 0; }
.replay { font: 600 .85rem Inter, sans-serif; color: var(--accent); background: transparent; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.replay:hover { border-color: var(--accent); }

/* Video clip tile: same 4:3 footprint as the photos beside it */
.photos.three { grid-template-columns: repeat(3, 1fr); }
.photos .clip video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: #1c1f23; }
@media (max-width: 820px) {
  .photos.three { grid-template-columns: 1fr 1fr; }
  .photos.three .clip { grid-column: 1 / -1; }
}
@media (max-width: 820px) { .photos.three .clip video { aspect-ratio: 16 / 9; object-position: center 25%; } }
