@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --color-navy: #0f172a;
  --color-slate: #1e293b;
  --color-teal: #14b8a6;
  --color-teal-dark: #0d9488;
  --color-teal-light: #f0fdfa;
  --color-amber: #f59e0b;
  --color-amber-light: #fffbeb;
  --color-purple: #8b5cf6;
  --color-purple-light: #f5f3ff;
  --color-text-muted: #475569;
  --color-border: #cbd5e1;
}

body {
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  color: var(--color-slate);
  margin: 0;
  padding: 0;
  background-color: #f1f5f9;
}

/* Page container for screen view */
.page {
  position: relative;
  background: #ffffff;
  width: 210mm;
  height: 297mm;
  margin: 20px auto;
  padding: 18mm 18mm 22mm 18mm; /* Extra bottom padding to clear footer and disclaimer */
  box-sizing: border-box;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid #94a3b8;
  page-break-after: always;
  overflow: hidden;
}

/* When printing, remove shadows and margins, use standard A4 dimensions */
@media print {
  body {
    background-color: #ffffff;
  }
  .page {
    margin: 0;
    box-shadow: none;
    width: 100%;
    height: 297mm;
    page-break-inside: avoid;
    page-break-after: always;
    border: none;
    overflow: hidden;
  }
  /* Last page must not emit a trailing blank sheet */
  .page:last-of-type {
    page-break-after: auto;
  }
}

/* Header */
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--color-navy);
  padding-bottom: 8px;
  margin-bottom: 15px;
}

.header-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-navy);
}

.header-link {
  font-size: 11px;
  color: var(--color-teal-dark);
  text-decoration: none;
  font-weight: 600;
}

.header-link:hover {
  text-decoration: underline;
}

.content-area {
  display: flex;
  justify-content: space-between;
  height: calc(297mm - 18mm - 22mm - 14mm); /* page − top pad − bottom pad − header allowance ≈ 243–247mm */
}

.main-column {
  width: 70%;
  padding-right: 15px;
  box-sizing: border-box;
  overflow: hidden;
}

.notes-margin {
  width: 26%;
  border-left: 1px dotted var(--color-border);
  padding-left: 15px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
}

.notes-margin-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.notes-lines {
  flex-grow: 1;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 8.5mm,
    var(--color-border) 8.5mm,
    var(--color-border) 9mm
  );
  background-size: 100% 9mm;
  width: 100%;
}

