:root {
  /* Climate: Typography */
  --display: "Fraunces", "Georgia", serif;
  --body: "Literata", "Iowan Old Style", serif;
  --mono: "JetBrains Mono", monospace;

  /* Climate: Scaling (The Golden Thread) */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.9rem;
  --fs-3xl: 2.3rem;
  --fs-4xl: clamp(2.5rem, 8vw, 4.5rem); /* Unified Feature/H1 Scaling */

  --lh-body: 1.7;
  --lh-tight: 0.95; /* Consistent Newspaper/Heading density */
  --lh-meta: 1.4;

  /* Climate: Layout (Unified Dimensions) */
  --header-h: 96px;
  --header-h-mobile: 72px;
  --max-width: 780px;
  --sidebar-w: 260px;
  --motif-bar-h: 54px;
  --toolbar-h: 44px;

  /* Climate: Palette */
  --bg: #ffffff;
  --bg-soft: #f8f8f8;
  --fg: #0f0f0f;
  --fg-soft: #2a2a2a;
  --fg-muted: #6b6b6b;
  
  --ember: #ff8d55;
  --ember-glow: #ffb478;
  --tint-monastic: rgba(255, 141, 85, 0.02); /* Centralized the lead article tint */

  --border: rgba(0, 0, 0, 0.05);
  --border-subtle: rgba(0, 0, 0, 0.03);

  /* Global control surfaces */
  --control-bg: rgba(255,255,255,0.9);
  --control-border: rgba(0,0,0,0.08);
  --control-shadow: 0 10px 24px rgba(0,0,0,0.06);
  --control-shadow-hover: 0 16px 40px rgba(0,0,0,0.14);

  /* Transitions */
  --t-slow: 0.85s cubic-bezier(0.19, 1, 0.22, 1);
}

.dark {
  --bg: #050505;
  --bg-soft: #0b0b0b;
  --fg: #f4f0ea;
  --tint-monastic: rgba(255, 255, 255, 0.01);
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --control-bg: rgba(20,18,16,0.9);
  --control-border: rgba(255,255,255,0.06);
  --control-shadow: 0 12px 30px rgba(0,0,0,0.55);
  --control-shadow-hover: 0 18px 45px rgba(0,0,0,0.7);
}

/* -------------------------------------------------------------
   RESET + BASE
   ------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg-soft);
  font-family: var(--body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-slow), color var(--t-slow);
}



/* -------------------------------------------------------------
   HEADINGS — FRAUNCES
   ------------------------------------------------------------- */
h1,h2,h3,h4,h5,h6 {
  font-family: var(--display);
  letter-spacing: 0.02em;
  color: var(--fg);
  margin: 0 0 1rem;
  text-rendering: geometricPrecision;
}

h1 {
  font-size: var(--fs-4xl);
  line-height: 1.05;
  margin-bottom: 1.2rem;
}

h2 {
  font-size: var(--fs-3xl);
  line-height: 1.2;
  margin-top: 2.5rem;
  margin-bottom: 1.1rem;
}

h3 {
  font-size: var(--fs-2xl);
  line-height: 1.25;
  margin-top: 2rem;
}

h4 {
  font-size: var(--fs-xl);
  margin-top: 1.5rem;
  color: var(--fg);
}



/* -------------------------------------------------------------
   ESSAY READING EXPERIENCE
   ------------------------------------------------------------- */
.page {
  padding: var(--pad-y) var(--pad-x);
  display: flex;
  justify-content: center;
}

.page-inner {
  width: 100%;
  max-width: var(--max-width);
}



/* Essay header ------------------------------------------------ */
.essay-header {
  margin-bottom: 3.5rem;
}

