/* ---------------------------------------------------------------------------
   Design tokens — taken from design/Personal Site.dc.html
   --------------------------------------------------------------------------- */
:root {
  --bg:          #FAEACB;
  --ink:         #1F5A73;
  --accent:      #2C7B9C;
  --sand:        #FBC896;
  --muted:       #3A6B80;
  --pale:        #DCEEF5;
  --hatch:       #F1D9A9;

  --rule:        rgba(31, 90, 115, 0.26);
  --rule-strong: rgba(31, 90, 115, 0.40);
  --on-ink:      rgba(250, 234, 203, 0.40);

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --wrap: 1100px;
  --gut:  28px;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

::selection { background: var(--sand); }

a { color: var(--accent); }
a:hover { color: var(--ink); }

img, iframe { max-width: 100%; }

main { flex: 1 0 auto; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: var(--gut);
  padding-right: var(--gut);
  width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Visible to screen readers only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 12px;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------------------
   Header / footer bars
   --------------------------------------------------------------------------- */
.bar { background: var(--ink); }
.bar--header { border-bottom: 1px solid var(--ink); }
.bar--footer { border-top: 1px solid var(--ink); margin-top: 24px; }

.bar-inner {
  padding-top: 16px;
  padding-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--sand);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-mark {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--sand);
  transform: rotate(45deg);
}
.brand-name { color: var(--bg); font-weight: 600; }
.brand:hover .brand-name { color: var(--sand); }

.bar-links { display: flex; gap: 18px; }
.bar-links a,
.bar--footer a { color: var(--sand); text-decoration: none; }
.bar-links a:hover { color: var(--bg); }

/* ---------------------------------------------------------------------------
   Tab navigation
   --------------------------------------------------------------------------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 18px;
  font-family: var(--mono);
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
  background: transparent;
  border: 1px solid rgba(31, 90, 115, 0.4);
  border-bottom: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: rgba(44, 123, 156, 0.12); color: var(--ink); }
.tab.is-active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* Dropdown built on <details> so it works without JavaScript. */
.tab-menu { position: relative; }
.tab-menu > summary { list-style: none; }
.tab-menu > summary::-webkit-details-marker { display: none; }
.tab-menu > summary::marker { content: ""; }

.chev {
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-bottom: 2px;
}
.tab-menu[open] .chev { transform: rotate(225deg); margin-bottom: -2px; }

.tab-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  max-width: calc(100vw - 2 * var(--gut));
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  box-shadow: 0 8px 24px rgba(31, 90, 115, 0.15);
  z-index: 10;
}
.tab-dropdown a {
  display: block;
  padding: 12px 18px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-decoration: none;
  border-top: 1px solid var(--rule);
}
.tab-dropdown a:first-child { border-top: none; }
.tab-dropdown a:hover { background: var(--accent); color: var(--bg); }

/* ---------------------------------------------------------------------------
   Shared typography
   --------------------------------------------------------------------------- */
.section { padding-top: 56px; padding-bottom: 80px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 12px;
}

.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
}

.page-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(36px, 6vw, 56px);
  line-height: 1.05;
  margin: 0 0 8px;
  color: var(--ink);
}

.page-subtitle,
.page-intro p {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 32px;
}

.stack   { display: flex; flex-direction: column; gap: 36px; }
.stack-s { display: flex; flex-direction: column; gap: 20px; }

/* ---------------------------------------------------------------------------
   Home hero
   --------------------------------------------------------------------------- */
.hero { padding-top: 64px; padding-bottom: 40px; }

.hero-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(48px, 9vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  color: var(--ink);
}

/* The bracketed measure-rule from the design. */
.rule {
  width: 120px;
  height: 2px;
  background: rgba(31, 90, 115, 0.6);
  position: relative;
  margin-bottom: 24px;
}
.rule::before,
.rule::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 2px;
  height: 10px;
  background: rgba(31, 90, 115, 0.6);
}
.rule::before { left: 0; }
.rule::after  { right: 0; }

.hero-intro { max-width: 560px; margin-bottom: 36px; }
.hero-intro p {
  font-size: 19px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 14px;
}

.btn-row { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 14px 24px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn--solid {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
.btn--solid:hover { background: var(--ink); color: var(--bg); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(31, 90, 115, 0.5);
}
.btn--ghost:hover { background: rgba(44, 123, 156, 0.12); color: var(--ink); }

/* ---------------------------------------------------------------------------
   Project cards
   --------------------------------------------------------------------------- */
.card {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.card-media { aspect-ratio: 16 / 9; border-bottom: 1px solid var(--accent); }
.card-media iframe,
.card-media img {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  object-fit: cover;
}

/* Image strip. Square tiles with `contain` so CAD views and dimensioned
   sketches are never cropped, regardless of their source aspect ratio. The 1px
   grid gap lets the card's accent colour read as hairline dividers. */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--accent);
  border-bottom: 1px solid var(--accent);
}
/* Fewer than three images shouldn't leave an empty column. */
.gallery[data-count="1"] { grid-template-columns: 1fr; }
.gallery[data-count="2"] { grid-template-columns: repeat(2, 1fr); }

.gallery-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  padding: 14px;
  display: block;
}
/* Square suits a 3-up mix of portrait and landscape. A 2-up strip is wider per
   tile, so a landscape ratio there avoids a band of empty space. */
.gallery[data-count="2"] .gallery-item img { aspect-ratio: 3 / 2; }
.gallery figcaption {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 9px 12px;
  border-top: 1px solid var(--rule);
  margin-top: auto;
}

.card-body { padding: 32px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.card-title {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(19px, 2.4vw, 26px);
  font-weight: 600;
  color: var(--bg);
}

.card-status,
.card-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(250, 234, 203, 0.85);
}
.card-meta { margin-bottom: 18px; }

