/* ============ Tokens ============ */
:root {
  --mauve: #B3899A;
  --mauve-deep: #9A6F81;
  --pink: #F7F1F3;
  --pink-line: #E9DCE1;
  --ink: #222222;
  --ink-soft: #4a4446;
  --white: #ffffff;

  --serif-display: "DM Serif Display", "Iowan Old Style", Georgia, serif;
  --serif-body: "Lora", "Iowan Old Style", Georgia, serif;

  --max: 1250px;
  --gutter: clamp(16px, 4vw, 40px);
  --section-gap: 120px;
  --project-gap: 96px;
  --radius: 14px;
  --gap: 16px;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--serif-display); font-weight: 400; line-height: 1.15; margin: 0; }
p { margin: 0; }
strong { font-weight: 700; }

.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--ink); color: var(--white); padding: 8px 14px; border-radius: 6px;
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--mauve-deep); outline-offset: 3px; border-radius: 3px; }

/* ============ Nav ============ */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247, 241, 243, 0.94);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--pink-line);
}
.site-nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { font-family: var(--serif-display); font-size: 22px; color: var(--mauve-deep); text-decoration: none; white-space: nowrap; }
.nav-links { display: flex; gap: clamp(14px, 3vw, 36px); list-style: none; margin: 0; padding: 0; }
.nav-links a {
  text-decoration: none; color: var(--ink-soft); font-size: 16px; letter-spacing: 0.02em;
  padding: 6px 0; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s;
}
.nav-links a:hover { color: var(--mauve-deep); border-bottom-color: var(--mauve); }

section[id] { scroll-margin-top: 72px; }

/* ============ About ============ */
.about {
  position: relative;
  overflow: hidden;
  background: var(--mauve);
  color: var(--white);
}
.about .wrap { position: relative; z-index: 1; padding-top: clamp(64px, 10vw, 120px); padding-bottom: clamp(64px, 10vw, 120px); }
.about h1 { font-size: clamp(48px, 8vw, 96px); letter-spacing: -0.01em; }
.about .subtitle { font-size: clamp(19px, 2.2vw, 24px); margin-top: 10px; opacity: 0.95; }
.about .intro { max-width: 34em; margin-top: 36px; font-size: clamp(17px, 1.6vw, 20px); line-height: 1.65; }
.about .intro p + p { margin-top: 1em; }
.contact { display: flex; flex-wrap: wrap; gap: 12px 28px; list-style: none; padding: 0; margin: 40px 0 0; }
.contact a {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--white); text-decoration: none; font-size: 17px;
  border-bottom: 1px solid rgba(255,255,255,0.45); padding-bottom: 2px; transition: border-color .2s;
}
.contact a:hover { border-bottom-color: var(--white); }
.contact svg { width: 30px; height: 30px; flex: none; }
.gears { position: absolute; right: -40px; top: -30px; width: clamp(180px, 26vw, 340px); height: auto; opacity: 0.9; pointer-events: none; }

/* ============ Sections ============ */
main > section + section { margin-top: var(--section-gap); }
main > section:last-child { margin-bottom: var(--section-gap); }

.section-title {
  display: flex; align-items: center; gap: 24px;
  color: var(--mauve); font-size: clamp(40px, 5vw, 60px);
  margin-bottom: 56px;
}
.section-title::after, .rule-heading::after { content: ""; flex: 1; height: 1px; background: var(--mauve); opacity: 0.7; }

/* ============ Project template ============ */
.project + .project { margin-top: var(--project-gap); }

.bar { background: var(--mauve); color: var(--white); padding: 18px 28px 16px; border-radius: 4px; }
.bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; }
.bar h3 { font-size: clamp(26px, 3.2vw, 38px); }
.bar h3 .status { font-family: var(--serif-body); font-style: italic; font-size: 0.85em; }
.bar h3 .sep { font-family: var(--serif-body); font-weight: 300; opacity: 0.85; margin: 0 0.15em; }
.bar .org { font-size: clamp(19px, 2vw, 24px); white-space: nowrap; }
.bar .tags { font-size: 15px; letter-spacing: 0.03em; margin-top: 6px; opacity: 0.97; }

.project-body { margin-top: 28px; display: grid; gap: 28px; }

/* Image rows: every image in a row ends up the same height.
   Each figure grows in proportion to its aspect ratio (--ar = width / height). */