/* Footer & Disclaimer */
.footer-container {
  position: absolute;
  bottom: 18mm;
  left: 18mm;
  right: 18mm;
  border-top: 1px solid var(--color-border);
  padding-top: 6px;
  font-size: 9px;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-link {
  color: var(--color-teal-dark);
  text-decoration: none;
  font-weight: 500;
}

.footer-link:hover {
  text-decoration: underline;
}

.disclaimer-text {
  position: absolute;
  bottom: 6mm;
  left: 18mm;
  right: 18mm;
  font-size: 8px;
  line-height: 1.3;
  color: var(--color-text-muted);
  text-align: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 4px;
}

/* Typography elements */
h1, h2, h3, h4 {
  color: var(--color-navy);
  margin-top: 0;
  font-weight: 700;
}

h2.topic-section-title {
  font-size: 19px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h3.section-subtitle {
  font-size: 14px;
  margin-top: 10px;
  margin-bottom: 6px;
  color: var(--color-navy);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

p {
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 12px;
  line-height: 1.65;
}

ul, ol {
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 8px;
  padding-left: 15px;
}

li {
  margin-bottom: 8px;
}

/* Strong highlighting */
strong {
  color: var(--color-navy);
}

/* Badges */
.badge-container {
  display: inline-flex;
  gap: 4px;
}

.badge {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

.badge-higher {
  background-color: var(--color-amber-light);
  border: 1px solid var(--color-amber);
  color: #b45309;
}

.badge-chemistry-only {
  background-color: var(--color-purple-light);
  border: 1px solid var(--color-purple);
  color: #6d28d9;
}

/* Callout Box Base */
.callout-box {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 12.5px;
}

/* Definitions Box */
.definition-box {
  background-color: var(--color-teal-light);
  border-left: 4px solid var(--color-teal);
}

.definition-box dl {
  margin: 0;
}

.definition-box dt {
  font-weight: 700;
  color: var(--color-navy);
  font-size: 12px;
  margin-bottom: 2px;
}

.definition-box dd {
  margin-left: 0;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--color-slate);
}

.definition-box dd:last-child {
  margin-bottom: 0;
}

/* Exam Tip Box */
.exam-tip-box {
  background-color: var(--color-amber-light);
  border-left: 4px solid var(--color-amber);
}

.exam-tip-title {
  font-weight: 700;
  color: #b45309;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Worked Example Box */
.worked-example-box {
  background-color: var(--color-purple-light);
  border-left: 4px solid var(--color-purple);
}

.worked-example-title {
  font-weight: 700;
  color: #6d28d9;
  margin-bottom: 4px;
}

.worked-example-steps {
  margin: 0;
  padding-left: 12px;
}

.worked-example-steps li {
  margin-bottom: 6px;
}

.worked-example-steps li:last-child {
  margin-bottom: 0;
}

/* Diagrams */
.topic-diagram {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 12px;
  margin: 14px 0;
  text-align: center;
  box-sizing: border-box;
  /* NO max-height and NO overflow:hidden — the figure grows to fit the whole SVG */
}

.topic-diagram svg {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  /* NO max-height — size by width; the full diagram is always visible */
}

.diagram-caption {
  font-size: 9px;
  color: var(--color-text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 11px;
}

.data-table th, .data-table td {
  border: 1px solid var(--color-border);
  padding: 4px 6px;
  text-align: left;
}

.data-table th {
  background-color: #f8fafc;
  color: var(--color-navy);
  font-weight: 600;
}

/* Quick Check Questions */
.quick-check-box {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  background-color: #f8fafc;
  margin-top: 10px;
}

.quick-check-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.quick-check-list {
  margin: 0;
  padding-left: 15px;
}

.quick-check-list li {
  font-size: 11px;
  margin-bottom: 4px;
}

.quick-check-list li:last-child {
  margin-bottom: 0;
}

/* Subscripts and Superscripts */
sub, sup {
  font-size: 70%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.25em;
}

/* Cover Page Styles */
.cover-container {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 14mm 14mm;
  box-sizing: border-box;
}

.cover-hex {
  position: absolute;
  right: -30px;
  bottom: -24px;
  width: 240px;
  height: 240px;
  opacity: 0.07;
  z-index: 0;
}
.cover-hex polygon { fill: none; stroke: var(--color-teal); stroke-width: 3; }

.cover-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--color-teal);
  padding-bottom: 14px;
  position: relative;
  z-index: 1;
}
.cover-brandrow { display: flex; align-items: center; gap: 12px; }
.cover-tile {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--color-teal-light);
  border: 1.5px solid var(--color-teal);
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1;
}
.cover-tile-num { font-size: 9px; color: var(--color-teal-dark); margin: 3px 0 0 5px; }
.cover-tile-sym { font-size: 18px; font-weight: 800; color: var(--color-navy); text-align: center; margin-top: -2px; }
.cover-brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--color-teal-dark);
  letter-spacing: 0.5px;
}
.cover-unofficial {
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid var(--color-border);
}

.cover-main { margin: auto 0; position: relative; z-index: 1; }
.cover-title {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.04;
  color: var(--color-navy);
  margin: 0;
}
.cover-title-accent {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.04;
  color: var(--color-teal-dark);
  margin: 0 0 16px 0;
}
.cover-spec {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin: 0 0 22px 0;
  max-width: 92%;
}

