/* ===========================================
   PAGE.CSS - Shared stylesheet for page.php and sitemap.php
   Inherits CSS custom properties from home.css (:root block)
   =========================================== */

/* Smooth scroll (home.css sets this too, kept here for standalone use) */
html {
  scroll-behavior: smooth;
}

/* ===========================================
   PAGE HERO - dark ink background, gold headline, breadcrumb
   =========================================== */
.page-hero {
  background: var(--ink, #0C0906);
  padding: calc(var(--nav-h, 72px) + var(--topbar-h, 40px) + 48px) 80px 56px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(200, 144, 10, 0.12);
}

/* Subtle radial glow behind the hero */
.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 80% at 15% 60%, rgba(200, 144, 10, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 50% 60% at 85% 30%, rgba(140, 28, 4, 0.12) 0%, transparent 55%);
  pointer-events: none;
}

.page-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
}

/* Breadcrumb nav */
.page-hero nav,
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(247, 237, 216, 0.45);
  flex-wrap: wrap;
}

.page-breadcrumb a {
  color: rgba(247, 237, 216, 0.45);
  text-decoration: none;
  transition: color 0.2s;
}

.page-breadcrumb a:hover {
  color: var(--gold-light, #E8B030);
}

/* Gold separator between breadcrumb items */
.page-breadcrumb .breadcrumb-sep {
  color: var(--gold, #C8900A);
  opacity: 0.6;
  font-size: 0.65rem;
  user-select: none;
}

.page-breadcrumb .breadcrumb-current {
  color: rgba(247, 237, 216, 0.65);
}

/* Hero H1 - gold-light, display font */
.page-hero h1,
.page-hero-title {
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(2.2rem, 4.5vw, 4rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--gold-light, #E8B030);
  margin: 0;
}

/* Optional eyebrow label above H1 */
.page-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold, #C8900A);
  margin-bottom: 16px;
}

.page-hero-eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--gold, #C8900A);
}

/* ===========================================
   PAGE LAYOUT - two-column grid: 220 px TOC + 1fr content
   =========================================== */
.page-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 80px 80px;
  align-items: start;
}

/* Full-width variant used when there is no TOC */
.page-layout.no-toc {
  grid-template-columns: 1fr;
  max-width: 820px;
}

/* ===========================================
   PAGE TOC - sticky sidebar table of contents
   =========================================== */
