/*
  stevenraines.org — "Shelf".
  A projects-first personal page: a short intro in Steve's words, then a grid
  of project tiles where the screenshots lead, then what he's into lately.
  Work history lives on /work/ and is linked from the footer.

  Theme: follows the visitor's system setting (prefers-color-scheme). The toggle
  in the top bar overrides it; that choice is stored in localStorage and
  applied as data-theme on <html> before first paint. Every color comes from a
  token below, with a dark value in both dark blocks: one for data-theme="dark",
  one for a dark system setting when the script hasn't run.

  Accessibility target: WCAG 2.2 AA. Text pairs meet 4.5:1 in both themes:
  --ink, --ink-2 and --muted on --bg, --surface; --accent on --bg and --surface.
*/

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-wght-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/assets/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
}

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --well: #eceff5;            /* behind screenshots */
  --ink: #111827;             /* 16:1 on --bg */
  --ink-2: #374151;           /* 9.6:1 on --bg */
  --muted: #4b5563;           /* 7:1 on --bg */
  --line: #e3e6eb;
  --line-strong: #c4cad3;
  --accent: #2453d6;          /* links: 6:1 on --bg, 6.4:1 on --surface */
  --accent-hover: #183c9e;
  --accent-solid: #2453d6;    /* button fill; --on-accent text on it */
  --on-accent: #ffffff;
  --focus: #2453d6;
  --shadow-img: rgb(15 23 42 / 0.22);
  --topbar-bg: rgb(246 247 249 / 0.9);

  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;

  --radius-lg: 1.25rem;
  --radius: 1rem;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #171b23;
  --well: #1e232d;
  --ink: #eef1f6;
  --ink-2: #d3d8e1;
  --muted: #a6aebb;           /* 8.6:1 on --bg, 7.9:1 on --surface */
  --line: #2a303c;
  --line-strong: #3d4554;
  --accent: #8fb8ff;          /* 9:1 on --bg */
  --accent-hover: #c2d6ff;
  --accent-solid: #8fb8ff;
  --on-accent: #0f1218;
  --focus: #8fb8ff;
  --shadow-img: rgb(0 0 0 / 0.5);
  --topbar-bg: rgb(15 18 24 / 0.9);

  color-scheme: dark;
}

/* Same dark values, for a dark system setting when the theme script hasn't run */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f1218;
    --surface: #171b23;
    --well: #1e232d;
    --ink: #eef1f6;
    --ink-2: #d3d8e1;
    --muted: #a6aebb;           /* 8.6:1 on --bg, 7.9:1 on --surface */
    --line: #2a303c;
    --line-strong: #3d4554;
    --accent: #8fb8ff;          /* 9:1 on --bg */
    --accent-hover: #c2d6ff;
    --accent-solid: #8fb8ff;
    --on-accent: #0f1218;
    --focus: #8fb8ff;
    --shadow-img: rgb(0 0 0 / 0.5);
    --topbar-bg: rgb(15 18 24 / 0.9);

    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img { max-width: 100%; height: auto; }
/* Icons from the sprite in icons.njk are line drawings */
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.015em; }
.wrap { width: 100%; max-width: 75rem; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 2rem); }
.muted { color: var(--muted); }
main:focus { outline: none; }

.skip {
  position: absolute; left: 1rem; top: -10rem; z-index: 100;
  padding: 0.75rem 1rem; border-radius: 0.5rem;
  background: var(--accent-solid); color: var(--on-accent); font-weight: 600;
}
.skip:focus { top: 1rem; }

