/* Mobile-first study guide — OpenDyslexic, cream background, large tap targets */

@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/woff/OpenDyslexic-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/woff/OpenDyslexic-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #faf6ef;
  --text: #1a1a1a;
  --blue: #1565c0;
  --blue-light: #e8f0fe;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --orange: #ef6c00;
  --orange-light: #fff3e0;
  --pink: #ec407a;
  --header-h: 3.25rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

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

body {
  margin: 0;
  font-family: "OpenDyslexic", Verdana, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(1.5rem + var(--safe-bottom));
  overflow-x: hidden;
}

/* Sticky header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 1rem 0;
  background: rgba(250, 246, 239, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.menu-toggle {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid var(--blue);
  border-radius: 8px;
  background: white;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--blue);
}

.site-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-size: 0.95rem;
}

.site-title strong {
  color: var(--blue);
}

.site-title span {
  color: #555;
  font-size: 0.85rem;
}

/* Slide-out TOC */
.toc-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(88vw, 320px);
  z-index: 200;
  background: white;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  transform: translateX(-105%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding-bottom: var(--safe-bottom);
}

.toc-panel.open {
  transform: translateX(0);
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(1rem + var(--safe-top)) 1rem 1rem;
  border-bottom: 1px solid #eee;
  background: var(--blue-light);
}

.toc-header button {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}

.toc-list a:active,
.toc-list a:hover {
  background: var(--blue-light);
  border-left-color: var(--blue);
}

.toc-list .toc-sub a {
  padding-left: 2rem;
  font-size: 0.88rem;
  color: #444;
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.35);
}

.toc-backdrop[hidden] {
  display: none;
}

/* Main content */
.content {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1rem;
}

section {
  margin-bottom: 2rem;
}

.cover {
  text-align: center;
  padding: 1.5rem 0 2rem;
  border-bottom: 2px solid var(--blue);
  margin-bottom: 2rem;
}

.cover h1 {
  font-size: 1.75rem;
  color: var(--blue);
  margin: 0 0 0.5rem;
}

.cover .subtitle {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.cover-meta {
  font-size: 0.9rem;
  color: #555;
  margin: 0;
}

h1, h2, h3 {
  line-height: 1.35;
  scroll-margin-top: calc(var(--header-h) + var(--safe-top) + 0.5rem);
}

h1.unit-heading,
.content > section > h1 {
  font-size: 1.35rem;
  background: var(--blue-light);
  border: 2px solid var(--blue);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 2rem 0 1rem;
  color: #0d47a1;
}

h2 {
  font-size: 1.15rem;
  color: #333;
  margin: 1.75rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #ddd;
}

h2.practice-heading {
  background: #fce4ec;
  border: 2px solid var(--pink);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  color: #880e4f;
  border-bottom: 2px solid var(--pink);
}

p, li {
  margin: 0 0 0.85rem;
}

ul, ol {
  padding-left: 1.25rem;
  margin: 0 0 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table tbody {
  display: table;
  width: 100%;
}

td, th {
  border: 1px solid #ccc;
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

td strong, th strong {
  color: var(--blue);
}

/* Styled blocks */
.key-idea {
  background: var(--green-light);
  border-left: 5px solid var(--green);
  border-radius: 0 6px 6px 0;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}

.key-idea-label {
  font-weight: 700;
  color: #1b5e20;
  margin-bottom: 0.4rem;
}

.exam-tip {
  background: var(--orange-light);
  border-left: 5px solid var(--orange);
  border-radius: 0 6px 6px 0;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}

.exam-tip-label {
  font-weight: 700;
  color: #e65100;
  margin-bottom: 0.4rem;
}

.example-block {
  background: #e3f2fd;
  border: 2px solid #42a5f5;
  border-radius: 8px;
  padding: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.example-title {
  font-weight: 700;
  color: #0d47a1;
  margin-bottom: 0.5rem !important;
}

.example-problem p:last-child {
  margin-bottom: 0;
}

.solution-block,
blockquote {
  background: white;
  border-left: 4px solid #78909c;
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 1.25rem;
}

.solution-label {
  font-weight: 700;
  color: #455a64;
  margin-bottom: 0.35rem !important;
}

.step-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.step-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: #f5f5f5;
  border-left: 3px solid var(--blue);
  border-radius: 0 4px 4px 0;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
}

.step-num {
  flex-shrink: 0;
  background: var(--blue);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.checklist li {
  padding-left: 1.75rem;
  position: relative;
  margin-bottom: 0.5rem;
}

.checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: var(--blue);
}

.map-section {
  border: 2px solid;
  border-radius: 8px;
  margin: 1rem 0;
  overflow: hidden;
}

.map-section-header {
  padding: 0.65rem 1rem;
  font-weight: 700;
  color: white;
}

.map-entry {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: white;
  font-size: 0.95rem;
}

.map-entry-label {
  font-weight: 700;
  color: #333;
}

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

.progress-item {
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  text-align: center;
}

.conversions-box {
  background: #fff8e1;
  border: 1px solid #ffb300;
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.formula-caption {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.5rem;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: #777;
  font-size: 0.85rem;
  border-top: 1px solid #ddd;
  margin-top: 2rem;
}

@media (min-width: 768px) {
  body {
    font-size: 18px;
  }

  .content {
    padding: 0 1.5rem;
  }
}

@media print {
  .site-header,
  .toc-panel,
  .toc-backdrop,
  .site-footer {
    display: none !important;
  }

  body {
    padding-top: 0;
  }

  .solution-body {
    display: block !important;
  }

  .reveal-btn {
    display: none !important;
  }
}

/* Back nav */
.back-link {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid var(--blue);
  border-radius: 8px;
  background: white;
  color: var(--blue);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
}

.site-header-home {
  justify-content: center;
}

.site-title-large {
  text-align: center;
  font-size: 1.05rem;
}

/* Solution reveal */
.solution-block .solution-body {
  display: none;
  margin-top: 0.5rem;
}

.solution-block.open .solution-body {
  display: block;
}

.reveal-btn {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  margin-top: 0.35rem;
  border: 2px solid #78909c;
  border-radius: 6px;
  background: #eceff1;
  color: #37474f;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.mark-done-btn {
  display: block;
  width: 100%;
  max-width: 20rem;
  margin: 0 0 1.25rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: white;
  color: var(--green);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.mark-done-btn.done {
  background: var(--green-light);
}

.progress-item {
  cursor: pointer;
  font-family: inherit;
}

.progress-item.done {
  background: var(--green-light);
  border-color: var(--green);
}

.section-visual {
  margin: 0.75rem 0 1rem;
  text-align: center;
}

.section-visual img {
  max-width: 100%;
  height: auto;
}

/* Dashboard */
.dash-hero {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem 0 1.5rem;
  border-bottom: 2px solid var(--blue);
  margin-bottom: 1.5rem;
}

.dash-progress {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  flex-shrink: 0;
}

.progress-ring {
  width: 100%;
  height: 100%;
}

.ring-bg {
  fill: none;
  stroke: #e0e0e0;
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--blue);
  stroke-width: 8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.4s ease;
}

.progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue);
}

.dash-hero h1 {
  font-size: 1.5rem;
  margin: 0 0 0.35rem;
  color: var(--blue);
}

.dash-hero-text p {
  margin: 0 0 0.75rem;
  color: #555;
  font-size: 0.95rem;
}

.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 0.7rem 1.25rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  border: none;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-secondary {
  background: white;
  color: var(--blue);
  border: 2px solid var(--blue);
}

.btn-large {
  display: block;
  width: 100%;
  padding: 0.85rem;
}

.dash-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.75rem;
}

.dash-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  background: white;
  border: 2px solid #ddd;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  min-height: 6.5rem;
}

