/* ============================================
   PSAT Legal Pages — Editorial Design System
   ============================================ */

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

:root {
  /* Colors — warm dark, NOT generic cyberpunk */
  --bg: #0b0b0c;
  --bg-elevated: #141416;
  --bg-soft: #1c1c1f;
  --border: #26262a;
  --border-strong: #35353a;

  --text-primary: #f4f1ea;       /* warm off-white, not cold #fff */
  --text-secondary: #a8a29e;     /* warm gray */
  --text-tertiary: #6b6660;      /* warm muted */

  --accent: #d4a574;             /* warm amber, NOT purple */
  --accent-hover: #e4b88a;
  --accent-dim: rgba(212, 165, 116, 0.12);

  /* Type scale */
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Spacing */
  --content-width: 680px;
  --sidebar-width: 260px;

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg);
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Subtle paper-like noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.025;
  z-index: 1;
  mix-blend-mode: overlay;
}

/* ============================================
   Reading Progress Bar (top)
   ============================================ */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  z-index: 100;
  transition: width 0.1s linear;
}

/* ============================================
   Top Navigation
   ============================================ */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(11, 11, 12, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 0 32px;
}

.top-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s var(--ease);
  cursor: pointer;
}

.top-nav-back:hover {
  color: var(--text-primary);
}

.top-nav-back svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s var(--ease);
}

.top-nav-back:hover svg {
  transform: translateX(-2px);
}

.top-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  font-style: italic;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.nav-brand-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(212, 165, 116, 0.2));
  transition: transform 0.4s var(--ease);
}

.top-nav-brand:hover .nav-brand-img {
  transform: rotate(-12deg) scale(1.08);
}

.top-nav-links {
  display: flex;
  gap: 28px;
}

.top-nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s var(--ease);
  cursor: pointer;
}

.top-nav-link:hover,
.top-nav-link.active {
  color: var(--accent);
}

/* ============================================
   Layout
   ============================================ */
.layout {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 160px 32px 120px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 80px;
}

/* ============================================
   Hero / Document Header
   ============================================ */
.doc-hero {
  grid-column: 1 / -1;
  max-width: var(--content-width);
  margin-bottom: 80px;
}

.doc-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 28px;
  font-family: var(--font-mono);
}

.doc-eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
}

.doc-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 24px;
  font-variation-settings: "SOFT" 30, "WONK" 1;
}

.doc-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 500;
}

.doc-subtitle {
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 560px;
  margin-bottom: 40px;
}

.doc-meta {
  display: flex;
  gap: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
}

.doc-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-meta-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  font-size: 10px;
}

.doc-meta-value {
  color: var(--text-primary);
  font-size: 13px;
}

/* ============================================
   Sidebar TOC (sticky)
   ============================================ */
.toc {
  position: sticky;
  top: 120px;
  align-self: start;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding-right: 16px;
}

.toc::-webkit-scrollbar {
  width: 4px;
}

.toc::-webkit-scrollbar-track {
  background: transparent;
}

.toc::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

.toc-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-tertiary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-item {
  position: relative;
}

.toc-link {
  display: block;
  padding: 10px 0 10px 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: all 0.3s var(--ease);
  border-left: 1px solid var(--border);
  cursor: pointer;
}

.toc-link:hover {
  color: var(--text-secondary);
  border-left-color: var(--border-strong);
}

.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  padding-left: 24px;
}

.toc-link-number {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  margin-right: 8px;
}

.toc-link.active .toc-link-number {
  color: var(--accent);
}

/* ============================================
   Content
   ============================================ */
.content {
  max-width: var(--content-width);
}

.section {
  margin-bottom: 72px;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-number {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 16px;
  display: block;
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 28px;
  font-variation-settings: "SOFT" 30, "WONK" 1;
}

.section-body {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-secondary);
}

.section-body > p {
  margin-bottom: 20px;
}

.section-body > p:last-child {
  margin-bottom: 0;
}

.section-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.section-body a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 100% 1px;
  background-position: 0 100%;
  transition: background-size 0.3s var(--ease);
  padding-bottom: 1px;
}

.section-body a:hover {
  background-size: 0% 1px;
}

.section-body ul {
  list-style: none;
  margin: 16px 0 24px;
  padding: 0;
}

.section-body ul li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 10px;
  line-height: 1.65;
}

.section-body ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 10px;
  height: 1px;
  background: var(--accent);
}

.section-body h3 {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 12px;
  letter-spacing: -0.01em;
}

/* Callout / Note block */
.callout {
  border-left: 2px solid var(--accent);
  background: var(--accent-dim);
  padding: 20px 24px;
  margin: 28px 0;
  border-radius: 0 4px 4px 0;
}

.callout-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  display: block;
}

.callout-body {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.65;
}

/* Contact card */
.contact-card {
  margin-top: 16px;
  padding: 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.contact-card-row {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.contact-card-row:last-child {
  border-bottom: none;
}

.contact-card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  min-width: 72px;
}

.contact-card-value {
  color: var(--text-primary);
  font-weight: 500;
}

.contact-card-value a {
  color: var(--accent);
  text-decoration: none;
}

.contact-card-value a:hover {
  text-decoration: underline;
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  max-width: 1200px;
  margin: 80px auto 0;
  padding: 48px 32px 64px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  position: relative;
  z-index: 2;
}

.site-footer-brand {
  font-family: var(--font-serif);
  font-size: 14px;
  font-style: italic;
  color: var(--text-secondary);
}

.site-footer-copy {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

.site-footer-links {
  display: flex;
  gap: 24px;
}

.site-footer-links a {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.site-footer-links a:hover {
  color: var(--accent);
}

/* ============================================
   Back to top button
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  z-index: 40;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 0.3s var(--ease);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.back-to-top svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 48px;
    padding: 120px 24px 80px;
  }

  .toc {
    position: static;
    max-height: none;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elevated);
  }

  .toc-label {
    margin-bottom: 12px;
  }

  .doc-hero {
    margin-bottom: 48px;
  }

  .doc-title {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .doc-meta {
    flex-wrap: wrap;
    gap: 20px;
  }

  .top-nav {
    padding: 0 20px;
  }

  .top-nav-links {
    gap: 16px;
  }

  .site-footer {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 600px) {
  .top-nav-brand {
    display: none;
  }

  .section {
    margin-bottom: 56px;
  }
}

/* ============================================
   Reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .section {
    opacity: 1;
    transform: none;
    transition: none;
  }

  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Print
   ============================================ */
@media print {
  .top-nav,
  .toc,
  .back-to-top,
  .progress-bar {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .section {
    opacity: 1;
    transform: none;
    page-break-inside: avoid;
  }
}