.essay-meta {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
  display: flex;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.essay-title {
  font-family: var(--display);
  font-size: var(--fs-4xl);
  line-height: 1.05;
  color: var(--fg);
}

.essay-subtitle {
  color: var(--fg-soft);
  font-size: var(--fs-lg);
  line-height: 1.5;
  margin-top: 0.5rem;
}



/* Paragraphs -------------------------------------------------- */
p {
  margin: 0 0 1.4em;
  font-size: var(--fs-base);
  letter-spacing: 0.005em;
}

/* Blockquotes ------------------------------------------------- */
blockquote {
  margin: 2.5rem 0;
  padding: 1.5rem 2rem;
  border-left: 2px solid var(--ember);
  background: linear-gradient(to right,
    rgba(255,140,85,0.08), transparent 70%);
  font-style: italic;
  font-size: var(--fs-lg);
  color: var(--fg-soft);
}



/* Lists ------------------------------------------------------- */
ul,ol {
  margin: 0 0 1.6em 1.4em;
  padding: 0;
}

li {
  margin-bottom: 0.45em;
}



/* Links ------------------------------------------------------- */
a {
  color: var(--ember-soft);
  transition: color var(--t-fast);
}

a:hover {
  color: var(--ember-faint);
}


/* -------------------------------------------------------------
   MOTIF TAGS — SYMBOLIC ECOLOGY CLUES
   ------------------------------------------------------------- */
.motif-tag {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 0.25rem 0.85rem;
  border-radius: var(--r-round);
  border: 1px solid var(--border);
  background: rgba(255,140,85,0.08);
  color: var(--fg-muted);
}



/* -------------------------------------------------------------
   OVEN FOOTER — SUPPORT LAYER
   ------------------------------------------------------------- */
.footer {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.footer-grid {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.footer-link {
  font-family: var(--body);
  font-size: var(--fs-base);
  color: var(--fg-soft);
  text-decoration: none;
  transition: color var(--t-fast), transform var(--t-fast);
}

.footer-link:hover {
  color: var(--ember-soft);
  transform: translateX(3px);
}



/* -------------------------------------------------------------
   UTILITIES
   ------------------------------------------------------------- */
.center { text-align: center; }

.upper {
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.mono {
  font-family: var(--mono);
  letter-spacing: 0.05em;
}

.muted { color: var(--fg-muted); }
.soft { color: var(--fg-soft); }

.mt-lg { margin-top: 3rem; }
.mb-lg { margin-bottom: 3rem; }


/* -------------------------------------------------------------
   APP FRAME + CANVAS LAYERS
   ------------------------------------------------------------- */
#day-view {
  min-height: 100vh;
}

#day-view footer.fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
}

#gallery-main {
  padding-top: var(--header-h);
  padding-bottom: 60px;
  box-sizing: border-box;
  background: transparent;
  position: relative;
  z-index: 0;
}

@media (max-width: 640px) {
  #gallery-main {
    padding-top: var(--header-h-mobile);
  }
}

#gallery-main.layer-chamber {
  padding-top: 64px;
  padding-bottom: 48px;
}

#gallery-toolbar {
  position: sticky;
  top: 20px; /* sits directly under header */
  z-index: 150;
  margin-top: 0;
  margin-bottom: 12px;
  padding-top: 8px;
  padding-bottom: 8px;
  align-items: center;
  background: transparent;
}

#essay-list {
  padding-top: 16px;
}

#gallery-main > .mt-\[96px\] {
  margin-top: 0;
}

#gallery-main > .mt-\[96px\].mb-\[56px\] {
  margin-bottom: 0;
}

#shared-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0; /* keep under header/UI */
}

.grain-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: soft-light;
  opacity: 0.25;
  z-index: 2;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cdefs%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3C/defs%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 120px 120px, 140px 140px, 180px 180px;
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.lang-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 999px;
  padding: 0;
  box-shadow: var(--control-shadow);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

.dark .lang-toggle {
  background: var(--control-bg);
  border-color: var(--control-border);
}

.lang-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--control-shadow-hover);
}

/* style.css */

.lang-toggle .lang-current {
  font-family: var(--mono);
  font-size: 15px;         /* Increased from 9px for better legibility */
  font-weight: 700;        /* Bold (700) matches the icon stroke width */
  letter-spacing: 0.05em;  /* Reduced tracking slightly to keep it tight */
  text-transform: uppercase;
  color: var(--fg);        /* Use main foreground color (black/white) instead of muted gray */
  background: transparent;
  border: none;
  padding: 0;
  transition: color var(--t-fast);
  
}

.lang-toggle .lang-list {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 999px;
  box-shadow: var(--control-shadow);
  white-space: nowrap;
  z-index: 20;
}

.dark .lang-toggle .lang-list {
  background: var(--control-bg);
  border-color: var(--control-border);
}

.lang-toggle.is-open .lang-list {
  display: inline-flex;
}

.lang-toggle .lang-btn {
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0 4px;
}

