/* The lesson books in the lodge look (DESIGN.md): a ledger page on the desk, the chapters as room keys on a walnut
   key board, brass as the one accent. Standalone: no other stylesheet. */
:root {
  --paper: #ede3c8;
  --card: #f6efda;
  --ink: #2b2017;
  --muted: #65523d;
  --rule: #c4b48f;
  --walnut: #3e2716;
  --grain: #523420;
  --brass: #9c7322;
  --brass-lit: #d2a954;
  --display: 'Young Serif', 'Iowan Old Style', Georgia, serif;
  --text: 'Literata', 'Iowan Old Style', Georgia, serif;
  --typed: 'Courier Prime', 'Courier New', monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* the page grows with a wide screen; A− A A+ (book.js) multiply that by --zoom */
html { font-size: calc(100% * var(--zoom, 1)); -webkit-text-size-adjust: 100%; }
@media (min-width: 1680px) { html { font-size: calc(112.5% * var(--zoom, 1)); } }
@media (min-width: 1880px) { html { font-size: calc(118.75% * var(--zoom, 1)); } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.1875rem/1.65 var(--text);
  font-optical-sizing: auto;
}
a { color: inherit; text-decoration-color: var(--brass); text-decoration-thickness: 0.09em; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.16em; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 9; background: var(--card); padding: 0.4rem 0.8rem; }

/* ---------- the desk: key board beside the ledger ---------- */
.desk { display: grid; grid-template-columns: 20rem minmax(0, 1fr); min-height: 100vh; }
.desk.single { display: block; }

.keys {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 7px, rgba(255, 255, 255, 0.025) 7px 9px, transparent 9px 23px),
    linear-gradient(var(--grain), var(--walnut) 40%);
  color: #f1e6cc;
  padding: 1.6rem 1.1rem 2rem 1.25rem;
}
.keys a { text-decoration: none; }
.keys summary { list-style: none; cursor: pointer; font-family: var(--display); font-size: 1.05rem; color: var(--brass-lit); }
.keys summary::-webkit-details-marker { display: none; }
@media (min-width: 960px) { .keys summary { display: none; } }
.keys .board-title { margin: 0 0 1.4rem; font-family: var(--display); font-size: 1.3rem; line-height: 1.2; }
.keys .board-title span { display: block; margin-top: 0.3rem; font: italic 400 0.85rem/1.3 var(--text); color: #cdbb95; }

/* each chapter hangs as a room key: a brass tag on a hook, its number stamped in */
.hooks { list-style: none; margin: 0; padding: 0; border-top: 2px solid rgba(0, 0, 0, 0.35); }
.hooks > li { position: relative; padding: 0.55rem 0 0.55rem 3.1rem; }
.hooks > li::before { /* the hook */
  content: ''; position: absolute; left: 1.02rem; top: 0; width: 0.32rem; height: 0.5rem;
  background: #8a8476; border-radius: 0 0 0.2rem 0.2rem;
}
.hooks .tag {
  position: absolute; left: 0.2rem; top: 0.45rem; width: 1.95rem; height: 1.95rem; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--brass-lit); color: var(--brass-lit);
  font: 400 0.95rem/1 var(--display);
}
.hooks .name { display: block; font-size: 1.02rem; line-height: 1.35; padding-top: 0.25rem; color: #efe4c8; }
.hooks a:hover .name { text-decoration: underline; text-decoration-color: var(--brass-lit); }
.hooks .here .tag { background: var(--brass-lit); color: var(--walnut); transform: rotate(-9deg); }
.hooks .here .name { color: #fff8e6; font-weight: 600; }
.hooks .sections { list-style: none; margin: 0.45rem 0 0.2rem; padding: 0; }
.hooks .sections a { display: block; padding: 0.12rem 0 0.12rem 0.7rem; border-left: 2px solid rgba(210, 169, 84, 0.3); font-size: 0.84rem; color: #d9c9a4; }
.hooks .sections a.on { border-left-color: var(--brass-lit); color: #fff8e6; }

/* search and text size sit at the top of the board, above the keys */
.desk-tools { display: grid; gap: 0.6rem; margin: 0 0 1.2rem; }
.find label { display: block; margin-bottom: 0.25rem; font-size: 0.85rem; color: #d9c9a4; }
.find input {
  width: 100%; font: 400 1rem/1.3 var(--text); padding: 0.55rem 0.65rem; min-height: 2.6rem;
  color: var(--ink); background: var(--card); border: 1px solid var(--brass-lit); border-radius: 2px;
}
.find input::placeholder { color: #8a7458; }
.found { margin: 0 0 0.6rem; font-size: 0.88rem; color: var(--brass-lit); }
.results { list-style: none; margin: 0; padding: 0; border-top: 2px solid rgba(0, 0, 0, 0.35); }
.results a { display: block; padding: 0.6rem 0; border-bottom: 1px solid rgba(210, 169, 84, 0.25); text-decoration: none; }
.results .where { display: block; font-size: 0.8rem; color: #cdbb95; }
.results .what { display: block; font-family: var(--display); font-size: 1rem; color: #fff8e6; }
.results .bit { display: block; margin-top: 0.15rem; font-size: 0.86rem; line-height: 1.4; color: #e3d5b4; }
.results mark { background: var(--brass-lit); color: var(--walnut); padding: 0 0.1em; }
.results a:hover .what, .results a:focus .what { text-decoration: underline; text-decoration-color: var(--brass-lit); }
.textsize { display: flex; gap: 0.35rem; margin: 0; }
.textsize button {
  flex: 0 0 auto; min-width: 2.6rem; min-height: 2.2rem; padding: 0 0.5rem;
  font: 600 0.85rem/1 var(--text); color: #efe4c8; background: transparent;
  border: 1px solid rgba(210, 169, 84, 0.55); border-radius: 2px; cursor: pointer;
}
.textsize button[aria-pressed='true'] { background: rgba(210, 169, 84, 0.2); }
.textsize button:disabled { opacity: 0.35; cursor: default; }
.keys .back { margin: 1.1rem 0 0; font-size: 0.88rem; }
.keys .back a { color: #d9c9a4; text-decoration: underline; text-decoration-color: rgba(210, 169, 84, 0.6); }

/* ---------- the ledger page ---------- */
.ledger { --inset: 4.4rem; position: relative; padding: 2.6rem 2rem 4rem var(--inset); }
.ledger::before { /* the ledger's double margin rule */
  content: ''; position: absolute; top: 0; bottom: 0; left: calc(var(--inset) - 1.8rem); width: 5px;
  border-left: 1px solid var(--rule); border-right: 1px solid var(--rule);
}
.single .ledger { max-width: 56rem; margin: 0 auto; }
.ledger { container-type: inline-size; }
.ledger > * { max-width: 48rem; }
.running { margin: 0 0 2.2rem; font-size: 0.86rem; color: var(--muted); }
.running a { text-decoration: none; }
.running a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.15; color: var(--ink); }
.chapter-head { margin: 0 0 1.6rem; }
.chapter-num { margin: 0; font-size: 0.95rem; color: var(--muted); font-style: italic; }
.chapter-head h1 { margin: 0.2rem 0 0; font-size: clamp(2.05rem, 4.4vw, 2.85rem); letter-spacing: -0.01em; }
article h2 {
  margin: 2.6rem 0 0.9rem; padding-bottom: 0.3rem; font-size: 1.5rem;
  border-bottom: 1px solid var(--ink); box-shadow: 0 3px 0 -2px var(--rule);
}
article h3 { margin: 1.8rem 0 0.5rem; font-size: 1.18rem; }
p { margin: 0 0 1rem; }
strong { font-weight: 650; }
.note { font-size: 0.93rem; font-style: italic; color: var(--muted); }
.note.draft { font-style: normal; border-left: 3px solid var(--brass); padding-left: 0.8rem; }

ul { margin: 0 0 1.1rem; padding-left: 1.3rem; }
ul > li::marker { color: var(--brass); }
li { margin-bottom: 0.45rem; }
li > p { margin-bottom: 0.5rem; }
ol.steps { list-style: none; counter-reset: step; margin: 0 0 1.2rem; padding: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 2.4rem; margin-bottom: 0.85rem; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0.05rem;
  font: 400 1.15rem/1.4 var(--display); color: var(--brass);
}
/* the Check: tick boxes down the ledger column */
h2#check + ol.steps > li::before {
  content: ''; top: 0.38rem; width: 1rem; height: 1rem; border: 1.5px solid var(--ink); background: var(--card);
}

code { font-family: var(--typed); font-size: 0.93em; background: rgba(156, 115, 34, 0.13); padding: 0.05em 0.25em; overflow-wrap: anywhere; }
a.file code { background: rgba(156, 115, 34, 0.22); }

/* a prompt to paste: a typed card from the front desk */
.prompt {
  position: relative; margin: 0.7rem 0 1.1rem; padding: 0.95rem 1rem 0.9rem 1.15rem;
  background: var(--card); border: 1px solid var(--ink); border-left: 6px solid var(--brass);
}
.prompt .said { padding-right: 4.8rem; font: 400 0.98rem/1.6 var(--typed); }
.prompt .said p:last-child { margin-bottom: 0; }
.prompt .said strong { font-weight: 700; }
button.copy {
  font: 600 0.82rem/1 var(--text); color: var(--ink); background: var(--paper);
  border: 1px solid var(--ink); border-radius: 2px; padding: 0.5rem 0.75rem; min-height: 2.2rem; cursor: pointer;
}
button.copy:hover { background: var(--brass-lit); }
.prompt > button.copy { position: absolute; top: 0.6rem; right: 0.6rem; }

.command { display: flex; gap: 0.8rem; align-items: start; margin: 0.6rem 0 1rem; padding: 0.7rem 0.9rem; background: var(--card); border: 1px solid var(--rule); }
.command code { flex: 1; background: none; white-space: pre-wrap; }

/* the three kinds of box */
aside { margin: 1.3rem 0 1.4rem; }
aside p:last-child { margin-bottom: 0; }
aside.tip { padding: 0.15rem 0 0.15rem 1rem; border-left: 2px solid var(--rule); font-style: italic; color: #3e3022; }
aside.tip strong { font-style: normal; }
aside.warn { padding: 0.8rem 0; border-top: 3px solid var(--brass); border-bottom: 1px solid var(--brass); }
aside.other { padding: 0.85rem 1rem; border: 1px dashed var(--muted); background: rgba(246, 239, 218, 0.55); }

table.ruled { width: 100%; border-collapse: collapse; margin: 0.6rem 0 1.3rem; font-size: 0.95rem; }
table.ruled th { text-align: left; font-weight: 650; border-bottom: 1px solid var(--ink); padding: 0.35rem 0.8rem 0.35rem 0; }
table.ruled td { vertical-align: top; border-bottom: 1px solid var(--rule); padding: 0.45rem 0.8rem 0.45rem 0; }
.figure { margin: 1rem 0 1.4rem; }
.figure img { max-width: 100%; height: auto; border: 1px solid var(--rule); }

/* turning the page */
.turn { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: start; margin-top: 3.2rem; padding-top: 1.1rem; border-top: 1px solid var(--ink); max-width: 48rem; }
.turn a { text-decoration: none; font-size: 0.92rem; }
.turn a:hover .name { text-decoration: underline; text-decoration-color: var(--brass); }
.turn .name { display: block; font-family: var(--display); font-size: 1.08rem; line-height: 1.25; margin-top: 0.15rem; }
.turn [rel='next'] { text-align: right; }
.turn .to-contents { color: var(--muted); padding-top: 0.15rem; }

/* ---------- the front page ---------- */
.front { display: grid; grid-template-columns: minmax(0, 1fr) 11rem; gap: 1.5rem 2.5rem; align-items: end; margin: 1.2rem 0 2.4rem; max-width: 50rem; }
.front h1 { margin: 0; font-size: clamp(2.6rem, 7vw, 4.6rem); line-height: 0.98; letter-spacing: -0.02em; }
.front .subtitle { grid-column: 1; margin: 0; font-size: 1.15rem; color: var(--muted); }
.front .bell { grid-column: 2; grid-row: 1 / span 2; width: 11rem; height: auto; }
.opening { font-size: 1.12rem; }
.ledger-list { list-style: none; margin: 0 0 1.6rem; padding: 0; border-top: 1px solid var(--ink); max-width: 48rem; }
.ledger-list li { margin: 0; border-bottom: 1px solid var(--rule); }
.ledger-list a { display: grid; grid-template-columns: 2.6rem 1fr; gap: 0.4rem; padding: 0.55rem 0; text-decoration: none; }
.ledger-list a:hover .name { text-decoration: underline; text-decoration-color: var(--brass); }
.ledger-list .num { font: 400 1.1rem/1.4 var(--display); color: var(--brass); }
.ledger-list .sub { grid-column: 2; font-size: 0.9rem; color: var(--muted); }
.begin { font-family: var(--display); font-size: 1.2rem; }

/* ---------- practice files: one registration card per message ---------- */
.message { margin: 1.4rem 0; padding: 1rem 1.15rem 1.1rem; background: var(--card); border: 1px solid var(--ink); }
.message h2 { margin: 0 0 0.7rem; font-size: 1.2rem; border: 0; box-shadow: none; padding: 0; }
.message .subject { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; margin: 0 0 0.7rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--rule); }
.message .subject b { font-weight: 650; }
.message .body { font: 400 0.98rem/1.6 var(--typed); white-space: normal; }
.message .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }

/* ---------- sign-in ---------- */
.signin { display: grid; gap: 0.6rem; max-width: 22rem; margin: 1.2rem 0; }
.signin label { font-weight: 600; }
.signin input { font: inherit; padding: 0.6rem 0.7rem; background: var(--card); border: 1px solid var(--ink); border-radius: 2px; }
.signin button { justify-self: start; font: 600 1rem/1 var(--text); padding: 0.75rem 1.1rem; color: var(--paper); background: var(--walnut); border: 0; border-radius: 2px; cursor: pointer; }
.wrong { color: #7a2a12; font-weight: 600; }

/* ---------- wide screens: tips and the ChatGPT box move into the ledger's right margin ---------- */
@container (min-width: 79rem) {
  article { display: flow-root; }
  article > aside.tip, article > aside.other { float: right; clear: right; width: 21rem; margin: 0.3rem -24.5rem 1.4rem 0; font-size: 0.95rem; }
  .front { max-width: 60rem; }
}

/* ---------- narrow screens: the key board folds above the page ---------- */
@media (max-width: 959px) {
  .desk { display: block; }
  .keys { position: static; height: auto; padding: 0.9rem 16px; }
  .keys .board-title { margin-top: 0.9rem; }
  .ledger { padding: 1.6rem 16px 3rem 2.2rem; }
  .ledger::before { left: 0.9rem; }
  .front { grid-template-columns: minmax(0, 1fr) 6rem; gap: 1rem; }
  .front .bell { width: 6rem; }
  .turn { grid-template-columns: 1fr 1fr; }
  .prompt .said { padding-right: 0; }
  .prompt > button.copy { position: static; margin-top: 0.7rem; }
  ol.steps > li { padding-left: 1.7rem; }
  .turn .to-contents { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .keys, .turn, button.copy, .textsize { display: none !important; }
  .desk { display: block; }
}
