/* The Mac Desk — site styles
   Warm paper, serif body, one burnt-sienna accent, hairline rules.
   No webfonts, no framework, no build step: this file ships as is. */

:root {
  --paper: #fbf9f4;
  --paper-soft: #f5f2ea;
  --card: #fffdf8;
  --ink: #23201b;
  --ink-soft: #3c3831;
  --muted: #6d675c;
  --line: #e2dccf;
  --line-strong: #cfc7b6;
  --accent: #9c3d1e;
  --accent-soft: #b65a34;
  --accent-tint: #f6e8e0;
  --code-bg: #f1ede3;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Charter, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --max: 1180px;
  --measure: 68ch;
  --radius: 12px;
}

[data-theme="dark"] {
  --paper: #12100d;
  --paper-soft: #191612;
  --card: #1b1814;
  --ink: #ece7dc;
  --ink-soft: #d6d0c3;
  --muted: #9d968a;
  --line: #2d2821;
  --line-strong: #3d372d;
  --accent: #e08459;
  --accent-soft: #eaa07c;
  --accent-tint: #2a1c14;
  --code-bg: #221e18;
}

/* System dark preference applies until the visitor picks a theme by hand.
   Values duplicate the block above on purpose: CSS cannot share a rule body
   between a media query and an attribute selector. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12100d;
    --paper-soft: #191612;
    --card: #1b1814;
    --ink: #ece7dc;
    --ink-soft: #d6d0c3;
    --muted: #9d968a;
    --line: #2d2821;
    --line-strong: #3d372d;
    --accent: #e08459;
    --accent-soft: #eaa07c;
    --accent-tint: #2a1c14;
    --code-bg: #221e18;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.68;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

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

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
}

p {
  margin: 0 0 1.1em;
}

.wrap {
  width: min(100% - 2.5rem, var(--max));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.1rem;
  z-index: 100;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 74px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}

.brand__name {
  display: block;
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand__tag {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.2rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.35rem;
}

.nav a {
  font-family: var(--sans);
  font-size: 0.83rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

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

.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tool {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
}

.tool:hover {
  background: var(--paper-soft);
  border-color: var(--line);
  color: var(--ink);
}

.nav-toggle {
  display: none;
}

.icon-sun,
.icon-moon {
  display: none;
}

:root:not([data-theme="dark"]) .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun {
    display: none;
  }

  :root:not([data-theme]) .icon-moon {
    display: block;
  }
}

/* ---------- home ---------- */

.lede {
  border-bottom: 1px solid var(--line);
  padding: clamp(2.2rem, 5vw, 3.6rem) 0 clamp(1.6rem, 3vw, 2.4rem);
}

.lede__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: clamp(1.6rem, 4vw, 3.4rem);
  align-items: start;
}

.kicker {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 0.75rem;
}

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

.lede__title {
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
  margin-bottom: 0.65rem;
}

.lede__title a {
  color: inherit;
  text-decoration: none;
}

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

.lede__dek {
  font-size: clamp(1.05rem, 1.6vw, 1.24rem);
  color: var(--ink-soft);
  line-height: 1.55;
  margin-bottom: 1rem;
  max-width: 52ch;
}

.meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.meta__dot {
  opacity: 0.5;
}

.side {
  border-left: 1px solid var(--line);
  padding-left: clamp(1rem, 2.4vw, 1.9rem);
  display: grid;
  gap: 1.15rem;
}

.side__item {
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--line);
}

.side__item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.side__title {
  font-size: 1.12rem;
  line-height: 1.3;
  margin: 0.25rem 0 0.3rem;
}

.side__title a {
  color: var(--ink);
  text-decoration: none;
}

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

