/* ============================================
   A Parent's Guide to Education
   Monocle-inspired typography — 40/60 split
   ============================================ */

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

:root {
  --bg: #F5F0E8;
  --text: #1A1613;
  --text-mid: #4A4039;
  --text-light: #9B9083;
  --accent: #1A1613;
  --accent-hover: #4A4039;
  --rule: #D4C9B8;
  --serif: 'PP Editorial New', 'GT Sectra', 'Freight Text', Georgia, serif;
  --sans: 'Suisse Intl', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  /* Fallback to available web fonts */
  --heading: 'Source Serif 4', Georgia, serif;
  --body: 'Source Serif 4', Georgia, serif;
  --ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: var(--body); background: var(--bg); color: var(--text); line-height: 1.75; }
::selection { background: rgba(26, 22, 19, 0.12); }
a { color: inherit; text-decoration: none; }

/* ========== 40/60 LAYOUT ========== */
.page-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Left: TOC panel --- */
.toc-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 40%;
  height: 100vh;
  overflow-y: auto;
  padding: 3.5rem 2rem 2.5rem 2.75rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
  transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
  transform: translateX(0);
  z-index: 60;
  background: var(--bg);
}
.toc-panel.collapsed {
  transform: translateX(-100%);
}

.toc-panel::-webkit-scrollbar { width: 0; }

/* Panel content starts below the bar */

/* Top-left control bar — single transforming container */
.toc-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 65;
  display: flex;
  align-items: stretch;
  height: 36px;
  width: 40%;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  transition: width 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.toc-bar.closed {
  width: 36px;
}

.toc-bar-title {
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  font-family: var(--ui);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-light);
  white-space: nowrap;
  width: 0;
  overflow: hidden;
  width: calc(100% - 36px);
  opacity: 1;
  transition: width 0.5s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.3s ease 0.2s;
}

.toc-bar.closed .toc-bar-title {
  width: 0;
  opacity: 0;
  transition: width 0.5s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.3s ease 0s;
}

.toc-bar-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  flex-shrink: 0;
  order: 2;
  border-left: 1px solid var(--rule);
}

.toc-bar.closed .toc-bar-btn {
  order: 0;
  border-left: none;
}

.toc-bar-btn:hover { color: var(--text); }

/* Hide mobile chapter rail on desktop */
.mobile-chapter-rail {
  display: none;
}

@media (max-width: 900px) {
  .toc-bar.open { width: 100%; }
}

/* --- TOC entries — label stacked above title --- */
.toc-entry + .toc-entry {
  border-top: 1px solid var(--rule);
  margin-top: 1rem;
  padding-top: 1rem;
}

.toc-entry > .toc-header,
.toc-entry > .toc-toggle {
  vertical-align: top;
}

.toc-header {
  display: inline-flex;
  align-items: flex-start;
  padding: 1.25rem 0;
  text-decoration: none;
  color: inherit;
  width: calc(100% - 28px);
}

.toc-header:hover .toc-title { color: var(--accent); }

.toc-meta {
  flex: 1;
  min-width: 0;
}

.toc-label {
  font-family: var(--heading);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-light);
  display: inline;
  margin-bottom: 0.2rem;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.toc-title {
  font-family: 'Single Day', cursive;
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--text);
  transition: color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.toc-title a {
  color: inherit;
  text-decoration: none;
}
.toc-title a:hover { color: var(--accent); }

.toc-toggle {
  font-family: var(--ui);
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-light);
  width: 24px;
  text-align: center;
  user-select: none;
  transition: color 0.15s;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 1.25rem 0;
  display: inline-block;
}

.toc-toggle:hover { color: var(--text); }

/* Active essay — no highlight change on titles */


