/* Styles for the Marga Research Hub page. */

/* Shared colors, sizes, fonts, and shadows used throughout the page. */
:root {
  /* Maroon brand ramp (darkest → lightest). */
  --maroon-950: #3F0D16;
  --maroon-900: #57121E;
  --maroon-800: #6E1A28;
  --maroon-700: #84202F;
  --maroon-600: #9A2A3B;
  /* Gold accent + cream/paper backgrounds. */
  --gold: #D4A937;
  --gold-light: #EAD08A;
  --cream: #F9F1E4;
  --paper-bg: #FBF7EF;
  /* Text + border tokens. */
  --ink: #2A1013;
  --ink-soft: #6B5257;
  --line: #E7DCC9;
  --line-dark: rgba(249, 241, 228, 0.16);
  --white: #FFFFFF;
  --surface: #FFFFFF;
  /* Corner radii used by cards, modals and pills. */
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  /* Two elevation levels: cards sit gently, popovers float higher. */
  --shadow-card: 0 10px 30px -14px rgba(63, 13, 22, 0.28);
  --shadow-pop: 0 24px 60px -20px rgba(30, 5, 10, 0.45);
  /* Two font stacks: Playfair for display headings, Inter for UI text. */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Colors used by the publication-status labels. */
  --status-published: #3F7D4F;
  --status-published-bg: #E9F2EA;
  --status-unpublished: #8A6A2F;
  --status-unpublished-bg: #F5EEDD;
  --status-presentation: #5E3B84;
  --status-presentation-bg: #EFE7F5;
  --status-report: #2F6C8A;
  --status-report-bg: #E6F0F4;

  /* Header height — bumped on tablet/desktop below. Used for scroll offsets
     and sticky positioning so sections don't hide under the header. */
  --header-h: 68px;
}

/* Taller header on wider screens. */
@media (min-width:641px) {
  :root {
    --header-h: 74px;
  }
}

/* Dark mode is enabled when script.js adds data-theme="dark" to <html>.
  The main page surfaces and text change, while the maroon brand areas stay dark. */
html[data-theme="dark"] {
  /* Tells the browser to render scrollbars + form controls in dark style. */
  color-scheme: dark;
  --paper-bg: #0C0C0C;
  --surface: #171515;
  --ink: #F5F5F5;
  --ink-soft: #d3cfcf;
  --line: rgba(212, 169, 55, 0.22);
  /* Two extra tokens only used in dark mode: the accent + its border color. */
  --dark-accent: var(--gold-light);
  --dark-accent-border: var(--gold);
}

/* Text that was dark on the light theme needs a brighter color here. */
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .logo-text span,
html[data-theme="dark"] .results-count strong,
html[data-theme="dark"] .paper-card h3,
html[data-theme="dark"] .empty-state h3,
html[data-theme="dark"] .error-state h3,
html[data-theme="dark"] .tour-card h3,
html[data-theme="dark"] .detail-head h3,
html[data-theme="dark"] .modal h3,
html[data-theme="dark"] .modal-paper-summary strong {
  color: var(--ink);
}

/* Use the light accent color for controls and icons against dark surfaces. */
html[data-theme="dark"] .btn-ghost:hover:not(:disabled),
html[data-theme="dark"] .icon-btn:hover,
html[data-theme="dark"] .search-toggle svg,
html[data-theme="dark"] .mobile-search-btn,
html[data-theme="dark"] .mobile-theme-btn,
html[data-theme="dark"] .advanced-toggle,
html[data-theme="dark"] .range-values span,
html[data-theme="dark"] .btn-reset-advanced:hover,
html[data-theme="dark"] .main-nav a:hover,
html[data-theme="dark"] .main-nav a.active,
html[data-theme="dark"] .main-nav button:hover,
html[data-theme="dark"] .main-nav button.active,
html[data-theme="dark"] .mobile-menu-btn,
html[data-theme="dark"] .mobile-menu-panel a.active,
html[data-theme="dark"] .mobile-menu-panel button.active,
html[data-theme="dark"] .paper-card h3 button:hover,
html[data-theme="dark"] .pill,
html[data-theme="dark"] .read-more,
html[data-theme="dark"] .empty-state svg,
html[data-theme="dark"] .error-state svg,
html[data-theme="dark"] .tour-close:hover,
html[data-theme="dark"] .detail-modal-close:hover,
html[data-theme="dark"] .detail-body h4,
html[data-theme="dark"] .detail-sidebar h4,
html[data-theme="dark"] .recent-item:hover,
html[data-theme="dark"] .chat-result-btn,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .a11y-list svg {
  color: var(--dark-accent);
}