.page-toc {
  position: sticky;
  /* fallback when custom props not available */
  top: 80px;
  top: calc(var(--nav-h, 72px) + var(--topbar-h, 40px) + 24px);
  max-height: calc(100vh - var(--nav-h, 72px) - var(--topbar-h, 40px) - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;

  /* Subtle scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 144, 10, 0.25) transparent;
}

.page-toc::-webkit-scrollbar {
  width: 3px;
}

.page-toc::-webkit-scrollbar-thumb {
  background: rgba(200, 144, 10, 0.3);
  border-radius: 2px;
}

/* TOC heading label */
.page-toc-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold, #C8900A);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-toc-label::before {
  content: '';
  width: 20px;
  height: 1px;
  background: var(--gold, #C8900A);
  opacity: 0.6;
}

/* TOC list */
.page-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid rgba(200, 144, 10, 0.15);
}

.page-toc ul li {
  margin: 0;
  padding: 0;
}

.page-toc ul li a {
  display: block;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  color: rgba(247, 237, 216, 0.45);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  border-radius: 0 4px 4px 0;
}

.page-toc ul li a:hover {
  color: var(--cream, #F7EDD8);
  border-left-color: rgba(200, 144, 10, 0.4);
  background: rgba(200, 144, 10, 0.04);
}

/* H3 indentation inside TOC */
.page-toc ul li.toc-h3 a {
  padding-left: 26px;
  font-size: 0.75rem;
}

/* Active TOC item */
.page-toc ul li a.toc-active,
.page-toc ul li.toc-active > a {
  color: var(--gold-light, #E8B030);
  border-left-color: var(--gold-light, #E8B030);
  background: rgba(232, 176, 48, 0.06);
  font-weight: 600;
}

/* Mobile TOC toggle button - visible only on small screens */
.page-toc-toggle {
  display: none;
  width: 100%;
  padding: 12px 16px;
  background: rgba(200, 144, 10, 0.08);
  border: 1px solid rgba(200, 144, 10, 0.2);
  border-radius: 8px;
  color: var(--gold-light, #E8B030);
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, border-color 0.2s;
  margin-bottom: 0;
}

.page-toc-toggle:hover {
  background: rgba(200, 144, 10, 0.13);
  border-color: rgba(200, 144, 10, 0.35);
}

/* Chevron arrow indicator */
.page-toc-toggle .toc-toggle-icon {
  transition: transform 0.25s ease;
  flex-shrink: 0;
  font-style: normal;
}

.page-toc-toggle[aria-expanded="true"] .toc-toggle-icon {
  transform: rotate(180deg);
}

/* ===========================================
   PAGE CONTENT - typography
   =========================================== */
.page-content {
  min-width: 0; /* prevent grid blowout */
  max-width: 72ch; /* comfortable reading width */
  color: rgba(247, 237, 216, 0.85);
}

/* Headings */
.page-content h2 {
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--cream, #F7EDD8);
  margin: 2.4em 0 0.7em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid rgba(200, 144, 10, 0.12);
}

.page-content h2:first-child {
  margin-top: 0;
}

.page-content h3 {
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--gold-light, #E8B030);
  margin: 2em 0 0.5em;
}

.page-content h4 {
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cream, #F7EDD8);
  margin: 1.6em 0 0.4em;
}

/* Body text */
.page-content p {
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(247, 237, 216, 0.75);
  margin: 0 0 1.25em;
}

/* Lists */
.page-content ul,
.page-content ol {
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(247, 237, 216, 0.72);
  margin: 0 0 1.25em 1.4em;
  padding: 0;
}

.page-content li {
  margin-bottom: 0.35em;
}

.page-content ul li::marker {
  color: var(--gold, #C8900A);
}

.page-content ol li::marker {
  color: var(--gold-light, #E8B030);
  font-weight: 600;
}

/* Links within content */
.page-content a {
  color: var(--gold-light, #E8B030);
  text-decoration: underline;
  text-decoration-color: rgba(232, 176, 48, 0.35);
  text-underline-offset: 3px;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.page-content a:hover {
  color: var(--cream, #F7EDD8);
  text-decoration-color: rgba(247, 237, 216, 0.5);
}

/* Strong / em */
.page-content strong {
  color: var(--cream, #F7EDD8);
  font-weight: 700;
}

.page-content em {
  color: var(--gold-light, #E8B030);
  font-style: italic;
}

/* Blockquote */
.page-content blockquote {
  margin: 1.6em 0;
  padding: 16px 24px;
  border-left: 3px solid var(--gold, #C8900A);
  background: rgba(200, 144, 10, 0.05);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: rgba(247, 237, 216, 0.65);
}

/* Inline code / pre */
.page-content code {
  font-size: 0.875em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 144, 10, 0.15);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--gold-light, #E8B030);
}

.page-content pre {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(200, 144, 10, 0.12);
  border-radius: 8px;
  padding: 20px 24px;
  overflow-x: auto;
  margin: 0 0 1.4em;
}

.page-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

/* HR divider */
.page-content hr {
  border: none;
  border-top: 1px solid rgba(200, 144, 10, 0.12);
  margin: 2.4em 0;
}

/* ===========================================
   PAGE LAST UPDATED - muted smaller notice
   =========================================== */
.page-last-updated {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(200, 144, 10, 0.1);
  border-radius: 8px;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 0.78rem;
  font-weight: 400;
  color: rgba(247, 237, 216, 0.38);
  letter-spacing: 0.02em;
}

.page-last-updated .updated-icon {
  font-size: 0.85rem;
  opacity: 0.6;
}

/* ===========================================
   SITEMAP GRID - responsive auto-fill columns
   =========================================== */
.sitemap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 80px 80px;
}

/* ===========================================
   SITEMAP CARD - dark bg, gold border on hover, icon + heading + links
   =========================================== */
.sitemap-card {
  background: var(--smoke, #2A2218);
  border: 1px solid rgba(200, 144, 10, 0.1);
  border-radius: 16px;
  padding: 32px 28px;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sitemap-card:hover {
  border-color: var(--gold, #C8900A);
  box-shadow: 0 12px 40px rgba(200, 144, 10, 0.12);
  transform: translateY(-3px);
}

/* Card icon */
.sitemap-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(200, 144, 10, 0.08);
  border: 1px solid rgba(200, 144, 10, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  transition: background 0.25s, transform 0.25s;
}

.sitemap-card:hover .sitemap-card-icon {
  background: rgba(200, 144, 10, 0.14);
  transform: scale(1.08) rotate(-4deg);
}

/* Card heading */
.sitemap-card h2,
.sitemap-card-heading {
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--cream, #F7EDD8);
  margin: 0;
  line-height: 1.2;
}

/* Card link list */
.sitemap-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sitemap-card ul li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 0.88rem;
  font-weight: 400;
  color: rgba(247, 237, 216, 0.55);
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}

.sitemap-card ul li a::before {
  content: '→';
  font-size: 0.7rem;
  color: var(--gold, #C8900A);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.sitemap-card ul li a:hover {
  color: var(--cream, #F7EDD8);
  background: rgba(200, 144, 10, 0.05);
}

.sitemap-card ul li a:hover::before {
  opacity: 1;
  transform: translateX(0);
}

/* ===========================================
   404 / NOT FOUND styles (used by page.php on missing page)
   =========================================== */
.page-not-found {
  text-align: center;
  padding: 80px 40px;
  max-width: 560px;
  margin: 0 auto;
}

.page-not-found .not-found-code {
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(5rem, 12vw, 9rem);
  font-weight: 700;
  line-height: 1;
  color: rgba(200, 144, 10, 0.18);
  letter-spacing: -0.05em;
  margin-bottom: 16px;
}

.page-not-found h2 {
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 600;
  color: var(--cream, #F7EDD8);
  margin-bottom: 16px;
}

.page-not-found p {
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(247, 237, 216, 0.5);
  margin-bottom: 32px;
}

.page-not-found .btn-return {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--gold, #C8900A);
  color: var(--ink, #0C0906);
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 100px;
  text-decoration: none;
  transition: background 0.25s, transform 0.25s, box-shadow 0.25s;
}

.page-not-found .btn-return:hover {
  background: var(--gold-light, #E8B030);
  transform: scale(1.04) translateY(-2px);
  box-shadow: 0 10px 30px rgba(200, 144, 10, 0.35);
}

/* ===========================================
   RESPONSIVE - max-width: 768px
   =========================================== */
@media (max-width: 768px) {

  /* Hero adjustments */
  .page-hero {
    padding: calc(var(--nav-h, 72px) + var(--topbar-h, 40px) + 32px) 24px 40px;
  }

  .page-hero h1,
  .page-hero-title {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
  }

  /* Collapse two-column layout → single column, TOC above content */
  .page-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 32px 24px 56px;
  }

  .page-layout.no-toc {
    padding: 32px 24px 56px;
  }

  /* TOC becomes a collapsible panel */
  .page-toc {
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 32px;
    border: 1px solid rgba(200, 144, 10, 0.15);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
  }

  /* Show toggle button on mobile */
  .page-toc-toggle {
    display: flex;
    border-radius: 10px;
    border: none;
    border-bottom: 1px solid rgba(200, 144, 10, 0.12);
  }

  .page-toc-toggle[aria-expanded="false"] {
    border-bottom: none;
    border-radius: 10px;
  }

  /* TOC label hidden on mobile (toggle button serves as label) */
  .page-toc-label {
    display: none;
  }

  /* TOC list hidden by default on mobile, shown when toggle is expanded */
  .page-toc-body {
    display: none;
    padding: 12px 0;
  }

  .page-toc-body.is-open {
    display: block;
  }

  /* Remove left border on mobile list */
  .page-toc ul {
    border-left: none;
  }

  .page-toc ul li a {
    border-left: none;
    border-radius: 0;
    padding: 9px 20px;
  }

  .page-toc ul li.toc-h3 a {
    padding-left: 32px;
  }

  /* Content */
  .page-content {
    max-width: 100%;
  }

  .page-content h2 {
    font-size: clamp(1.35rem, 5vw, 1.75rem);
  }

  .page-content h3 {
    font-size: clamp(1.1rem, 4vw, 1.3rem);
  }

  /* Sitemap grid → single column */
  .sitemap-grid {
    grid-template-columns: 1fr;
    padding: 32px 24px 56px;
    gap: 16px;
  }

  .sitemap-card {
    padding: 24px 20px;
  }
}

/* Extra-small screens */
@media (max-width: 480px) {
  .page-hero {
    padding: calc(var(--nav-h, 72px) + var(--topbar-h, 40px) + 24px) 20px 32px;
  }

  .page-layout {
    padding: 24px 20px 48px;
  }

  .sitemap-grid {
    padding: 24px 20px 48px;
  }
}
