@layer reset, tokens, base, layout, components, states, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p, ol { margin: 0; }
  button, summary { font: inherit; }
  img, svg, canvas { display: block; max-width: 100%; }
  button { color: inherit; }
}

@layer tokens {
  :root {
    --ink: #101513;
    --ink-raised: #171d1a;
    --paper: #f1ede4;
    --paper-bright: #faf7f0;
    --paper-deep: #dfd7c9;
    --copper: #d0844f;
    --copper-dark: #8f451c;
    --copper-bright: #ee9f69;
    --verdigris: #76a99b;
    --smoke: #aba99f;
    --line-dark: rgba(16, 21, 19, 0.22);
    --line-light: rgba(241, 237, 228, 0.2);
    --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
    --body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --measure: 68rem;
    --gutter: clamp(1.2rem, 4vw, 4.5rem);
    --section-y: clamp(6rem, 12vw, 11rem);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  }
}

@layer base {
  html { background: var(--ink); }
  body {
    min-width: 18rem;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--body);
    font-size: 1rem;
    line-height: 1.62;
    text-rendering: optimizeLegibility;
  }

  ::selection { background: var(--copper); color: var(--ink); }

  a { color: inherit; text-decoration-thickness: 0.08em; text-underline-offset: 0.25em; }
  button { border: 0; background: none; }

  h1, h2, h3 {
    font-family: var(--display);
    font-weight: 400;
    text-wrap: balance;
  }

  h2 {
    font-size: clamp(3rem, 7vw, 7.7rem);
    line-height: 0.91;
    letter-spacing: -0.045em;
  }

  h3 {
    font-size: clamp(2rem, 4vw, 4.6rem);
    line-height: 1;
    letter-spacing: -0.035em;
  }

  p { text-wrap: pretty; }
}

@layer layout {
  .skip-link {
    position: fixed;
    z-index: 100;
    top: 0.75rem;
    left: 0.75rem;
    transform: translateY(-180%);
    padding: 0.75rem 1rem;
    background: var(--paper-bright);
    color: var(--ink);
    text-decoration: none;
  }

  .skip-link:focus { transform: translateY(0); }

  .hero-shell {
    position: relative;
    min-height: 100svh;
    overflow: clip;
    background: var(--ink);
    color: var(--paper);
    isolation: isolate;
  }

  .thread-field {
    position: absolute;
    z-index: -1;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: pan-y;
  }

  .site-header {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1.25rem var(--gutter);
    border-bottom: 1px solid var(--line-light);
  }

  .site-header nav { display: flex; gap: clamp(1rem, 2.5vw, 2.75rem); }
  .site-header nav a {
    color: color-mix(in srgb, var(--paper) 78%, transparent);
    font-size: 0.84rem;
    text-decoration: none;
  }

  .wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--paper);
    font-family: var(--display);
    font-size: 1.25rem;
    text-decoration: none;
  }

  .wordmark svg { width: 2rem; height: 2rem; overflow: visible; }
  .wordmark path { fill: none; stroke: var(--copper); stroke-width: 1.7; stroke-linecap: round; }

  .hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(18rem, 0.78fr) minmax(28rem, 1.22fr);
    align-items: end;
    gap: clamp(2rem, 4vw, 5rem);
    min-height: calc(100svh - 4.6rem);
    padding: clamp(4rem, 8vh, 7rem) var(--gutter) clamp(3rem, 7vh, 5.5rem);
  }

  .hero-copy { position: relative; z-index: 2; max-width: 47rem; }
  .hero-intro { margin-bottom: clamp(2rem, 5vh, 4rem); color: var(--verdigris); font-size: 0.94rem; }
  .hero h1 {
    max-width: 8ch;
    font-size: clamp(5.1rem, 11vw, 12.2rem);
    line-height: 0.72;
    letter-spacing: -0.07em;
  }

  .hero-lede {
    max-width: 36rem;
    margin-top: clamp(2.4rem, 5vh, 4.5rem);
    color: color-mix(in srgb, var(--paper) 73%, transparent);
    font-size: clamp(1rem, 1.35vw, 1.25rem);
  }

  .field-instruction {
    position: absolute;
    right: var(--gutter);
    bottom: 1.25rem;
    color: #858983;
    font-size: 0.72rem;
  }

  .field-instruction span { margin-right: 0.5rem; color: var(--copper); }

  .section-wrap {
    display: grid;
    grid-template-columns: minmax(3rem, 0.22fr) minmax(0, 1.55fr) minmax(12rem, 0.58fr);
    column-gap: clamp(2rem, 6vw, 7rem);
    max-width: 100rem;
    margin-inline: auto;
    padding: var(--section-y) var(--gutter);
  }

  .section-number {
    color: var(--copper-dark);
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
    padding-top: 0.65rem;
  }
}