.img-row { display: flex; gap: var(--gap); align-items: flex-start; }
.img-row > figure { flex: var(--ar) 1 0; min-width: 0; margin: 0; }
.img-row img { width: 100%; height: auto; border-radius: 6px; }
.img-row figcaption { font-size: 15px; color: var(--ink-soft); text-align: center; margin-top: 10px; line-height: 1.45; }

/* Rows of four are built as two pairs so mobile can show two per row.
   flex-basis = gap keeps heights equal across the pairs. */
/* Capped so the small USB-C photo isn't blown up past its real resolution */
.img-row.four { max-width: 1080px; margin: 0 auto; width: 100%; }
.img-row.four > .pair { flex: var(--ar) 1 var(--gap); display: flex; gap: var(--gap); min-width: 0; align-items: flex-start; }
.img-row.four > .pair > figure { flex: var(--ar) 1 0; min-width: 0; margin: 0; }

/* Pale pink text boxes */
.boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.boxes.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.box { background: var(--pink); border-radius: var(--radius); padding: 24px 28px 26px; }
.box h4 { font-size: 24px; color: var(--mauve-deep); margin-bottom: 10px; }
.box h4 + p { margin-bottom: 8px; }
.box p + h4 { margin-top: 18px; }
.box ul + h4 { margin-top: 20px; }
.box ul + p { margin-top: 10px; }
.box ul { margin: 0; padding-left: 1.2em; }
.box li { margin: 0.35em 0; padding-left: 0.2em; }
.box li::marker, .exp li::marker { color: var(--mauve); }

.shown { font-size: 17px; color: var(--ink-soft); font-style: italic; }

/* Sub-headings with a thin line extending right */
.rule-heading { display: flex; align-items: center; gap: 20px; color: var(--mauve); font-size: clamp(28px, 3vw, 36px); margin-top: 20px; }

/* ============ Handheld ============ */
.hero-row { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 36px; align-items: center; }

.callout { margin: 0; container-type: inline-size; }
.callout-canvas { position: relative; aspect-ratio: 1000 / 673; }
.callout-img { position: absolute; left: 28%; top: 0; width: 72%; }
.callout-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.callout-lines line { stroke: var(--ink); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.callout-lines circle { fill: var(--mauve-deep); }
.callout-labels { list-style: none; margin: 0; padding: 0; }
.callout-labels li {
  position: absolute; right: 73%; top: calc(var(--y) / 673 * 100%);
  transform: translateY(-50%); white-space: nowrap; text-align: right;
  font-size: clamp(12px, 2.5cqw, 16px); line-height: 1.2;
}
/* Not enough room for side labels: show them as a short list under the image */
@container (max-width: 520px) {
  .callout-canvas { aspect-ratio: auto; }
  .callout-img { position: static; width: 100%; max-width: 440px; margin: 0 auto; }
  .callout-lines { display: none; }
  .callout-labels {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px;
  }
  .callout-labels li {
    position: static; transform: none; white-space: normal; text-align: center;
    font-size: 15px; background: var(--pink); border-radius: 999px; padding: 4px 12px;
  }
  .callout-labels li.dup { display: none; }
}

.iterations { display: flex; align-items: flex-start; gap: var(--gap); }
.iterations > figure { flex: var(--ar) 1 0; min-width: 0; margin: 0; }
.iterations img { width: 100%; height: auto; }
.iterations figcaption { text-align: center; font-size: 16px; margin-top: 12px; line-height: 1.5; padding: 0 6px; }
.iterations figcaption b { font-family: var(--serif-display); font-weight: 400; color: var(--mauve-deep); font-size: 1.15em; }
.arrow { flex: 0 0 56px; align-self: center; color: var(--mauve); display: flex; justify-content: center; margin-top: -40px; }
.arrow svg { width: 52px; height: 20px; }

/* ============ Tesla ============ */
.tesla-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr);
  grid-template-rows: auto auto; gap: 20px;
}
/* Photo keeps its full frame (no cropping) and follows the reader down the boxes */
.tesla-grid .photo { grid-column: 3; grid-row: 1 / 3; margin: 0; align-self: start; position: sticky; top: 80px; }
.tesla-grid .photo img { width: 100%; height: auto; border-radius: 6px; }
.tesla-grid .box p { margin-bottom: 4px; }

