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

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

@layer base {
  :root {
    --ink-950: #071113;
    --ink-900: #0a171a;
    --ink-800: #102227;
    --ink-700: #193239;
    --paper: #eee8da;
    --paper-deep: #e2dbc9;
    --paper-light: #f6f2e8;
    --graphite: #15282b;
    --muted-ink: #506365;
    --ivory: #f2ecde;
    --teal: #72b8ad;
    --teal-deep: #326e68;
    --brass: #b99b68;
    --line-dark: rgb(238 232 218 / 0.18);
    --line-light: rgb(21 40 43 / 0.18);
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans: "Avenir Next", Avenir, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --content: 76rem;
    --reading: 43rem;
  }

  body {
    min-width: 20rem;
    background: var(--ink-950);
    color: var(--ivory);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
  }

  body::before {
    position: fixed;
    z-index: 20;
    inset: 0;
    pointer-events: none;
    content: "";
    opacity: 0.12;
    background-image:
      repeating-radial-gradient(circle at 17% 23%, transparent 0 1px, rgb(255 255 255 / 0.05) 1px 2px, transparent 2px 5px),
      repeating-linear-gradient(92deg, transparent 0 7px, rgb(0 0 0 / 0.035) 7px 8px);
    mix-blend-mode: soft-light;
  }

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

  a {
    color: inherit;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.22em;
  }

  a:focus-visible,
  button:focus-visible,
  [tabindex]:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 5px;
  }

  .skip-link {
    position: fixed;
    z-index: 100;
    top: 0.8rem;
    left: 0.8rem;
    padding: 0.65rem 0.9rem;
    background: var(--paper-light);
    color: var(--graphite);
    transform: translateY(-180%);
    transition: transform 160ms ease;
  }

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

