/* ===============================================================
   Shared reading-first lesson system.
   Structure:  <article class="lesson-reading">
                 <section class="reading-section">
                   <p class="chapter-number">01 · Label</p>
                   <h2>A full sentence.</h2>
                   <p>Prose.</p>
   Palette comes from styles.css: --jade, --moss, --faint, --line,
   --panel, --panel-strong, --bg-soft, --muted, --text.
   =============================================================== */

.lesson-reading {
  width: 100%;
  margin: 0 auto;
}

.reading-section {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
  padding: clamp(5rem, 10vw, 9rem) 0;
  border-top: 1px solid var(--line);
}

.chapter-number {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 1.25rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--jade) 38%, var(--line));
  border-left: 3px solid var(--jade);
  border-radius: 5px;
  background: color-mix(in srgb, var(--jade) 6%, var(--panel));
  color: var(--jade);
  font-family: var(--mono);
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.reading-section h2 {
  max-width: 850px;
  margin: 0 0 1.6rem;
  font-size: clamp(2.25rem, 4vw, 3.85rem);
  font-weight: 500;
  line-height: 1.08;
}

.reading-section h3 {
  max-width: 820px;
  margin: 2.5rem 0 1rem;
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  font-weight: 500;
  line-height: 1.2;
}

.reading-section > p:not(.chapter-number),
.reading-section > ul,
.reading-section > ol {
  max-width: 780px;
  margin: 0 0 1.3rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  line-height: 1.85;
}

.reading-section > ul,
.reading-section > ol {
  padding-left: 1.4rem;
}

.reading-section li {
  margin-bottom: 0.7rem;
}

.reading-section p strong,
.reading-section li strong {
  color: var(--text);
}

/* long inline identifiers must not push the page sideways on narrow screens */
.reading-section code {
  overflow-wrap: anywhere;
}

.quiet-highlight {
  padding-inline: 0.08em;
  background: linear-gradient(
    transparent 58%,
    color-mix(in srgb, var(--moss) 26%, transparent) 58%
  );
  color: inherit;
}

.reading-section > p.source-note {
  max-width: 900px;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  line-height: 1.7;
}

.source-note a {
  color: var(--moss);
  text-underline-offset: 0.2em;
}

.reading-section p.transition-callout {
  margin-top: 2rem;
  padding: 1.2rem 1.4rem;
  border-left: 3px solid var(--moss);
  background: color-mix(in srgb, var(--moss) 8%, transparent);
  color: var(--text);
}

/* --- prose beside a diagram ------------------------------------ */

.reading-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: clamp(2rem, 6vw, 4rem);
  align-items: start;
  margin: 0 0 2.5rem;
}

.reading-split > div > p {
  margin: 0 0 1.3rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  line-height: 1.85;
}

.reading-split > div > p:last-child {
  margin-bottom: 0;
}

/* --- tables ---------------------------------------------------- */

.table-wrap {
  max-width: 960px;
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

caption {
  padding: 1rem 1rem 0.6rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  padding: 1rem 0.8rem;
  font-size: 0.98rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
  vertical-align: top;
}

thead th {
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody th {
  color: var(--text);
}

tbody tr:last-child > * {
  border-bottom: 0;
}

.numeric {
  font-family: var(--mono);
  white-space: nowrap;
}

.win td,
.win th {
  color: var(--text);
  font-weight: 700;
}

/* --- arithmetic panel ------------------------------------------ */

.capacity-example {
  max-width: 960px;
  margin: 2.25rem 0;
  padding: clamp(1.4rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.capacity-example p {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 0;
}

.capacity-example span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.capacity-example strong {
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5vw, 3.6rem);
}

.capacity-example .capacity-math {
  display: block;
  margin: 1.1rem 0;
  padding: 1rem 0;
  border-block: 1px dashed var(--line);
  color: var(--jade);
  font-family: var(--mono);
  font-size: clamp(0.8rem, 2vw, 1rem);
  text-align: center;
}

/* --- code ------------------------------------------------------ */

.sql-block,
.plan-pair pre,
.query-example pre {
  margin: 0;
  overflow-x: auto;
  color: var(--text);
  font: 500 0.85rem/1.75 var(--mono);
  white-space: pre;
}

.sql-block {
  max-width: 760px;
  margin: 2rem 0;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
}

.query-example {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr);
  margin: 2rem 0 2.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
}

.query-example > div {
  display: grid;
  align-content: center;
  gap: 0.65rem;
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.query-example span,
.plan-pair article > span {
  color: var(--jade);
  font: 800 0.67rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.query-example > div strong {
  max-width: 360px;
  font: 500 clamp(1.8rem, 3vw, 2.7rem)/1.08 var(--serif);
}

.query-example pre {
  display: grid;
  align-items: center;
  min-height: 220px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
}

.plan-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0 0 2.5rem;
}

.plan-pair article {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
}

.plan-pair article > span {
  display: block;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.plan-pair pre {
  min-height: 190px;
  padding: 1.2rem;
}

.plan-pair .preferred-plan {
  border-color: color-mix(in srgb, var(--moss) 45%, var(--line));
}

/* --- the Old Dragon's closing word ------------------------------
   Matches the portrait treatment of .dragon-counsel so every saying
   in the course carries the same face.                             */

.dragon-line {
  position: relative;
  display: block;
  margin: clamp(2rem, 5vw, 3.5rem) 0 0;
  padding: 1.6rem 0 0 5.4rem;
  border-top: 1px solid var(--line);
  border-left: 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  line-height: 1.45;
}

.dragon-line::before {
  content: '';
  position: absolute;
  top: 1.6rem;
  left: 0;
  width: 64px;
  aspect-ratio: 1;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--jade) 14%, transparent), transparent 70%), url('../public/og.png');
  background-position: center, 100% center;
  background-size: cover, 190%;
  background-repeat: no-repeat;
  filter: grayscale(0.3) sepia(0.42) saturate(0.82) contrast(1.05) brightness(1.03);
}

.dragon-line span {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--moss);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@media (max-width: 620px) {
  .dragon-line {
    padding-left: 4.4rem;
  }

  .dragon-line::before {
    width: 52px;
  }
}

.closing-line {
  max-width: 780px;
  margin-top: 3rem;
}

.next-gate > a {
  white-space: nowrap;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
}

/* --- narrow screens -------------------------------------------- */

@media (max-width: 900px) {
  .query-example {
    grid-template-columns: 1fr;
  }

  .query-example pre {
    min-height: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .reading-section {
    width: min(100% - 28px, 1180px);
  }

  .reading-split,
  .plan-pair {
    grid-template-columns: 1fr;
  }

  .plan-pair pre {
    min-height: 0;
  }

  .capacity-example p {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  th,
  td {
    min-width: 110px;
    padding: 0.85rem 0.6rem;
    font-size: 0.94rem;
  }
}

/* --- point-wise list of paths/locations ------------------------ */

.read-paths {
  max-width: 820px;
  margin: 1.8rem 0 2rem;
  padding: 0;
  list-style: none;
}

.read-paths li {
  margin: 0 0 0.7rem;
  padding: 1.15rem 1.3rem 1.15rem 1.5rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--jade);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: clamp(1.05rem, 1.7vw, 1.15rem);
  line-height: 1.75;
}

.read-paths li:last-child {
  margin-bottom: 0;
  border-left-color: var(--moss);
}

.read-paths li strong {
  color: var(--text);
}