/* ============ Experience ============ */
.exp-block + .exp-block { margin-top: 64px; }
.exp-block > h3 {
  font-size: clamp(28px, 3vw, 36px); color: var(--mauve);
  padding-bottom: 10px; border-bottom: 1px solid var(--mauve); margin-bottom: 28px;
}
.kv { display: grid; gap: 10px; margin: 0; }
.kv > div { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 4px 24px; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0; }
.kv .when { font-style: italic; color: var(--ink-soft); }

.exp { display: grid; gap: 36px; }
.exp-item { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 4px 24px; }
.exp-meta { color: var(--ink-soft); font-size: 16px; line-height: 1.5; padding-top: 3px; }
.exp-meta em { display: block; }
.exp-item h4 { font-family: var(--serif-body); font-weight: 700; font-size: 19px; }
.exp-item .role { margin-top: 2px; }
.exp-item .status { font-weight: 400; font-style: italic; }
.exp ul { margin: 10px 0 0; padding-left: 1.2em; }
.exp li { margin: 0.4em 0; padding-left: 0.2em; }
.exp-item.no-meta { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 769px) { .exp-item.no-meta > div { grid-column: 2; } .exp-item.no-meta { grid-template-columns: 190px minmax(0, 1fr); } }

/* ============ Footer ============ */
.site-footer { background: var(--pink); border-top: 1px solid var(--pink-line); padding: 36px 0; font-size: 15px; color: var(--ink-soft); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; }
.site-footer a { color: var(--mauve-deep); }

/* ============ Tablet ============ */
@media (max-width: 1024px) {
  .hero-row { grid-template-columns: minmax(0, 1fr); }
  .tesla-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tesla-grid .photo { grid-column: 1 / -1; grid-row: auto; order: -1; position: static; }
  .tesla-grid .photo img { width: auto; max-width: 100%; max-height: 640px; margin: 0 auto; }
}

/* ============ Mobile (under 768px) ============ */
@media (max-width: 767.98px) {
  :root { --section-gap: 88px; --project-gap: 72px; }
  body { font-size: 16.5px; }
  .site-nav .wrap { min-height: 54px; }
  .brand { font-size: 18px; }
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 15.5px; }

  .about .wrap { padding-top: 56px; padding-bottom: 64px; }
  .contact { flex-direction: column; gap: 14px; }
  .gears { width: 130px; right: -48px; top: -36px; opacity: 0.6; }

  .section-title { margin-bottom: 36px; gap: 16px; }

  .bar { padding: 16px 18px 14px; }
  .bar-top { flex-direction: column; gap: 2px; }
  .bar .org { white-space: normal; }
  .bar .tags { font-size: 14.5px; line-height: 1.5; }

  .img-row { flex-direction: column; gap: 20px; }
  .img-row > figure { flex: none; width: 100%; }
  .img-row.four { gap: 20px; }
  .img-row.four > .pair { flex: none; width: 100%; }

  .boxes, .boxes.two { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .box { padding: 20px 20px 22px; }

  .iterations { flex-direction: column; align-items: center; gap: 8px; }
  .iterations > figure { flex: none; width: 100%; }
  .iterations img { width: auto; max-width: 100%; max-height: 340px; margin: 0 auto; }
  .arrow { flex: none; margin: 4px 0; }
  .arrow svg { transform: rotate(90deg); }

  .tesla-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }

  .kv > div, .exp-item, .exp-item.no-meta { grid-template-columns: minmax(0, 1fr); }
  .exp-meta { padding-top: 0; }
  .exp-meta em { display: inline; }
  .exp-meta em::before { content: " · "; font-style: normal; }
}

/* Keep every bit of mobile text at 16px or more */
@media (max-width: 767.98px) {
  .nav-links a, .bar .tags, .img-row figcaption, .iterations figcaption,
  .exp-meta, .site-footer, .contact a { font-size: 16px; }
  .callout-labels li { font-size: 16px !important; }
}
@media (max-width: 400px) {
  .site-nav .wrap { gap: 12px; }
  .brand { font-size: 16px; }
  .nav-links { gap: 10px; }
}
@media (max-width: 359px) {
  .brand { display: none; }
  .site-nav .wrap { justify-content: center; }
}

.nw { white-space: nowrap; }
