/* ═══════════════════════════════════════════════════════════
   Papier — WonderCMS Editorial Theme
   Warm paper tones · Playfair Display + DM Sans
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ── */
:root {
  /* Paper Palette */
  --paper-50:  #fdfaf4;
  --paper-100: #f7f0e0;
  --paper-200: #ede3c8;
  --paper-300: #dfd1aa;
  --paper-400: #c9b882;
  --paper-500: #b39c5a;

  /* Ink */
  --ink-900: #1a160f;
  --ink-800: #2c2519;
  --ink-700: #433a28;
  --ink-600: #5c5038;
  --ink-400: #8a7b62;
  --ink-300: #b0a48e;
  --ink-200: #d4ccbe;

  /* Gold Accent */
  --gold:       #c9973a;
  --gold-light: #e8c47a;
  --gold-pale:  #f5e8c8;

  /* Typography */
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-body:    'DM Sans', 'Helvetica Neue', sans-serif;

  /* Spacing Scale */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;
  --space-4xl: 9rem;

  /* Layout */
  --max-content: 100rem;
  --max-prose:   70rem;

  /* Motion */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:   cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 200ms;
  --duration-med:  380ms;
  --duration-slow: 600ms;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(26,22,15,0.08), 0 1px 2px rgba(26,22,15,0.05);
  --shadow-md: 0 4px 16px rgba(26,22,15,0.10), 0 2px 6px rgba(26,22,15,0.06);
  --shadow-lg: 0 12px 40px rgba(26,22,15,0.14), 0 4px 12px rgba(26,22,15,0.08);

  /* Header */
  --header-h: 4rem;
}

/* ── 2. Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--paper-50);
  color: var(--ink-800);
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ── 3. Grain Texture ── */
.grain {
  pointer-events: none;
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 1000;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  animation: grain-drift 8s steps(2) infinite;
}

@keyframes grain-drift {
  0%, 100% { transform: translate(0, 0); }
  25%       { transform: translate(-1%, -0.5%); }
  50%       { transform: translate(0.5%, 1%); }
  75%       { transform: translate(-0.5%, 0.5%); }
}

/* ── 4. Sticky Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(253, 250, 244, 0.82);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--paper-200);
  transition: box-shadow var(--duration-med) var(--ease-in-out),
              background var(--duration-med) var(--ease-in-out);
}

.site-header.scrolled {
  background: rgba(253, 250, 244, 0.95);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 var(--space-xl);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--ink-900);
  flex-shrink: 0;
}

.site-logo:hover .logo-ornament { color: var(--gold); transform: rotate(20deg); }
.site-logo:hover .logo-text     { color: var(--gold); }

.logo-ornament {
  font-size: 1.3rem;
  color: var(--gold);
  transition: transform var(--duration-med) var(--ease-out-expo),
              color var(--duration-fast) ease;
  display: inline-block;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  transition: color var(--duration-fast) ease;
}

/* Desktop Nav — $Wcms->menu() outputs <ul> directly */
.site-nav { display: flex; align-items: center; }

.site-nav ul {
  display: flex;
  list-style: none;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
}

.site-nav li { position: relative; }

.site-nav a {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-600);
  text-decoration: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  letter-spacing: 0.02em;
  position: relative;
  display: block;
  white-space: nowrap;
  transition: color var(--duration-fast) ease;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: var(--space-md);
  right: var(--space-md);
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--duration-med) var(--ease-out-expo);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--ink-900);
}

.site-nav a:hover::after,
.site-nav a.active::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Subpages dropdown */
.site-nav li ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  flex-direction: column;
  background: var(--paper-50);
  border: 1px solid var(--paper-200);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  padding: var(--space-xs) 0;
  z-index: 100;
}

.site-nav li:hover ul { display: flex; }
.site-nav li ul a { font-size: 0.8125rem; padding: 0.4rem var(--space-md); }
.site-nav li ul a::after { display: none; }

/* Mobile Toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.toggle-bar {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--ink-700);
  border-radius: 2px;
  transform-origin: center;
  transition: transform var(--duration-med) var(--ease-out-expo),
              opacity var(--duration-fast) ease;
}

.nav-toggle[aria-expanded="true"] .toggle-bar:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .toggle-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle[aria-expanded="true"] .toggle-bar:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Mobile Nav Drawer */
.mobile-nav {
  display: none;
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--duration-slow) var(--ease-out-expo);
  border-top: 1px solid var(--paper-200);
  background: var(--paper-50);
}

.mobile-nav.open { max-height: 400px; }

.mobile-nav-inner {
  padding: var(--space-md) var(--space-xl) var(--space-xl);
}

