/* The ePortfolio, backwards. Ink on white, one teal accent, red only for failure.
   Text column 70ch, serif body, sans chrome. */

:root {
  --ink: #191919;
  --ink-soft: #4d4d4d;
  --paper: #ffffff;
  --hairline: #d9d9d9;
  --wash: #f6f6f4;
  --teal: #0d8377;
  --teal-wash: #e9f3f1;
  --red: #b3261e;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.65;
}

.site-header {
  border-bottom: 1px solid var(--hairline);
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--sans);
}
.site-header .brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.site-header .brand::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.5em;
  background: var(--teal);
  border-radius: 2px;
}
.site-header .site-tag { color: var(--ink-soft); font-size: 0.85rem; }

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Sidebar */
.book-nav { font-family: var(--sans); font-size: 0.86rem; }
.book-nav .nav-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 1.2rem 0 0.4rem;
}
.book-nav .nav-title:first-child { margin-top: 0; }
.book-nav ol { list-style: none; margin: 0; padding: 0; }
.book-nav li { margin: 0.15rem 0; }
.book-nav a { color: var(--ink); text-decoration: none; }
.book-nav a:hover { color: var(--teal); text-decoration: underline; }
.book-nav a[aria-current="page"] { color: var(--teal); font-weight: 700; }
.book-nav li.done a::after { content: " \2713"; color: var(--teal); }
.stage-list label {
  display: block;
  margin: 0.2rem 0;
  color: var(--ink);
  cursor: pointer;
}
.stage-list input { accent-color: var(--teal); margin-right: 0.4em; }
.nav-note { color: var(--ink-soft); font-size: 0.75rem; }

/* Main column. min-width 0 so a wide table scrolls inside the column
   instead of stretching the whole page past the viewport. */
.page { max-width: 70ch; min-width: 0; }
.page h1 {
  font-size: 2.1rem;
  line-height: 1.15;
  margin: 0.2rem 0 0.6rem;
}
.subtitle {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink-soft);
  margin: 0 0 1.6rem;
}
.book-links {
  font-family: var(--sans);
  font-size: 0.85rem;
  margin: -0.8rem 0 1.6rem;
}
.book-links a { color: var(--teal); text-decoration: none; }
.book-links a:hover { text-decoration: underline; }
.chapter-no {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0;
}
.page h2 {
  font-size: 1.4rem;
  margin: 3.2rem 0 1rem;
  line-height: 1.25;
}
.page h3 { font-size: 1.12rem; margin: 2rem 0 0.8rem; }
.page p { margin: 0 0 1.15rem; }
.page a { color: var(--teal); }
.page ul, .page ol { padding-left: 1.4rem; }
.page li { margin: 0.3rem 0; }
strong { color: var(--ink); }

figure { margin: 2rem 0; text-align: center; }
figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--hairline);
  background: var(--paper);
}

/* Teaching furniture */
.outcomes, .done-check, .next-session, .tip, .example, .persona, .mistake {
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1rem 1.2rem;
  margin: 1.6rem 0;
  background: var(--paper);
}
.outcomes { border-left: 3px solid var(--teal); background: var(--teal-wash); }
.done-check { border-left: 3px solid var(--ink); background: var(--wash); }
.next-session { border-left: 3px solid var(--teal); }
.tip { border-left: 3px solid var(--teal); }
.example { background: var(--wash); font-size: 0.98rem; }
.persona { border-left: 3px solid var(--ink-soft); font-size: 0.97rem; }

.outcomes .box-label, .done-check .box-label, .next-session .box-label,
.tip .box-label, .example .box-label, .persona .box-label,
.mistake .box-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.4rem;
}
.done-check .box-label, .persona .box-label { color: var(--ink-soft); }

/* Icon system: red only for failure, teal for important, ink for neutral. */
.box-label::before {
  content: "";
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.45em;
  vertical-align: -0.12em;
  background: center / contain no-repeat;
}
.tip .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 2v4M10 14v4M2 10h4M14 10h4M5 5l2.5 2.5M15 5l-2.5 2.5M5 15l2.5-2.5M15 15l-2.5-2.5' stroke='%230d8377' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.callout::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 4l6 6-6 6M11 4l6 6-6 6' fill='none' stroke='%230d8377' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.outcomes .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 10h11M10 5l5 5-5 5' fill='none' stroke='%230d8377' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.next-session .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='7' fill='none' stroke='%230d8377' stroke-width='2'/%3E%3Cpath d='M10 6v4l3 2' fill='none' stroke='%230d8377' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.done-check .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 11l4 5 8-11' fill='none' stroke='%230d8377' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.persona .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='6' r='3' fill='none' stroke='%234d4d4d' stroke-width='2'/%3E%3Cpath d='M4 17c1-4 4-5 6-5s5 1 6 5' fill='none' stroke='%234d4d4d' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.example .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7 3H5v14h2M13 3h2v14h-2' fill='none' stroke='%234d4d4d' stroke-width='2'/%3E%3C/svg%3E");
}

/* Mistake blocks: red, because red is for failure. */
.mistake { border-left: 3px solid var(--red); background: #fbf3f2; }
.mistake .box-label { color: var(--red); }
.mistake .box-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 4L16 16M16 4L4 16' fill='none' stroke='%23b3261e' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.mistake-parts { list-style: none; padding: 0; margin: 0.2rem 0 0; }
.mistake-parts li { margin: 0.55rem 0; }
.box-label + p, .box-label + ul, .box-label + ol { margin-top: 0.2rem; }

.callout {
  margin: 2.6rem 0;
  padding: 0.4rem 0 0.4rem 1.2rem;
  border-left: 3px solid var(--teal);
  font-size: 1.22rem;
  line-height: 1.5;
  font-style: italic;
}

.failure, .warn { color: var(--red); }

/* Landing page blocks */
.landing-blocks { display: grid; gap: 1.2rem; margin: 2rem 0; }
.landing-block {
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--teal);
  border-radius: 4px;
  padding: 1.1rem 1.3rem;
}
.landing-block h2 { margin: 0 0 0.6rem; font-size: 1.2rem; }
.landing-block[data-block="do-not-do"] { border-top-color: var(--red); }
.landing-block p:last-child { margin-bottom: 0; }