/* Same set of interactive elements — this time swapping the *border* color
   to the dark-mode accent border for hover/focus states. */
html[data-theme="dark"] .btn-ghost:hover:not(:disabled),
html[data-theme="dark"] .icon-btn:hover,
html[data-theme="dark"] .search-toggle:hover,
html[data-theme="dark"] .search-toggle[aria-expanded="true"],
html[data-theme="dark"] .search-input:focus,
html[data-theme="dark"] .detail-modal-close:hover,
html[data-theme="dark"] .chat-result-btn:hover,
html[data-theme="dark"] .chat-input-row input:focus {
  border-color: var(--dark-accent-border);
}

/* Make status labels softer so their colored backgrounds work in dark mode. */
/* The light-mode backgrounds are pastel; these muted tints give the same
   "pill" feel without blowing out against the near-black surface. */
html[data-theme="dark"] .pill-status[data-status="published"] {
  background: rgba(63, 125, 79, .16);
  border-color: rgba(63, 125, 79, .4);
  color: #7FCB93;
}

html[data-theme="dark"] .pill-status[data-status="unpublished"] {
  background: rgba(138, 106, 47, .2);
  border-color: rgba(212, 169, 55, .4);
  color: var(--gold-light);
}

html[data-theme="dark"] .pill-status[data-status="presentation"] {
  background: rgba(94, 59, 132, .22);
  border-color: rgba(160, 110, 210, .45);
  color: #C9A8EA;
}

html[data-theme="dark"] .pill-status[data-status="report"] {
  background: rgba(47, 108, 138, .2);
  border-color: rgba(90, 165, 205, .45);
  color: #7EC3E8;
}

/* Use darker shimmer colors while loading in dark mode. */
html[data-theme="dark"] .sk {
  background: linear-gradient(90deg, var(--line) 25%, #2C2C2C 37%, var(--line) 63%);
  background-size: 400% 100%;
}

/* Fade theme-related colors instead of changing them abruptly. */
/* Applied to the big "surface" elements so toggling dark mode looks like
   a cross-fade rather than an instant switch. */
body,
.site-header,
.search-panel,
.mobile-menu-panel,
.paper-card,
.skeleton-card,
.modal,
.detail-modal,
.chat-panel,
.chat-msg-bot,
.tour-card,
.detail-sidebar,
input,
select,
textarea,
.field-select,
.sort-select,
.scope-select,
.pill,
.chip,
.filter-chip {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* Padding and borders count toward widths — safer global box model. */
* {
  box-sizing: border-box;
}

/* Smooth scrolling for in-page anchors (e.g. #papers from the hero CTA). */
html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper-bg);
  color: var(--ink);
  /* Slightly crisper text rendering on WebKit. */
  -webkit-font-smoothing: antialiased;
}

/* Highlight color for selected text — matches the brand palette. */
::selection {
  background: rgba(222, 108, 104, 0.35);
  color: var(--maroon-950);
}

/* Media elements default to block so inline-gap whitespace disappears,
   and never overflow their container. */
img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Buttons inherit the page font (browser default would be system UI). */
button {
  font-family: inherit;
  cursor: pointer;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
}

p {
  margin: 0;
}

/* Small uppercase label with a short gold rule before it. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1.5px;
  background: var(--gold);
  display: inline-block;
}

/* Global reduced-motion fallback: near-zero durations rather than `none`
   so animationend/transitionend events still fire for any JS that waits on them. */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Gold focus ring shown only when navigating with the keyboard. */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
