/* andytwoods.com — a maker's notebook.
   Warm paper, dark ink, monospace for anything the workshop would have
   written in the margin: dates, tags, filenames.

   Theme, contrast, text size and motion are driven by data-* attributes on
   <html> (set by static/js/a11y.js before first paint), not by media queries
   alone — so a stated preference always beats the OS default. */

:root {
  --paper: #f6f2ea;
  --paper-2: #efeae0;
  --ink: #1c1a17;
  --ink-soft: #55504a;
  --ink-faint: #8a837a;
  --rule: #ddd5c8;
  --accent: #b4471f;
  --accent-soft: #f0e3dc;
  --measure: 34rem;
  --scale: 1;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="system"] { color-scheme: light dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

/* The dark palette, applied for an explicit dark choice... */
html[data-theme="dark"] {
  --paper: #16150f;
  --paper-2: #1e1c16;
  --ink: #ece6da;
  --ink-soft: #a9a294;
  --ink-faint: #7b7466;
  --rule: #322e26;
  --accent: #e8804f;
  --accent-soft: #2a211b;
}

/* ...and for "system" when the OS asks for dark. */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --paper: #16150f;
    --paper-2: #1e1c16;
    --ink: #ece6da;
    --ink-soft: #a9a294;
    --ink-faint: #7b7466;
    --rule: #322e26;
    --accent: #e8804f;
    --accent-soft: #2a211b;
  }
}

/* Contrast. Low softens the ink; high pushes everything to the extremes and
   firms up the rules, which is what actually helps at low vision. */
html[data-a11y-contrast="low"] {
  --ink: #45413b;
  --ink-soft: #6e685f;
}
html[data-a11y-contrast="high"] {
  --ink: #000;
  --ink-soft: #1a1a1a;
  --ink-faint: #333;
  --rule: #666;
  --paper: #fff;
  --paper-2: #f2f2f2;
  --accent: #8f2f0d;
}
html[data-theme="dark"][data-a11y-contrast="high"] {
  --ink: #fff;
  --ink-soft: #e8e8e8;
  --ink-faint: #c8c8c8;
  --rule: #8a8a8a;
  --paper: #000;
  --paper-2: #121212;
  --accent: #ffa06a;
}

/* Text size. One variable, so every clamp() and rem-derived size follows. */
html[data-a11y-text="large"] { --scale: 1.15; }
html[data-a11y-text="extra-large"] { --scale: 1.35; }

/* Motion. Respect both the stored preference and the OS setting. */
html[data-a11y-motion="reduced"] *,
html[data-a11y-motion="reduced"] *::before,
html[data-a11y-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: calc(clamp(1.05rem, 0.98rem + 0.3vw, 1.2rem) * var(--scale));
  line-height: 1.6;
  font-synthesis-weight: none;
}

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--accent); color: var(--accent); }

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

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 10; }

.wrap { width: min(100% - 2.5rem, 68rem); margin-inline: auto; }
.prose-wrap { max-width: min(100% - 2.5rem, 46rem); }
.prose-wrap.wide { max-width: min(100% - 2.5rem, 62rem); }

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

.masthead {
  width: min(100% - 2.5rem, 68rem);
  margin: 0 auto;
  padding: 2.4rem 0 1.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}