/* Global control buttons (language, mode, threshold, close) */
#mode-toggle,
#threshold-toggle-button,
#global-close-button {
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  box-shadow: var(--control-shadow);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

#mode-toggle:hover,
#threshold-toggle-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--control-shadow-hover);
}

#global-close-button:hover {
  box-shadow: var(--control-shadow-hover);
}

@media (min-width: 1024px) {
  .app-grid {
    /* Match header's left rail width for clean vertical alignment */
    grid-template-columns: 260px 1fr;
  }
}

@media (max-width: 640px) {
  /* Header + padding adjustments */
  #day-view-header {
    height: 72px;
  }
  #gallery-main {
    padding-top: calc(var(--header-h-mobile) + var(--motif-bar-h));
    padding-bottom: 56px;
  }
  #gallery-main.layer-chamber {
    padding-top: calc(var(--header-h-mobile) + var(--motif-bar-h));
  }
  #gallery-toolbar {
    top: calc(var(--header-h-mobile) + var(--motif-bar-h) + 12px);
    margin-bottom: 10px;
  }
  #essay-list-title {
    font-size: 1.25rem;
  }
  
/* -------------------------------------------------------------
   GENERATIVE NAVIGATION CARDS (Consolidated)
   ------------------------------------------------------------- */

/* 1. Constrain the overall footer width */
#essay-footer .max-width-2xl, 
#essay-footer .max-w-2xl {
    max-width: 840px !important; 
    margin: 0 auto;
}

/* 2. Unified Card Base */
.card-base {
    height: auto !important;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02); /* Very subtle monastic depth */
    transition: transform 0.4s var(--t-slow), border-color 0.4s var(--t-slow);
}

/* 3. Force-Muffle the "Huge" Orientation Text */
/* -------------------------------------------------------------
   GENERATIVE NAVIGATION CARDS (Scoped Fix)
   ------------------------------------------------------------- */

/* --- REFINED GENERATIVE NAVIGATION HIERARCHY --- */

/* 1. Constrain the overall footer width */
#essay-footer .max-w-3xl {
    max-width: 820px !important;
    margin: 0 auto;
}

/* 2. Tighten the Grid and padding */
#related-essays-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 3rem !important; /* Increased from 2rem to 3rem for more air */
    margin-top: 1.5rem !important;
    max-width: 900px !important; /* Slightly wider to accommodate more padding */
    margin-left: auto;
    margin-right: auto;
}

/* 3. Increase Internal Padding and add subtle depth */
#related-essays-grid .card-base {
    min-height: 200px !important; 
    padding: 3rem 2.5rem !important;
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-radius: 16px;
    box-shadow: none !important;
}

.dark #related-essays-grid .card-base {
    background: rgba(255, 255, 255, 0.02) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

/* 4. Restore Title Prominence */
#related-essays-grid h4 {
    font-size: 1.25rem !important; /* Larger than body text */
    line-height: 1.2 !important;
    font-weight: 500;
    margin-bottom: 0.75rem !important;
    color: var(--fg) !important;
    font-family: var(--display);
}

/* 5. Shrink the Orientation Text (The "Huge" Problem) */
#related-essays-grid .orientation-text {
    font-size: 13px !important; /* Smaller, UI-level text */
    line-height: 1.6 !important;
    color: #44403c !important;
    font-family: var(--body);
    margin-top: 0 !important;
    opacity: 1;
    
    /* Clamp text to 3 lines to maintain uniform card heights */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 6. Interaction */
#related-essays-grid .card-base:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: var(--ember) !important;
    transform: translateY(-2px);
}

/* Specific Dark Mode boost for legibility */
.dark #related-essays-grid .orientation-text {
    color: #e7e5e4 !important; 
    opacity: 1 !important;
}

  .card-content {
    padding: 0.5rem 1.2rem 1.2rem 2rem;
  }
  .vault-card .card-content,
  .vault-card-content {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }
  .card-spine {
    width: 20px;
  }
  .card-spine.is-essay {
    width: 12px;
  }

  /* Footer controls stack better */
  #footer-controls {
    gap: 8px;
  }

  /* Language toggle / mode toggle sizing */
  .lang-toggle {
    width: 36px;
    height: 36px;
    z-index: 500 !important;
  }
  .lang-toggle .lang-current {
    font-size: 10px;
  }
  #mode-toggle {
    width: 36px !important;
    height: 36px !important;
  }
}