.dash-card:active {
  border-color: var(--blue);
  background: var(--blue-light);
}

.dash-card-icon {
  font-size: 1.5rem;
}

.dash-card strong {
  color: var(--blue);
  font-size: 0.95rem;
}

.dash-card span:last-child {
  font-size: 0.8rem;
  color: #666;
}

.dash-units h2,
.dash-quiz h2 {
  font-size: 1.15rem;
  border: none;
  margin-bottom: 0.75rem;
  padding: 0;
}

.dash-sub {
  font-size: 0.85rem;
  font-weight: 400;
  color: #666;
}

.unit-cards {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.unit-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}

.unit-card.done {
  border-color: var(--green);
  background: var(--green-light);
}

.unit-card-check {
  font-size: 1.1rem;
  color: var(--blue);
}

.unit-card.done .unit-card-check {
  color: var(--green);
}

.unit-card strong {
  color: #333;
}

/* Quiz */
.quiz-unit-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.quiz-unit-btn {
  padding: 0.45rem 0.75rem;
  border: 2px solid #ccc;
  border-radius: 999px;
  background: white;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.quiz-unit-btn.active {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 700;
}

.quiz-q {
  font-weight: 700;
  margin-bottom: 1rem;
}

.quiz-choices {
  display: grid;
  gap: 0.5rem;
}

.quiz-choice {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: white;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.quiz-choice.correct {
  border-color: var(--green);
  background: var(--green-light);
}

.quiz-choice.wrong {
  border-color: #c62828;
  background: #ffebee;
}

.quiz-choice:disabled {
  opacity: 0.85;
}

.quiz-feedback {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

.quiz-feedback.correct {
  background: var(--green-light);
}

.quiz-feedback.wrong {
  background: #ffebee;
}

.quiz-progress {
  font-size: 0.85rem;
  color: #666;
}

.dash-exam-tip {
  margin-top: 1.5rem;
}

/* Tools page */
.tool-card {
  background: white;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.tool-card h2 {
  margin-top: 0;
  font-size: 1.1rem;
  border: none;
  padding: 0;
}

.tool-hint {
  font-size: 0.9rem;
  color: #666;
}

.tool-row,
.tool-card label {
  display: block;
  margin-bottom: 0.65rem;
}

.tool-card input,
.tool-card select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid #ccc;
  border-radius: 6px;
}

.tool-card .btn-primary {
  width: 100%;
  margin-top: 0.5rem;
}

.tool-result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--blue-light);
  border-radius: 6px;
}

.tool-visual {
  display: block;
  max-width: 100%;
  margin-top: 1rem;
}

.formula-output {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #fff8e1;
  border-radius: 6px;
  min-height: 2.5rem;
}

/* Flashcards */
.flashcard-wrap {
  perspective: 800px;
  margin: 1.5rem 0 1rem;
}

.flashcard {
  display: block;
  width: 100%;
  min-height: 12rem;
  padding: 1.5rem;
  border: 3px solid var(--blue);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 8rem;
  font-size: 1.15rem;
  font-weight: 700;
  backface-visibility: hidden;
}

.flashcard-back {
  position: absolute;
  inset: 1.5rem;
  transform: rotateY(180deg);
  color: var(--green);
  font-size: 1rem;
}

.flashcard-counter {
  text-align: center;
  color: #666;
}

.flashcard-nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.flashcard-hint {
  text-align: center;
  font-size: 0.9rem;
  color: #666;
}

.site-footer a {
  color: var(--blue);
}

@media (min-width: 768px) {
  .dash-tools {
    grid-template-columns: repeat(4, 1fr);
  }
}
