/* ============================================================
   Alien Lab — Chapter notes page
   ============================================================ */

.lesson-main {
  position: relative;
  z-index: 2;
}

.lesson-hero {
  position: relative;
  padding: calc(var(--header-h) + 64px) 0 58px;
  overflow: hidden;
}

.lesson-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 55% at 78% 38%, rgba(47, 198, 255, 0.12), transparent 65%),
    radial-gradient(ellipse 40% 50% at 12% 20%, rgba(167, 139, 250, 0.08), transparent 65%);
  pointer-events: none;
}

.lesson-hero .container {
  position: relative;
  z-index: 1;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  margin-bottom: 26px;
}

.breadcrumb a {
  color: var(--muted);
  transition: color 0.2s ease;
}

.breadcrumb a:hover {
  color: var(--cyan);
}

.breadcrumb i {
  font-style: normal;
  opacity: 0.5;
}

.lesson-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 44px;
  align-items: center;
}

.lesson-hero h1 {
  margin: 20px 0 16px;
  font-size: clamp(2.8rem, 6.2vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.lesson-hero h1 span {
  display: block;
}

.lesson-sub {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-soft);
  max-width: 52ch;
}

.lesson-lede {
  max-width: 58ch;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.lesson-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(9, 18, 31, 0.5);
}

.lesson-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.lesson-orb {
  position: relative;
  width: min(390px, 34vw);
  aspect-ratio: 1;
  margin-inline: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(88, 240, 210, 0.12);
  background: radial-gradient(circle, rgba(47, 198, 255, 0.1), transparent 62%);
}

.lesson-orb::before,
.lesson-orb::after {
  content: "";
  position: absolute;
  inset: 17%;
  border: 1px solid rgba(88, 240, 210, 0.25);
  border-radius: 50%;
  transform: rotate(28deg) scaleY(0.45);
}

.lesson-orb::after {
  transform: rotate(-32deg) scaleY(0.45);
  border-color: rgba(167, 139, 250, 0.28);
}

.orb-core {
  position: relative;
  z-index: 2;
  width: 122px;
  height: 122px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(88, 240, 210, 0.4);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.3), transparent 26%),
    radial-gradient(circle at 50% 60%, #173d51, #091a2b 70%);
  box-shadow: 0 0 50px rgba(47, 198, 255, 0.28);
}

.orb-core strong {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  color: #dcfff8;
  text-shadow: 0 0 22px rgba(88, 240, 210, 0.55);
}

.orb-core small {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(220, 255, 248, 0.55);
}

.orb-chip {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(9, 18, 31, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.orb-chip b {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--cyan);
}

.orb-chip span {
  font-size: 9.5px;
  color: var(--muted);
}

.orb-chip.ox {
  top: 9%;
  left: 0;
}

.orb-chip.red {
  bottom: 9%;
  right: 0;
}

.orb-chip.red b { color: var(--violet); }

.orb-e {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.orb-e.e1 { top: 28%; right: 13%; }
.orb-e.e2 { bottom: 22%; left: 17%; background: var(--violet); box-shadow: 0 0 12px var(--violet); }
.orb-e.e3 { top: 51%; left: 5%; width: 5px; height: 5px; background: var(--amber); box-shadow: 0 0 10px var(--amber); }

/* ---------- body layout ---------- */

.lesson-body {
  padding: 34px 0 80px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.42), transparent 22%);
}

.lesson-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 760px);
  justify-content: space-between;
  gap: 54px;
  align-items: start;
}

.lesson-toc {
  position: sticky;
  top: 98px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 19, 33, 0.65);
  backdrop-filter: blur(10px);
}

.lesson-toc > span {
  display: block;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 12px;
}

.lesson-toc nav {
  display: grid;
  gap: 1px;
}

.lesson-toc a {
  display: flex;
  gap: 9px;
  padding: 7px 8px;
  border-left: 1px solid transparent;
  border-radius: 0 6px 6px 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.lesson-toc a b {
  font-family: var(--font-mono);
  font-size: 7.5px;
  color: var(--muted-2);
  font-weight: 400;
  padding-top: 1px;
}

.lesson-toc a:hover,
.lesson-toc a.is-active {
  color: var(--text);
  background: rgba(88, 240, 210, 0.06);
  border-left-color: var(--cyan);
}

.lesson-toc a.is-active b {
  color: var(--cyan);
}

.toc-tip {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 9.5px;
  line-height: 1.7;
  color: var(--muted-2);
}

.toc-tip b {
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

/* ---------- content ---------- */

.lesson-content {
  min-width: 0;
}

.lesson-section {
  padding-bottom: 46px;
  margin-bottom: 46px;
  border-bottom: 1px solid rgba(150, 190, 255, 0.08);
  scroll-margin-top: 96px;
}

.lesson-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.lesson-section-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 16px;
}

.lesson-section-head > span {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(88, 240, 210, 0.28);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--cyan);
  background: rgba(88, 240, 210, 0.06);
  margin-top: 2px;
}