/* Universal Monastic Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 120, 0.35) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 120, 0.35);
  border-radius: 999px;
}

.dark *::-webkit-scrollbar-thumb {
  background: rgba(180, 180, 180, 0.35);
}


/* -------------------------------------------------------------
   CARD SHELL (CHAMBERS / VAULTS / EQUATORIALS)
   ------------------------------------------------------------- */
.card-base {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 20px 50px rgba(0,0,0,0.08);
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med), background var(--t-med);
  backdrop-filter: none;
}

/* Default fill for non-simulation cards */
.card-base:not(:has(.simulation-window)) {
  background: rgba(255,255,255,0.35);
}

/* Chamber cards: keep left readable, right fully transparent */
.card-base:has(.simulation-window)::before {
  content: "";
  position: absolute;
  inset: 0;
  background: none;
  z-index: 1;
  pointer-events: none;
}

.card-base:has(.simulation-window) .card-content {
  z-index: 2;
}

.dark .card-base {
  background: transparent;
  border-color: rgba(255,255,255,0.08);
  box-shadow: none;
}

.dark .card-base:not(:has(.simulation-window)) {
  background: transparent;
}

.card-base:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.14);
  border-color: rgba(255,140,85,0.22);
}

.card-spine {
  position: absolute;
  inset: 0;
  width: 28px;
  background: linear-gradient(180deg, var(--ash-mid), var(--ember-glow));
  opacity: 0.9;
}

.card-spine.is-essay {
  width: 14px;
}

.card-content {
  position: relative;
  padding: 0.5rem 1.8rem 1.6rem 2.6rem;
  z-index: 10;
}

.vault-card .card-content,
.vault-card-content {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.simulation-window {
  position: relative;
  isolation: isolate;
}

.canvas-placeholder {
  background: transparent;
  border: none;
  border-radius: 0 18px 18px 0;
  overflow: hidden;
}

.fade-in {
  opacity: 0;
  animation: fadeIn 0.6s forwards ease-out;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.fade-in-up {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s var(--ease-ember), transform 0.45s var(--ease-ember);
}

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


/* -------------------------------------------------------------
   MOTIF COLUMN
   ------------------------------------------------------------- */
#motif-container {
  position: relative;
  height: 100%;
  overflow-y: auto;
  padding: 1.2rem 1.4rem;
}

#motif-container::before,
#motif-container::after {
  content: "";
  position: sticky;
  left: 0;
  right: 0;
  height: 40px;
  pointer-events: none;
  z-index: 20;
}

#motif-container::before {
  top: 0;
  background: linear-gradient(180deg, rgba(250,250,250,0.95), transparent);
}

#motif-container::after {
  bottom: 0;
  background: linear-gradient(0deg, rgba(250,250,250,0.95), transparent);
}

.dark #motif-container::before {
  background: linear-gradient(180deg, rgba(18,16,14,0.95), transparent);
}
.dark #motif-container::after {
  background: linear-gradient(0deg, rgba(18,16,14,0.95), transparent);
}

.motif-item.is-active {
  border-right-color: var(--ember);
  color: var(--fg);
  letter-spacing: 0.14em;
}


/* -------------------------------------------------------------
   DASHBOARD BUTTONS
   ------------------------------------------------------------- */
.sc-dashboard-btn {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  box-shadow: var(--control-shadow);
  color: var(--fg);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

.sc-dashboard-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--control-shadow-hover);
}


/* -------------------------------------------------------------
   ESSAY OVERLAY + PROGRESS
   ------------------------------------------------------------- */
#essay-overlay {
  backdrop-filter: blur(8px);
}

#essay-content-window {
  background: linear-gradient(90deg, rgba(250, 248, 244, 0.9) 0%, rgba(250, 248, 244, 0.94) 60%, rgba(250, 248, 244, 0.92) 100%);
}

.dark #essay-content-window {
  background: linear-gradient(90deg, rgba(8,7,6,0.9) 0%, rgba(8,7,6,0.95) 60%, rgba(8,7,6,0.92) 100%);
}

.sc-wall {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16px;
  opacity: 0.8;
}

#sc-left-wall { left: 0; }
#sc-right-wall { right: 0; }

.essay-content {
  scroll-behavior: smooth;
}

