/* ==========================================================
   Eilidh's Year 8 Maths — clean dark
   ========================================================== */

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

:root {
  /* Surfaces */
  --bg: #1a1d22;
  --surface: #252830;
  --surface-raised: #2d3038;
  --surface-hover: #343843;

  /* Text */
  --ink: #e8e6e0;
  --ink-soft: #a8a59c;
  --ink-faint: #6e6c63;

  /* Lines */
  --line: #2d3038;
  --line-soft: #25282f;

  /* Semantic */
  --info-bg: #1f3a5a;
  --info-text: #9bbfde;
  --info-border: #2d4f73;

  --tip-bg: #1f3a2c;
  --tip-text: #a3c89a;
  --tip-border: #2f5642;

  --warn-bg: #3a241e;
  --warn-text: #e0a78c;
  --warn-border: #5a3527;

  --example-bg: #2d2820;
  --example-text: #d4b889;
  --example-border: #4a3f2c;

  --accent: #d4a866;

  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;

  --radius: 8px;
  --radius-lg: 12px;

  --max-width: 760px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent); color: var(--bg); }

/* ==========================================================
   Header
   ========================================================== */

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(26, 29, 34, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 14px;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s;
  font-weight: 500;
}

.site-nav a:hover { color: var(--ink); }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}

/* ==========================================================
   Typography
   ========================================================== */

h1 {
  font-weight: 600;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

h2 {
  font-weight: 600;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

p { margin-bottom: 1rem; color: var(--ink-soft); }
p + p { margin-top: -0.25rem; }

main p { color: var(--ink-soft); }
main p strong, main p b { color: var(--ink); font-weight: 600; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

a:hover { border-bottom-color: var(--accent); }

ul, ol { margin-bottom: 1rem; padding-left: 1.4rem; color: var(--ink-soft); }
li { margin-bottom: 0.4rem; }
ul li::marker, ol li::marker { color: var(--ink-faint); }

code, .mono {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--ink);
}

pre.code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  border-radius: var(--radius);
  color: var(--ink);
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.55;
}

pre.code code { background: none; padding: 0; }

/* ==========================================================
   Module intro
   ========================================================== */

.module-intro {
  margin-bottom: 2rem;
}

.module-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.module-intro p.lede {
  font-size: 16px;
  color: var(--ink-soft);
  margin-top: 0.5rem;
  max-width: 540px;
}

/* ==========================================================
   Subtle cards (the look from the widget)
   ========================================================== */

.card-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin: 1rem 0;
}

.card-row {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
}

.card-row .card-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 0.1rem;
}

.card-row .card-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.card-row .card-desc .mono {
  background: transparent;
  padding: 0;
  color: var(--ink);
}

/* ==========================================================
   Boxes (example, tip, warn, info)
   ========================================================== */

.box {
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 15px;
  line-height: 1.65;
}

.box .box-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.box p { color: inherit; margin-bottom: 0.5rem; }
.box p:last-child { margin-bottom: 0; }

