/* Layout: one narrow left-aligned column, like a notebook in a terminal.
   Sections are directories (~/writing, ~/now, ~/challenges). Dark first, light follows the OS.
   Type roles: Martian Mono = the machine (labels, dates, ranks), Newsreader = the person (everything you read).
   Colour roles: amber = the cursor and ~, cyan = links and the prompt, fg = what matters, dim = scaffolding. */
:root {
  --bg: #0f1214;
  --fg: #e6e1d4;
  --dim: #8a908a;
  --rule: #262c2f;
  --amber: #ffb53d;
  --cyan: #86d4c4;
  --raise: #161a1d;

  --f-mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --f-text: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono-w: 85;

  --s-1: 0.8125rem;
  --s0: 1.1875rem;
  --s1: 1.4rem;
  --s2: 2.1rem;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f2ee; --fg: #17191a; --dim: #61675f; --rule: #d8dad3;
    --amber: #b06a00; --cyan: #1c7466; --raise: #e8e9e3;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f2ee; --fg: #17191a; --dim: #61675f; --rule: #d8dad3;
  --amber: #b06a00; --cyan: #1c7466; --raise: #e8e9e3;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--s0)/1.6 var(--f-text);
  -webkit-font-smoothing: antialiased;
  padding-inline: 1.25rem;
}
a { color: var(--cyan); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--amber); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
::selection { background: var(--amber); color: var(--bg); }
.mono, code, time, .label, .note, .top, .foot, .meta {
  font-family: var(--f-mono);
  font-variation-settings: "wdth" var(--mono-w);
}

.top, .wrap, .foot { max-width: 38rem; margin-inline: auto; }

/* header */
.top {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  padding-block: 2.5rem 0;
  font-size: var(--s-1);
}
.brand { color: var(--fg); text-decoration: none; font-weight: 600; letter-spacing: 0.01em; }
.brand:hover { color: var(--fg); }
.cursor {
  display: inline-block; width: 0.55em; height: 1.05em; margin-left: 0.15em; vertical-align: -0.18em;
  background: var(--amber); animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.top nav, .foot nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.top nav a, .foot nav a { color: var(--dim); text-decoration: none; }
.top nav a:hover, .foot nav a:hover { color: var(--amber); }

/* sections */
.wrap { padding-block: 4.5rem 2rem; display: grid; gap: 4.5rem; }
.wrap > section { min-width: 0; }
.label { margin: 0 0 1.25rem; font-size: var(--s-1); font-weight: 500; color: var(--dim); letter-spacing: 0.02em; }
.label span { color: var(--amber); }
.note { margin: 0; font-size: var(--s-1); color: var(--dim); }

.intro { font-size: var(--s1); line-height: 1.45; }
.intro p { margin: 0 0 0.9em; text-wrap: pretty; }
.intro p:last-child { margin-bottom: 0; }

/* post list */
.posts { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.4rem; }
.posts li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.25rem 1rem; align-items: baseline; }
.posts time { font-size: var(--s-1); color: var(--dim); font-variant-numeric: tabular-nums; }
.posts a { text-decoration: none; color: var(--fg); display: grid; gap: 0.1rem; }
.posts .t { font-weight: 500; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
.posts a:hover .t { text-decoration-color: var(--amber); }
.posts .s { color: var(--dim); font-size: 0.95em; font-style: italic; }

/* prose (now + posts) */
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote { margin: 0 0 1.1em; }
.prose > :last-child { margin-bottom: 0; }
.prose h2 { margin: 2.2em 0 0.6em; font: 500 var(--s-1)/1.3 var(--f-mono); font-variation-settings: "wdth" var(--mono-w); letter-spacing: 0.02em; }
.prose h2::before { content: "## "; color: var(--amber); }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.35em; }
.prose li::marker { color: var(--dim); }
.prose strong { font-weight: 500; }
.prose code { font-size: 0.78em; background: var(--raise); padding: 0.1em 0.35em; border-radius: 3px; }
.prose pre { background: var(--raise); padding: 1rem; overflow-x: auto; border-radius: 3px; }
.prose pre code { background: none; padding: 0; font-size: var(--s-1); }
.prose blockquote { margin-left: 0; padding-left: 1rem; border-left: 2px solid var(--amber); color: var(--dim); font-style: italic; }
.now ul { list-style: none; padding: 0; }
.now li { margin-bottom: 0.6em; }
#now .note { margin-top: 1rem; }