.essay-content p {
  font-size: 1.25rem;
  line-height: 1.8;
}

.essay-content a {
  text-decoration: underline;
}

.essay-content .content-block {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s var(--ease-ember), transform 0.7s var(--ease-ember);
  will-change: opacity, transform;
}

.essay-content .content-block.is-visible {
  opacity: 1;
  transform: translateY(0);
}


/* -------------------------------------------------------------
   WORD / LETTER REVEAL
   ------------------------------------------------------------- */
.word-reveal-paragraph .word-span,
.list-reveal-group .word-span {
  display: inline-block;
  margin-right: 0.25em;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s var(--t-med), transform 0.4s var(--t-med);
}

.word-reveal-paragraph.is-visible .word-span,
.list-reveal-group.is-visible .word-span {
  opacity: 1;
  transform: translateY(0);
}

.letter-reveal-heading .letter-span {
  display: inline-block;
  white-space: pre;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s var(--t-fast), transform 0.25s var(--t-fast);
}

.letter-reveal-heading.is-visible .letter-span {
  opacity: 1;
  transform: translateY(0);
}


/* -------------------------------------------------------------
   FOOTER (OVEN / FIRE / LETTER / INNER OVEN)
   ------------------------------------------------------------- */
.footer-trigger {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 1.2rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: transform var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

.footer-trigger:hover {
  transform: translateY(-2px);
  border-color: rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.6);
}

.footer-trigger.is-active {
  border-color: rgba(255,140,85,0.4);
  background: rgba(255,140,85,0.08);
}

.dark .footer-trigger:hover {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
}

.dark .footer-trigger.is-active {
  border-color: rgba(255,140,85,0.5);
  background: rgba(255,140,85,0.08);
}

.footer-content-panel {
  transition: opacity var(--t-fast);
}


/* -------------------------------------------------------------
   MISC
   ------------------------------------------------------------- */
.is-focus-active {
  outline: 1px solid rgba(255,140,85,0.3);
  box-shadow: 0 0 0 6px rgba(255,140,85,0.08);
}

/* --- SMOOTHER READING REVEAL: disable per-word/per-letter animations --- */
.word-reveal-paragraph .word-span,
.list-reveal-group .word-span,
.letter-reveal-heading .letter-span {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

/* Reading mode: no scroll-gated content. */
.essay-content .content-block {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

/* -------------------------------------------------------------
   NEWSPAPER LANDING GRID (DISCRETE ROWS)
   ------------------------------------------------------------- */

/* The main container acts as a simple vertical stack for our rows */
#landing-view .grid {
    display: block !important; 
    width: 100%;
}

/* Landing grid fade-in */
#landing-grid {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1.4s ease, transform 1.4s ease;
    will-change: opacity, transform;
}

#landing-grid.is-visible,
#landing-grid:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    #landing-grid {
        transition: none;
        transform: none;
    }
    #landing-grid.is-visible,
    #landing-grid:not(.hidden) {
        opacity: 1;
    }
}

/* Individual Row Logic */
.newspaper-row {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: Single column stack */
    gap: 3rem;
    margin-bottom: 4rem;
    padding-bottom: 4rem;
    border-bottom: 1px solid var(--border);
    align-items: stretch;
}

/* Tablet (iPad) Reflow: Lead story on top, sidebars below */
@media (min-width: 768px) and (max-width: 1023px) {
    .newspaper-row {
        grid-template-columns: 1fr 1fr;
    }
    /* Make the middle (lead) item span both columns on iPad */
    .newspaper-row > div:nth-child(2) {
        grid-column: span 2;
        border-bottom: 1px solid var(--border-subtle);
        padding-bottom: 3rem;
        margin-bottom: 1rem;
    }
}

/* Desktop 1:2:1 Monastic Layout */
@media (min-width: 1024px) {
    .newspaper-row {
        grid-template-columns: 1fr 2fr 1fr; /* The discrete 1:2:1 ratio */
        gap: 0; /* Gutters are handled by internal padding for borders */
    }

    /* Left Sidebar */
    .newspaper-row > div:nth-child(1) {
        padding-right: 3rem;
        border-right: 1px solid var(--border-subtle);
    }

    /* Center Lead Feature */
    .newspaper-row > div:nth-child(2) {
        padding: 0 3rem;
        background: rgba(255, 141, 85, 0.02); /* Subtle monastic tint */
    }

    /* Right Sidebar */
    .newspaper-row > div:nth-child(3) {
        padding-left: 3rem;
        border-left: 1px solid var(--border-subtle);
    }
}

