/* Tokens, base, and page layouts for every page. */

:root {
  color-scheme: light;

  --bg: #f2f2f3;
  --ink: #1d1f20;
  --ink-soft: #5d5d60;
  --rule: #98989b;
  --rule-box: #b7b7ba;
  --solid: #2b2b2d;
  --solid-hover: #424244;
  --solid-active: #1d1f20;

  --space-1: 3.4px;
  --space-2: 6.8px;
  --space-3: 10.2px;
  --space-4: 13.6px;
  --space-6: 20.4px;
  --space-8: 27.2px;

  --font-body: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-heading: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-heading-weight: 500;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* 3px dash, 2px gap, 1.5px thick: the same 5px rhythm as --dots. See .rule-* below. */
  --dash: linear-gradient(to right, var(--rule) 0 3px, transparent 3px 100%);
  /* 1.5px round dots every 5px, for the home spread's dividers. */
  --dots: radial-gradient(circle, var(--rule) 0.75px, transparent 1.1px);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--ink);
  text-underline-offset: 3px;
}

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

:focus {
  outline: none;
}

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

::selection {
  background: color-mix(in srgb, var(--solid) 30%, transparent);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

figure {
  margin: 0;
}

figcaption {
  margin-top: var(--space-3);
  font-size: 15px;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* ── the dashed rule ─────────────────────────────────────────────────── */

.rule-top,
.rule-bottom,
.rule-both {
  background-image: var(--dash);
  background-size: 5px 1.5px;
  background-repeat: repeat-x;
}

.rule-top {
  background-position: top left;
}

.rule-bottom {
  background-position: bottom left;
}

.rule-both {
  background-image: var(--dash), var(--dash);
  background-position: top left, bottom left;
}

/* ── page shell ──────────────────────────────────────────────────────── */

.page {
  min-height: 100vh;
  padding: calc(var(--space-6) * 1.4) var(--space-6) calc(var(--space-8) * 2);
  display: flex;
  justify-content: center;
}

.column {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.column-home {
  gap: calc(var(--space-8) * 1.6);
}

.column-index {
  gap: calc(var(--space-8) * 1.4);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: 0 0 var(--space-3);
}

.nav a {
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}

.nav a:hover {
  color: var(--ink-soft);
}

.nav .nav-brand {
  margin-right: auto;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 15px;
  letter-spacing: 0.02em;
}

.stack {
  display: flex;
  flex-direction: column;
}

.gap-2 {
  gap: var(--space-2);
}

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

.gap-4 {
  gap: var(--space-4);
}

.soft {
  color: var(--ink-soft);
}

.btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border: 1px solid var(--solid);
  border-radius: 0;
  background: var(--solid);
  color: var(--bg);
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--solid-hover);
  border-color: var(--solid-hover);
  color: var(--bg);
}

.btn:active {
  background: var(--solid-active);
  border-color: var(--solid-active);
}

/* ── home ────────────────────────────────────────────────────────────── */

.home-title {
  font-size: clamp(38px, 8vw, 62px);
  line-height: 1;
}

.identity {
  font-size: 19px;
  line-height: 1.45;
  max-width: 30em;
}

.contracting {
  font-size: 17px;
}

.section-title {
  margin: 0 0 var(--space-4);
  font-size: 26px;
}

.work-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) 0;
}

.work-item h3 {
  font-size: 21px;
}

.work-item p {
  font-size: 15px;
  max-width: 46em;
}

.work-item-last {
  gap: var(--space-3);
  padding-bottom: 0;
}

.hardware {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: var(--space-3) var(--space-6);
  margin-top: var(--space-2);
}

.hardware > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hardware-title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 16px;
}

.hardware-desc {
  font-size: 14px;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* Stacked (narrow) home: same order and spacing as a plain column. The
   spread below rearranges these into a grid. */
.home-nav {
  justify-content: flex-end;
}

.home-nav,
.home-title,
.home-identity,
.home-contract {
  order: -1;
}

.home-identity {
  margin-top: calc(var(--space-4) - var(--space-8) * 1.6);
}

.home-side {
  display: contents;
}

.post-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-4) 0;
  color: var(--ink);
  text-decoration: none;
}

.post-list-title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 19px;
}

.post-list-date {
  font-size: 14px;
  color: var(--ink-soft);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  font-size: 15px;
}

/* ── home spread ───────────────────────────────────────────────────────
   One screen on laptops and up. The name runs across the top two
   columns, work sits under it, and the side column holds writing at the
   top and contracting at the bottom, so the page reads corner to corner.
   Dotted dividers mark where the columns meet. */

