/* ==========================================================================
   styles.css
   --------------------------------------------------------------------------
   Contents
     0. Cascade layers ... the order the sections below win in
     1. Fonts
     2. Design tokens .... colors, type scale, spacing, layout sizes
     3. Reset ............ browser default clean-up
     4. Base ............. global element styles (page, links, focus, motion)
     5. Typography ....... text defaults and shared text styles
     6. Layout ........... page width and the shared section grid
     7. Components ....... reusable pieces (buttons, links, icons)
     8. Page sections .... header, hero, About, ... in page order
     9. Utilities ........ single-purpose helpers that must always win

   Responsive approach
     Mobile-first: rules start with the small-screen version.
     Breakpoints: 48rem (768px) and 64rem (1024px).
     Media queries are nested inside the rule they change, so everything
     about one component lives in one place.

   Modern CSS used here
     @layer            Sections are cascade layers, so a later section always
                       beats an earlier one, whatever the selector specificity.
     Nesting (&)       Native CSS nesting, no preprocessor.
                       Note: unlike Sass, "&__title" does NOT build a class name
                       in plain CSS, so BEM classes stay as their own rules.
     Range queries     (width >= 48rem) instead of (min-width: 48rem).
     Grid + Flexbox    Grid for two-dimensional layouts, flexbox for rows/stacks.
   ========================================================================== */


/* ==========================================================================
   0. Cascade layers
   Declared once, in priority order: later layers win over earlier ones.
   ========================================================================== */
@layer tokens, reset, base, typography, layout, components, sections, utilities;


/* ==========================================================================
   1. Fonts
   Self-hosted Geist (SIL OFL, see assets/fonts/OFL.txt).
   Variable fonts: one file covers every weight.
   ========================================================================== */