/* ladder */
.ladder { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 1.1rem; }
.rung { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 1rem; align-items: baseline; font-family: var(--f-mono); font-variation-settings: "wdth" var(--mono-w); font-size: var(--s-1); }
.rung .game { color: var(--fg); font-weight: 500; }
.rung .queue { color: var(--dim); font-weight: 400; }
.rung .rank { color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }
.rung .goal { color: var(--dim); }
.rung .pct { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.track { grid-column: 1 / -1; height: 3px; background: var(--rule); position: relative; overflow: hidden; }
.track i { position: absolute; inset: 0 auto 0 0; background: var(--amber); }

/* post page */
.post .meta { margin: 0 0 0.75rem; font-size: var(--s-1); color: var(--dim); }
.post h1 { margin: 0 0 2rem; font: 500 var(--s2)/1.15 var(--f-text); letter-spacing: -0.01em; text-wrap: balance; }
.back { margin: 0; font: 400 var(--s-1)/1.4 var(--f-mono); font-variation-settings: "wdth" var(--mono-w); }

/* footer */
.foot {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 1rem;
  padding-block: 1.5rem 3rem; border-top: 1px solid var(--rule); font-size: var(--s-1);
}
.tilde { font: inherit; color: var(--dim); background: none; border: 0; padding: 0; cursor: pointer; }
.tilde kbd { font: inherit; color: var(--amber); }
.tilde:hover { color: var(--fg); }

/* console */
.console {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  height: min(55vh, 24rem);
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--raise); border-bottom: 2px solid var(--amber);
  display: flex; flex-direction: column;
  font: 400 var(--s-1)/1.7 var(--f-mono); font-variation-settings: "wdth" var(--mono-w); color: var(--dim);
  transform: translateY(-105%); transition: transform 0.2s ease-out;
}
.console[hidden] { display: none; }
.console.open { transform: none; }
.console-out { flex: 1; overflow-y: auto; padding: 1rem 1.25rem 0.25rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.console-out .in { color: var(--fg); }
.console-out .in::first-letter { color: var(--cyan); }
.console-out .acc { color: var(--amber); }
.console-form { display: flex; gap: 0.5rem; padding: 0.25rem 1.25rem 1rem; align-items: center; }
.console-form label { white-space: nowrap; }
.ps1 { color: var(--cyan); }
.console-form input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--fg); font: inherit; caret-color: var(--amber); }

@media (max-width: 34rem) {
  .posts li { grid-template-columns: minmax(0, 1fr); }
  .top { padding-block-start: 1.5rem; }
  .wrap { padding-block-start: 3rem; gap: 3.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- multi-page additions ---------- */
.top nav a[aria-current="page"] { color: var(--fg); }
.top nav a[aria-current="page"]::before { content: "~/"; color: var(--amber); }
.intro .also { font-size: var(--s0); color: var(--dim); }

/* content pages (now, challenges, shelf) share the post header */
.page .meta { margin: 0 0 0.75rem; font-size: var(--s-1); color: var(--dim); }
.page .meta .label { margin: 0; font-size: inherit; }
.page h1 { margin: 0 0 2rem; font: 500 var(--s2)/1.15 var(--f-text); letter-spacing: -0.01em; text-wrap: balance; }
.page .prose > h2:first-child { margin-top: 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0 1.5rem; }
.prose hr + p { color: var(--dim); font-size: 0.95em; }
.sample {
  margin: -1rem 0 2rem; padding: 0.6rem 0.8rem; border: 1px dashed var(--rule); border-radius: 3px;
  font: 400 var(--s-1)/1.5 var(--f-mono); font-variation-settings: "wdth" var(--mono-w); color: var(--dim);
}
.sample code { font-size: 1em; background: none; padding: 0; color: var(--fg); }

/* task lists on challenges */
.prose li.task, .prose li.rec { list-style: none; }
.prose ul:has(> li.task), .prose ul:has(> li.rec) { padding-left: 0; }
.box { font-family: var(--f-mono); font-variation-settings: "wdth" var(--mono-w); font-size: 0.8em; color: var(--dim); margin-right: 0.35em; }
.task.done { color: var(--dim); }
.task.done .box { color: var(--cyan); }

/* shelf */
.prose ul:has(> li.rec) li:not(.rec), .prose ul:has(> li.rec) li.rec { list-style: none; }
.prose ul:has(> li.rec) li:not(.rec) { padding-left: 1.35em; }
.star { color: var(--amber); display: inline-block; width: 1em; }
.filter { margin: 0 0 0.5rem; }
.filter button {
  font: 400 var(--s-1)/1 var(--f-mono); font-variation-settings: "wdth" var(--mono-w);
  color: var(--dim); background: none; border: 1px solid var(--rule); border-radius: 3px; padding: 0.45rem 0.65rem; cursor: pointer;
}
.filter button:hover { color: var(--fg); }
.filter button[aria-pressed="true"] { color: var(--fg); border-color: var(--amber); }

/* challenge titles on the ladder */
.goal-title { grid-column: 1 / -1; font: 500 var(--s0)/1.35 var(--f-text); color: var(--fg); margin-bottom: 0.15rem; }
.page .ladder { margin-bottom: 1.5rem; }
.page .ladder .rung + .rung { padding-top: 0.6rem; }
.prose .ladder { padding-left: 0; }
.prose .ladder li { margin-bottom: 0; }
/* hanging indent so wrapped lines align with the text, not the [x] or ★ */
.prose li.rec, .prose li.task { padding-left: 1.35em; text-indent: -1.35em; }
.prose li.task { padding-left: 2.1em; text-indent: -2.1em; }
.box { display: inline-block; width: 1.9em; margin-right: 0.2em; text-indent: 0; }