.lesson-section h2 {
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  letter-spacing: -0.035em;
}

.lesson-section h3 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
  letter-spacing: -0.02em;
}

.lesson-content p {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--muted);
  margin-bottom: 12px;
}

.lesson-content p strong,
.lesson-content li strong {
  color: var(--text-soft);
  font-weight: 600;
}

.lesson-content .intro-line {
  font-size: 14.5px;
  color: var(--text-soft);
}

.lesson-content ul {
  display: grid;
  gap: 6px;
  margin: 12px 0 16px;
}

.lesson-content li {
  position: relative;
  padding-left: 17px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

.lesson-content li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.7em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.7;
}

.definition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0;
}

.definition-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(155deg, rgba(17, 30, 49, 0.8), rgba(8, 15, 26, 0.7));
}

.definition-card.ox { border-top-color: rgba(255, 180, 84, 0.45); }
.definition-card.red { border-top-color: rgba(88, 240, 210, 0.45); }

.definition-card .def-tag {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}

.definition-card.red .def-tag { color: var(--cyan); }

.definition-card h3 {
  margin: 6px 0 3px;
  font-size: 1.15rem;
}

.definition-card p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

.definition-card code {
  display: inline-block;
  margin-top: 9px;
  font-size: 10px;
  color: var(--text-soft);
}

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 19, 33, 0.55);
}

.callout-icon {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--cyan);
  border: 1px solid rgba(88, 240, 210, 0.25);
  background: rgba(88, 240, 210, 0.07);
}

.callout.tip { border-left: 2px solid rgba(88, 240, 210, 0.6); }
.callout.warn { border-left: 2px solid rgba(255, 180, 84, 0.65); }
.callout.warn .callout-icon { color: var(--amber); border-color: rgba(255, 180, 84, 0.3); background: rgba(255, 180, 84, 0.08); }

.callout h4 {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 4px;
}

.callout p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.65;
}

.callout b {
  color: var(--text-soft);
}

.oil-rig {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.oil-rig div {
  padding: 14px 16px;
  border: 1px dashed rgba(88, 240, 210, 0.25);
  border-radius: 10px;
  background: rgba(88, 240, 210, 0.03);
}

.oil-rig strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--cyan);
  margin-bottom: 4px;
}

.oil-rig span {
  font-size: 11px;
  color: var(--muted);
}

.example-box {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid rgba(88, 240, 210, 0.2);
  border-radius: 12px;
  background:
    linear-gradient(rgba(150, 190, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 190, 255, 0.03) 1px, transparent 1px),
    rgba(5, 11, 20, 0.55);
  background-size: 30px 30px;
}

.example-box .example-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 7px;
}

.example-box .equation {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(13px, 2vw, 18px);
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

.example-box p {
  margin: 9px 0 0;
  font-size: 11.5px;
}

.key-points {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.key-points span {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(6, 13, 23, 0.5);
}

.reaction-flow {
  display: grid;
  grid-template-columns: 1fr 34px 1fr;
  gap: 6px;
  align-items: center;
  margin: 18px 0;
}

.flow-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 19, 33, 0.6);
  text-align: center;
}

.flow-card .flow-tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}

.flow-card:nth-child(3) .flow-tag { color: var(--cyan); }

.flow-card strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.flow-card small {
  display: block;
  margin-top: 5px;
  font-size: 9.5px;
  color: var(--muted-2);
}

.flow-arrow {
  text-align: center;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 16px;
}

.agent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0;
}

.agent-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(155deg, rgba(17, 30, 49, 0.8), rgba(8, 15, 26, 0.7));
}

.agent-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.agent-card .agent-role {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--violet);
}

.agent-card:nth-child(2) .agent-role { color: var(--cyan); }

.agent-card ul {
  margin: 10px 0 0;
  gap: 4px;
}

.agent-card li {
  font-size: 11px;
  padding-left: 14px;
}

.table-scroll {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  min-width: 340px;
}

.data-table th {
  text-align: left;
  padding: 9px 13px;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: rgba(150, 190, 255, 0.05);
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}

.data-table td {
  padding: 10px 13px;
  color: var(--muted);
  border-bottom: 1px solid rgba(150, 190, 255, 0.06);
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: 0; }

.data-table td:first-child {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.data-table .role-ox { color: var(--amber); }
.data-table .role-red { color: var(--cyan); }

.rules-list {
  counter-reset: rule;
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 0;
}

.rules-list li {
  counter-increment: rule;
  position: relative;
  padding: 10px 12px 10px 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(10, 19, 33, 0.45);
  font-size: 12px;
  line-height: 1.65;
}

.rules-list li::before {
  content: counter(rule);
  position: absolute;
  left: 12px;
  top: 10px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1px solid rgba(88, 240, 210, 0.25);
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--cyan);
  background: rgba(88, 240, 210, 0.06);
}

.rules-list b {
  color: var(--text-soft);
}

.worked {
  padding: 18px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(167, 139, 250, 0.06), rgba(6, 13, 23, 0.5));
  margin: 16px 0;
}