/* --- Expandable sections --- */
.toc-sections {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.toc-entry.open .toc-sections {
  max-height: 600px;
}

.toc-section-link {
  display: block;
  font-family: var(--heading);
  font-size: 0.88rem;
  font-weight: 400;
  text-transform: capitalize;
  color: var(--text-light);
  padding: 0.25rem 0;
  transition: color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-section-link:hover { color: var(--text); }
.toc-section-link.active { color: var(--text); }


.toc-sections-pad {
  padding-bottom: 0.65rem;
}

/* --- TOC footer --- */
.toc-footer {
  margin-top: auto;
  padding-top: 2rem;
  font-family: var(--ui);
  font-size: 0.58rem;
  color: var(--text-light);
}
.toc-footer a { color: var(--accent); }

/* --- Vertical title running up left edge — mobile only --- */
.toc-vertical-title {
  display: none;
}

@media (max-width: 900px) {
  .toc-vertical-title {
    display: block;
    position: fixed;
    bottom: 1.5rem;
    left: 0;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: var(--ui);
    font-size: 0.48rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--rule);
    padding-left: 0.6rem;
    pointer-events: none;
    z-index: 5;
  }
}

/* --- Right: Content panel --- */
.content-panel {
  margin-left: 0;
  margin-top: 36px;
  width: 100%;
  min-height: calc(100vh - 36px);
  transition: margin-left 0.5s cubic-bezier(0.25, 0.1, 0.25, 1), width 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Fade text as it scrolls under the top bar */
.content-panel::before {
  content: '';
  position: fixed;
  top: 36px;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(to bottom, var(--bg) 0%, var(--bg) 20%, transparent 100%);
  z-index: 5;
  pointer-events: none;
}

.content-inner {
  max-width: 620px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

/* ========== READING PROGRESS — floating bullet ========== */
.reading-progress {
  display: none; /* replaced by bullet marker */
}

.toc-marker {
  position: absolute;
  left: -1.4rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text);
  transition: top 0.25s ease;
  z-index: 10;
  pointer-events: none;
}

.toc-entries {
  position: relative;
}

/* ========== SHARE QUOTE TOOLTIP ========== */
.share-tooltip {
  position: absolute;
  z-index: 100;
  background: var(--text);
  color: var(--bg);
  font-family: var(--ui);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.4rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.share-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}

.share-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
}

/* ========== ESSAY SECTIONS (single page) ========== */
.essay-section {
  scroll-margin-top: 4rem;
}

.essay-section + .essay-section {
  margin-top: 4rem;
  padding-top: 0;
  border-top: none;
}

.essay-section + .essay-section::before {
  content: '\2014';
  display: block;
  text-align: center;
  color: var(--rule);
  font-size: 1.2rem;
  margin-top: -6rem;
  margin-bottom: 4rem;
}

/* ========== ESSAY HERO ========== */
.essay-hero {
  margin-bottom: 2.5rem;
}

.essay-number {
  font-family: var(--heading);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 0.6rem;
  display: inline-block;
  background: var(--rule);
  padding: 0.1em;
}

.essay-hero h1 {
  font-family: 'Single Day', cursive;
  color: #3D3229;
  font-size: 1.6rem;
  text-wrap: balance;
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  max-width: 80%;
}

/* ========== ESSAY CONTENT — Monocle typography ========== */
.essay-content p {
  margin-bottom: 1.35rem;
  font-size: 1.07rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.essay-content h2 {
  font-family: var(--heading);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.15;
  margin: 3rem 0 1rem;
  letter-spacing: -0.01em;
  scroll-margin-top: 4rem;
}

.essay-content h3 {
  font-family: var(--heading);
  font-size: 1.8rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.15;
  margin: 5rem 0 1.5rem;
  text-transform: capitalize;
  text-wrap: balance;
  scroll-margin-top: 4rem;
}

.essay-content h4 {
  font-family: var(--ui);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 2rem 0 0.6rem;
  letter-spacing: 0.01em;
}

/* Blockquote — Monocle: thin rule, no background */
.essay-content blockquote {
  margin: 1.75rem 0;
  padding: 0 0 0 1.25rem;
  border-left: 1.5px solid var(--accent);
  font-style: italic;
  color: var(--text-mid);
}
.essay-content blockquote p { margin-bottom: 0.5rem; }
.essay-content blockquote p:last-child { margin-bottom: 0; }

/* Lists */
.essay-content ul, .essay-content ol {
  margin-bottom: 1.35rem;
  padding-left: 1.1rem;
}
.essay-content li {
  margin-bottom: 0.35rem;
  line-height: 1.7;
  font-size: 1.07rem;
  font-style: italic;
}
.essay-content li::marker { color: var(--accent); }

/* Figures */
.essay-content figure {
  margin: 2rem 0;
}
.essay-content figure img {
  width: 100%;
  height: auto;
  filter: grayscale(1) sepia(0.25) contrast(1.1) brightness(0.95);
  mix-blend-mode: luminosity;
  opacity: 0.8;
}
.essay-content figcaption {
  font-family: var(--ui);
  font-size: 0.62rem;
  color: var(--text-light);
  margin-top: 0.45rem;
  letter-spacing: 0.01em;
}

.essay-content strong { font-weight: 600; }
.essay-content em { font-style: italic; }

.essay-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* ========== PRESIDENTIAL QUOTES ========== */
.quotes-wrapper {
  margin-bottom: 3rem;
}

.quotes-block {
  display: flex;
  overflow-x: auto;
  gap: 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.quotes-block::-webkit-scrollbar { height: 0; }
.quotes-block { padding-right: 1px; }

.pres-quote {
  padding: 2rem 2rem 2.5rem;
  text-align: center;
  background: #EEEBE4;
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Dot nav */
.quotes-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.quotes-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rule);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s;
}

.quotes-dot.active {
  background: var(--text);
}

.pres-mark {
  font-family: var(--heading);
  font-size: 3rem;
  line-height: 1;
  color: var(--rule);
  margin-bottom: 0.25rem;
}

.pres-text {
  font-size: 1.55rem;
  font-style: italic;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 1rem;
  text-wrap: balance;
  max-width: 82%;
  margin-left: auto;
  margin-right: auto;
}

.pres-name {
  font-family: var(--heading);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-light);
}

.pres-source {
  font-family: var(--heading);
  font-size: 0.7rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-light);
  margin-top: 0.15rem;
}