@layer layout {
  .site-header {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    width: min(calc(100% - 3rem), 90rem);
    min-height: 5.25rem;
    margin-inline: auto;
    border-bottom: 1px solid var(--line-dark);
  }

  .site-header nav {
    display: flex;
    align-items: center;
    gap: clamp(1.25rem, 3vw, 2.75rem);
  }

  .site-header nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding-block: 0.7rem;
    color: rgb(242 236 222 / 0.67);
    font-size: 0.73rem;
    font-weight: 650;
    letter-spacing: 0.13em;
    text-decoration: none;
    text-transform: uppercase;
  }

  .site-header nav a::after {
    position: absolute;
    right: 0;
    bottom: 0.35rem;
    left: 0;
    height: 1px;
    background: var(--teal);
    content: "";
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 180ms ease;
  }

  .site-header nav a:hover,
  .site-header nav a[aria-current="page"] { color: var(--ivory); }

  .site-header nav a:hover::after,
  .site-header nav a[aria-current="page"]::after {
    transform: scaleX(1);
    transform-origin: left;
  }

  .wordmark {
    display: inline-flex;
    align-items: baseline;
    width: fit-content;
    gap: 0.72rem;
    text-decoration: none;
  }

  .wordmark span {
    font-family: var(--serif);
    font-size: 1.55rem;
    line-height: 1;
  }

  .wordmark small {
    color: var(--teal);
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
  }

  #main:focus { outline: none; }

  .site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: min(calc(100% - 3rem), var(--content));
    min-height: 8rem;
    margin-inline: auto;
    color: rgb(242 236 222 / 0.7);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
  }

  .site-footer a { color: var(--teal); }

  .hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(22rem, 0.82fr) minmax(34rem, 1.18fr);
    width: min(100%, 96rem);
    min-height: min(47rem, calc(100svh - 5.25rem));
    margin-inline: auto;
    overflow: hidden;
    isolation: isolate;
  }

  .hero::before {
    position: absolute;
    z-index: 3;
    top: clamp(3rem, 10vh, 7rem);
    left: clamp(1.5rem, 3.5vw, 4rem);
    width: 1px;
    height: clamp(5rem, 18vh, 9rem);
    background: linear-gradient(to bottom, var(--brass), transparent);
    content: "";
  }

  .hero-copy {
    position: relative;
    z-index: 4;
    align-self: center;
    padding: clamp(5rem, 11vh, 8rem) 0 clamp(5rem, 11vh, 8rem) clamp(3.6rem, 7vw, 7.5rem);
  }

  .hero-art {
    position: relative;
    z-index: 1;
    min-height: 100%;
    margin-left: -10%;
    overflow: hidden;
  }

  .hero-art::before {
    position: absolute;
    z-index: 2;
    inset: 0;
    background:
      linear-gradient(90deg, var(--ink-950) 0%, rgb(7 17 19 / 0.82) 13%, transparent 47%),
      linear-gradient(0deg, rgb(7 17 19 / 0.46), transparent 35%);
    content: "";
    pointer-events: none;
  }

  .hero-art img {
    width: 100%;
    height: 100%;
    min-height: min(47rem, calc(100svh - 5.25rem));
    object-fit: cover;
    object-position: 67% center;
    filter: saturate(0.9) contrast(1.03);
  }

  .hero-art figcaption {
    position: absolute;
    z-index: 3;
    right: clamp(1.2rem, 3vw, 3.5rem);
    bottom: 1.3rem;
    color: rgb(242 236 222 / 0.78);
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 4px rgb(7 17 19 / 0.95);
  }

  .latest-note {
    display: grid;
    grid-template-columns: minmax(10rem, 0.36fr) minmax(0, 1fr);
    gap: clamp(2rem, 7vw, 7rem);
    padding: clamp(5rem, 10vw, 9rem) max(1.5rem, calc((100vw - var(--content)) / 2));
    background: var(--paper);
    color: var(--graphite);
  }

  .latest-note article { max-width: 47rem; }

  .latest-label {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding-top: 0.65rem;
    color: var(--teal-deep);
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .latest-label span {
    width: min(7rem, 8vw);
    height: 1px;
    margin-top: 0.72rem;
    background: var(--teal-deep);
  }

  .entry-page main,
  .archive-page main,
  .about-page main,
  .not-found-page main {
    min-height: calc(100svh - 13.25rem);
    background: var(--paper);
    color: var(--graphite);
  }

  .entry {
    width: min(calc(100% - 3rem), var(--reading));
    margin-inline: auto;
    padding-block: clamp(4rem, 9vw, 8rem) clamp(6rem, 12vw, 10rem);
  }

  .archive,
  .about,
  .not-found {
    width: min(calc(100% - 3rem), 61rem);
    margin-inline: auto;
    padding-block: clamp(4rem, 9vw, 8rem) clamp(6rem, 12vw, 10rem);
  }
}

