/* ==========================================================================
   Dom Casmurro — edição lado a lado (original de 1899 + português atual, C1)
   One stylesheet for the book's contents page (index.html) and every
   chapter page (chapter-NNN.html).

   Idea: an open book. The left page is old, warm paper set in a period
   typeface (the 1899 original); the right page is clean paper set in a
   modern serif (today's Portuguese). Sea green = original, wine = today.
   The scalloped edge under the top band is the "ressaca", the undertow.

   Classes
     shared    .crumbs .sep .here .wrap .kicker .colophon
     contents  .book-head .byline .lede .start .about .steps .spelling
               .note .contents .toc .num .ttl
     chapter   .chapter-head .num .modern-title .parallel .colheads
               .label-orig .label-adapt .pair .orig .adapt .verse .w
               .words .word .pos .ex .chapter-nav .prev .up .next .home
               .dir .ttl
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Jost:wght@500;600&family=Old+Standard+TT:ital,wght@0,400;0,700;1,400&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap");

:root {
  --paper: #f5eedf;
  --page-old: #ebe0c8;
  --page-new: #fffdf7;
  --hover-old: #e2d4b4;
  --hover-new: #f6eedb;
  --ink: #26211b;
  --ink-soft: #5d5446;
  --rule: #cdbe9d;
  --band: #14474b;
  --band-2: #7a2233;
  --on-band: #f6eedc;
  --accent: #14474b;
  --accent-2: #7a2233;
  --tint: #dde8e3;
  --focus: #b07f1c;
  --display: "Old Standard TT", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --text: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --label: "Jost", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141a1b;
    --page-old: #2b281f;
    --page-new: #1b2224;
    --hover-old: #363225;
    --hover-new: #232d30;
    --ink: #ece5d5;
    --ink-soft: #b7ad97;
    --rule: #4a473a;
    --accent: #8ccdc3;
    --accent-2: #e8a3ae;
    --tint: #1c2e2f;
    --focus: #e2b755;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-2); }
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.12; }

/* ---------- shared: top band with breadcrumbs ---------- */

.crumbs {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.2rem 0.7rem;
  padding: 0.85rem 1.25rem 0.75rem;
  background: var(--band);
  color: var(--on-band);
  font-family: var(--label);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.crumbs::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 10px;
  background: radial-gradient(circle at 50% 0, var(--band) 0, var(--band) 8px, transparent 8.5px) 0 0 / 20px 10px repeat-x;
}
.crumbs a { color: var(--on-band); text-decoration: none; border-bottom: 1px solid rgba(246, 238, 220, 0.45); }
.crumbs a:hover { color: #ffffff; border-bottom-color: #ffffff; }
.crumbs .sep { opacity: 0.6; }
.crumbs .here { opacity: 0.8; }

/* ---------- shared: page frame ---------- */

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 3.5rem;
}