/* ========== ESSAY NAV (prev/next) ========== */
.essay-nav {
  display: flex;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.essay-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}
.essay-nav a:hover .nav-title { color: var(--accent); }

.essay-nav .nav-label {
  font-family: var(--ui);
  font-size: 0.52rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-light);
  margin-bottom: 0.2rem;
}
.essay-nav .nav-title {
  font-family: var(--heading);
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  transition: color 0.15s;
}
.essay-nav a.next { text-align: right; }

/* ========== FOOTER ========== */
.content-footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--ui);
  font-size: 0.58rem;
  color: var(--text-light);
}
.content-footer a { color: var(--accent); }

/* ========== LANDING HERO ========== */
.landing-hero h1 {
  font-family: var(--heading);
  font-size: 2.8rem;
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin-bottom: 1.25rem;
}

.landing-hero .subtitle {
  font-size: 0.95rem;
  color: var(--text-mid);
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.landing-hero .cta {
  display: inline-block;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
  transition: all 0.15s;
}
.landing-hero .cta:hover {
  color: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ========== MOBILE ========== */

/* Old mobile header — hidden, replaced by rail */
.mobile-header {
  display: none;
}

.toc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 19, 0.08);
  z-index: 40;
}

/* Top bar — spans full width */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  z-index: 10;
  transition: left 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-bar-title {
  font-family: var(--ui);
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-light);
  transition: opacity 0.3s ease;
}

.top-bar-title {
  opacity: 0;
}

body.panel-closed .top-bar-title {
  opacity: 1;
}

/* Chapter rail — hidden */
.mobile-rail {
  display: none;
}

/* Rail boxes — proportional height */
.rail-box {
  font-family: var(--heading);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-light);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--rule);
  transition: color 0.2s;
}

.rail-box:last-child {
  border-bottom: none;
}

.rail-box.active {
  color: var(--text);
}

/* Desktop: panel open by default, content pushed */
@media (min-width: 901px) {
  .content-panel {
    margin-left: 40%;
    width: calc(60% - 36px);
  }
  .content-panel::before {
    left: 40%;
  }
  .top-bar {
    left: 40%;
  }
  body.panel-closed .content-panel {
    margin-left: 0;
    width: 100%;
  }
  body.panel-closed .content-panel::before {
    left: 0;
  }
  body.panel-closed .top-bar {
    left: 0;
  }
  .toc-overlay { display: none !important; }
}

/* Mobile: overlay instead of push */
@media (max-width: 900px) {
  .toc-overlay.open { display: block; }
}

@media (max-width: 900px) {
  .toc-panel {
    width: 100%;
    max-width: 100%;
    padding: 2.5rem 2rem 2.5rem 2.5rem;
  }
  .toc-title { white-space: normal; overflow: visible; text-overflow: clip; }
  .content-inner { padding: 2rem 1.25rem 4rem 1.25rem; max-width: 100%; }
  .essay-hero h1 { font-size: 1.5rem; max-width: 100%; }
  .landing-hero h1 { font-size: 2rem; }
  /* Top bar persists with centered title */
  .top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    left: 0;
    z-index: 55;
  }
  .top-bar-title { opacity: 1 !important; }
  body.panel-closed .top-bar-title { opacity: 1 !important; }

  /* +/× in top-right corner */
  .toc-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: 36px;
    height: 36px;
    z-index: 66;
    border: none;
    border-bottom: 1px solid var(--rule);
    border-left: 1px solid var(--rule);
    background: var(--bg);
  }
  .toc-bar .toc-bar-title { display: none !important; }
  .toc-bar .toc-bar-btn {
    order: 0;
    width: 36px;
    height: 36px;
    border: none;
    transition: transform 0.4s ease, color 0.15s;
  }
  .toc-bar.closed .toc-bar-btn {
    order: 0;
    transform: rotate(0deg);
  }
  .toc-bar:not(.closed) .toc-bar-btn {
    transform: rotate(45deg);
  }

  .content-panel { margin-left: 0; margin-top: 36px; width: 100%; }
  .content-panel::before { left: 0; top: 36px; }

  /* Panel slides up from below top bar */
  .toc-panel {
    width: 100%;
    max-width: 100%;
    top: 36px;
    height: calc(100vh - 36px);
    padding: 2rem 2rem 2.5rem;
    transform: translateX(-100%);
  }
  .toc-panel:not(.collapsed) {
    transform: translateX(0);
  }
  .pres-quote { padding: 1.5rem 1.25rem 1.75rem; }
  .pres-mark { font-size: 2rem; margin-bottom: 0.15rem; }
  .pres-text { font-size: 1.1rem; line-height: 1.3; max-width: 90%; }
  .pres-name { font-size: 0.55rem; }
  .pres-source { font-size: 0.55rem; }
}
