/* ==========================================================================
   COOKEDMAINS — UNIFIED EDITORIAL PAPER & INK DESIGN SYSTEM (Phase 1 & 2)
   Shared across Home, Mains Studio, Prelims Command Center & SEO Pages
   ========================================================================== */

:root {
  --cm-bg-light: #FAF9F6;
  --cm-surface-light: #FFFFFF;
  --cm-border-light: #E2E8F0;
  --cm-text-light: #0F172A;
  --cm-muted-light: #475569;

  --cm-bg-dark: #0B1120;
  --cm-surface-dark: #111827;
  --cm-border-dark: rgba(255, 255, 255, 0.08);
  --cm-text-dark: #F8FAFC;
  --cm-muted-dark: #94A3B8;

  --cm-accent: #D97706;
  --cm-accent-bright: #F59E0B;
  --cm-font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --cm-font-serif: 'Newsreader', Georgia, Cambria, serif;
  --cm-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

/* Unified Typography Stack */
body {
  font-family: var(--cm-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-serif {
  font-family: var(--cm-font-serif) !important;
}

.font-mono {
  font-family: var(--cm-font-mono) !important;
  font-variant-numeric: tabular-nums;
}

/* Warm Editorial Paper (Light) & Deep Slate (Dark) */
html:not(.dark) body {
  background-color: var(--cm-bg-light);
  color: var(--cm-text-light);
}

html.dark body {
  background-color: var(--cm-bg-dark);
  color: var(--cm-text-dark);
}

/* Cross-Document View Transitions (MPA App-Like Fluidity) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root) {
    animation: cm-fade-out 140ms cubic-bezier(0.4, 0, 1, 1) both;
  }

  ::view-transition-new(root) {
    animation: cm-fade-in 180ms cubic-bezier(0, 0, 0.2, 1) both;
  }
}

@keyframes cm-fade-out {
  to { opacity: 0; }
}

@keyframes cm-fade-in {
  from { opacity: 0; }
}

/* Reduced Motion Guard */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Utility Helpers */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Mobile Safe-Area Bottom Dock */
.cm-mobile-dock {
  padding-bottom: max(0.375rem, env(safe-area-inset-bottom));
}

/* Below-the-Fold Offscreen Rendering Deferral (Phase 3 Performance) */
.cm-deferred-section {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 600px;
}

/* UPSC Niche Micro-Textures (3-4% opacity, crafted Paper & OMR feel) */
.cm-qcab-bg {
  background-image:
    linear-gradient(to right, transparent 36px, rgba(225, 29, 72, 0.08) 36px, rgba(225, 29, 72, 0.08) 37px, transparent 37px),
    repeating-linear-gradient(to bottom, transparent 0, transparent 27px, rgba(148, 163, 184, 0.07) 27px, rgba(148, 163, 184, 0.07) 28px);
}
html.dark .cm-qcab-bg {
  background-image:
    linear-gradient(to right, transparent 36px, rgba(244, 63, 94, 0.10) 36px, rgba(244, 63, 94, 0.10) 37px, transparent 37px),
    repeating-linear-gradient(to bottom, transparent 0, transparent 27px, rgba(148, 163, 184, 0.05) 27px, rgba(148, 163, 184, 0.05) 28px);
}

.cm-omr-bg {
  background-image: radial-gradient(rgba(100, 116, 139, 0.12) 1px, transparent 1px);
  background-size: 18px 18px;
}
html.dark .cm-omr-bg {
  background-image: radial-gradient(rgba(148, 163, 184, 0.10) 1px, transparent 1px);
  background-size: 18px 18px;
}

/* Linear-Style Crisp Card Surface */
.cm-card-surface {
  transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1), transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
html.dark .cm-card-surface {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.cm-card-surface:hover {
  border-color: rgba(245, 158, 11, 0.45);
}