/* Dark Mode Tint Adjustment */
.dark .newspaper-row > div:nth-child(2) {
    background: rgba(255, 255, 255, 0.01);
}

/* -------------------------------------------------------------
   NEWSPAPER TYPOGRAPHY & SPACING
   ------------------------------------------------------------- */

/* Lead Headline (Center Column) */
.newspaper-row h3.text-6xl {
    /* Reduced from 4rem max to 3rem max */
    font-size: clamp(2rem, 4vw, 2rem); 
    line-height: 1.05; /* Slightly more breathing room for the descenders */
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    text-wrap: pretty !important; 
    width: 100% !important;
    max-width: none !important;
}

/* Sidebar Headlines */
.newspaper-row h3.text-2xl {
    font-size: 1.6rem;
    line-height: 1.1;
    margin-bottom: 1rem;
}

/* Ensure consistent text-block heights so borders look even */
.newspaper-row p {
    min-height: 5em;
    margin-top: 1rem;
}

/* Last Row cleanup */
.newspaper-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* -------------------------------------------------------------
   MOBILE & TABLET ADAPTATION — FINAL
   ------------------------------------------------------------- */

/* Tablet & Small Desktop (Reflow Sidebar to Top) */
@media (max-width: 1023px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  #sidebar-region {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    width: 100%;
    height: var(--motif-bar-h);
    padding-top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    z-index: 150;
  }

  /* Motif Lexicon transforms into a horizontal strip */
  #motif-container {
    height: var(--motif-bar-h);
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Switch vertical fades to horizontal */
  #motif-container::before {
    top: 0; left: 0; bottom: 0; right: auto;
    width: 40px; height: 100%;
    background: linear-gradient(90deg, var(--bg-soft), transparent);
  }

  #motif-container::after {
    top: 0; right: 0; bottom: 0; left: auto;
    width: 40px; height: 100%;
    background: linear-gradient(-90deg, var(--bg-soft), transparent);
  }

  #motif-button-list {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
  }

  .motif-item {
    border-right: none !important;
    border-bottom: 2px solid transparent;
    padding: 1rem 0;
  }

  .motif-item.is-active {
    border-bottom-color: var(--ember);
    color: var(--fg);
  }

  #gallery-main {
    padding-top: calc(var(--header-h) + var(--motif-bar-h));
  }

  #gallery-main.layer-chamber {
    padding-top: calc(var(--header-h) + var(--motif-bar-h));
  }

  #gallery-toolbar {
    top: calc(var(--header-h) + var(--motif-bar-h) + 12px);
  }
}