/* Markdown body of a _projects/*.md file. First paragraph is the summary, the
   list that follows is the detail. */
.card-body .prose > :first-child { margin-top: 0; }
.card-body .prose > :last-child { margin-bottom: 0; }
.card-body .prose p { margin: 0 0 16px; font-size: 15px; line-height: 1.7; color: var(--bg); }
.card-body .prose ul,
.card-body .prose ol { margin: 0; padding-left: 18px; display: grid; gap: 10px; }
.card-body .prose li { font-size: 14px; line-height: 1.65; color: rgba(250, 234, 203, 0.92); }
.card-body .prose li::marker { color: rgba(250, 234, 203, 0.6); }
.card-body .prose a { color: var(--bg); }
.card-body .prose code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(250, 234, 203, 0.15);
  padding: 1px 5px;
}
.card-body .prose strong { color: var(--bg); font-weight: 600; }

.card-links {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 12px;
}
.card-links a { color: var(--bg); text-decoration: none; border-bottom: 1px solid var(--on-ink); }
.card-links a:hover { border-bottom-color: var(--bg); }

/* Home hero card: media beside the body instead of above it. */
.card--hero { display: grid; grid-template-columns: 1.1fr 1fr; }
.card--hero .card-media { aspect-ratio: auto; min-height: 240px; border-bottom: none; border-left: 1px solid var(--accent); order: 2; }
.card--hero .card-body { display: flex; flex-direction: column; justify-content: center; }

/* Placeholder panel for projects with no image or video yet. */
.media-placeholder {
  background-color: var(--hatch);
  background-image: repeating-linear-gradient(45deg, var(--sand) 0, var(--sand) 2px, transparent 2px, transparent 13px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-height: 240px;
  height: 100%;
}

/* ---------------------------------------------------------------------------
   Tags
   --------------------------------------------------------------------------- */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 5px 10px;
  border: 1px solid var(--rule-strong);
  color: var(--muted);
}
.tag--invert { border-color: var(--on-ink); color: var(--bg); }
.tag--lg { font-size: 11px; padding: 6px 12px; }

/* ---------------------------------------------------------------------------
   Projects page — year groups
   --------------------------------------------------------------------------- */
.year-group { margin-bottom: 56px; scroll-margin-top: 24px; }

.year-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.year-head h2 {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--ink);
}
.year-head .line { flex: 1; height: 1px; background: var(--rule); }
.year-head .count { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.card-grid { display: grid; gap: 20px; }
.card-anchor { scroll-margin-top: 24px; }

.empty-slot {
  border: 1px dashed rgba(31, 90, 115, 0.5);
  background: var(--pale);
  padding: 60px 32px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* ---------------------------------------------------------------------------
   About page
   --------------------------------------------------------------------------- */
.about-grid { display: grid; grid-template-columns: 260px 1fr; gap: 48px; }

.photo {
  aspect-ratio: 3 / 4;
  background-color: var(--hatch);
  background-image: repeating-linear-gradient(45deg, var(--sand) 0, var(--sand) 2px, transparent 2px, transparent 13px);
  border: 1px dashed rgba(31, 90, 115, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
/* With a real photo in place, drop the dashed placeholder treatment. */
.photo--filled {
  border: 1px solid var(--rule-strong);
  background-image: none;
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Bias the crop upward so the face survives the 3:4 container. */
  object-position: 50% 25%;
  display: block;
}

.contact-box {
  border: 1px solid var(--rule-strong);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
}
.contact-list { display: flex; flex-direction: column; gap: 8px; }
.contact-list a { text-decoration: none; }
.contact-list a:hover { text-decoration: underline; }

/* Markdown body of about.md. */
.about-prose > :first-child { margin-top: 0; }
.about-prose > :last-child { margin-bottom: 0; }
.about-prose p { margin: 0 0 16px; font-size: 17px; line-height: 1.7; color: var(--muted); }
.about-prose h2,
.about-prose h3 {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 28px 0 10px;
}
.about-prose ul,
.about-prose ol { margin: 0 0 16px; padding-left: 20px; display: grid; gap: 8px; }
.about-prose li { font-size: 16px; line-height: 1.65; color: var(--muted); }
.about-prose blockquote {
  margin: 0 0 16px;
  padding-left: 16px;
  border-left: 2px solid var(--rule-strong);
  color: var(--muted);
  font-style: italic;
}

/* Two-column definition rows: experience, education. */
.entry { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.entry:first-of-type { border-top: 1px solid var(--rule); }
.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.entry-title { font-weight: 600; font-size: 15px; color: var(--ink); }
.entry-when { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--accent); }
.entry-org { font-size: 14px; color: var(--muted); margin-top: 2px; }
.entry-points { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.entry-points li { font-size: 14px; line-height: 1.6; color: var(--muted); }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .photo { max-width: 260px; }
  .card--hero { grid-template-columns: 1fr; }
  .card--hero .card-media { order: 0; border-left: none; border-bottom: 1px solid var(--accent); min-height: 200px; }
}

@media (max-width: 620px) {
  :root { --gut: 20px; }
  .section { padding-top: 40px; padding-bottom: 56px; }
  .hero { padding-top: 44px; }
  .card-body { padding: 22px; }
  .gallery { grid-template-columns: 1fr 1fr; }
  .gallery-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .gallery-item img { padding: 10px; }
  .tabs { gap: 6px; }
  .tab { padding: 9px 12px; font-size: 11px; }
  .btn-row .btn { flex: 1 1 auto; text-align: center; }
  /* The projects tab sits near the right edge here — anchor the menu to its
     right so it can't run off screen. */
  .tab-dropdown { left: auto; right: 0; }
}

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