.chapter-cards { list-style: none; padding: 0; margin: 1.5rem 0; display: grid; gap: 0.9rem; }
.chapter-cards li {
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 0.9rem 1.1rem;
}
.chapter-cards a { font-weight: 700; text-decoration: none; }
.chapter-cards a:hover { text-decoration: underline; }
.chapter-cards .promise { margin: 0.25rem 0 0; color: var(--ink-soft); font-size: 0.95rem; }
.stage-tag {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

/* Trace and crosswalk (ch02) */
.trace { counter-reset: trace-step; list-style: none; padding: 0; margin: 1.5rem 0; }
.trace li {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--teal);
  border-radius: 4px;
  padding: 0.7rem 1rem;
  margin: 0.6rem 0;
}
table.crosswalk, table.wordbudget {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  overflow-x: auto;
}
table.crosswalk th, table.crosswalk td,
table.wordbudget th, table.wordbudget td {
  border: 1px solid var(--hairline);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
table.crosswalk thead th, table.wordbudget thead th {
  background: var(--teal-wash);
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
code, .marker {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--wash);
  padding: 0.05em 0.35em;
  border-radius: 3px;
}
pre.letter {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  background: var(--wash);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Prev/next */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.chapter-nav a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
}
.chapter-nav a:hover { border-color: var(--teal); color: var(--teal); }
.chapter-nav .next { margin-left: auto; border-color: var(--teal); color: var(--teal); }

footer.site-footer {
  border-top: 1px solid var(--hairline);
  padding: 1.2rem 1.5rem 2rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.version {
  color: var(--ink-soft);
  font-size: 0.75rem;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  margin-left: 0.4rem;
  white-space: nowrap;
}

/* Cover: title first, slimmer chrome */
.cover-title { font-size: 1.9rem; }
.cover-body .site-tag { display: none; }
@media (max-width: 1100px) {
  .site-header .site-tag { display: none; }
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .page { margin-inline: auto; }
  .nav-toggle { display: inline-block; }
  .book-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--paper);
    border-right: 1px solid var(--hairline);
    box-shadow: 4px 0 18px rgba(0, 0, 0, 0.12);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 1.2rem;
    z-index: 30;
  }
  body.nav-open .book-nav { transform: none; }
}

@media (min-width: 881px) {
  body.nav-collapsed .layout { grid-template-columns: 1fr; }
  body.nav-collapsed .book-nav { display: none; }
  /* Hidden on wide screens unless the sidebar is collapsed. Kept inside
     this media query so it cannot override the narrow-screen rule below
     by source order. */
  body:not(.nav-collapsed) .nav-toggle { display: none; }
}

/* Same teal outline chip as button.mark-done. */
.nav-toggle {
  font-family: var(--sans);
  font-size: 0.85rem;
  border: 1px solid var(--teal);
  color: var(--teal);
  background: var(--paper);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}
.nav-toggle:hover { background: var(--teal-wash); }
body.nav-collapsed .nav-toggle { display: inline-block; }
.nav-toggle::before {
  content: "";
  display: inline-block;
  width: 0.95em;
  height: 2px;
  background: currentColor;
  box-shadow: 0 0.3em 0 currentColor, 0 -0.3em 0 currentColor;
  margin-right: 0.45em;
  vertical-align: middle;
}

button.mark-done {
  font-family: var(--sans);
  font-size: 0.85rem;
  border: 1px solid var(--teal);
  color: var(--teal);
  background: var(--paper);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}
button.mark-done:hover { background: var(--teal-wash); }

/* Mermaid diagrams: fit the column, never tower over the page */
pre.mermaid {
  text-align: center;
  margin: 2rem 0;
  background: var(--paper);
}
pre.mermaid svg {
  /* Mermaid writes an inline max-width at the diagram's natural size,
     which leaves the chain tiny; take the full column instead. */
  max-width: 100% !important;
  min-width: 100%;
  height: auto;
  margin-inline: auto;
  display: block;
}

/* Stage handoff arrow between chapters */
.handoff {
  margin: 2.2rem 0 0;
  padding: 0.7rem 1.1rem;
  border: 1px dashed var(--teal);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.handoff .handoff-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--teal);
}
.handoff a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 700;
  margin-left: auto;
}
.handoff a:hover { text-decoration: underline; }
.nav-strip {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 16px;
  background: var(--teal-wash);
  border-right: 1px solid var(--hairline);
  cursor: pointer;
  z-index: 20;
}
.nav-strip::after {
  content: "Contents";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  white-space: nowrap;
}
.nav-strip:hover { background: var(--teal); }
.nav-strip:hover::after { color: var(--paper); }
body.nav-collapsed .nav-strip { display: block; }

/* Generated heroes sit cleaner without the box border.
   Portrait art (covers) is capped so it never dominates the page. */
figure.hero img, figure.cover-art img {
  border: none;
  max-height: 30rem;
  width: auto;
  margin-inline: auto;
}

/* The mistake list must not inherit the page's list indent */
.page ul.mistake-parts { padding-left: 0; }

@media print {
  .book-nav, .chapter-nav, .site-header { display: none; }
  .layout { display: block; padding: 0; }
}