/* Mobile Devices (Narrow Viewport) */
@media (max-width: 640px) {
  #sidebar-region {
    top: var(--header-h-mobile);
  }

  /* Chamber Gallery: Ensure 3D visuals stack correctly */
  .card-base:has(.simulation-window) {
    min-height: auto;
    height: auto !important;
    flex-direction: column !important;
  }

  .card-base:has(.simulation-window) .simulation-window {
    position: relative !important;
    inset: auto !important;
    height: 220px;
    width: 100% !important;
    border-bottom: 1px solid var(--border);
    border-left: none;
    order: -1; /* Place visual above title for better context */
  }

  .canvas-placeholder {
    border-radius: 14px 14px 0 0;
  }

  .card-base:has(.simulation-window) .card-content {
    padding: 1.4rem 1.4rem 1.8rem 1.4rem;
    justify-content: flex-start;
  }

  .card-base:has(.simulation-window) h3 {
    font-size: clamp(1.9rem, 7vw, 2.6rem);
    max-width: 100% !important;
  }

  .card-base:has(.simulation-window) p {
    max-width: 100% !important;
    font-size: 0.95rem;
    line-height: 1.5;
  }

  #gallery-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: nowrap;
    position: fixed;
    top: calc(var(--header-h-mobile) + var(--motif-bar-h));
    left: 0;
    right: 0;
    z-index: 140;
    max-width: none;
    margin: 0;
    padding: 0.35rem 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--toolbar-h);
  }

  #gallery-toolbar #back-to-exhibitions-btn,
  #gallery-toolbar #gallery-category-label {
    white-space: nowrap;
  }

  #gallery-toolbar #gallery-category-label {
    margin-left: auto;
    text-align: right;
  }

  #gallery-toolbar #back-to-exhibitions-btn span,
  #gallery-toolbar #gallery-category-label {
    letter-spacing: 0.1em;
  }

  #gallery-main.layer-vaults,
  #gallery-main.layer-equatorials {
    padding-top: calc(var(--header-h-mobile) + var(--motif-bar-h) + var(--toolbar-h));
  }

  .vault-card .card-content,
  .vault-card-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .vault-card .card-content > .flex {
    width: 100%;
    justify-content: space-between;
  }

  [id^="list-"] {
    margin-left: 0 !important;
    padding-left: 0.75rem !important;
    border-left-width: 1px;
  }

  /* Side walls remain as slim vertical bars on mobile */
  .sc-wall {
    width: 8px !important;
    height: auto !important;
    top: 0;
    bottom: 0;
    opacity: 0.7;
  }

  #sc-left-wall { left: 0; right: auto; }
  #sc-right-wall { right: 0; left: auto; }

  /* Monastic Typography adjustments for smaller screens */
  #essay-content-window {
    padding: 2rem 1.25rem;
  }

  .essay-content p {
    font-size: 1.15rem;
    line-height: 1.75;
    margin-bottom: 1.6rem;
  }

  .essay-title {
    font-size: 2.2rem;
    line-height: 1.1;
    margin-top: 1rem;
  }

  /* Sticky Footer Controls optimization */
  #day-view footer.fixed {
    padding: 0.75rem;
  }

  .sc-dashboard-btn {
    width: 48px;
    height: 48px;
  }
}

/* Dark Mode Depth Refinement */
.dark {
  --border: rgba(255, 255, 255, 0.08);
  --shadow-soft: 0 20px 40px rgba(0, 0, 0, 0.8);
}

/* Ensure buttons are physically clickable */
#app-controls {
    z-index: 600 !important;
}

#threshold-toggle-button {
    z-index: 700 !important;
    pointer-events: auto !important;
}

.lang-toggle {
    z-index: 700 !important;
    pointer-events: auto !important;
}

/* Ensure the landing view doesn't "blanket" the buttons */
#landing-view {
    position: relative;
    z-index: 10;
}

#threshold-view {
    position: relative;
    z-index: 20;
}

/* Refinement for Home Page in Dark Mode */
.dark #threshold-view {
    background-color: #0c0a09; /* Deep stone/ash black */
}

.home-signature {
    word-spacing: 0.18em;
    letter-spacing: -0.015em;
    padding-right: clamp(2.5rem, 5vw, 3.5rem);
}

#day-view-header .site-signature {
    font-size: clamp(1.2rem, 1.8vw, 1.9rem);
    line-height: 1.02;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

#day-view:has(#gallery-main.layer-chamber) #essay-list-title {
    font-size: clamp(0.95rem, 1.4vw, 1.25rem);
    letter-spacing: -0.005em;
}

@media (max-width: 1023px) {
    #day-view-header .site-signature {
        font-size: clamp(1.05rem, 5vw, 1.45rem);
        line-height: 1.05;
    }
}

@media (max-width: 640px) {
    #day-view:has(#gallery-main.layer-chamber) #essay-list-title {
        font-size: 1rem;
    }
}

@media (max-width: 640px) {
    .home-header {
        align-items: center;
        text-align: center;
    }

    .home-header #enter-button {
        width: auto !important;
        text-align: center;
        align-self: center;
    }

    .home-header #enter-button span {
        display: inline-block;
    }

    .home-signature {
        word-spacing: 0.14em;
        padding-left: clamp(2.5rem, 8vw, 3.5rem);
        padding-right: clamp(2.5rem, 8vw, 3.5rem);
        text-align: center;
    }
}

.dark #landing-view h1 {
    color: #f5f5f4; /* Stone-100 */
}

.research-desc {
    display: block;
}

.research-desc-line {
    display: block;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .research-desc-line {
        white-space: normal;
    }
}

.dark .newspaper-row {
    border-color: rgba(255, 255, 255, 0.05);
}