.cover-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.cover-badge {
  font-size: 11px;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--color-teal-light);
  color: var(--color-teal-dark);
  border: 1px solid var(--color-teal);
}
.cover-badge-solid { background: var(--color-teal-dark); color: #ffffff; border-color: var(--color-teal-dark); }

.cover-stats {
  display: flex;
  border: 1px solid var(--color-teal-light);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}
.cover-stat {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  border-right: 1px solid var(--color-teal-light);
}
.cover-stat:last-child { border-right: none; }
.cover-stat-num { font-size: 22px; font-weight: 800; color: var(--color-teal-dark); }
.cover-stat-label { font-size: 10px; color: var(--color-text-muted); margin-top: 2px; }

.cover-features-list { list-style-type: none; padding-left: 0; margin: 0; }
.cover-features-list li {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cover-features-list li::before { content: ""; color: var(--color-teal); font-weight: 700; }

.cover-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}
.cover-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.cover-url { color: var(--color-teal-dark); font-weight: 600; }
.cover-disclaimer { font-size: 8px; line-height: 1.4; color: var(--color-text-muted); }

/* How to use page styles */
.how-to-use-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.how-to-use-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.how-to-use-step {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  background-color: #f8fafc;
}

.how-to-use-step h3 {
  font-size: 11px;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 4px;
  color: var(--color-navy);
}

.how-to-use-step p {
  margin-bottom: 0;
  font-size: 11px;
  line-height: 1.35;
}

/* Key to Symbols Styles */
.key-to-symbols {
  margin-top: 15px;
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
}

.key-to-symbols h2 {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-navy);
  margin-bottom: 8px;
}

.symbol-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.symbol-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.symbol-item.def {
  background-color: var(--color-teal-light);
  border-color: var(--color-teal);
  color: var(--color-slate);
}

.symbol-item.tip {
  background-color: var(--color-amber-light);
  border-color: var(--color-amber);
  color: var(--color-slate);
}

.symbol-item.work {
  background-color: var(--color-purple-light);
  border-color: var(--color-purple);
  color: var(--color-slate);
}

.symbol-item.mistake {
  background-color: #fef2f2;
  border-color: #ef4444;
  color: var(--color-slate);
}

.symbol-title {
  font-weight: 700;
  margin-right: 4px;
}

/* Contents Page Styles */
.contents-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.contents-list {
  list-style-type: none;
  padding-left: 0;
  margin-top: 15px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 24px;
}

.contents-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 12px;
}

.contents-item a {
  color: var(--color-navy);
  text-decoration: none;
  font-weight: 600;
}

.contents-item a:hover {
  color: var(--color-teal-dark);
  text-decoration: underline;
}

.contents-dots {
  flex-grow: 1;
  border-bottom: 1px dotted var(--color-border);
  margin: 0 8px;
}

.contents-page-num {
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Screen-only utility classes */
.screen-only {
  display: block;
}

@media print {
  .screen-only {
    display: none !important;
  }
}

/* Common Mistake Box */
.common-mistake-box {
  background-color: #fef2f2;
  border-left: 4px solid #ef4444;
}

.common-mistake-title {
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Equation Block */
.equation-block {
  background-color: var(--color-teal-light);
  border: 1px solid var(--color-teal);
  border-radius: 4px;
  padding: 8px 14px;
  margin: 14px 0;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--color-navy);
}

/* Per-topic mini-contents (Part 2.4) */
.topic-mini-contents {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  line-height: 1.6;
}

.topic-mini-contents a {
  color: var(--color-teal-dark);
  text-decoration: none;
  font-weight: 500;
}

.topic-mini-contents a:hover {
  text-decoration: underline;
}

/* Internal link styling */
a.internal-link {
  color: var(--color-teal-dark);
  text-decoration: none;
}

a.internal-link:hover {
  text-decoration: underline;
}

/* Quick-check box answer link */
.quick-check-box a.answers-link {
  color: var(--color-teal-dark);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
}

/* Two-level contents list */
.contents-list .contents-sub-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
  font-size: 10px;
  padding-left: 16px;
}

.contents-sub-item a {
  color: var(--color-text-muted) !important;
  font-weight: 400 !important;
}

/* Sidebar Tab-Strip Navigation */
.tab-strip {
  position: absolute;
  right: 6mm;
  top: 35mm;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}

.tab-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 18px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 9px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.tab-item:hover {
  background-color: var(--color-teal-light);
  border-color: var(--color-teal);
  color: var(--color-teal-dark);
}

.tab-item.active {
  background-color: var(--color-teal-dark);
  border-color: var(--color-teal-dark);
  color: #ffffff;
}