@font-face {
  font-family: "Geist";
  src: url("../assets/fonts/geist-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("../assets/fonts/geist-mono-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}


/* ==========================================================================
   2. Design tokens
   Values come straight from the pen.dev file's variables.
   Comments give the design's px value.
   ========================================================================== */
@layer tokens {
  :root {
    /* Color: light sections */
    --color-bg: #f6f5f1;
    --color-surface: #eceae3;
    --color-ink: #15171a;
    --color-muted: #5b6067;
    --color-rule: #dad7cf;
    --color-accent: #1d5c43;
    --color-on-accent: #ffffff;
    --color-paper: #ffffff; /* browser mockup and flow boxes */
    --color-mockup-dot: #d2cfc6;
    --color-placeholder-start: #fbfaf7; /* screenshot area while the image loads */
    --color-placeholder-end: #f1efe9;

    /* Color: dark Contact block */
    --color-dark-bg: #15171a;
    --color-dark-text: #f6f5f1;
    --color-dark-muted: #a2a7ad;
    --color-dark-rule: #2e3136;
    --color-accent-on-dark: #8fcbae;

    /* Type: families */
    --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

    /* Type: sizes (named by their px size in the design) */
    --font-size-12: 0.75rem;
    --font-size-13: 0.8125rem;
    --font-size-14: 0.875rem;
    --font-size-15: 0.9375rem;
    --font-size-16: 1rem;
    --font-size-17: 1.0625rem;
    --font-size-18: 1.125rem;
    --font-size-19: 1.1875rem;
    --font-size-22: 1.375rem;
    --font-size-26: 1.625rem;

    /* Type: fluid sizes. Grow with the viewport, capped at the design size. */
    --font-size-display: clamp(2.5rem, 1.5rem + 4.5vw, 5.25rem); /* 40 → 84 */
    --font-size-display-sm: clamp(2.25rem, 1.5rem + 3vw, 3.75rem); /* 36 → 60 */
    --font-size-lead: clamp(1.25rem, 1rem + 1vw, 1.5rem); /* 20 → 24 */
    --font-size-email: clamp(1.25rem, 0.25rem + 4vw, 1.875rem); /* 20 → 30; small enough on phones that the address stays on one line */

    /* Type: weight, line height, letter spacing */
    --font-weight-regular: 400;
    --font-weight-medium: 500;

    --leading-display: 1.03;
    --leading-tight: 1.3;
    --leading-snug: 1.45;
    --leading-body: 1.55;
    --leading-relaxed: 1.6;

    --tracking-display: -0.035em;
    --tracking-heading: -0.02em;
    --tracking-subheading: -0.01em;

    /* Spacing: rem on a 4px grid, plus a few half steps the design uses */
    --space-0-75: 0.1875rem; /* 3 */
    --space-1: 0.25rem; /* 4 */
    --space-1-5: 0.375rem; /* 6 */
    --space-2: 0.5rem; /* 8 */
    --space-2-5: 0.625rem; /* 10 */
    --space-3: 0.75rem; /* 12 */
    --space-3-5: 0.875rem; /* 14 */
    --space-4: 1rem; /* 16 */
    --space-4-5: 1.125rem; /* 18 */
    --space-5: 1.25rem; /* 20 */
    --space-5-5: 1.375rem; /* 22 */
    --space-6: 1.5rem; /* 24 */
    --space-7: 1.75rem; /* 28 */
    --space-8: 2rem; /* 32 */
    --space-9: 2.25rem; /* 36 */
    --space-10: 2.5rem; /* 40 */
    --space-12: 3rem; /* 48 */
    --space-14: 3.5rem; /* 56 */
    --space-16: 4rem; /* 64 */
    --space-18: 4.5rem; /* 72 */
    --space-24: 6rem; /* 96 */
    --space-26: 6.5rem; /* 104 */
    --space-28: 7rem; /* 112 */
    --space-30: 7.5rem; /* 120 */

    /* Shape */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --border-width: 1px;
    --border-width-thick: 2px;

    /* Layout */
    --content-width: 70rem; /* 1120 */
    --label-column: 17.5rem; /* 280: the numbered section labels on the left */
    --period-column: 11.25rem; /* 180: the dates column in Experience, the category column in Toolkit */
    --page-gutter: var(--space-5);

    /* Icons drawn by CSS (Lucide "arrow-right"). Used as a mask so it takes the text color. */
    --icon-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m12 5 7 7-7 7'/%3E%3C/svg%3E");

    /* Motion: transitions are off unless the visitor is fine with motion. */
    --duration-fast: 150ms;
    --transition-colors: none;

    @media (width >= 48rem) {
      --page-gutter: var(--space-10);
    }

    @media (prefers-reduced-motion: no-preference) {
      --transition-colors:
        color var(--duration-fast) ease,
        background-color var(--duration-fast) ease,
        border-color var(--duration-fast) ease;
    }
  }
}


/* ==========================================================================
   3. Reset
   ========================================================================== */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  :where(body, h1, h2, h3, h4, p, figure, dl, dd, ol, ul) {
    margin: 0;
  }

  :where(img, svg) {
    display: block;
    max-width: 100%;
  }

  img {
    height: auto;
  }

  /* Keep the hidden attribute working (the svg rule above would otherwise un-hide the icon sprite). */
  [hidden] {
    display: none;
  }
}


/* ==========================================================================
   4. Base
   Global element styles: the page itself, links, focus, scrolling.
   ========================================================================== */
@layer base {
  html {
    @media (prefers-reduced-motion: no-preference) {
      scroll-behavior: smooth;
    }
  }

  body {
    background-color: var(--color-bg);
    color: var(--color-ink);
  }

  a {
    color: inherit;
  }

  /* One focus style for everything keyboard-focusable. :focus-visible skips it for mouse clicks. */
  :focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
  }
}


/* ==========================================================================
   5. Typography
   Text defaults, plus text styles that several sections share.
   ========================================================================== */