.mobile-nav ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-xs); margin: 0; padding: 0; }
.mobile-nav li ul { padding-left: var(--space-md); }
.mobile-nav a {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--ink-700);
  text-decoration: none;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--paper-200);
  transition: color var(--duration-fast) ease, padding-left var(--duration-med) var(--ease-out-expo);
}
.mobile-nav a:hover { color: var(--gold); padding-left: var(--space-md); }
.mobile-nav li ul a { font-size: 1rem; }

/* ── 5. Hero Section ── */
.hero {
  position: relative;
  min-height: calc(90vh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4xl) var(--space-xl) var(--space-3xl);
  text-align: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, var(--gold-pale) 0%, transparent 70%),
    var(--paper-50);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(201,151,58,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(201,151,58,0.06) 0%, transparent 50%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: 52rem;
  z-index: 1;
}

/* Kicker / eyebrow */
.hero-kicker, .page-kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.kicker-text {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.kicker-line {
  flex: 1;
  max-width: 3rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin-bottom: var(--space-lg);
}

.hero-title em {
  font-style: italic;
  color: var(--gold);
}

.hero-subtitle {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 300;
  color: var(--ink-600);
  max-width: 36rem;
  margin: 0 auto var(--space-xl);
  line-height: 1.75;
}

.hero-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
}

.scroll-hint {
  font-size: 1.25rem;
  color: var(--ink-300);
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(6px); }
}

.hero-rule {
  position: absolute;
  bottom: var(--space-xl);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  color: var(--gold-light);
}

/* ── 6. Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.75rem 1.75rem;
  border-radius: 3px;
  transition: all var(--duration-med) var(--ease-out-expo);
  cursor: pointer;
  border: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}

.btn:hover::before { opacity: 1; }

.btn-primary {
  background: var(--gold);
  color: var(--paper-50);
  box-shadow: 0 2px 12px rgba(201,151,58,0.35);
}

.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201,151,58,0.4);
}

.btn-secondary {
  background: transparent;
  color: var(--ink-700);
  border: 1.5px solid var(--paper-300);
}

.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-2px);
}

/* ── 7. Main Content ── */
.site-main {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl);
}

/* Page Header (non-homepage) */
.page-header {
  padding: var(--space-3xl) 0 var(--space-2xl);
  border-bottom: 1px solid var(--paper-200);
  margin-bottom: var(--space-3xl);
  text-align: center;
}

.page-header-inner { max-width: var(--max-prose); margin: 0 auto; }

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin-top: var(--space-md);
  line-height: 1.2;
}

/* Content Layout */
.content-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3xl);
}

/* ── 8. Typography (Prose) ── */
.content-body {
  max-width: var(--max-prose);
  margin: 0 auto;
}

.content-body h1,
.content-body h2,
.content-body h3,
.content-body h4 {
  font-family: var(--font-display);
  color: var(--ink-900);
  line-height: 1.25;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
}

.content-body h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 500; letter-spacing: -0.02em; }
.content-body h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 500; }
.content-body h3 { font-size: 1.35rem; }
.content-body h4 { font-size: 1.1rem; font-style: italic; }

.content-body h2 { position: relative; padding-bottom: var(--space-md); }
.content-body h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 2.5rem;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}

.content-body p {
  color: var(--ink-700);
  font-size: 1.0625rem;
  line-height: 1.8;
  margin-bottom: var(--space-lg);
}

.content-body a {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: var(--gold-light);
  text-underline-offset: 3px;
  transition: color var(--duration-fast) ease, text-decoration-color var(--duration-fast) ease;
}

.content-body a:hover {
  color: var(--ink-900);
  text-decoration-color: var(--ink-900);
}

.content-body blockquote {
  position: relative;
  margin: var(--space-2xl) 0;
  padding: var(--space-xl) var(--space-xl) var(--space-xl) var(--space-2xl);
  background: var(--paper-100);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
}

.content-body blockquote::before {
  content: '\201C';
  position: absolute;
  top: -0.2em;
  left: 0.5rem;
  font-family: var(--font-display);
  font-size: 4rem;
  color: var(--gold-light);
  line-height: 1;
}

.content-body blockquote p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-700);
  margin-bottom: 0;
}

.content-body ul, .content-body ol {
  padding-left: var(--space-xl);
  margin-bottom: var(--space-lg);
  color: var(--ink-700);
}

.content-body li { margin-bottom: var(--space-sm); }

.content-body ul li::marker { color: var(--gold); }
.content-body ol li::marker {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--gold);
}

.content-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: var(--space-xl) 0;
  box-shadow: var(--shadow-md);
}

.content-body figure { margin: var(--space-2xl) 0; }
.content-body figcaption {
  font-size: 0.85rem;
  color: var(--ink-400);
  text-align: center;
  margin-top: var(--space-sm);
  font-style: italic;
}

.content-body hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--paper-300), transparent);
  margin: var(--space-3xl) 0;
  position: relative;
}