@layer components {
  .eyebrow {
    max-width: 31rem;
    margin-bottom: 2rem;
    color: var(--teal);
    font-family: var(--mono);
    font-size: clamp(0.62rem, 0.9vw, 0.72rem);
    font-weight: 600;
    letter-spacing: 0.13em;
    line-height: 1.7;
    text-transform: uppercase;
  }

  .hero h1 {
    max-width: 45rem;
    font-family: var(--serif);
    font-size: clamp(4.2rem, 7.4vw, 7.75rem);
    font-weight: 400;
    letter-spacing: -0.055em;
    line-height: 0.79;
    text-wrap: balance;
  }

  .hero h1 span,
  .hero h1 em { display: block; }

  .hero h1 em {
    margin-top: 0.16em;
    color: var(--paper-deep);
    font-weight: 400;
  }

  .hero-intro {
    max-width: 35rem;
    margin-top: 2.6rem;
    color: rgb(242 236 222 / 0.72);
    font-family: var(--serif);
    font-size: clamp(1.05rem, 1.7vw, 1.38rem);
    line-height: 1.62;
    text-wrap: pretty;
  }

  .hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.4rem 2rem;
    margin-top: 2.8rem;
  }

  .primary-link,
  .quiet-link,
  .read-link,
  .back-link {
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .primary-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.8rem;
    padding: 0.72rem 1.1rem;
    border: 2px solid var(--teal);
    color: var(--ivory);
    text-decoration: none;
    transition: background 180ms ease, color 180ms ease;
  }

  .primary-link::after { margin-left: 0.8rem; content: "↗"; }
  .primary-link:hover { background: var(--teal); color: var(--ink-950); }
  .quiet-link { color: rgb(242 236 222 / 0.66); }

  .latest-note time,
  .entry-meta,
  .archive time {
    color: var(--muted-ink);
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }

  .latest-note h2 {
    margin-top: 1rem;
    font-family: var(--serif);
    font-size: clamp(3rem, 7vw, 6.4rem);
    font-weight: 400;
    letter-spacing: -0.045em;
    line-height: 0.96;
  }

  .latest-note h2 a { text-decoration: none; }
  .latest-note h2 a:hover { color: var(--teal-deep); }

  .latest-note article > p {
    max-width: 38rem;
    margin-top: 1.5rem;
    color: var(--muted-ink);
    font-family: var(--serif);
    font-size: clamp(1.05rem, 2vw, 1.28rem);
    line-height: 1.62;
  }

  .read-link {
    display: inline-block;
    margin-top: 2rem;
    color: var(--teal-deep);
  }

  .back-link {
    display: inline-block;
    margin-bottom: clamp(3rem, 7vw, 5rem);
    color: var(--teal-deep);
  }

  .entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .entry h1,
  .archive h1,
  .about h1 {
    margin-top: 1.2rem;
    font-family: var(--serif);
    font-size: clamp(3.4rem, 8vw, 6.3rem);
    font-weight: 400;
    letter-spacing: -0.05em;
    line-height: 0.94;
  }

  .entry .dek {
    margin-top: 1.8rem;
    color: var(--muted-ink);
    font-family: var(--serif);
    font-size: clamp(1.25rem, 2.8vw, 1.65rem);
    font-style: italic;
    line-height: 1.5;
    text-wrap: pretty;
  }

  .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 2rem;
    padding: 0;
    color: var(--teal-deep);
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.07em;
    list-style: none;
    text-transform: uppercase;
  }

  .tag-list li:not(:last-child)::after {
    margin-left: 0.45rem;
    color: var(--brass);
    content: "/";
  }

  .prose {
    margin-top: clamp(3.8rem, 8vw, 6rem);
    font-family: var(--serif);
    font-size: clamp(1.12rem, 2.2vw, 1.29rem);
    line-height: 1.78;
  }

  .prose > * + * { margin-top: 1.55em; }
  .prose > p { text-wrap: pretty; }

  .entry .prose > p:first-child::first-letter {
    float: left;
    margin: 0.04em 0.13em 0 0;
    color: var(--teal-deep);
    font-size: 3.8em;
    line-height: 0.78;
  }

  .prose h2 {
    margin-top: 2.8em;
    color: var(--teal-deep);
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    line-height: 1.4;
    text-transform: uppercase;
  }

  .prose blockquote {
    margin-block: 2.2em;
    padding-block: 1.25em;
    border-block: 1px solid var(--line-light);
    color: var(--teal-deep);
    font-size: 1.18em;
    font-style: italic;
  }

  .prose a { color: var(--teal-deep); }

  .archive > .eyebrow { color: var(--teal-deep); }

  .archive ol {
    margin-top: clamp(3.5rem, 8vw, 6rem);
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line-light);
  }

  .archive li {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 0 2rem;
    padding-block: 2.2rem;
    border-bottom: 1px solid var(--line-light);
  }

  .archive li > a {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: -0.025em;
    line-height: 1.05;
    text-decoration: none;
  }

  .archive li > a:hover { color: var(--teal-deep); }

  .archive li p {
    grid-column: 2;
    max-width: 36rem;
    margin-top: 0.8rem;
    color: var(--muted-ink);
  }

  .about > h1 { max-width: 48rem; }
  .about > h1 + p { margin-top: 3rem; }
  .about > p, .about > h2 { max-width: var(--reading); margin-inline: auto; }

  .not-found {
    display: grid;
    align-content: center;
    min-height: calc(100svh - 13.25rem);
  }

  .not-found .eyebrow { color: var(--teal-deep); }

  .not-found h1 {
    max-width: 48rem;
    font-family: var(--serif);
    font-size: clamp(3.4rem, 8vw, 6.3rem);
    font-weight: 400;
    letter-spacing: -0.05em;
    line-height: 0.94;
  }

  .not-found > p:not(.eyebrow) {
    max-width: 35rem;
    margin-top: 1.5rem;
    color: var(--muted-ink);
    font-family: var(--serif);
    font-size: 1.25rem;
  }

  .not-found .primary-link {
    width: fit-content;
    margin-top: 2.4rem;
    border-color: var(--teal-deep);
    color: var(--graphite);
  }

  .not-found .primary-link:hover { background: var(--teal-deep); color: var(--paper-light); }
}