/* Ensure the background iframe dims properly in dark mode */
.dark #geometry-hero-iframe {
    opacity: 0.15; /* Subtler default for dark mode */
    transition: opacity 1s ease;
}

/* Ensure Global Icons are visible in both modes */
#mode-toggle i, 
#threshold-toggle-button i,
#global-close-button i {
    color: var(--fg); /* Automatically switches between black and off-white */
    stroke: var(--fg);
    transition: color var(--t-slow), stroke var(--t-slow);
}

/* Keep global controls consistent in dark mode */
.dark #mode-toggle,
.dark #threshold-toggle-button,
.dark #global-close-button {
    background: var(--control-bg);
    border-color: var(--control-border);
}

#mode-toggle i, #threshold-toggle-button i, #global-close-button i {
    color: var(--fg) !important;
    stroke: var(--fg) !important;
}

/* Ensure the pop-down list has a smooth entry */
[id^="list-"] {
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Make nested cards slightly subtler so they don't fight the vault title */
[id^="list-"] .card-base {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.dark [id^="list-"] .card-base {
    background: rgba(255, 255, 255, 0.02);
}


/* -------------------------------------------------------------
   FINAL OVERRIDE: CARD DESCRIPTION LEGIBILITY
   ------------------------------------------------------------- */

#related-essays-grid .orientation-text {
    /* Pure readable gray for Light Mode */
    color: #33322e !important; 
    opacity: 1 !important;
    font-weight: 400 !important;
    font-size: 14px !important; /* Slightly larger for easier reading */
    line-height: 1.6 !important;
}

.dark #related-essays-grid .orientation-text {
    /* Pure readable off-white for Dark Mode */
    color: #e7e5e4 !important; 
    opacity: 1 !important;
}

/* -------------------------------------------------------------
   DARK MODE HIERARCHY OVERRIDE
   ------------------------------------------------------------- */

/* 1. Force the Title to be bright and sharp */
.dark #related-essays-grid h4 {
    color: #ffffff !important; 
    opacity: 1 !important;
}

/* 2. Force the Orientation Text to a readable stone-gray */
.dark #related-essays-grid .orientation-text {
    color: #d6d3d1 !important; /* Brighter Stone-300 */
    opacity: 0.9 !important;   /* Slight dip creates hierarchy without losing legibility */
}

#essay-scroll-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px !important;
    /* MATCHED PALETTE: 
       #ff8d55 (Orange) -> #ffb478 (Gold) -> #ff4d4d (Red) 
    */
    background: linear-gradient(90deg, 
        #ff8d55 0%, 
        #ffb478 50%, 
        #ff4d4d 100%
    ) !important;
    z-index: 9999 !important;
    box-shadow: 0 0 12px rgba(255, 141, 85, 0.5);
    pointer-events: none;
    transition: width 0.2s ease-out; /* Slightly smoother transition */
}

/* style.css - Final override for headline elegance */

.newspaper-row h3,
.card-base h3 {
    /* Prevents the browser from forcing a 'diamond' shape */
    text-wrap: wrap !important; 
    
    /* Forces the text to fill the container before breaking */
    width: 100% !important;
    max-width: none !important;
    
    /* Ensures characters don't crowd even when wrapping */
    letter-spacing: -0.01em !important;
    
    /* Eliminates potential word-break logic issues */
    word-break: normal !important;
    overflow-wrap: break-word !important;
}

/* style.css */

.card-base h3 {
    /* Prevents the 50/50 "wall" from cutting off the text */
    white-space: normal;
    text-wrap: wrap !important;
    
    /* Mix-blend-mode can make the overlap look very intentional and "monastic" */
    mix-blend-mode: normal; 
}

/* Ensure the title stays readable over the wireframes in light mode */
h3 {
    text-shadow: 0 0 20px var(--bg);
}

.dark h3 {
    text-shadow: 0 0 20px var(--bg);
}

/* Force the 50% split visually if you want a clear line */
.card-base .simulation-window {
    border-left: 1px solid var(--border-subtle);
}

#threshold-content p {
    max-width: 65ch; /* Optimal reading length for dense thought */
    margin-bottom: 2rem;
    animation: fadeIn 0.8s ease-out forwards;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

#threshold-toggle-button {
    /* Ensures it sits perfectly below your language toggle */
    transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

#threshold-toggle-button:hover i {
    color: #ff8d55; /* Use your ember accent on hover */
}