@layer typography {
  body {
    font-family: var(--font-sans);
    font-size: var(--font-size-16);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
  }

  /* balance: evens out line lengths in headings. pretty: avoids a lone word on the last line. */
  :where(h1, h2, h3, h4) {
    text-wrap: balance;
  }

  p {
    text-wrap: pretty;
  }

  /*
    Label: the small muted captions ("Discipline", "Stack", "Period", ...), styled like the
    column headings on a ledger. Mono is kept for figures and dates, not for labels.
    Each section adds its own labels to this list.
  */
  :is(.project__kicker, .project__meta dt, .timeline__headers, .toolkit dt, .ledger thead th) {
    color: var(--color-muted);
    font-size: var(--font-size-13);
  }
}


/* ==========================================================================
   6. Layout
   Two ways content gets its 1120px width, without wrapper <div>s.
   ========================================================================== */
@layer layout {
  /*
    Full-bleed blocks (backgrounds can run edge to edge): pad the sides so content
    is never wider than --content-width or closer than --page-gutter to the edge.
  */
  .site-header,
  .hero,
  .section--contact,
  .site-footer {
    padding-inline: max(var(--page-gutter), (100% - var(--content-width)) / 2);
  }

  /*
    Sections 01–05: their top rule only spans the content, so the section itself is
    sized to the content width and centered.
    Grid: label stacked above content on phones; label column + content from 1024px.
  */
  .section {
    display: grid;
    gap: var(--space-6);
    width: min(100% - 2 * var(--page-gutter), var(--content-width));
    margin-inline: auto;
    padding-block: var(--space-8) var(--space-16);
    border-top: var(--border-width) solid var(--color-rule);

    @media (width >= 64rem) {
      grid-template-columns: var(--label-column) 1fr;
      gap: 0;
      padding-block: var(--space-10) var(--space-26);
    }
  }

  .section__label {
    display: flex;
    align-items: center;
    align-self: start;
    gap: var(--space-3);
    font-size: var(--font-size-15);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
  }

  .section__icon {
    color: var(--color-muted);
  }

  /*
    Contact is full-bleed (its dark background runs edge to edge), so it swaps the
    centered width for the side padding above, and drops the top rule.
  */
  .section--contact {
    width: auto;
    margin-inline: 0;
    padding-block: var(--space-16) var(--space-18);
    border-top: 0;

    @media (width >= 64rem) {
      padding-block: var(--space-24) var(--space-30);
    }
  }

  /* min-width: 0 lets long content shrink inside the grid instead of overflowing it. */
  .section__content {
    min-width: 0;
  }
}


/* ==========================================================================
   7. Components
   Reusable pieces that appear in more than one section.
   ========================================================================== */
@layer components {
  .icon {
    flex-shrink: 0;
  }

  /* Solid green call-to-action. Used on <a> elements that look like buttons. */
  .button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3-5) var(--space-5-5);
    border: var(--border-width) solid var(--color-accent);
    border-radius: var(--radius-md);
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    font-size: var(--font-size-16);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
    text-decoration: none;
    transition: var(--transition-colors);

    &:hover {
      border-color: var(--color-ink);
      background-color: var(--color-ink);
    }
  }

  /* Smaller, outlined version (the header's Résumé link). */
  .button--small {
    gap: var(--space-1-5);
    padding: var(--space-2) var(--space-3-5);
    border-color: var(--color-ink);
    border-radius: var(--radius-sm);
    background-color: transparent;
    color: var(--color-ink);
    font-size: var(--font-size-14);

    &:hover {
      color: var(--color-bg);
    }
  }

  /*
    Underlined link with a trailing icon. The underline is a border so it runs under the icon too.
    In the HTML, keep the visually-hidden "(opens in new tab)" AFTER the icon: placed before it,
    the line break that follows becomes an empty flex item and adds an extra 6px gap.
  */
  .text-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1-5);
    padding-bottom: var(--space-0-75);
    border-bottom: var(--border-width) solid currentColor;
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
    text-decoration: none;
    transition: var(--transition-colors);

    &:hover {
      color: var(--color-accent);
    }
  }

  /* Green version for the primary link in a block ("Visit live site", "Download full résumé"). */
  .text-link--accent {
    color: var(--color-accent);

    &:hover {
      color: var(--color-ink);
    }
  }

  /* Off-screen until a keyboard user tabs to it, then it appears top-left. */
  .skip-link {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 1;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    background-color: var(--color-ink);
    color: var(--color-bg);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transform: translateY(-200%);

    &:focus-visible {
      transform: none;
    }
  }
}