@layer responsive {
  @media (max-width: 55rem) {
    .site-header { width: min(calc(100% - 2rem), 90rem); }

    .hero {
      grid-template-columns: 1fr;
      min-height: auto;
    }

    .hero::before { left: 1rem; }

    .hero-copy {
      padding: 5.25rem 1.5rem 3.5rem;
    }

    .hero-art {
      min-height: clamp(25rem, 67vw, 37rem);
      margin-left: 0;
    }

    .hero-art::before {
      background: linear-gradient(180deg, var(--ink-950) 0%, transparent 24%, rgb(7 17 19 / 0.18) 70%, rgb(7 17 19 / 0.74) 100%);
    }

    .hero-art img {
      position: absolute;
      inset: 0;
      min-height: 100%;
      object-position: 65% center;
    }

    .latest-note { grid-template-columns: 1fr; }
    .latest-label span { width: 6rem; }
  }

  @media (max-width: 39rem) {
    .site-header {
      grid-template-columns: 1fr;
      gap: 0.55rem;
      padding-block: 1rem;
    }

    .site-header nav { justify-content: space-between; width: 100%; }
    .wordmark small { display: none; }
    .hero h1 { font-size: clamp(3.3rem, 13.5vw, 3.8rem); }
    .hero-copy { padding-top: 4.3rem; }
    .hero::before { top: 2.2rem; height: 4.5rem; }
    .hero-actions { align-items: flex-start; flex-direction: column; }
    .hero-art { min-height: 29rem; }
    .hero-art figcaption { right: 1rem; }

    .latest-note,
    .entry,
    .archive,
    .about,
    .not-found {
      width: 100%;
      padding-inline: 1.5rem;
    }

    .archive li {
      grid-template-columns: 1fr;
      gap: 0.75rem;
    }

    .archive li p { grid-column: 1; }

    .site-footer {
      align-items: flex-start;
      flex-direction: column;
      justify-content: center;
      gap: 0.45rem;
      width: calc(100% - 2.7rem);
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .hero-copy > * {
      animation: settle 680ms both;
    }
    .hero-copy > :nth-child(2) { animation-delay: 70ms; }
    .hero-copy > :nth-child(3) { animation-delay: 130ms; }
    .hero-copy > :nth-child(4) { animation-delay: 190ms; }
    .hero-art img { animation: quiet-focus 1100ms both; }

    @keyframes settle {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    @keyframes quiet-focus {
      from { opacity: 0; transform: scale(1.018); }
      to { opacity: 1; transform: scale(1); }
    }
  }

  @media print {
    .site-header, .site-footer, .back-link, .tag-list { display: none; }
    body, .entry-page main { background: white; color: black; }
    .entry { width: 100%; padding: 0; }
    .prose { font-size: 12pt; }
  }
}
