/* Warm off-black by default (same black as the hoodie), paper-white in light mode */
:root {
  --bg: #121211;
  --text: #e7e5df;
  --muted: #9a978f;
  --rule: #2b2a27;
  --field: #1a1a18;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

:root[data-theme="light"] {
  --bg: #f6f5f1;
  --text: #1c1b19;
  --muted: #6d6a63;
  --rule: #dcd9d0;
  --field: #ffffff;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

::selection { background: var(--text); color: var(--bg); }

.hidden { display: none; }

/* Header */
.site-header,
main,
.site-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-top: 32px;
  padding-bottom: 32px;
}
.name {
  font-weight: 600;
  text-decoration: none;
  font-size: 1.05rem;
}
.site-header nav {
  display: flex;
  align-items: baseline;
  gap: 18px;
  font-family: var(--mono);
  font-size: .8rem;
}
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: var(--text); }
.theme-toggle {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.theme-toggle::before { content: "["; }
.theme-toggle::after { content: "]"; }
.theme-toggle:hover { color: var(--text); }

/* Content */
main section { margin: 0 0 56px; scroll-margin-top: 24px; }

h1, h2 { font-weight: 600; line-height: 1.2; }
h1 { font-size: 2.4rem; margin: 24px 0 20px; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 0 0 14px; }

p { margin: 0 0 16px; }

.aside { color: var(--muted); }
.aside em { color: var(--text); }

/* fig. 1 */
.flow-figure { margin: 36px 0 0; }
/* The canvas is absolutely positioned so its pixel buffer never feeds back into layout */
.fig-frame {
  position: relative;
  height: 300px;
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.fig-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.process-frame { height: 250px; }
@media (max-width: 560px) {
  .fig-frame { height: 270px; }
  .process-frame { height: 210px; }
}
figcaption {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
  margin-top: 8px;
}

/* Work */
.timeline, .plain { list-style: none; margin: 0 0 18px; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 12px;
  padding: 6px 0;
}
.when {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  padding-top: .3em;
}
.tools { color: var(--muted); }
.kind {
  display: block;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
}

.plain li { padding-left: 1.1em; position: relative; margin-bottom: 6px; }
.plain li::before { content: "–"; position: absolute; left: 0; color: var(--muted); }

/* Hoodie */
.hoodie-row { display: flex; gap: 28px; align-items: center; }
.hoodie-row p { margin: 0; }
.polaroid {
  margin: 8px 0 0;
  flex: 0 0 190px;
  background: #fff;
  padding: 8px 8px 4px;
  transform: rotate(-2.5deg);
  box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 18px rgba(0,0,0,.18);
}
.polaroid img { display: block; width: 100%; height: auto; }
.polaroid figcaption { color: #555; text-align: center; margin: 4px 0 0; }

/* Footer */
.site-footer {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
  padding-top: 24px;
  padding-bottom: 48px;
}
.site-footer p { border-top: 1px solid var(--rule); padding-top: 20px; }

/* Contact form */
.contact-form { display: flex; flex-direction: column; gap: 18px; margin: 8px 0 32px; }
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--muted);
}
.contact-form input,
.contact-form textarea {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 10px 12px;
}
.contact-form textarea { resize: vertical; min-height: 140px; }
.contact-form input:focus,
.contact-form textarea:focus { outline: none; border-color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.form-actions p { margin: 0; font-size: .9rem; color: var(--muted); }
.contact-form button {
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--bg);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 3px;
  padding: 9px 22px;
  cursor: pointer;
}
.contact-form button:hover { opacity: .85; }
.contact-form button:disabled { opacity: .5; cursor: wait; }

/* Wide screens: the map sits to the right of the intro; everything else
   stays a readable column on the left, aligned with it */
@media (min-width: 1180px) {
  .site-header,
  main,
  .site-footer { max-width: 1240px; padding-left: 48px; padding-right: 48px; }
  main > *:not(.intro-split):not(.work-split) { max-width: 640px; }

  .intro-split,
  .work-split {
    display: grid;
    grid-template-columns: minmax(0, 580px) minmax(0, 1fr);
    column-gap: 48px;
    align-items: stretch;
  }
  .intro-split > :not(.flow-figure),
  .work-split > :not(.flow-figure) { grid-column: 1; }
  .intro-split > p:last-of-type,
  .work-split > p:last-of-type { margin-bottom: 0; }
  /* Top of the map lines up with the heading, bottom with the end of the intro */
  .intro-split .flow-figure {
    grid-column: 2;
    grid-row: 1 / span 4;
    margin: 30px 0 0;
    display: flex;
    flex-direction: column;
  }
  .intro-split .fig-frame { flex: 1; height: auto; min-height: 320px; }

  /* fig. 2 beside the Work section: top with the heading, bottom with the last line */
  .work-split .flow-figure {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
  }
  .work-split .fig-frame { flex: 1; height: auto; min-height: 260px; }
}

@media (max-width: 560px) {
  body { font-size: 18px; }
  h1 { font-size: 2rem; }
  .timeline li { grid-template-columns: 1fr; gap: 0; padding: 8px 0; }
  .hoodie-row { flex-direction: column; align-items: flex-start; }
  .polaroid { flex-basis: auto; width: 200px; }
}