.content-body hr::after {
  content: '◆';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper-50);
  color: var(--gold-light);
  padding: 0 var(--space-md);
  font-size: 0.6rem;
}

.content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  font-size: 0.9375rem;
}

.content-body th {
  font-family: var(--font-body);
  font-weight: 500;
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  background: var(--paper-100);
  border-bottom: 2px solid var(--gold-light);
  color: var(--ink-800);
  letter-spacing: 0.04em;
  font-size: 0.875rem;
  text-transform: uppercase;
}

.content-body td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--paper-200);
  color: var(--ink-700);
}

.content-body tr:hover td { background: var(--paper-100); }

.content-body code {
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: 0.875em;
  background: var(--paper-200);
  color: var(--ink-800);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.content-body pre {
  background: var(--ink-800);
  color: var(--paper-200);
  padding: var(--space-xl);
  border-radius: 6px;
  overflow-x: auto;
  margin: var(--space-xl) 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.content-body pre code {
  background: none;
  color: inherit;
  padding: 0;
}

/* ── 9. Sidebar Card ── */
.content-sidebar { max-width: 24rem; margin: 0 auto; }

.sidebar-card {
  background: var(--paper-100);
  border: 1px solid var(--paper-200);
  border-radius: 8px;
  padding: var(--space-xl);
  position: sticky;
  top: calc(var(--header-h) + var(--space-xl));
}

.sidebar-card h2,
.sidebar-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink-900);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--paper-300);
}

/* ── 10. Footer ── */
.site-footer {
  background: var(--ink-900);
  color: var(--paper-300);
  margin-top: var(--space-4xl);
}

.footer-inner {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: var(--space-2xl);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.footer-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--paper-200);
}

.footer-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg); justify-content: center; margin: 0; padding: 0; }
.footer-nav li ul { display: none; }
.footer-nav a {
  font-size: 0.875rem;
  color: var(--ink-300);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
  letter-spacing: 0.03em;
}
.footer-nav a:hover { color: var(--gold-light); }

.footer-meta {
  text-align: right;
  font-size: 0.8125rem;
  color: var(--ink-400);
  line-height: 1.6;
}

.footer-copy a { color: var(--gold-light); text-decoration: none; }
.footer-copy a:hover { text-decoration: underline; }

.footer-meta a { display: block; margin-top: var(--space-sm); color: var(--ink-300); font-size: 0.75rem; }
.footer-meta a:hover { color: var(--gold-light); }

.footer-rule {
  text-align: center;
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.6rem;
  letter-spacing: 0.4em;
  color: var(--ink-600);
}

/* ── 11. Scroll Reveal Animations ── */
.reveal-up,
.reveal-fade {
  opacity: 1;
  transition:
    opacity var(--duration-slow) var(--ease-out-expo),
    transform var(--duration-slow) var(--ease-out-expo);
}

.reveal-up   { transform: translateY(28px); }
.reveal-fade { transform: none; }

.reveal-up.visible,
.reveal-fade.visible {
  opacity: 1;
  transform: translateY(0);
}

.delay-1 { transition-delay: 120ms; }
.delay-2 { transition-delay: 240ms; }
.delay-3 { transition-delay: 360ms; }

/* ── 12. WonderCMS Admin Overrides ── */
/* Make sure CMS edit interface doesn't break layout */
.editContent { outline: 2px dashed rgba(201,151,58,0.4); outline-offset: 4px; }
.editContent:hover { outline-color: var(--gold); }

/* ── 13. Responsive ── */
@media (min-width: 900px) {
  .content-wrap { grid-template-columns: 1fr 18rem; }
  .content-sidebar { max-width: 100%; }
}

@media (max-width: 768px) {
  :root { --header-h: 3.5rem; }

  .header-inner { padding: 0 var(--space-lg); }
  .site-nav { display: none; }
  .nav-toggle { display: flex; }
  .mobile-nav { display: block; }

  .hero { min-height: 80vh; padding: var(--space-3xl) var(--space-lg) var(--space-2xl); }
  .hero-cta { flex-direction: column; gap: var(--space-md); }

  .site-main { padding: var(--space-2xl) var(--space-lg); }

  .footer-inner {
    grid-template-columns: 1fr;
    text-align: center;
    gap: var(--space-xl);
  }
  .footer-brand { justify-content: center; }
  .footer-meta { text-align: center; }
  .footer-meta a { display: inline; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 2.2rem; }
  .logo-text { font-size: 1.05rem; }
}

/* ── 14. Print ── */
@media print {
  .site-header, .site-footer, .grain, .hero-cta { display: none; }
  body { background: white; color: black; }
  .content-body { max-width: 100%; }
}

/* ── 15. Focus & Accessibility ── */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ── 16. Selection ── */
::selection {
  background: var(--gold-pale);
  color: var(--ink-900);
}
