/* Methodos. Paper-and-ink palette; every state reads in grayscale (shape, weight,
   words), so color only ever flavors what is already there. */

:root {
  --paper: #f3f0e8;
  --card: #fbfaf6;
  --ink: #1d1b17;
  --ink-2: #4a463e;
  --muted: #6e685c;
  --rule: #d5cfc2;
  --rule-strong: #9a9385;
  --link: #24456b;
  --focus: #1d1b17;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14130f;
    --card: #1e1c17;
    --ink: #ece7dc;
    --ink-2: #c9c2b4;
    --muted: #9c9586;
    --rule: #34312a;
    --rule-strong: #6b655a;
    --link: #a9c3e3;
    --focus: #ece7dc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
code { font-size: 0.92em; }

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

.kicker {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta { font-size: 0.85rem; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

/* ---- top bar */

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--gutter);
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 2;
}
.bar-title { flex: 1; min-width: 0; }
/* outside the reader, line the bar up with the centered column below it */
:not(.reader) > .bar { padding-inline: max(var(--gutter), calc((100% - 920px) / 2 + var(--gutter))); }
.bar h1 {
  margin: 0;
  font: 600 1.25rem/1.2 var(--serif);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.back {
  flex-shrink: 0;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.back:hover { text-decoration: underline; }

/* ---- buttons */

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 500 0.9rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:disabled { opacity: 0.6; cursor: progress; }
.button.primary,
.button.toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 650;
}

/* ---- library and guide pages */

.page-body {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px var(--gutter) 64px;
}

.lede {
  font: 1.12rem/1.55 var(--serif);
  color: var(--ink-2);
  max-width: 62ch;
  margin: 4px 0 20px;
}

.guide-grid, .cards, .steps, .tags, .link-list { list-style: none; margin: 0; padding: 0; }

.guide-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.guide-card, .card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.guide-card:hover, .card:hover { border-color: var(--rule-strong); }
.guide-card h2 { margin: 0; font: 600 1.5rem/1.15 var(--serif); }
.guide-card p { margin: 0; color: var(--ink-2); }
.guide-card .meta { margin-top: auto; padding-top: 8px; }

.guide-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.library-tools { margin-top: 24px; }
.search { flex: 1 1 220px; }
.search input {
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

.group {
  margin: 36px 0 0;
  font: 600 1.6rem/1.2 var(--serif);
}
.section { margin-top: 24px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 12px;
}
.section h3 { margin: 0; font: 600 1.15rem/1.3 var(--serif); }
.section-desc { margin: -4px 0 12px; color: var(--ink-2); max-width: 62ch; }

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.results { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-title { font-weight: 650; }
.done-word { font-size: 0.8rem; font-weight: 650; white-space: nowrap; }
.summary { color: var(--ink-2); font-size: 0.93rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tags li {
  font-size: 0.75rem;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
}

/* steps: an open ring with the number, or a filled disc with a check */
.steps { display: flex; flex-direction: column; }
.step {
  display: flex;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--rule);
  color: inherit;
  text-decoration: none;
}
.step:hover .step-title { text-decoration: underline; }
.step-text { display: flex; flex-direction: column; gap: 2px; padding-top: 3px; }
.step-title { font-weight: 600; }
.mark {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--rule-strong);
  border-radius: 50%;
  font: 600 0.85rem/1 var(--sans);
  color: var(--ink-2);
}
.mark.is-done {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-size: 1rem;
}

/* ---- reader */

.reader {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.reader .bar { position: static; }
.reader-main { position: relative; flex: 1; min-height: 0; display: flex; }
.frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(360px, 100%);
  overflow-y: auto;
  padding: 16px var(--gutter);
  background: var(--paper);
  border-left: 1px solid var(--rule-strong);
  box-shadow: -8px 0 24px rgb(0 0 0 / 0.18);
}
.panel h2 {
  margin: 18px 0 8px;
  font: 600 0.78rem/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel h2:first-child { margin-top: 0; }
.link-list li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.link-list .meta { display: block; }

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px var(--gutter);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
.pager-link {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  min-width: 0;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}
.pager-link.next { justify-content: flex-end; text-align: right; }
.pager-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-link:hover .pager-text { text-decoration: underline; }

@media (max-width: 560px) {
  .bar { flex-wrap: wrap; }
  .reader .bar-title { order: 3; flex-basis: 100%; }
  .reader .bar-actions { margin-left: auto; }
  .bar h1 { font-size: 1.1rem; }
  .button { min-height: 36px; padding: 0 12px; }
}