@media (min-width: 1120px) and (min-height: 680px) {
  .page-home {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: var(--space-6) clamp(var(--space-6), 3vw, 48px);
  }

  .home-spread {
    max-width: 1360px;
    display: grid;
    grid-template-columns: 2.5fr 5.7fr 2.8fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "nav   nav   nav"
      "name  name  side"
      "id    work  side"
      "foot  foot  foot";
    gap: 0;
  }

  .home-spread > *,
  .home-contract {
    order: 0;
    margin: 0;
  }

  .home-nav {
    grid-area: nav;
  }

  .home-title {
    grid-area: name;
    align-self: end;
    padding: clamp(var(--space-4), 4vh, 56px) var(--space-8) clamp(var(--space-3), 2vh, 28px) 0;
    font-size: clamp(40px, min(6.1vw, 11vh), 84px);
    letter-spacing: -0.035em;
    white-space: nowrap;
  }

  .home-identity {
    grid-area: id;
    padding: var(--space-4) var(--space-8) 0 0;
    font-size: clamp(16px, 1.5vw, 19px);
  }

  .home-work {
    grid-area: work;
    min-height: 0;
    padding: clamp(var(--space-3), 3vh, 56px) var(--space-8) var(--space-4);
  }

  .home-work .section-title {
    margin-bottom: var(--space-3);
    font-size: 22px;
  }

  .home-work .work-item {
    display: grid;
    grid-template-columns: 7em minmax(0, 1fr);
    column-gap: var(--space-6);
    row-gap: var(--space-2);
    padding: var(--space-3) 0;
  }

  .home-work .work-item > * {
    grid-column: 2;
  }

  .home-work .work-item h3 {
    grid-column: 1;
    grid-row: 1 / span 2;
    padding-top: 1px;
    font-size: 17px;
  }

  .home-work .work-item p {
    font-size: 14px;
  }

  .home-work .work-item-last {
    padding-bottom: 0;
  }

  /* Titles only; the active item's description takes the caption slot
     reserved under the grid. */
  .home-work .hardware {
    --caption: calc(4 * 1.5em + var(--space-4));
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-1) var(--space-6);
    margin-top: var(--space-1);
    padding-bottom: calc(var(--caption) + var(--space-3));
    font-size: 14px;
  }

  .hw {
    align-self: start;
    cursor: default;
  }

  .hw .hardware-title {
    align-self: flex-start;
    padding-bottom: 3px;
    font-size: 15px;
    color: var(--ink-soft);
    transition: color 120ms;
  }

  .hw:hover .hardware-title,
  .hw.is-active .hardware-title {
    color: var(--ink);
  }

  .hw.is-active .hardware-title {
    background-image: var(--dots);
    background-size: 5px 2px;
    background-repeat: repeat-x;
    background-position: bottom left;
  }

  .hw:focus-visible {
    outline-offset: 4px;
  }

  .hw .hardware-desc {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--caption);
    padding-top: var(--space-4);
    line-height: 1.5;
    color: var(--ink);
    background-image: var(--dots);
    background-size: 5px 2px;
    background-repeat: repeat-x;
    background-position: top left;
    visibility: hidden;
    opacity: 0;
  }

  .hw.is-active .hardware-desc {
    visibility: visible;
    opacity: 1;
    transition: opacity 160ms;
  }

  .home-side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 0;
  }

  .home-writing {
    padding: clamp(var(--space-4), 4vh, 56px) 0 var(--space-6) var(--space-8);
  }

  .home-writing .section-title {
    margin-bottom: var(--space-3);
    font-size: 22px;
  }

  .home-writing .post-list-item {
    padding: var(--space-3) 0;
  }

  .home-writing .post-list-title {
    font-size: 16px;
    line-height: 1.3;
  }

  .home-writing .post-list-date {
    font-size: 13px;
  }

  .home-contract {
    padding: 0 0 var(--space-6) var(--space-8);
    font-size: 15px;
  }

  .home-foot {
    grid-area: foot;
    padding-top: var(--space-3);
    font-size: 14px;
  }

  /* Every rule on the spread is the same dotted line. */
  .home-spread .rule-top,
  .home-spread .rule-bottom {
    background-image: var(--dots);
    background-size: 5px 2px;
  }

  .home-spread .rule-both {
    background-image: var(--dots), var(--dots);
    background-size: 5px 2px;
  }

  .home-work,
  .home-side {
    background-image: var(--dots);
    background-size: 2px 5px;
    background-repeat: repeat-y;
    background-position: top left;
  }

  .home-foot {
    background-image: var(--dots);
    background-size: 5px 2px;
    background-repeat: repeat-x;
    background-position: top left;
  }

}

/* ── writing index ───────────────────────────────────────────────────── */

.index-title {
  font-size: clamp(34px, 7vw, 52px);
  line-height: 1;
}

.index-deck {
  font-size: 18px;
  max-width: 32em;
}

.index-item {
  gap: var(--space-2);
  padding: var(--space-6) 0;
}

.index-item-title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 26px;
  line-height: 1.1;
}

.index-item-meta {
  font-size: 15px;
  color: var(--ink-soft);
}

.index-item-summary {
  font-size: 15px;
  max-width: 44em;
  text-wrap: pretty;
}

/* ── post ────────────────────────────────────────────────────────────── */

.post-title {
  font-size: clamp(34px, 7vw, 54px);
  line-height: 1;
}

.post-deck {
  font-size: 19px;
  line-height: 1.45;
  max-width: 34em;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  padding-top: var(--space-2);
  font-size: 15px;
  color: var(--ink-soft);
}

.prose,
.prose-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.prose {
  max-width: 40em;
}

.prose h2 {
  font-size: 30px;
}

.prose p,
.prose-body {
  font-size: 16px;
  line-height: 1.6;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--space-8) var(--space-6);
  align-items: start;
}

.split > .prose {
  max-width: none;
}

.figure img {
  width: 100%;
}

/* A grid rather than a wrapping flex row, so the dashed dividers stay a
   closed lattice whatever the width: 3×2 in the narrow split column,
   one row of 6 when there's room. */
.packet-wrap {
  container-type: inline-size;
}

.packet {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px dashed var(--rule-box);
  border-left: 1px dashed var(--rule-box);
  font-family: var(--font-heading);
  font-size: 13px;
  line-height: 1.2;
}

.packet > span {
  padding: var(--space-2) var(--space-3);
  border-right: 1px dashed var(--rule-box);
  border-bottom: 1px dashed var(--rule-box);
  white-space: nowrap;
}

@container (min-width: 480px) {
  .packet {
    grid-template-columns: repeat(6, auto);
  }
}

.post-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  padding-top: var(--space-4);
  font-size: 15px;
}