.kicker {
  margin: 0;
  font-family: var(--label);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.book-head,
.chapter-head {
  padding: 3.75rem 0 0;
  text-align: center;
}
.book-head::after,
.chapter-head::after {
  content: "";
  display: block;
  width: 11rem;
  height: 5px;
  margin: 2.25rem auto 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.colophon {
  padding: 1.75rem 1.5rem 3rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-family: var(--label);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.colophon p { max-width: 44rem; margin: 0 auto 0.4rem; }

/* ---------- contents page (index.html) ---------- */

.book-head h1 {
  margin: 0.9rem 0 0.2rem;
  font-size: clamp(2.9rem, 9vw, 5.6rem);
  letter-spacing: -0.01em;
}
.byline {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--ink-soft);
}
.lede {
  max-width: 41rem;
  margin: 1.6rem auto 0;
  font-size: 1.16rem;
  line-height: 1.6;
}
.start {
  display: inline-block;
  margin-top: 1.6rem;
  padding: 0.8rem 1.5rem 0.75rem;
  background: var(--band);
  color: var(--on-band);
  font-family: var(--label);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 2px;
}
.start:hover { background: var(--band-2); color: var(--on-band); }

.about {
  max-width: 44rem;
  margin: 3rem auto 0;
}
.about h2,
.contents h2 {
  margin: 0 0 0.9rem;
  font-size: 1.95rem;
}
.about h2::before {
  content: "";
  display: block;
  width: 2.75rem;
  height: 3px;
  margin-bottom: 0.9rem;
  background: var(--band-2);
}
.about p { margin: 0 0 1rem; }

.steps {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  position: relative;
  margin: 0 0 0.9rem;
  padding-left: 3rem;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--accent);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 1.05rem;
  line-height: 1.9rem;
  text-align: center;
  color: var(--accent);
}

.spelling {
  width: 100%;
  margin: 0.5rem 0 1.25rem;
  border-collapse: collapse;
  font-size: 0.97rem;
}
.spelling caption {
  padding-bottom: 0.5rem;
  text-align: left;
  font-family: var(--label);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.spelling th,
.spelling td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.spelling thead th {
  border-bottom: 2px solid var(--accent);
  font-family: var(--label);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.spelling tbody th { font-family: var(--display); font-weight: 700; white-space: nowrap; }
.spelling td em { font-family: var(--display); font-size: 1.04em; }

.note {
  margin: 0 0 1.5rem;
  padding: 0.7rem 1rem;
  border-left: 4px solid var(--band-2);
  background: var(--tint);
  font-size: 0.95rem;
}

.contents {
  margin: 3.5rem 0 0;
  padding-top: 2.5rem;
  border-top: 3px double var(--rule);
}
.contents h2 { text-align: center; font-size: 2.3rem; }
.contents .note { max-width: 44rem; margin-left: auto; margin-right: auto; }

.toc {
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  columns: 3 17rem;
  column-gap: 2.75rem;
}
.toc li { break-inside: avoid; }
.toc a {
  display: grid;
  grid-template-columns: 4.7rem 1fr;
  gap: 0.85rem;
  align-items: baseline;
  padding: 0.42rem 0;
  border-bottom: 1px dotted var(--rule);
  color: var(--ink);
  text-decoration: none;
}
.toc .num {
  font-family: var(--label);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: right;
  color: var(--accent-2);
}
.toc .ttl { font-family: var(--display); font-size: 1.1rem; line-height: 1.3; }
.toc a:hover .ttl { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }

/* ---------- chapter page: head ---------- */

.chapter-head h1 {
  margin: 0.9rem 0 0.35rem;
  font-size: clamp(2.3rem, 6.5vw, 4.1rem);
}
.chapter-head h1 .num {
  display: block;
  margin-bottom: 0.7rem;
  font-family: var(--label);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.modern-title {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
}
.modern-title strong { font-style: normal; font-weight: 600; color: var(--ink); }

/* ---------- chapter page: the two aligned columns ---------- */

.parallel {
  margin: 2.5rem 0 3rem;
  border: 1px solid var(--rule);
  background: var(--page-new);
  box-shadow: 0 1px 0 var(--rule), 0 18px 40px -28px rgba(38, 33, 27, 0.55);
}

.colheads {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.colheads p {
  margin: 0;
  padding: 0.7rem 2rem 0.62rem;
  color: var(--on-band);
  font-family: var(--label);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.label-orig { background: var(--band); }
.label-adapt { background: var(--band-2); }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.pair > p {
  margin: 0;
  padding: 0.62rem 2rem;
  overflow-wrap: break-word;
  transition: background-color 0.15s ease;
}
.orig {
  background: var(--page-old);
  border-right: 1px solid var(--rule);
  font-family: var(--display);
  font-size: 1.1rem;
  line-height: 1.58;
}
.adapt {
  background: var(--page-new);
  font-family: var(--text);
  font-size: 1.04rem;
  line-height: 1.68;
}
.colheads + .pair > p { padding-top: 1.7rem; }
.pair:last-child > p { padding-bottom: 1.9rem; }
.pair:hover > .orig { background: var(--hover-old); }
.pair:hover > .adapt { background: var(--hover-new); }

.pair > .verse {
  padding-left: 3.5rem;
  font-style: italic;
}

.w {
  border-bottom: 2px dotted var(--accent-2);
  padding-bottom: 1px;
}

/* ---------- chapter page: words worth learning ---------- */

.words {
  max-width: 54rem;
  margin: 0 auto 3rem;
  padding: 1.6rem 2rem 1.8rem;
  border: 1px solid var(--rule);
  border-top: 6px solid var(--band-2);
  background: var(--tint);
}
.words h2 {
  margin: 0 0 1.1rem;
  font-family: var(--label);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.words dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem 2.5rem;
  margin: 0;
}
.word dt {
  font-family: var(--display);
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.3;
}
.pos {
  margin-left: 0.45em;
  font-family: var(--label);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.word dd {
  margin: 0.15rem 0 0;
  font-size: 0.98rem;
  line-height: 1.5;
}
.ex {
  display: block;
  margin-top: 0.2rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- chapter page: previous / contents / next / home ---------- */

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.25rem 1.5rem;
  align-items: center;
  padding-top: 1.75rem;
  border-top: 3px double var(--rule);
}
.chapter-nav a { text-decoration: none; }
.chapter-nav .prev { grid-column: 1; grid-row: 1; text-align: left; }
.chapter-nav .up { grid-column: 2; grid-row: 1; }
.chapter-nav .next { grid-column: 3; grid-row: 1; text-align: right; }
.chapter-nav .home { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
.chapter-nav .dir,
.chapter-nav .up,
.chapter-nav .home {
  font-family: var(--label);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.chapter-nav .dir { display: block; color: var(--accent-2); }
.chapter-nav .ttl {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--display);
  font-size: 1.3rem;
  line-height: 1.25;
  color: var(--ink);
}
.chapter-nav a:hover .ttl { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }
.chapter-nav .up {
  padding: 0.6rem 1.1rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--accent);
}
.chapter-nav .up:hover { background: var(--band); border-color: var(--band); color: var(--on-band); }
.chapter-nav .home { color: var(--ink-soft); border-bottom: 1px solid var(--rule); }
.chapter-nav .home:hover { color: var(--accent-2); }

/* ---------- phones and narrow windows: the columns stack ---------- */

@media (max-width: 46rem) {
  body { font-size: 1rem; }
  .wrap { padding: 0 0.9rem 2.5rem; }
  .crumbs { font-size: 0.7rem; letter-spacing: 0.12em; }
  .book-head,
  .chapter-head { padding-top: 2.75rem; }
  .lede { font-size: 1.06rem; }

  .parallel { margin: 2rem -0.9rem 2.5rem; border-left: 0; border-right: 0; }
  .colheads p { padding: 0.55rem 0.9rem 0.5rem; font-size: 0.66rem; letter-spacing: 0.12em; }
  .pair { grid-template-columns: 1fr; border-top: 1px solid var(--rule); }
  .colheads + .pair { border-top: 0; }
  .pair > p,
  .colheads + .pair > p,
  .pair:last-child > p { padding: 0.75rem 0.95rem 0.75rem 1.05rem; }
  .orig { border-right: 0; border-left: 5px solid var(--band); font-size: 1.06rem; }
  .adapt { border-left: 5px solid var(--band-2); font-size: 1.02rem; }
  .pair > .verse { padding-left: 2rem; }

  .words { padding: 1.3rem 1.1rem 1.5rem; }
  .words dl { grid-template-columns: 1fr; }

  .chapter-nav { grid-template-columns: 1fr 1fr; }
  .chapter-nav .prev { grid-column: 1; grid-row: 1; }
  .chapter-nav .next { grid-column: 2; grid-row: 1; }
  .chapter-nav .up { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .chapter-nav .home { grid-row: 3; }
  .chapter-nav .ttl { font-size: 1.1rem; }

  .spelling { font-size: 0.9rem; }
  .spelling tbody th { white-space: normal; }
  .toc a { grid-template-columns: 4.3rem 1fr; }
}

/* ---------- print ---------- */

@media print {
  body { background: #ffffff; color: #000000; font-size: 10.5pt; }
  .crumbs, .chapter-nav, .start { display: none; }
  .colheads { position: static; }
  .colheads p { color: #000000; background: none; border-bottom: 1px solid #000000; }
  .parallel { border: 0; box-shadow: none; }
  .orig, .adapt, .words { background: none; }
  .pair { break-inside: avoid; }
}