.box-example {
  background: var(--example-bg);
  color: var(--example-text);
}
.box-example .box-label { color: var(--example-text); }
.box-example p { color: var(--example-text); }
.box-example strong { color: #f0d9a8; }
.box-example .mono-block {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.95;
  color: var(--example-text);
}

.box-tip {
  background: var(--tip-bg);
  color: var(--tip-text);
}
.box-tip .box-label { color: var(--tip-text); }
.box-tip p { color: var(--tip-text); }
.box-tip strong { color: #c5e0bd; }

.box-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}
.box-warn .box-label { color: var(--warn-text); }
.box-warn p { color: var(--warn-text); }
.box-warn strong { color: #f0c4ad; }

.box-info {
  background: var(--info-bg);
  color: var(--info-text);
}
.box-info .box-label { color: var(--info-text); }
.box-info p { color: var(--info-text); }
.box-info strong { color: #b8d4ed; }

/* ==========================================================
   Tables
   ========================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 14.5px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child td { border-bottom: none; }

th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: var(--surface-raised);
}

td { color: var(--ink-soft); }
td .mono { background: transparent; padding: 0; color: var(--ink); }

/* ==========================================================
   Sign grid
   ========================================================== */

.sign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.sign-cell {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.sign-cell .sign-op {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  margin-bottom: 0.15rem;
}

.sign-cell .sign-result {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.sign-cell.positive .sign-result { color: var(--tip-text); }
.sign-cell.negative .sign-result { color: var(--warn-text); }

/* ==========================================================
   Quick reference (the blue panel from the widget)
   ========================================================== */

.quick-ref {
  background: var(--info-bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0 1rem;
}

.quick-ref h3 {
  font-size: 18px;
  color: var(--info-text);
  margin: 0 0 0.6rem 0;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.quick-ref ul {
  margin-bottom: 0;
  padding-left: 1.25rem;
  color: var(--info-text);
}

.quick-ref li { margin-bottom: 0.35rem; }
.quick-ref li::marker { color: var(--info-text); }
.quick-ref .mono { background: rgba(255,255,255,0.08); color: var(--info-text); border: none; }
.quick-ref strong { color: #c5dcef; }

/* ==========================================================
   Index — hero & module cards
   ========================================================== */

.hero {
  margin: 1rem 0 2.5rem;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 44px);
  margin-bottom: 0.5rem;
}

.hero p.tagline {
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 500px;
}

.modules-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 2.5rem 0 1rem;
}

.modules-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.modules-header .count {
  font-size: 13px;
  color: var(--ink-faint);
}

.module-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin: 0 0 2rem;
}

.module-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s;
  border-bottom: none;
}

.module-card:hover {
  background: var(--surface-hover);
  border-bottom: none;
}

.module-card.locked {
  cursor: default;
  opacity: 0.55;
}

.module-card.locked:hover { background: var(--surface); }

.module-card-num {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.05em;
  font-family: var(--mono);
  flex-shrink: 0;
  width: 30px;
  padding-top: 1px;
}

.module-card.locked .module-card-num {
  color: var(--ink-faint);
}

.module-card-body { flex: 1; }

.module-card-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.module-card-topics {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.module-card-status {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  white-space: nowrap;
  padding-top: 2px;
  flex-shrink: 0;
}

.module-card-status.ready {
  color: var(--accent);
}

/* ==========================================================
   Tabs / prev-next
   ========================================================== */

.page-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0.5rem 0 2rem;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius);
  width: fit-content;
}

.page-tab {
  padding: 0.5rem 0.9rem;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  font-weight: 500;
  border-bottom: none;
}

.page-tab:hover {
  color: var(--ink);
  border-bottom: none;
}

.page-tab.active {
  color: var(--ink);
  background: var(--surface-raised);
  font-weight: 600;
}

.prev-next {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  gap: 1rem;
  flex-wrap: wrap;
}

.prev-next a {
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: none;
  display: inline-block;
}

.prev-next a:hover { color: var(--accent); border-bottom: none; }

.prev-next .label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.15rem;
  font-weight: 600;
}

/* ==========================================================
   Practice questions
   ========================================================== */

.section-divider {
  font-weight: 600;
  font-size: 20px;
  color: var(--ink);
  margin-top: 2.5rem;
  margin-bottom: 0.25rem;
}

.section-sub {
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 1.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.q {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0;
  align-items: flex-start;
}

.q-num {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  min-width: 1.75rem;
  flex-shrink: 0;
  padding-top: 4px;
  font-weight: 500;
}

.q-body { flex: 1; padding-top: 0.1rem; }

.q-body p { margin-bottom: 0.4rem; color: var(--ink); }

.q-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--ink-soft);
}

.answer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 2rem 0 0;
  padding: 0.65rem 1.1rem;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 14px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s;
  border-bottom: none;
}

.answer-link:hover {
  background: var(--surface-hover);
  border-bottom: none;
  color: var(--ink);
}

.answer-link::after { content: "→"; }

/* ==========================================================
   Answers
   ========================================================== */

.answer {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line-soft);
  align-items: flex-start;
}

.answer:last-child { border-bottom: none; }

.answer-num {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  min-width: 1.75rem;
  flex-shrink: 0;
  padding-top: 4px;
  font-weight: 500;
}

.answer-body { flex: 1; padding-top: 0.1rem; }

.answer-body .working {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 0.4rem;
  line-height: 1.85;
  background: var(--surface);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
}

.answer-body .final {
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
}

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 600px) {
  body { font-size: 15px; }
  main { padding: 2rem 1.25rem 3rem; }
  .site-header { padding: 0.85rem 1.25rem; }
  .site-nav { gap: 1rem; font-size: 13px; }
  h1 { font-size: 26px; }
  .hero h1 { font-size: 32px; }
  h2 { font-size: 19px; }
  .module-card { padding: 1rem; gap: 0.75rem; }
  .module-card-status { display: none; }
  .module-card-title { font-size: 15px; }
}

/* ==========================================================
   Diagrams (inline SVG)
   ========================================================== */

.diagram {
  margin: 24px auto;
  padding: 20px;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.diagram svg {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  overflow: visible;
}

.diagram figcaption {
  margin-top: 12px;
  font-size: 0.9em;
  color: var(--ink-soft);
  font-style: italic;
}

.diagram-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.diagram-row .diagram {
  margin: 0;
  padding: 12px;
  max-width: none;
}

.diagram-row .diagram figcaption {
  margin-top: 8px;
  font-size: 0.85em;
}

@media (max-width: 600px) {
  .diagram-row { grid-template-columns: 1fr; }
}

/* ==========================================================
   Print
   ========================================================== */

@media print {
  body { background: white; color: black; }
  .site-header, .site-footer, .page-tabs, .prev-next, .answer-link { display: none; }
  main { max-width: 100%; padding: 0; }
  .box, .quick-ref, .module-card, .card-row {
    page-break-inside: avoid;
    border: 1px solid #ddd;
    background: white;
    color: black;
  }
  .quick-ref h3, .quick-ref li { color: black; }
  h1, h2 { page-break-after: avoid; color: black; }
  a { color: black; border-bottom: none; }
  p, td, li { color: black; }
}
