/* ── FoxChild@Learn SEO Pages Stylesheet ────────────────────────────── */

:root {
  --teal: #3d9ea5;
  --teal-dark: #2b8a91;
  --teal-light: #e8f6f7;
  --bg: #f7f7f3;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5a5a7a;
  --border: #e2e2d8;
  --surface-alt: #f2f2ee;
  --surface-accent: #edf5f0;
  --font-ui: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  --font-display: "Georgia", "Palatino", "Times New Roman", serif;
  --radius: 8px;
  --max-width: 820px;
  --ink: #1a1a2e;
  --muted: #6b6b7b;
  --line: #e2e2d8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
}

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

/* ── Shared Header / Footer ──────────────────────────────────────────── */

.seo-header,
.sb-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.seo-logo,
.sb-page-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--teal);
}
.seo-logo:hover,
.sb-page-logo:hover { text-decoration: none; }

.seo-logo-img {
  height: 28px;
  width: auto;
  display: block;
  border-radius: 4px;
}

.seo-nav,
.sb-page-nav {
  display: flex;
  gap: 1.2rem;
}
.seo-nav a,
.sb-page-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}
.seo-nav a:hover,
.sb-page-nav a:hover { color: var(--teal); }

.seo-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.seo-footer a { font-weight: 500; }

/* ── Standard Page Layout (subjects, index) ──────────────────────────── */

.seo-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.seo-main {
  flex: 1;
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 0 1.5rem;
  width: 100%;
}

.seo-main h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
  line-height: 1.3;
}

.seo-main h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

.seo-main h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.seo-main p { margin-bottom: 1rem; color: var(--text); }

.seo-main .lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* ── Subject Grid ─────────────────────────────────────────────────── */

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.subject-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.subject-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-decoration: none;
}
.subject-card h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 0.25rem;
  color: var(--teal);
}
.subject-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Book Grid ────────────────────────────────────────────────────── */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.book-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.book-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-decoration: none;
}

.book-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.book-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.book-card-meta {
  font-size: 0.8rem;
  color: var(--teal);
  font-weight: 500;
}

/* ── CTA Section ──────────────────────────────────────────────────── */

.cta-section {
  margin: 2.5rem 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.cta-button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--teal);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.cta-button:hover {
  background: var(--teal-dark);
  text-decoration: none;
  color: #fff;
}
.cta-button.secondary {
  background: transparent;
  color: var(--teal);
  border: 2px solid var(--teal);
}
.cta-button.secondary:hover {
  background: var(--teal-light);
}

/* ── Related Section ──────────────────────────────────────────────── */

.related-section { margin: 2rem 0; }
.related-section h2 { border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }

/* ═══════════════════════════════════════════════════════════════════════
   Study Book Page (mirrors the app's StudyBookDrawer)
   Fixed viewport height — header/titlebar/search stay put.
   TOC and content scroll independently inside.
   ═══════════════════════════════════════════════════════════════════════ */

.sb-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Title bar (stays at top) ────────────────────────────────────────── */

.sb-page-titlebar {
  padding: 1rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.sb-page-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}

.sb-page-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.3rem 0 0;
}

/* ── Search bar (stays at top, below title) ──────────────────────────── */

.sb-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.sb-search-input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.88rem;
  color: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  min-width: 0;
}

.sb-search-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(61, 158, 165, 0.15);
}

.sb-search-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.sb-search-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  flex-shrink: 0;
}

.sb-search-nav:hover {
  background: var(--teal-light);
  border-color: var(--teal);
  color: var(--teal);
}

/* ── Inner layout (TOC sidebar + content) fills remaining height ─────── */

.sb-inner {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Table of contents (stays on the left, scrolls independently) ────── */

.sb-toc {
  width: 158px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px 8px 14px 12px;
  border-right: 1px solid var(--border);
  font-size: 0.80rem;
  background: var(--surface-alt);
}

.sb-toc-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 8px 0;
}

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

.sb-toc-h1 > a,
.sb-toc-h2 > a,
.sb-toc-h3 > a {
  display: block;
  padding: 3px 6px;
  border-radius: 5px;
  text-decoration: none;
  color: var(--text-muted);
  transition: background 120ms ease, color 120ms ease;
  line-height: 1.4;
}