@layer components {
  .instrument {
    position: relative;
    align-self: center;
    justify-self: end;
    width: min(51vw, 48rem);
    min-width: 30rem;
    aspect-ratio: 1;
  }

  .instrument-stage {
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    --pull-x: 0px;
    --pull-y: 0px;
    position: absolute;
    inset: 4%;
    perspective: 75rem;
  }

  .thread-plate {
    width: 100%;
    height: 100%;
    overflow: visible;
    transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) translate(var(--pull-x), var(--pull-y));
    transition: transform 700ms var(--ease-out);
  }

  .plate-orbit, .plate-tick, .thread-path, .thread-knot-ring {
    fill: none;
    vector-effect: non-scaling-stroke;
  }

  .plate-orbit { stroke: rgba(241, 237, 228, 0.13); stroke-width: 1; }
  .plate-orbit-inner { stroke-dasharray: 2 9; }
  .plate-tick { stroke: rgba(241, 237, 228, 0.32); stroke-width: 1; }
  .thread-path {
    stroke: rgba(208, 132, 79, 0.17);
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-dasharray: 0.84 0.16;
    stroke-dashoffset: 0.04;
    transition: stroke 500ms ease, stroke-width 500ms ease, filter 500ms ease;
  }

  .thread-path.is-active {
    stroke: var(--copper-bright);
    stroke-width: 2.2;
    filter: drop-shadow(0 3px 2px rgba(208, 132, 79, 0.16));
    animation: thread-travel 12s linear infinite;
  }

  .thread-knot { fill: var(--copper-bright); transform-origin: center; }
  .thread-knot-ring { stroke: rgba(238, 159, 105, 0.44); stroke-width: 1; }

  .instrument-controls {
    position: absolute;
    inset: 0;
  }

  .verb-button {
    position: absolute;
    z-index: 2;
    min-width: 4rem;
    min-height: 2.75rem;
    padding: 0.4rem;
    color: rgba(241, 237, 228, 0.52);
    cursor: pointer;
    font-size: 0.8rem;
    transition: color 220ms ease;
  }

  .verb-button::before {
    content: "";
    position: absolute;
    width: 0.35rem;
    height: 0.35rem;
    border: 1px solid currentColor;
    border-radius: 50%;
    transition: background-color 220ms ease, transform 450ms var(--ease-out);
  }

  .verb-button[data-verb="notice"] { top: 0; left: 50%; transform: translateX(-50%); }
  .verb-button[data-verb="notice"]::before { left: 50%; bottom: -0.15rem; transform: translateX(-50%); }
  .verb-button[data-verb="think"] { top: 50%; right: -0.35rem; transform: translateY(-50%); }
  .verb-button[data-verb="think"]::before { left: -0.15rem; top: 50%; transform: translateY(-50%); }
  .verb-button[data-verb="make"] { bottom: 0; left: 50%; transform: translateX(-50%); }
  .verb-button[data-verb="make"]::before { left: 50%; top: -0.15rem; transform: translateX(-50%); }
  .verb-button[data-verb="keep"] { top: 50%; left: -0.35rem; transform: translateY(-50%); }
  .verb-button[data-verb="keep"]::before { right: -0.15rem; top: 50%; transform: translateY(-50%); }

  .verb-button.is-active { color: var(--paper); }
  .verb-button.is-active::before { background: var(--copper-bright); border-color: var(--copper-bright); transform: scale(1.5); }
  .verb-button[data-verb="notice"].is-active::before,
  .verb-button[data-verb="make"].is-active::before { transform: translateX(-50%) scale(1.5); }
  .verb-button[data-verb="think"].is-active::before,
  .verb-button[data-verb="keep"].is-active::before { transform: translateY(-50%) scale(1.5); }

  .instrument-note {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 13rem;
    transform: translate(-50%, -50%);
    color: rgba(241, 237, 228, 0.63);
    font-family: var(--display);
    font-size: 1.05rem;
    line-height: 1.35;
    text-align: center;
  }

  .verb-index {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--copper);
    color: var(--ink);
  }

  .verb-index p {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 4.25rem;
    padding: 0.85rem clamp(1rem, 2.5vw, 2.3rem);
    border-right: 1px solid rgba(16, 21, 19, 0.24);
    font-family: var(--display);
    font-size: clamp(1rem, 1.7vw, 1.35rem);
  }

  .verb-index p:last-child { border-right: 0; }
  .verb-index span { font-family: var(--body); font-size: 0.66rem; }

  .statement { background: var(--paper); }
  .statement-main h2 { max-width: 10ch; }
  .statement-lead {
    max-width: 20ch;
    margin-top: clamp(3rem, 7vw, 6.5rem);
    font-family: var(--display);
    font-size: clamp(2rem, 3.5vw, 3.7rem);
    line-height: 1.05;
    letter-spacing: -0.025em;
  }

  .statement-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(2rem, 4vw, 4.5rem);
    max-width: 54rem;
    margin-top: clamp(4rem, 8vw, 8rem);
    color: color-mix(in srgb, var(--ink) 76%, transparent);
  }

  .margin-note {
    align-self: start;
    margin-top: clamp(10rem, 18vw, 19rem);
    padding-top: 1rem;
    border-top: 1px solid var(--copper);
    color: color-mix(in srgb, var(--ink) 65%, transparent);
    font-size: 0.82rem;
  }

  .practice { background: var(--paper-bright); }
  .practice-heading { padding-bottom: clamp(4rem, 7vw, 7rem); }
  .practice-heading > div:nth-child(2) { grid-column: 2 / 4; }
  .practice-heading h2 { max-width: 8ch; }
  .practice-heading p { max-width: 30rem; margin-top: 2rem; color: color-mix(in srgb, var(--ink) 62%, transparent); }

  .practice-list { border-top: 1px solid var(--line-dark); }
  .practice-row {
    display: grid;
    grid-template-columns: minmax(3rem, 0.22fr) minmax(12rem, 0.62fr) minmax(18rem, 0.96fr);
    gap: clamp(2rem, 6vw, 7rem);
    align-items: baseline;
    max-width: 100rem;
    margin-inline: auto;
    padding: clamp(2.6rem, 5vw, 5rem) var(--gutter);
    border-bottom: 1px solid var(--line-dark);
  }

  .practice-count { color: var(--copper-dark); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
  .practice-row > p:last-child { max-width: 37rem; color: color-mix(in srgb, var(--ink) 70%, transparent); font-size: clamp(1rem, 1.4vw, 1.2rem); }

  .boundaries {
    position: relative;
    overflow: clip;
    background: var(--ink-raised);
    color: var(--paper);
  }

  .boundaries::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--gutter) + 3rem);
    width: 1px;
    background: rgba(208, 132, 79, 0.2);
  }

  .boundary-intro { padding-bottom: clamp(4rem, 8vw, 7rem); }
  .boundary-intro .section-number { color: var(--copper-bright); }
  .boundary-intro > div:nth-child(2) { grid-column: 2 / 4; }
  .boundary-intro h2 { max-width: 9ch; }
  .boundary-intro p { max-width: 40rem; margin-top: 2.5rem; color: rgba(241, 237, 228, 0.62); }

  .boundary-list {
    max-width: 100rem;
    margin-inline: auto;
    padding: 0 var(--gutter) var(--section-y);
    list-style: none;
    counter-reset: boundary;
  }

  .boundary-list li {
    display: grid;
    grid-template-columns: minmax(15rem, 0.95fr) minmax(17rem, 0.75fr);
    gap: clamp(2rem, 8vw, 9rem);
    align-items: baseline;
    padding: clamp(2.5rem, 5vw, 5rem) 0;
    border-top: 1px solid var(--line-light);
    counter-increment: boundary;
  }

  .boundary-list li::before {
    content: "0" counter(boundary);
    position: absolute;
    color: var(--copper);
    font-size: 0.75rem;
    transform: translateY(0.5rem);
  }

  .boundary-list li > span { padding-left: clamp(3rem, 6vw, 6rem); font-family: var(--display); font-size: clamp(2rem, 4.2vw, 4.7rem); line-height: 1; }
  .boundary-list li p { color: rgba(241, 237, 228, 0.58); }

  .now { background: var(--paper-deep); }
  .now-main h2 { max-width: 11ch; }
  .now-date { margin-bottom: 2rem; color: #595b56; font-size: 0.8rem; }
  .now-main > p:not(.now-date) { max-width: 43rem; margin-top: 2rem; color: color-mix(in srgb, var(--ink) 72%, transparent); }

  .colophon {
    align-self: end;
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
  }

  .colophon summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 3.5rem;
    cursor: pointer;
    list-style: none;
    font-size: 0.82rem;
  }

  .colophon summary::-webkit-details-marker { display: none; }
  .colophon summary::after { content: "+"; color: var(--copper); font-family: var(--display); font-size: 1.6rem; }
  .colophon[open] summary::after { content: "−"; }
  .colophon div { padding: 0.5rem 0 1.5rem; color: color-mix(in srgb, var(--ink) 68%, transparent); font-size: 0.8rem; }
  .colophon div p + p { margin-top: 1rem; }

  .site-footer {
    display: grid;
    grid-template-columns: minmax(7rem, 0.55fr) minmax(12rem, 1.25fr) minmax(12rem, 0.8fr);
    grid-template-rows: auto auto;
    gap: 1rem clamp(2rem, 6vw, 7rem);
    align-items: end;
    min-height: 37rem;
    padding: clamp(5rem, 10vw, 9rem) var(--gutter) 2.2rem;
    background: var(--ink);
    color: var(--paper);
  }

  .footer-mark { grid-row: 1 / 3; width: min(16vw, 10rem); }
  .footer-mark path { fill: none; stroke: var(--copper); stroke-width: 1.6; stroke-linecap: round; }
  .footer-name { align-self: end; font-family: var(--display); font-size: clamp(5rem, 13vw, 13rem); line-height: 0.7; letter-spacing: -0.06em; }
  .footer-line { align-self: start; color: rgba(241, 237, 228, 0.5); }
  .site-footer > a { align-self: end; justify-self: start; color: var(--paper); font-size: 0.84rem; }
  .footer-meta { align-self: start; color: #858983; font-size: 0.7rem; }

  .not-found {
    display: grid;
    min-height: 100svh;
    place-items: center;
    padding: 2rem;
    background: var(--ink);
    color: var(--paper);
  }

  .not-found main { width: min(100%, 48rem); }
  .not-found svg { width: 6rem; margin-bottom: 3rem; }
  .not-found svg path { fill: none; stroke: var(--copper); stroke-width: 1.7; stroke-linecap: round; }
  .not-found main > p { margin-bottom: 1.5rem; color: var(--verdigris); font-size: 0.8rem; }
  .not-found h1 { max-width: 12ch; margin-bottom: 3rem; font-size: clamp(3rem, 9vw, 7rem); line-height: 0.92; letter-spacing: -0.045em; }
  .not-found a { color: var(--paper); }
}