.link-arrow { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.link-arrow svg { width: 1em; height: 1em; flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .link-arrow svg { transition: transform 0.15s ease; }
  .link-arrow:hover svg { transform: translateX(3px); }
}

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px;
  padding: 0 1.25rem; border-radius: 999px; font-weight: 600; text-decoration: none;
}
.btn-primary { background: var(--accent-solid); color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { color: var(--ink); border-color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.25rem; min-height: 4rem; }
.brand {
  display: inline-flex; align-items: center; gap: 0.75rem; min-height: 44px; margin-right: 1rem;
  color: var(--ink); text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }
.brand picture { display: block; }
.brand-photo { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--well); }
.topnav { margin-right: auto; }
.topnav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
.topnav li { display: flex; align-items: center; }
/* A dot between links; the empty alt text keeps screen readers from announcing it */
.topnav li + li::before { content: "·"; content: "·" / ""; padding-inline: 0.15rem; color: var(--muted); font-weight: 700; }
.topnav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.6rem;
  border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 500;
}
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--ink); background: var(--well); }
.theme-toggle {
  display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: 0.25rem;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle svg { width: 20px; height: 20px; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* Phones: name and theme toggle on the first row, the nav on its own row below */
@media (max-width: 40rem) {
  .topbar { position: static; }
  .topbar-inner { padding-block: 0.25rem; }
  .theme-toggle { order: 1; }
  .brand { margin-right: auto; }
  .topnav { order: 2; flex: 0 0 100%; margin-right: 0; }
  .topnav ul { justify-content: center; }
}

/* ---------- Intro ---------- */
.intro { padding-block: clamp(3rem, 8vw, 5.5rem) clamp(2.5rem, 6vw, 3.5rem); }
.eyebrow { margin: 0 0 1rem; font-size: 0.95rem; font-weight: 500; color: var(--muted); }
.intro h1 { font-size: clamp(2.6rem, 7vw, 4.25rem); line-height: 1.04; letter-spacing: -0.025em; max-width: 15ch; }
.intro-lead { margin: 1.25rem 0 0; font-size: clamp(1.15rem, 2.4vw, 1.35rem); line-height: 1.5; color: var(--ink-2); max-width: 42ch; }
.now { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 1.75rem; }
.now-label {
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.now-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.now-list li {
  display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.25rem 0.9rem;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-size: 0.95rem; font-weight: 500;
}

/* Read by screen readers, not shown */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- Sections ---------- */
.section { padding-block: 1rem clamp(3.5rem, 8vw, 5rem); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; margin-bottom: 1.5rem; }
.section-head h2 { font-size: clamp(1.6rem, 3.5vw, 1.9rem); }
.section-head p { margin: 0; color: var(--muted); }

/* ---------- Project shelf ----------
   One column on phones and tablets. From 60rem it is three columns and a wide
   tile takes two, so each row is a wide and a narrow tile (projects.json keeps
   the order that way) and no row ends with a gap. */
.shelf { --media-h: 17.5rem; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
@media (min-width: 60rem) {
  .shelf { --media-h: 21rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile--wide { grid-column: span 2; }
}
.tile {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
  scroll-margin-top: 5rem;
}
.tile-media {
  --inner-h: calc(var(--media-h) - 3rem);
  height: var(--media-h); padding: 1.5rem; background: var(--well);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.tile-media img { display: block; filter: drop-shadow(0 14px 22px var(--shadow-img)); }

/* A desktop window with a phone over its corner */
.device-stack { --ratio: 1.35; position: relative; width: min(100%, calc(var(--inner-h) * var(--ratio))); aspect-ratio: var(--ratio) / 1; }
.device-stack picture { position: absolute; }
.device-desktop { top: 0; left: 0; width: 85%; }
.device-phone { right: 0; bottom: 0; width: 22%; }
.device-stack img { width: 100%; height: auto; }
/* The phone held sideways: wider, and hanging further below the window */
.device-stack--landscape .device-phone { width: 46%; }

/* A desktop window on its own */
.device-solo img { width: auto; max-width: 100%; max-height: var(--inner-h); }

/* Two app windows, the second lower and to the right */
.window-pair { position: relative; width: min(100%, calc(var(--inner-h) * 1.5)); aspect-ratio: 1.5 / 1; }
.window-pair picture { position: absolute; width: 66%; }
.window-pair picture:first-child { top: 0; left: 0; }
.window-pair picture:last-child { right: 0; bottom: 0; }
.window-pair img { width: 100%; height: auto; }

/* Phone screenshots side by side */
.phones { list-style: none; margin: 0; padding: 0; height: 100%; display: flex; align-items: center; justify-content: center; gap: 1rem; }
.phones li { height: 100%; min-width: 0; flex: 0 1 auto; display: flex; align-items: center; }
.phones img { height: 100%; width: auto; max-width: 100%; object-fit: contain; }

/* A photo with its own shadows baked in */
.tile-photo img { width: auto; max-width: 100%; max-height: var(--inner-h); filter: none; }

.tile-body { flex: 1; display: flex; flex-direction: column; gap: 0.6rem; padding: 1.35rem 1.5rem 1.5rem; }
.tile-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; }
.tile h3 { font-size: 1.4rem; }
.tile--wide h3 { font-size: 1.6rem; }
.tile-body p { margin: 0; color: var(--ink-2); }
.tile-body .tile-date { margin-top: -0.35rem; font-size: 0.9rem; color: var(--muted); }
.status {
  display: inline-flex; align-items: center; gap: 0.3rem; min-height: 1.75rem; padding: 0.15rem 0.65rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
/* A status that links to the project: accent colour and an arrow say it goes somewhere */
.status--link { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.status--link:hover { color: var(--accent-hover); border-color: var(--accent-hover); background: var(--well); text-decoration: underline; text-underline-offset: 0.15em; }
.status--link svg { width: 0.95em; height: 0.95em; flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .status--link svg { transition: transform 0.15s ease; }
  .status--link:hover svg { transform: translateX(2px); }
}

/* ---------- Newest posts on the home page ---------- */
.post-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1.25rem; }
.post-cards li { padding: 1.25rem 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.post-cards time { font-size: 0.85rem; color: var(--muted); }
.post-cards h3 { margin: 0.35rem 0 0.5rem; font-size: 1.2rem; }
.post-cards h3 a { color: var(--ink); text-decoration: none; }
.post-cards h3 a:hover { text-decoration: underline; }
.post-cards p { margin: 0; color: var(--ink-2); }

/* ---------- Lately ---------- */
.lately-band { padding-block: clamp(3rem, 7vw, 4rem); background: var(--surface); border-block: 1px solid var(--line); }
.lately-band h2 { margin-bottom: 1.25rem; font-size: clamp(1.6rem, 3.5vw, 1.9rem); }
.lately-text { margin: 0; max-width: 62ch; font-size: clamp(1.1rem, 2.2vw, 1.25rem); line-height: 1.65; color: var(--ink-2); }
.lately-text em { padding-right: 0.08em; }
.lately-updated { margin: 1rem 0 0; font-size: 0.9rem; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { padding-block: clamp(3rem, 7vw, 4rem) 3rem; }
.footer-top {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem 2rem;
  padding-bottom: 1.75rem; border-bottom: 1px solid var(--line);
}
.site-footer h2 { font-size: clamp(1.6rem, 3.5vw, 1.9rem); }
.footer-email { margin: 0.5rem 0 0; font-size: 1.25rem; font-weight: 600; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.footer-links a {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink-2); background: var(--surface);
}
.footer-links a:hover { color: var(--accent); border-color: var(--accent); }
.footer-links a[aria-current="page"] { color: var(--accent); border-color: var(--accent); background: var(--well); }
.footer-links svg { width: 1.3rem; height: 1.3rem; }
.footer-meta { margin: 1.25rem 0 0; font-size: 0.9rem; color: var(--muted); }

/* ---------- Work history page ---------- */
.page { max-width: 56rem; padding-block: clamp(3rem, 7vw, 4.5rem) clamp(3rem, 7vw, 4rem); }
.page-head h1, .page-narrow h1 { font-size: clamp(2.3rem, 6vw, 3.25rem); letter-spacing: -0.025em; }
.lead { margin: 1rem 0; font-size: 1.2rem; line-height: 1.55; color: var(--ink-2); }
.page-head p:last-child { margin-bottom: 0; }
.page-section { margin-top: clamp(3rem, 7vw, 4rem); scroll-margin-top: 5rem; }
.page-section > h2 { margin-bottom: 1.25rem; font-size: clamp(1.5rem, 3vw, 1.8rem); }

.principles { margin: 0; }
.principles > div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.35rem 2rem; padding-block: 1.25rem; border-top: 1px solid var(--line); }
.principles > div:last-child { border-bottom: 1px solid var(--line); }
@media (min-width: 48rem) { .principles > div { grid-template-columns: 11rem minmax(0, 1fr); } }
.principles dt { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.principles dd { margin: 0; color: var(--ink-2); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.5rem; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 2.25rem; }
.job { position: relative; scroll-margin-top: 5rem; }
.job::before {
  content: ""; position: absolute; left: calc(-1.5rem - 7px); top: 0.5rem;
  width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.job--now::before { background: var(--accent); }
.job-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.job h3 { font-size: 1.35rem; }
.job p { margin: 0 0 0.5rem; }
.job .job-title { margin: 0.3rem 0 0.5rem; font-weight: 600; color: var(--ink-2); }
.job .job-highlights-intro { margin-top: 0.75rem; font-weight: 500; }
.job-highlights { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.job-highlights li { margin: 0.3rem 0; }

.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.facts li { padding-left: 1rem; border-left: 2px solid var(--line); }

/* ---------- Blog ---------- */
.page-narrow { max-width: 46rem; padding-block: clamp(3rem, 7vw, 4.5rem) clamp(3rem, 7vw, 4rem); }
.posts { list-style: none; margin: 2rem 0 0; padding: 0; }
.posts li { padding-block: 1.5rem; border-top: 1px solid var(--line); }
.posts time { font-size: 0.9rem; color: var(--muted); }
.posts h2 { margin: 0.35rem 0 0.5rem; font-size: 1.4rem; }
.posts h2 a { color: var(--ink); text-decoration: none; }
.posts h2 a:hover { text-decoration: underline; }
.posts p { margin: 0; color: var(--ink-2); }

.post-header { margin-bottom: 2rem; }
.post-meta { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--muted); }
.draft-flag {
  display: inline-block; margin-left: 0.5rem; padding: 0.05rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 0.8rem; font-weight: 600; color: var(--ink-2);
}
.prose { font-size: 1.125rem; line-height: 1.75; }
.prose > * { margin-block: 0 1.25em; }
.prose h2 { margin-top: 2em; font-size: 1.55rem; }
.prose h3 { margin-top: 1.75em; font-size: 1.25rem; }
.prose img { border-radius: 0.75rem; }
.prose iframe { max-width: 100%; }
.prose blockquote { margin-inline: 0; padding-left: 1.25rem; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.prose pre { overflow-x: auto; padding: 1rem; border-radius: 0.75rem; background: var(--well); font-size: 0.95rem; }
.prose code { font-size: 0.92em; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35em; }

.post-nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 3rem; }
@media (min-width: 40rem) {
  .post-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-nav-older { grid-column: 2; text-align: right; }
}
.post-nav-link {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.post-nav-link:hover { color: var(--ink); border-color: var(--accent); }
.post-nav-label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.post-nav-older .post-nav-label { justify-content: flex-end; }
.post-nav-label svg { width: 1em; height: 1em; }
.post-nav-title { font-family: var(--font-display); font-weight: 600; }
.post-back { margin-top: 1.5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