.side__dek {
  font-size: 0.94rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ---------- blocks ---------- */

.block {
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-bottom: 1px solid var(--line);
}

.block:last-of-type {
  border-bottom: 0;
}

.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.block__title {
  font-size: clamp(1.4rem, 2.4vw, 1.75rem);
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.block__count {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.block__more {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.block__more:hover {
  text-decoration: underline;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.4rem, 3vw, 2.4rem);
}

.card {
  display: flex;
  flex-direction: column;
  padding-top: 1.15rem;
  border-top: 2px solid var(--ink);
}

.card--plain {
  border-top-color: var(--line-strong);
}

.card__title {
  font-size: 1.3rem;
  line-height: 1.24;
  margin-bottom: 0.45rem;
}

.card__title a {
  color: var(--ink);
  text-decoration: none;
}

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

.card__dek {
  font-size: 0.96rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.9rem;
}

.card__meta {
  margin-top: auto;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* rows used in section lists and archive */

.rows {
  display: grid;
  gap: 0;
}

.row {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 1.4rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.row:first-child {
  border-top: 1px solid var(--line);
}

.row__date {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row__title {
  font-size: 1.24rem;
  line-height: 1.28;
  margin-bottom: 0.3rem;
}

.row__title a {
  color: var(--ink);
  text-decoration: none;
}

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

.row__dek {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0;
  max-width: 62ch;
}

/* ---------- section / archive headers ---------- */

.page-head {
  padding: clamp(2.2rem, 5vw, 3.4rem) 0 1.5rem;
  border-bottom: 1px solid var(--line);
}

.page-head__title {
  font-size: clamp(2rem, 4vw, 2.9rem);
  margin-bottom: 0.5rem;
}

.page-head__dek {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 60ch;
  margin: 0;
}

.page-head__meta {
  margin-top: 1rem;
}

/* ---------- article ---------- */

.post {
  padding: clamp(2rem, 4vw, 3.2rem) 0 0;
}

.post__head {
  max-width: 46rem;
  margin-bottom: clamp(1.6rem, 3vw, 2.4rem);
}

.post__title {
  font-size: clamp(2rem, 4.4vw, 3.1rem);
  margin: 0.4rem 0 0.7rem;
}

.post__dek {
  font-size: clamp(1.06rem, 1.7vw, 1.25rem);
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0;
}

.post__body {
  display: grid;
  grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

.prose {
  font-size: 1.06rem;
  line-height: 1.72;
  color: var(--ink);
  min-width: 0;
}

.prose > p:first-of-type {
  font-size: 1.14rem;
  color: var(--ink-soft);
}

.prose h2 {
  font-size: 1.52rem;
  margin: 2.1em 0 0.6em;
  scroll-margin-top: 96px;
}

.prose h3 {
  font-size: 1.2rem;
  margin: 1.7em 0 0.45em;
  scroll-margin-top: 96px;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
  margin: 0 0 1.2em;
}

.prose li {
  margin-bottom: 0.45em;
}

.prose li::marker {
  color: var(--muted);
}

.prose blockquote {
  margin: 1.6em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.14em 0.36em;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.prose pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.4em 0;
  font-size: 0.86rem;
  line-height: 1.55;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 1em;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.prose pre:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn[data-copied="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.94rem;
  font-family: var(--sans);
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.prose th {
  font-weight: 600;
  border-bottom: 2px solid var(--line-strong);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.4em 0;
}

.prose img {
  border-radius: var(--radius);
  margin: 1.6em 0;
}

.toc {
  position: sticky;
  top: 96px;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.5;
  border-top: 1px solid var(--line-strong);
  padding-top: 0.8rem;
}

.toc__label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.toc a {
  color: var(--ink-soft);
  text-decoration: none;
}

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

.toc .toc__sub {
  padding-left: 0.9rem;
  font-size: 0.76rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
}

.tag {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.26rem 0.66rem;
  text-decoration: none;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.note {
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1.1rem;
  margin: 0 0 1.6rem;
}

.source {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--line);
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pager__link {
  text-decoration: none;
  display: grid;
  gap: 0.3rem;
}

.pager__link--next {
  text-align: right;
  justify-items: end;
}

.pager__label {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.pager__title {
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.3;
}

.pager__link:hover .pager__title {
  color: var(--accent);
}

/* ---------- search ---------- */

.search {
  display: grid;
  gap: 0.6rem;
  margin: 1.6rem 0 2rem;
  max-width: 34rem;
}

.search__input {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  width: 100%;
}

.search__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.search__hint {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
}

.search__empty {
  font-family: var(--sans);
  color: var(--muted);
  padding: 1.4rem 0;
}

/* ---------- empty state ---------- */

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: clamp(1.6rem, 4vw, 2.6rem);
  margin: 2rem 0;
  background: var(--card);
  max-width: 46rem;
}

.empty__title {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.empty__text {
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 58ch;
}

/* ---------- footer ---------- */

.footer {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
  padding: clamp(2rem, 4vw, 3rem) 0 2rem;
}

.footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
  gap: 2rem;
  padding-bottom: 1.8rem;
}

.footer__title {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.footer__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.footer__list a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.93rem;
}

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

.footer__note {
  color: var(--muted);
  font-size: 0.93rem;
  max-width: 38ch;
}

.footer__bottom {
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.6rem;
  align-items: center;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--muted);
}

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .post__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    display: none;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .nav {
    display: none;
  }

  .nav-toggle {
    display: grid;
  }

  .masthead__inner {
    min-height: 66px;
  }

  .masthead[data-open="true"] .nav {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.6rem 1.25rem 1rem;
  }

  .masthead[data-open="true"] .nav a {
    width: 100%;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
  }

  .lede__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 1.3rem;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 17px;
  }

  .brand__tag {
    display: none;
  }

  .brand__mark {
    width: 30px;
    height: 30px;
  }

  .wrap {
    width: min(100% - 2rem, var(--max));
  }

  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
  }

  .footer__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .pager__link--next {
    text-align: left;
    justify-items: start;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
  }

  .block__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .masthead,
  .footer,
  .pager,
  .toc,
  .tags,
  .copy-btn {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .post__body {
    display: block;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}