@layer states {
  @keyframes thread-travel { to { stroke-dashoffset: -0.96; } }

  :focus-visible { outline: 2px solid var(--copper-bright); outline-offset: 0.3rem; }
  .verb-button:hover, .site-header nav a:hover { color: var(--paper); }
  .site-footer a:hover { text-decoration-thickness: 0.15em; }

  .no-js .field-instruction { display: none; }
  .no-js .thread-path:first-of-type { stroke: var(--copper-bright); stroke-width: 2.2; }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.001ms !important; }
    .field-instruction { display: none; }
  }

  @media (forced-colors: active) {
    .thread-field { display: none; }
    .thread-path, .plate-orbit, .plate-tick, .thread-knot-ring, .wordmark path, .footer-mark path { stroke: CanvasText; }
    .thread-knot { fill: CanvasText; }
    .verb-button::before { forced-color-adjust: none; }
  }
}

@layer responsive {
  @media (max-width: 68rem) {
    .hero {
      grid-template-columns: 1fr;
      align-items: start;
      padding-top: 4rem;
    }

    .hero-copy { max-width: 43rem; }
    .hero h1 { font-size: clamp(5rem, 17vw, 9rem); }
    .instrument {
      justify-self: center;
      width: min(82vw, 42rem);
      min-width: 0;
      margin-top: -1rem;
    }

    .section-wrap { grid-template-columns: 3rem minmax(0, 1fr); }
    .statement-main, .now-main { grid-column: 2; }
    .margin-note, .colophon { grid-column: 2; }
    .margin-note { margin-top: 5rem; max-width: 23rem; }
    .practice-heading > div:nth-child(2), .boundary-intro > div:nth-child(2) { grid-column: 2; }
    .practice-row { grid-template-columns: 3rem minmax(12rem, 0.65fr) minmax(16rem, 1fr); }
    .site-footer { grid-template-columns: 8rem 1fr; }
    .footer-mark { grid-row: 1 / 4; }
    .footer-name { grid-column: 2; }
    .footer-line { grid-column: 2; }
    .site-footer > a { grid-column: 2; margin-top: 3rem; }
    .footer-meta { grid-column: 2; }
  }

  @media (max-width: 46rem) {
    :root { --gutter: 1.25rem; --section-y: 6.5rem; }
    .site-header { align-items: flex-start; }
    .site-header nav { display: grid; grid-template-columns: repeat(2, auto); gap: 0.55rem 1.2rem; }
    .site-header nav a { font-size: 0.72rem; }
    .wordmark span { display: none; }
    .hero { min-height: auto; padding-top: 3.5rem; padding-bottom: 4.5rem; }
    .hero-intro { margin-bottom: 2.5rem; }
    .hero h1 { font-size: clamp(4.7rem, 23vw, 7rem); line-height: 0.76; }
    .hero-lede { margin-top: 2.5rem; }
    .instrument { width: calc(100vw - 1rem); margin-left: -0.75rem; margin-top: 2rem; }
    .instrument-note { width: 10rem; font-size: 0.9rem; }
    .field-instruction { display: none; }
    .verb-index { grid-template-columns: repeat(2, 1fr); }
    .verb-index p { min-height: 3.6rem; border-bottom: 1px solid rgba(16, 21, 19, 0.24); }
    .verb-index p:nth-child(2) { border-right: 0; }
    .section-wrap { grid-template-columns: 2rem minmax(0, 1fr); column-gap: 1rem; }
    .section-number { padding-top: 0.3rem; }
    .statement-main h2, .now-main h2 { max-width: none; }
    .statement-lead { max-width: 16ch; }
    .statement-body { grid-template-columns: 1fr; gap: 1.7rem; }
    .margin-note { margin-top: 4rem; }
    .practice-row {
      grid-template-columns: 2rem minmax(0, 1fr);
      gap: 1rem;
      padding-block: 2.8rem;
    }
    .practice-row h3 { grid-column: 2; }
    .practice-row > p:last-child { grid-column: 2; }
    .boundary-list li { grid-template-columns: 1fr; gap: 1.5rem; }
    .boundary-list li > span { padding-left: 2.5rem; }
    .boundary-list li p { padding-left: 2.5rem; }
    .colophon { margin-top: 4rem; }
    .site-footer {
      grid-template-columns: 4.5rem 1fr;
      min-height: 31rem;
      gap: 1rem 1.25rem;
    }
    .footer-mark { width: 4.5rem; }
    .footer-name { font-size: clamp(5rem, 23vw, 8rem); }
  }

  @media (max-width: 23rem) {
    .site-header nav { gap: 0.4rem 0.8rem; }
    .instrument { width: calc(100vw - 2rem); margin-left: 0; }
    .verb-button { font-size: 0.7rem; }
  }
}