.sb-toc-h1 > a { font-weight: 600; color: var(--text); }
.sb-toc-h2 > a { padding-left: 14px; }
.sb-toc-h3 > a { padding-left: 22px; font-size: 0.76rem; }

.sb-toc-h1 > a:hover,
.sb-toc-h2 > a:hover,
.sb-toc-h3 > a:hover {
  background: var(--surface-accent);
  color: var(--teal);
}

.sb-toc-active > a {
  color: var(--teal);
  font-weight: 700;
  background: var(--surface-accent);
}

.sb-toc-empty {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ── Markdown content area ──────────────────────────────────────────── */

.sb-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 40px;
  scroll-behavior: smooth;
  line-height: 1.75;
  font-size: 0.93rem;
}

/* Typography inside markdown */
.sb-content h1,
.sb-content h2,
.sb-content h3,
.sb-content h4 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 1.4em 0 0.5em;
  line-height: 1.3;
}

.sb-content h1 { font-size: 1.4rem; }
.sb-content h2 {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.sb-content h3 { font-size: 1.02rem; }
.sb-content h4 { font-size: 0.95rem; }

.sb-content p {
  margin: 0 0 0.9em;
  color: var(--text);
}

.sb-content ul,
.sb-content ol {
  padding-left: 1.4em;
  margin: 0 0 0.9em;
}

.sb-content li { margin-bottom: 0.3em; }

.sb-content blockquote {
  border-left: 3px solid var(--teal);
  margin: 0 0 0.9em;
  padding: 6px 12px;
  color: var(--text-muted);
  background: var(--teal-light);
  border-radius: 0 6px 6px 0;
}

.sb-content table {
  border-collapse: collapse;
  width: 100%;
  overflow-x: auto;
  display: block;
  font-size: 0.88rem;
  margin-bottom: 1em;
}

.sb-content th,
.sb-content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.sb-content th {
  background: var(--surface-alt);
  font-weight: 600;
}

.sb-content tr:nth-child(even) td {
  background: var(--surface-accent);
}

.sb-content code {
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

.sb-content pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 1em;
}

.sb-content pre code {
  background: none;
  padding: 0;
  font-size: 0.87rem;
  display: block;
}

.sb-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.sb-content a {
  color: var(--teal);
  text-decoration: underline;
}

/* Search highlight */
mark.sb-highlight {
  background: rgba(247, 182, 20, 0.40);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

mark.sb-highlight-active {
  background: rgba(232, 132, 26, 0.70);
  outline: 2px solid rgba(232, 132, 26, 0.90);
  border-radius: 2px;
}

/* ── File tabs ───────────────────────────────────────────────────────── */

.sb-file-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sb-file-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.sb-file-tab:hover {
  background: var(--surface-accent);
  border-color: var(--teal);
}

.sb-file-tab.active {
  background: var(--surface-accent);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
}

/* ── Notes unavailable ────────────────────────────────────────────── */

.notes-unavailable {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem;
  background: #fef9e7;
  border-radius: var(--radius);
  border: 1px solid #f5d76e;
}
.notes-unavailable a { font-weight: 600; }

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .sb-toc { display: none; }
  .sb-content { padding: 16px; }
  .sb-page-titlebar { padding: 0.75rem 1rem 0.5rem; }
  .sb-page-title { font-size: 1.1rem; }
  .sb-page { height: 100dvh; }
}

@media (max-width: 640px) {
  .seo-main { padding: 0 1rem; margin: 1.5rem auto; }
  .seo-main h1 { font-size: 1.5rem; }
  .subject-grid { grid-template-columns: 1fr 1fr; }
  .book-grid { grid-template-columns: 1fr; }
  .book-grid.compact { grid-template-columns: 1fr 1fr; }
  .cta-section { flex-direction: column; }
  .cta-button { text-align: center; }
  .sb-page-header { flex-direction: column; gap: 0.5rem; }
}

@media (max-width: 480px) {
  .subject-grid { grid-template-columns: 1fr; }
  .book-grid.compact { grid-template-columns: 1fr; }
  .seo-header { flex-direction: column; gap: 0.5rem; }
}