.worked h4 {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 9px;
}

.worked .eq-line {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.7;
}

.worked p {
  font-size: 11.5px;
  margin: 6px 0 0;
}

.worked .answer {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 9px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #c9bfff;
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.22);
}

.everyday-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin: 16px 0;
}

.everyday-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 19, 33, 0.5);
}

.everyday-card .everyday-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(88, 240, 210, 0.2);
  background: rgba(88, 240, 210, 0.06);
  color: var(--cyan);
  margin-bottom: 10px;
}

.everyday-card .everyday-icon svg {
  width: 19px;
  height: 19px;
}

.everyday-card h4 {
  font-size: 12.5px;
  margin-bottom: 4px;
}

.everyday-card p {
  font-size: 10.5px;
  line-height: 1.6;
  margin: 0;
}

.summary-card {
  padding: 18px;
  border: 1px solid rgba(88, 240, 210, 0.2);
  border-radius: 14px;
  background:
    radial-gradient(ellipse 50% 100% at 100% 0%, rgba(167, 139, 250, 0.08), transparent 60%),
    rgba(9, 18, 31, 0.6);
  margin: 16px 0;
}

.next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.lesson-end {
  margin-top: 44px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    radial-gradient(ellipse 60% 90% at 80% 10%, rgba(47, 198, 255, 0.1), transparent 65%),
    linear-gradient(145deg, rgba(14, 27, 45, 0.9), rgba(7, 14, 25, 0.9));
}

.lesson-end h3 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.lesson-end p {
  max-width: 55ch;
  margin-bottom: 16px;
}

.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 120;
  background: var(--grad);
  box-shadow: 0 0 14px rgba(88, 240, 210, 0.55);
}

/* ---------- responsive ---------- */

@media (max-width: 1020px) {
  .lesson-layout {
    grid-template-columns: 1fr;
    gap: 28px;
    justify-content: stretch;
  }
  .lesson-toc {
    position: static;
    padding: 14px;
  }
  .lesson-toc nav {
    grid-template-columns: repeat(3, 1fr);
  }
  .lesson-toc a {
    font-size: 9.5px;
  }
  .toc-tip {
    display: none;
  }
  .lesson-orb {
    width: min(330px, 42vw);
  }
}

@media (max-width: 900px) {
  .lesson-hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .lesson-hero {
    padding-top: calc(var(--header-h) + 44px);
  }
  .lesson-orb {
    width: min(330px, 72vw);
    margin-top: 6px;
  }
  .lesson-hero-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .lesson-toc nav {
    grid-template-columns: repeat(2, 1fr);
  }
  .lesson-toc a {
    padding: 6px 6px;
  }
  .definition-grid,
  .agent-grid,
  .everyday-grid,
  .oil-rig {
    grid-template-columns: 1fr;
  }
  .reaction-flow {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .flow-arrow {
    transform: rotate(90deg);
    line-height: 1;
  }
  .lesson-section {
    padding-bottom: 34px;
    margin-bottom: 34px;
  }
  .lesson-section h2 {
    font-size: 1.45rem;
  }
  .lesson-content p {
    font-size: 13px;
  }
  .lesson-hero-actions .btn {
    flex: 1;
    min-width: 160px;
  }
}

@media (max-width: 480px) {
  .lesson-hero h1 {
    font-size: clamp(2.5rem, 13vw, 3.5rem);
  }
  .lesson-toc nav {
    grid-template-columns: 1fr;
  }
  .lesson-toc {
    max-height: 280px;
    overflow-y: auto;
  }
  .lesson-section-head {
    gap: 10px;
  }
  .lesson-section-head > span {
    width: 26px;
    height: 26px;
  }
  .example-box {
    padding: 13px;
  }
  .example-box .equation {
    font-size: 12px;
  }
}

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

@media print {
  .lesson-hero {
    padding: 10px 0 20px;
  }
  .lesson-hero-actions,
  .lesson-toc,
  .lesson-hero-orb,
  .lesson-orb,
  .lesson-banner,
  .lesson-end,
  .chat-widget,
  .site-header,
  .bg-canvas,
  .ambient,
  .scroll-progress,
  .toast,
  .confetti-canvas,
  .term-marquee {
    display: none !important;
  }
  .lesson-layout {
    display: block;
  }
  .lesson-content {
    max-width: none;
  }
  .lesson-section {
    break-inside: avoid-page;
    border-color: #ddd;
  }
  .lesson-body {
    border: 0;
    padding: 0;
  }
  .definition-card,
  .callout,
  .example-box,
  .agent-card,
  .everyday-card,
  .worked,
  .summary-card,
  .data-table {
    break-inside: avoid;
    background: #fff !important;
    color: #111;
    border-color: #ddd;
  }
  .lesson-content p,
  .lesson-content li,
  .data-table td,
  .data-table th,
  .callout p {
    color: #333;
  }
  .lesson-section h2,
  .lesson-section h3,
  .definition-card h3,
  .agent-card h3,
  .everyday-card h4 {
    color: #111;
  }
}