/* ==========================================================================
   8. Page sections
   In page order. Each block holds everything for that section,
   including its responsive changes.
   ========================================================================== */
@layer sections {
  /* ---------- Header ---------- */
  /*
    Flexbox row. Phones: name and Résumé share the first row, the nav takes a full
    second row. From 768px: name, then nav and Résumé pushed to the right.
  */
  .site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4) var(--space-8);
    padding-block: var(--space-5);

    @media (width >= 48rem) {
      column-gap: var(--space-9);
      padding-block: var(--space-7);
    }
  }

  .site-nav {
    flex-basis: 100%;
    order: 1;

    @media (width >= 48rem) {
      flex-basis: auto;
      order: 0;
      margin-inline-start: auto;
    }
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2-5);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
  }

  .brand__avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
  }

  .site-nav__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
    padding: 0;
    list-style: none;

    @media (width >= 48rem) {
      gap: var(--space-9);
    }
  }

  /*
    Padding grows each link's tap target to about 47px tall; the negative margin
    cancels it out so the header's height and spacing don't change.
  */
  .site-nav a {
    display: inline-block;
    margin-block: calc(-1 * var(--space-3));
    padding-block: var(--space-3);
    color: var(--color-muted);
    font-size: var(--font-size-15);
    text-decoration: none;
    transition: var(--transition-colors);

    &:hover {
      color: var(--color-ink);
    }
  }

  /* ---------- Hero ---------- */
  /*
    Grid. Phones: headline, summary + actions, ledger, stacked.
    From 1024px: the headline runs the full width; below it, summary + actions on the left
    and the ledger in a fixed column on the right.
  */
  .hero {
    display: grid;
    gap: var(--space-8);
    padding-block: var(--space-14) var(--space-16);

    @media (width >= 48rem) {
      gap: var(--space-12);
      padding-block: var(--space-28) var(--space-24);
    }

    @media (width >= 64rem) {
      grid-template-columns: minmax(0, 1fr) 24rem;
      column-gap: var(--space-18);
      align-items: start;
    }
  }

  .hero__title {
    font-size: var(--font-size-display);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-display);
    letter-spacing: var(--tracking-display);

    @media (width >= 64rem) {
      grid-column: 1 / -1;
    }
  }

  .hero__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-8);
  }

  .hero__summary {
    max-width: 36rem;
    color: var(--color-muted);
    font-size: var(--font-size-18);
    line-height: var(--leading-relaxed);
  }

  .hero__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-6) var(--space-8);
  }

  /*
    The ledger: an accountant's schedule. Hairlines between rows, a single ink rule
    above the total and a double rule below it. Figures are mono with tabular digits
    so they line up in a column, like a spreadsheet.
  */
  .ledger {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-16);
    line-height: var(--leading-tight);

    & caption {
      padding-bottom: var(--space-4);
      font-weight: var(--font-weight-medium);
      text-align: left;
    }

    & :is(th, td) {
      padding-block: var(--space-3-5);
      border-bottom: var(--border-width) solid var(--color-rule);
      font-weight: var(--font-weight-regular);
      text-align: left;
    }

    /* Period and Years columns sit on the right, like amount columns. */
    & :is(th, td):not(:first-child) {
      padding-left: var(--space-5);
      text-align: right;
      white-space: nowrap;
    }

    /* Text style comes from the shared label style (Typography). */
    & thead th {
      padding-block: 0 var(--space-2-5);
      border-bottom-color: var(--color-ink);
    }

    & td {
      font-family: var(--font-mono);
      font-variant-numeric: tabular-nums;
    }

    /* Period dates are supporting detail; the years are the figures that matter. */
    & tbody td:nth-child(2) {
      color: var(--color-muted);
      font-size: var(--font-size-14);
    }

    & tbody td:last-child,
    & tfoot td {
      font-size: var(--font-size-19);
    }

    & tbody tr:last-child :is(th, td) {
      border-bottom: 0;
    }

    & tfoot :is(th, td) {
      border-top: var(--border-width) solid var(--color-ink);
      border-bottom: 3px double var(--color-ink);
      font-weight: var(--font-weight-medium);
    }
  }

  /* ---------- 01 About ---------- */
  /* The bio alone (the ledger moved up to the hero). Capped so lines stay readable. */
  .about__bio {
    display: flex;
    max-width: 42rem;
    flex-direction: column;
    gap: var(--space-5);
    color: var(--color-muted);
    font-size: var(--font-size-17);
    line-height: var(--leading-relaxed);
  }

  .about__lead {
    color: var(--color-ink);
    font-size: var(--font-size-lead);
    line-height: var(--leading-snug);
    letter-spacing: var(--tracking-heading);
  }

  /* ---------- 02 Selected work ---------- */
  /*
    Each project is a flexbox row with wrap, like About: the text takes the space,
    the 240px meta column sits beside it, and they stack when there isn't room.
    Projects after the first are separated by a top rule.
  */
  .project {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6) var(--space-14);
    padding-block: var(--space-9);
    border-top: var(--border-width) solid var(--color-rule);
  }

  .project__text {
    display: flex;
    flex: 1 1 24rem;
    flex-direction: column;
    gap: var(--space-2-5);
  }

  .project__kicker,
  .project__meta dt {
    line-height: var(--leading-tight);
  }

  .project .text-link {
    font-size: var(--font-size-15);
  }

  /* A link inside the text column: keep it (and its underline) as wide as its text. */
  .project__text > .text-link {
    align-self: flex-start;
    margin-top: var(--space-2);
  }

  .project__title {
    font-size: var(--font-size-22);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-heading);
  }

  .project__description {
    color: var(--color-muted);
    line-height: var(--leading-relaxed);
  }

  /* Meta column: fixed 240px, never grows. On the plain projects it's a <dl> of label/value pairs. */
  .project__meta {
    display: flex;
    flex: 0 0 15rem;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
    padding-top: var(--space-1);

    & > div {
      display: flex;
      flex-direction: column;
      gap: var(--space-1);
    }

    & dd {
      font-size: var(--font-size-15);
      line-height: var(--leading-tight);
    }
  }

  /* Featured project: a column (mockup on top, then the text/meta row), no top rule, extra room below. */
  .project--featured {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: var(--space-7);
    padding-block: 0 var(--space-14);
    border-top: 0;

    & .project__kicker {
      color: var(--color-accent);
    }

    & .project__title {
      @media (width >= 48rem) {
        font-size: var(--font-size-26);
      }
    }

    & .project__meta {
      gap: var(--space-3-5);
    }
  }

  /* The text/meta row under the mockup. */
  .project__body {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6) var(--space-14);
  }

  .project__note {
    color: var(--color-muted);
    font-size: var(--font-size-14);
  }

  .project__stack {
    color: var(--color-muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-13);
  }

  /*
    Archive: same two columns as the projects above (text left, 240px meta column right),
    so the GitHub link lines up with their Stack/Role column. Just tighter padding.
  */
  .project--archive {
    padding-block: var(--space-6) 0;

    /* Its kicker is an <h3>, so reset the browser's bold to match the other labels. */
    & .project__kicker {
      font-weight: var(--font-weight-medium);
    }

    & .project__description {
      font-size: var(--font-size-15);
    }
  }

  /* Browser mockup: a white card with a fake toolbar on top of the screenshot. */
  .browser-mockup {
    overflow: clip; /* keeps the screenshot inside the rounded corners */
    border: var(--border-width) solid var(--color-rule);
    border-radius: var(--radius-lg);
    background-color: var(--color-paper);
  }

  .browser-mockup__toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--space-10);
    /* Extra room on the right balances the three dots, so the address sits near the center. */
    padding-inline: var(--space-4) calc(var(--space-4) + var(--space-14));
    background-color: var(--color-surface);
  }

  .browser-mockup__dot {
    width: var(--space-2-5);
    height: var(--space-2-5);
    border-radius: 50%;
    background-color: var(--color-mockup-dot);
  }

  .browser-mockup__url {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1-5);
    margin-inline: auto; /* centers it in the space after the dots */
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    background-color: var(--color-bg);
    color: var(--color-muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-12);
    line-height: var(--leading-snug);
  }

  /*
    The width/height attributes give the image its 840:400 shape before it loads.
    The gradient shows while it loads; object-fit crops a taller screenshot from the top.
  */
  .browser-mockup__screenshot {
    width: 100%;
    object-fit: cover;
    object-position: top;
    background-image: linear-gradient(var(--color-placeholder-start), var(--color-placeholder-end));
  }

  /* Workflow steps: outlined boxes joined by arrows. Flexbox with wrap so it fits on phones. */
  .flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2-5);
    padding: var(--space-2-5) 0 0;
    list-style: none;

    & li {
      display: flex;
      align-items: center;
      gap: var(--space-2-5);
    }

    /* Arrow after every step but the last. The mask shape is filled with the muted text color. */
    & li:not(:last-child)::after {
      content: "";
      width: var(--space-3-5);
      height: var(--space-3-5);
      background-color: var(--color-muted);
      mask: var(--icon-arrow-right) center / contain no-repeat;
    }
  }

  /* Padding minus the border, because the design draws its borders inside the box. */
  .flow__step {
    padding: calc(var(--space-1-5) - var(--border-width)) calc(var(--space-3) - var(--border-width));
    border: var(--border-width) solid var(--color-rule);
    border-radius: var(--radius-sm);
    background-color: var(--color-paper);
    font-family: var(--font-mono);
    font-size: var(--font-size-13);
    line-height: var(--leading-tight);
  }

  /* ---------- 03 Experience ---------- */
  /* Grid column: work history, education, then the résumé link, 56px apart. */
  .experience {
    display: grid;
    gap: var(--space-14);

    /* Keep the link its natural width instead of stretching across the grid. */
    & > .text-link {
      justify-self: start;
      font-size: var(--font-size-15);
    }
  }

  /*
    Header row and each entry share the same two columns from 768px: a 180px date column, then the rest.
    On phones the entry stacks (date above role), so the headers just sit side by side.
  */
  .timeline__headers {
    display: flex;
    gap: var(--space-4);
    /* Bottom padding minus the rule, because the design draws rules inside the row. */
    padding-bottom: calc(var(--space-2-5) - var(--border-width));
    border-bottom: var(--border-width) solid var(--color-ink);
    line-height: var(--leading-tight);

    @media (width >= 48rem) {
      display: grid;
      grid-template-columns: var(--period-column) 1fr;
      gap: 0;
    }
  }

  .timeline__list {
    padding: 0;
    list-style: none;
  }

  .timeline__item {
    display: grid;
    gap: var(--space-1);
    padding-block: var(--space-5-5) calc(var(--space-5-5) - var(--border-width));
    border-bottom: var(--border-width) solid var(--color-rule);

    @media (width >= 48rem) {
      grid-template-columns: var(--period-column) 1fr;
      gap: 0;
    }
  }

  .timeline__period {
    font-family: var(--font-mono);
    font-size: var(--font-size-14);
    line-height: var(--leading-relaxed);
  }

  .timeline__detail {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    color: var(--color-muted);
    font-size: var(--font-size-15);
  }

  /* Role and organization on one line, sitting on a shared baseline; the org wraps below when it won't fit. */
  .timeline__role {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: var(--space-2-5);
    color: var(--color-ink);
    font-size: var(--font-size-18);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-subheading);
  }

  .timeline__org {
    color: var(--color-muted);
    font-size: var(--font-size-16);
    font-weight: var(--font-weight-regular);
    letter-spacing: normal;
  }

  /* ---------- 04 Toolkit ---------- */
  /*
    A <dl>: category (dt) and skills (dd) in each row.
    Grid from 768px reuses Experience's 180px date column, so the two sections line up.
    align-items: baseline puts the small label on the same text line as the 16px skills.
  */
  .toolkit__row {
    display: grid;
    gap: var(--space-1);
    padding-block: var(--space-4-5) calc(var(--space-4-5) - var(--border-width));
    border-bottom: var(--border-width) solid var(--color-rule);

    &:first-child {
      padding-top: 0;
    }

    @media (width >= 48rem) {
      grid-template-columns: var(--period-column) 1fr;
      align-items: baseline;
      gap: 0;
    }
  }

  /* ---------- 05 Contact + footer (the dark block) ---------- */
  /* Light-on-dark colors for both. The focus outline switches to the light green so it stays visible. */
  .section--contact,
  .site-footer {
    background-color: var(--color-dark-bg);
    color: var(--color-dark-text);

    & :focus-visible {
      outline-color: var(--color-accent-on-dark);
    }
  }

  .section--contact {
    & .section__icon {
      color: var(--color-dark-muted);
    }

    /* Nudges the label down to line up with the first line of the big heading. */
    & .section__label {
      @media (width >= 64rem) {
        padding-top: var(--space-4);
      }
    }
  }

  /* Flexbox column, 28px apart. align-items: flex-start keeps the links their natural width. */
  .contact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-7);
  }

  /*
    max-width in em scales with the font, so "role in mind?" drops to the second line,
    like the design's manual line break. Below that width the text just wraps.
  */
  .contact__lead {
    max-width: 10.5em;
    font-size: var(--font-size-display-sm);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-display);
    letter-spacing: var(--tracking-display);
  }

  .contact__note {
    max-width: 32.5rem; /* 520 measure from the design */
    color: var(--color-dark-muted);
    font-size: var(--font-size-18);
  }

  /*
    The email: big text with a green underline under the address only (not the arrow).
    text-decoration only underlines text, so the icon stays clean without extra markup.
    overflow-wrap: anywhere is the last resort on very narrow screens; the <wbr> in the HTML
    makes the address break after the "@" first, instead of mid-word.
  */
  .contact__email {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2-5);
    margin-block: var(--space-3) var(--space-1-5);
    font-size: var(--font-size-email);
    font-weight: var(--font-weight-medium);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-heading);
    text-decoration-line: underline;
    text-decoration-color: var(--color-accent-on-dark);
    text-decoration-thickness: var(--border-width-thick);
    text-underline-offset: 0.35em;
    overflow-wrap: anywhere;
    transition: var(--transition-colors);

    & .icon {
      width: 0.875em; /* 26px at 30px text; shrinks with the text on phones */
      height: 0.875em;
      color: var(--color-accent-on-dark);
    }

    &:hover {
      color: var(--color-accent-on-dark);
    }
  }

  /* Flexbox row of links that wraps on small screens. No underline in the design: the trailing icon marks them as links. */
  .contact__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-8);
    padding: var(--space-3) 0 0;
    list-style: none;

    & .text-link {
      border-bottom-color: transparent;
      font-size: var(--font-size-15);

      &:hover {
        border-bottom-color: currentColor;
        color: var(--color-accent-on-dark);
      }
    }

    & .icon {
      color: var(--color-dark-muted);
    }
  }

  /*
    Footer: copyright left, colophon right; stacks on phones.
    Its top rule only spans the content width (like the other sections), but the footer
    itself is full-bleed, so a border won't do. Instead, the first background layer is a
    1px line sized with the same width formula as .section, centered at the top.
  */
  .site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-6);
    padding-block: var(--space-7);
    background:
      linear-gradient(var(--color-dark-rule) 0 0)
        top center / min(100% - 2 * var(--page-gutter), var(--content-width)) var(--border-width)
        no-repeat,
      var(--color-dark-bg);
    color: var(--color-dark-muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-13);
    line-height: var(--leading-tight);
  }
}


/* ==========================================================================
   9. Utilities
   Last layer, so these win over everything above without !important.
   ========================================================================== */
@layer utilities {
  /* Hides text visually but keeps it for screen readers (e.g. "(opens in new tab)"). */
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