.wordmark { text-decoration: none; display: block; }
.wordmark:hover { color: inherit; }
.wordmark-name {
  display: block;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.wordmark-sub {
  display: block;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  margin-top: 0.15rem;
}

.masthead nav { display: flex; gap: 1.4rem; font-family: var(--mono); font-size: 0.85rem; }
.masthead nav a { text-decoration: none; color: var(--ink-soft); }
.masthead nav a:hover { color: var(--accent); }

/* ---------- shared type ---------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 2.6rem 0 0.6rem;
}
.eyebrow a { text-decoration: none; }

.page-title:first-child { margin-top: 2.8rem; }

.page-title {
  font-size: clamp(1.9rem, 1.35rem + 2.2vw, 3rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.022em;
  margin: 0 0 0.7rem;
  text-wrap: balance;
}

.lede { color: var(--ink-soft); max-width: var(--measure); margin: 0 0 2rem; }
.wide .lede { max-width: 44rem; font-size: 1.1em; }

.rule { border-top: 1px solid var(--rule); margin: 3rem 0 1.2rem; }

/* ---------- index ---------- */

.entries { list-style: none; margin: 1rem 0 0; padding: 0; }

.entry { border-top: 1px solid var(--rule); }
.entry:first-child { border-top: 0; }

.entry-link {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1.6rem;
  align-items: start;
  padding: 1.6rem 0 0.9rem;
  text-decoration: none;
}
.entry-link:hover { color: inherit; }

.entry-thumb {
  aspect-ratio: 4 / 3;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.entry-thumb img { width: 100%; height: 100%; object-fit: cover; }
.entry-link:hover .entry-thumb { border-color: var(--accent); }

.entry-text time {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.entry-text h2 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0.25rem 0 0;
  text-wrap: balance;
}
.entry-link:hover h2 { color: var(--accent); }
.entry-text p { color: var(--ink-soft); font-size: 0.95rem; margin: 0.45rem 0 0; }

.entry-tags { margin: 0 0 1.5rem 10.1rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.entry-tags a, .byline-tags a {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.1rem 0.42rem;
}
.entry-tags a:hover, .byline-tags a:hover {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}

@media (max-width: 34rem) {
  .entry-link { grid-template-columns: 5rem 1fr; gap: 1rem; }
  .entry-tags { margin-left: 6rem; }
}

/* ---------- post ---------- */

.byline { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-faint); margin: 0 0 2rem;
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.byline-tags { display: inline-flex; gap: 0.35rem; }

.hero { margin: 0 0 2.4rem; }
.hero img { width: 100%; border: 1px solid var(--rule); }

.prose > * + * { margin-top: 1.15em; }
.prose h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; margin-top: 2.4em; }
.prose h3 { font-size: 1.2rem; font-weight: 600; margin-top: 2em; }
.prose img { margin: 2rem 0; border: 1px solid var(--rule); }
.prose blockquote {
  margin: 2rem 0; padding-left: 1.2rem;
  border-left: 2px solid var(--accent); color: var(--ink-soft); font-style: italic;
}
.prose code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 2px; padding: 0.08em 0.3em;
}
.prose pre {
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.55;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  padding: 1rem 1.1rem; overflow-x: auto; margin: 2rem 0;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose iframe, .prose blockquote.twitter-tweet { max-width: 100% !important; }

.backlink { font-family: var(--mono); font-size: 0.82rem; }
.backlink a { text-decoration: none; color: var(--ink-soft); }

/* ---------- work page: photo-led project grid ---------- */

.prose .project {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
  padding: 2.2rem 0;
  border-top: 1px solid var(--rule);
  margin-top: 0;
}
.prose .project h3 { margin-top: 0; }
.prose .project > * { margin-top: 0; }
.prose .project-text > * + * { margin-top: 1em; }
.prose .project-shot { margin: 0; }
.prose .project-shot img { margin: 0; width: 100%; }

/* Two columns only once a project actually has a photo. Until then a single
   column reads as deliberate rather than as a missing image. */
@media (min-width: 46rem) {
  .prose .project:has(.project-shot img) {
    grid-template-columns: 1fr 1.1fr;
    gap: 2.4rem;
    align-items: start;
  }
  .prose .project:not(:has(.project-shot img)) .project-text { max-width: 44rem; }
}

.prose .made {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.4em;
}

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

.foot {
  width: min(100% - 2.5rem, 68rem);
  margin: 4rem auto 3rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
}
.foot a { text-decoration: none; }
.foot .rule { margin-bottom: 1.2rem; }

/* ---------- accessibility panel ---------- */

.masthead nav button {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.masthead nav button:hover { color: var(--accent); }

.a11y {
  width: min(100% - 2.5rem, 68rem);
  margin: 1.2rem auto 0;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--rule);
  background: var(--paper-2);
}
.a11y h2 {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  margin: 0 0 1rem;
}
.a11y-group { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-bottom: 0.7rem; }
.a11y-label { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); min-width: 6rem; }
.a11y-options { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.a11y-options button {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.22rem 0.6rem;
  cursor: pointer;
}
.a11y-options button:hover { border-color: var(--accent); color: var(--accent); }
.a11y-options button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
.a11y-note { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-faint); margin: 0.9rem 0 0; }

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