/* ==========================================================================
   Media Publik Aktual - Global Styling & Typography
   Design System: Modern Contemporary Indonesian News Portal
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block");

/* Keyframe for universal page preloader */
@keyframes mpaPreloadSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Prevent icon ligature FOIT (Flash of Unstyled Icons) */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined" !important;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

@layer base {
  html,
  body {
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
    overflow-x: hidden;
    max-width: 100vw;
  }

  body {
    background-color: #f9f9ff;
    color: #161c27;
    font-family: "Plus Jakarta Sans", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  main > :first-child {
    margin-top: 0 !important;
  }

  main > :last-child {
    margin-bottom: 0 !important;
  }
}

/* Custom Scrollbar */
:root {
  --color-surface: #f9f9ff;
  --color-background: #f9f9ff;
  --color-on-surface: #161c27;
  --color-on-surface-variant: #45474c;
  --color-surface-dim: #d4daea;
  --color-surface-bright: #ffffff;
  --color-surface-variant: #dde2f3;
  --color-surface-tint: #535f74;
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-low: #f1f3ff;
  --color-surface-container: #e8eeff;
  --color-surface-container-high: #e3e8f9;
  --color-surface-container-highest: #dde2f3;
  --color-outline: #75777d;
  --color-outline-variant: #c5c6cd;
}

html.dark {
  --color-surface: #0b0f17;
  --color-background: #0b0f17;
  --color-on-surface: #f8fafc;
  --color-on-surface-variant: #cbd5e1;
  --color-surface-dim: #070a10;
  --color-surface-bright: #ffffff;
  --color-surface-variant: #cbd5e1;
  --color-surface-tint: #cbd5e1;
  --color-surface-container-lowest: #101726;
  --color-surface-container-low: #162032;
  --color-surface-container: #1d293d;
  --color-surface-container-high: #26354e;
  --color-surface-container-highest: #33445e;
  --color-outline: #64748b;
  --color-outline-variant: #94a3b8;
  color-scheme: dark;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f3ff;
}

::-webkit-scrollbar-thumb {
  background: #c5c6cd;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #75777d;
}

/* Material Symbols Optical Size */
.material-symbols-outlined {
  font-variation-settings:
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
  vertical-align: middle;
}

/* Sidebar interactive navigation */
aside nav a {
  cursor: pointer;
  user-select: none;
}

aside nav a:hover {
  cursor: pointer;
}

/* ==========================================================================
   Contenteditable Editorial Canvas Typography & Formatting
   ========================================================================== */
#article-canvas h1,
[contenteditable="true"] h1 {
  font-family: "Merriweather", serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: #161c27;
}

#article-canvas h2,
[contenteditable="true"] h2 {
  font-family: "Merriweather", serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #161c27;
}

#article-canvas h3,
[contenteditable="true"] h3 {
  font-family: "Merriweather", serif;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: #161c27;
}

#article-canvas p,
[contenteditable="true"] p {
  margin-bottom: 0.75rem;
  line-height: 1.8;
}

#article-canvas ul,
[contenteditable="true"] ul {
  list-style-type: disc !important;
  margin-left: 1.75rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.75rem !important;
}

#article-canvas ol,
[contenteditable="true"] ol {
  list-style-type: decimal !important;
  margin-left: 1.75rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.75rem !important;
}

#article-canvas li,
[contenteditable="true"] li {
  margin-bottom: 0.25rem;
  display: list-item !important;
  line-height: 1.7;
}

#article-canvas blockquote,
[contenteditable="true"] blockquote {
  border-left: 4px solid #b7102a;
  padding-left: 1.25rem;
  margin: 1.25rem 0;
  font-style: italic;
  color: #33363f;
  font-family: "Merriweather", serif;
  font-size: 1.125rem;
  background: rgba(183, 16, 42, 0.03);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  border-radius: 0 0.5rem 0.5rem 0;
}

#article-canvas a,
[contenteditable="true"] a {
  color: #b7102a;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 600;
}

#article-canvas b,
#article-canvas strong,
[contenteditable="true"] b,
[contenteditable="true"] strong {
  font-weight: 700;
  color: #161c27;
}

#article-canvas i,
#article-canvas em,
[contenteditable="true"] i,
[contenteditable="true"] em {
  font-style: italic;
}

#article-canvas u,
[contenteditable="true"] u {
  text-decoration: underline;
}

#article-canvas strike,
#article-canvas s,
[contenteditable="true"] strike,
[contenteditable="true"] s {
  text-decoration: line-through;
}

#article-canvas table,
[contenteditable="true"] table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.925rem;
}

#article-canvas th,
[contenteditable="true"] th,
#article-canvas td,
[contenteditable="true"] td {
  border: 1px solid #dcdce4;
  padding: 0.5rem 0.75rem;
}

/* Editor Placeholder Styling */
#article-canvas:empty::before,
#article-canvas > p:only-child:empty::before,
#article-canvas > p:only-child:has(> br:only-child)::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  font-style: italic;
  pointer-events: none;
}

/* ==========================================================================
   Navigation Drawer & Category Ribbon - Bulletproof Contrast in All Modes
   ========================================================================== */
#mpa-nav-drawer-card {
  background-color: #0b1320 !important;
  color: #f8fafc !important;
  border-right: 1px solid #1e293b !important;
}

#mpa-nav-drawer-card .border-b,
#mpa-nav-drawer-card .border-t {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Base Drawer Links */
#mpa-drawer-nav a {
  color: #cbd5e1 !important;
  background-color: transparent !important;
  transition: all 0.15s ease-in-out !important;
}

#mpa-drawer-nav a span {
  color: #cbd5e1 !important;
}

#mpa-drawer-nav a span.material-symbols-outlined {
  color: inherit !important;
}

/* Hover State: Sleek translucent navy background with crisp white text */
#mpa-drawer-nav a:hover {
  background-color: rgba(255, 255, 255, 0.14) !important;
}

#mpa-drawer-nav a:hover span:not(.material-symbols-outlined) {
  color: #ffffff !important;
  font-weight: 600 !important;
}

/* Active State: Red background badge with crisp white text */
#mpa-drawer-nav a.active-drawer-link,
#mpa-drawer-nav a.bg-secondary {
  background-color: #b7102a !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(183, 16, 42, 0.4) !important;
}

#mpa-drawer-nav a.active-drawer-link span,
#mpa-drawer-nav a.bg-secondary span {
  color: #ffffff !important;
  font-weight: 700 !important;
}

#mpa-drawer-nav a.active-drawer-link:hover,
#mpa-drawer-nav a.bg-secondary:hover {
  background-color: #cf1734 !important;
  color: #ffffff !important;
}

/* Top Ribbon Navbar */
header nav.bg-primary-container {
  background-color: #0b1320 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

header nav.bg-primary-container a:not(.bg-secondary) {
  color: #cbd5e1 !important;
  background-color: transparent !important;
  font-weight: 600 !important;
}

header nav.bg-primary-container a:not(.bg-secondary):hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.14) !important;
}

header nav.bg-primary-container a.bg-secondary {
  background-color: #b7102a !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

header nav.bg-primary-container a.bg-secondary:hover {
  background-color: #cf1734 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   Comprehensive Dark Mode Overrides (Guaranteed High-Contrast Legibility)
   ========================================================================== */
html.dark {
  color-scheme: dark;
}

html.dark body {
  background-color: #080c14 !important;
  color: #f8fafc !important;
}

/* Headings & Typography */
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6 {
  color: #f8fafc !important;
}

html.dark .text-on-surface {
  color: #f8fafc !important;
}

html.dark .text-on-surface-variant {
  color: #cbd5e1 !important;
}

html.dark .text-surface-variant {
  color: #cbd5e1 !important;
}

html.dark .text-surface-bright {
  color: #ffffff !important;
}

html.dark .text-outline-variant {
  color: #cbd5e1 !important;
}

html.dark .text-outline {
  color: #94a3b8 !important;
}

html.dark .text-on-primary-container {
  color: #cbd5e1 !important;
}

html.dark .text-secondary {
  color: #f87171 !important;
}

html.dark .text-secondary-fixed {
  color: #fca5a5 !important;
}

html.dark .text-on-secondary-fixed {
  color: #fca5a5 !important;
}

html.dark .text-on-secondary {
  color: #ffffff !important;
}

/* Header & Brand in Dark Mode */
html.dark header,
html.dark .bg-surface\/95,
html.dark .bg-surface\/90 {
  background-color: rgba(11, 15, 23, 0.97) !important;
  border-bottom-color: #1e293b !important;
}

html.dark header .text-on-surface-variant {
  color: #e2e8f0 !important;
}

html.dark header .text-on-surface {
  color: #ffffff !important;
}

/* Category Navbar (Ribbon) in Dark Mode */
html.dark nav.bg-primary-container {
  background-color: #0a121e !important;
  border-bottom: 1px solid #1e293b !important;
}

html.dark nav.bg-primary-container a:not(.bg-secondary) {
  color: #cbd5e1 !important;
  font-weight: 600 !important;
}

html.dark nav.bg-primary-container a:not(.bg-secondary):hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Background Containers & Cards */
html.dark .bg-surface {
  background-color: #080c14 !important;
}

html.dark .bg-surface-container-lowest {
  background-color: #0f1726 !important;
  border: 1px solid #1e293b !important;
}

html.dark .bg-surface-container-lowest p,
html.dark .bg-surface-container-lowest span:not(.material-symbols-outlined):not(.bg-secondary-fixed):not(.bg-secondary):not(.text-secondary):not(.text-on-secondary-fixed):not([class*="bg-secondary"]):not([class*="text-secondary"]) {
  color: #e2e8f0 !important;
}

html.dark .bg-surface-container-low {
  background-color: #151d2e !important;
}

html.dark .bg-surface-container-low\/60,
html.dark .bg-surface-container-low\/50 {
  background-color: rgba(21, 29, 46, 0.8) !important;
  border: 1px solid rgba(45, 59, 78, 0.5) !important;
}

html.dark .bg-surface-container-low\/60 span:not(.material-symbols-outlined):not(.bg-secondary-fixed):not(.bg-secondary):not(.text-secondary):not(.text-on-secondary-fixed):not([class*="bg-secondary"]):not([class*="text-secondary"]),
html.dark .bg-surface-container-low\/60 p {
  color: #e2e8f0 !important;
}

html.dark .bg-surface-container {
  background-color: #1b253b !important;
}

html.dark .bg-surface-container-high {
  background-color: #24314c !important;
}

/* Category & Status Badges in Dark Mode (Anti-Clash & High Contrast) */
html.dark .bg-secondary-fixed,
html.dark span.bg-secondary-fixed,
html.dark .bg-surface-container-lowest span.bg-secondary-fixed,
html.dark .bg-surface-container-low span.bg-secondary-fixed,
html.dark .bg-surface-container span.bg-secondary-fixed {
  background-color: rgba(183, 16, 42, 0.22) !important;
  border: 1px solid rgba(248, 113, 113, 0.35) !important;
  color: #fca5a5 !important;
}

html.dark .bg-secondary-fixed span,
html.dark span.bg-secondary-fixed,
html.dark .bg-secondary-fixed.text-on-secondary-fixed,
html.dark .text-on-secondary-fixed,
html.dark .bg-surface-container-lowest span.text-on-secondary-fixed {
  color: #fca5a5 !important;
}

html.dark .bg-secondary-container {
  background-color: rgba(183, 16, 42, 0.28) !important;
  border: 1px solid rgba(248, 113, 113, 0.3) !important;
  color: #fecaca !important;
}

html.dark .text-on-secondary-container {
  color: #fecaca !important;
}

/* News Detail Category Badge */
html.dark #detail-category-badge {
  background-color: rgba(29, 78, 216, 0.22) !important;
  border: 1px solid rgba(96, 165, 250, 0.4) !important;
  color: #93c5fd !important;
}

/* Subcategory Filter Pills */
html.dark .subcat-pill:not(.bg-secondary) {
  background-color: #1e293b !important;
  color: #cbd5e1 !important;
  border: 1px solid #334155 !important;
}

html.dark .bg-surface-container-high\/60 {
  background-color: rgba(36, 49, 76, 0.7) !important;
}

html.dark .bg-surface-container-high\/20 {
  background-color: rgba(36, 49, 76, 0.35) !important;
}

html.dark .border-surface-container-high,
html.dark .border-surface-container-high\/60,
html.dark .border-surface-container-high\/40,
html.dark .border-surface-container-high\/20 {
  border-color: #1e293b !important;
}

html.dark .border-outline-variant {
  border-color: #2d3b4e !important;
}

/* Empty State Icons */
html.dark .material-symbols-outlined {
  opacity: 0.85;
}

/* Footer in Dark Mode - High Contrast Guarantee */
html.dark footer,
html.dark footer.bg-primary-container {
  background-color: #05080f !important;
  border-top: 1px solid #1e293b !important;
  color: #cbd5e1 !important;
}

html.dark footer .text-surface-bright,
html.dark footer h2,
html.dark footer h3,
html.dark footer h4,
html.dark footer span.font-headline-card {
  color: #ffffff !important;
}

html.dark footer p,
html.dark footer span,
html.dark footer .text-outline-variant,
html.dark footer .text-on-surface-variant {
  color: #cbd5e1 !important;
}

html.dark footer a {
  color: #cbd5e1 !important;
}

html.dark footer a:hover {
  color: #ffffff !important;
}

html.dark footer .text-surface-container-high a {
  color: #94a3b8 !important;
}

html.dark footer .text-surface-container-high a:hover {
  color: #ffffff !important;
}

/* Custom Overrides for Specialized Legal & Notice Banners */
html.dark .bg-amber-50 {
  background-color: rgba(120, 53, 15, 0.25) !important;
  color: #fef3c7 !important;
}

html.dark .text-amber-950 {
  color: #fde68a !important;
}

html.dark .bg-blue-100 {
  background-color: rgba(30, 58, 138, 0.35) !important;
  color: #bfdbfe !important;
}

html.dark .bg-emerald-100 {
  background-color: rgba(6, 78, 59, 0.35) !important;
  color: #a7f3d0 !important;
}

html.dark .bg-purple-100 {
  background-color: rgba(88, 28, 135, 0.35) !important;
  color: #e9d5ff !important;
}

/* Theme Toggle Button Hover & Elevation */
#theme-toggle-btn {
  user-select: none;
}

#theme-toggle-btn:hover {
  transform: scale(1.05);
}

#theme-toggle-btn:active {
  transform: scale(0.95);
}

/* Form Controls & Inputs in Dark Mode */
html.dark input,
html.dark textarea,
html.dark select {
  background-color: #172133 !important;
  color: #f8fafc !important;
  border-color: #28364d !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #94a3b8 !important;
}

/* Modals, Dialogs, and Search Overlays */
html.dark dialog,
html.dark .modal-content {
  background-color: #0f1726 !important;
  color: #f8fafc !important;
  border-color: #28364d !important;
}

/* Cookie & Consent Banner in Dark Mode */
html.dark #cookie-banner > div {
  background-color: #0d1524 !important;
  border: 1px solid #28364d !important;
  color: #f8fafc !important;
}

html.dark #cookie-banner p,
html.dark #cookie-banner .text-outline-variant {
  color: #e2e8f0 !important;
}

/* Bottom Nav in Dark Mode */
html.dark nav.fixed.bottom-0 {
  background-color: rgba(11, 15, 23, 0.95) !important;
  border-top: 1px solid #1e293b !important;
}

html.dark nav.fixed.bottom-0 a:not(.text-secondary) {
  color: #94a3b8 !important;
}

html.dark nav.fixed.bottom-0 a:not(.text-secondary):hover {
  color: #f8fafc !important;
}

/* Shadow Elevation in Dark Mode */
html.dark .shadow-sm,
html.dark .shadow-md,
html.dark .shadow-lg,
html.dark .shadow-xl {
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5) !important;
}


/* ==========================================================================
   Comprehensive Sidebar & Drawer Contrast Safeguard
   ========================================================================== */
aside nav a {
  background-color: transparent !important;
  color: #94a3b8 !important;
  transition: all 0.15s ease-in-out;
}
aside nav a span {
  color: #94a3b8 !important;
}
aside nav a span.material-symbols-outlined {
  color: #94a3b8 !important;
}

/* Hover State: ONLY when hovered by the cursor */
aside nav a:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}
aside nav a:hover span,
aside nav a:hover span.material-symbols-outlined {
  color: #ffffff !important;
}

/* Active State: ONLY the single active page item */
aside nav a.active-nav-link {
  background-color: rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) !important;
}
aside nav a.active-nav-link span {
  color: #ffffff !important;
  font-weight: 700 !important;
}
aside nav a.active-nav-link span.material-symbols-outlined {
  color: #ef4444 !important; /* Secondary Red accent for the active icon */
}

#mpa-drawer-nav a {
  color: #cbd5e1 !important;
  background-color: transparent !important;
  transition: all 0.15s ease-in-out;
}
#mpa-drawer-nav a span {
  color: #cbd5e1 !important;
}
#mpa-drawer-nav a:hover {
  background-color: rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
}
#mpa-drawer-nav a:hover span {
  color: #ffffff !important;
}
#mpa-drawer-nav a.bg-secondary,
#mpa-drawer-nav a.active-drawer-link {
  background-color: #b7102a !important;
  color: #ffffff !important;
}
#mpa-drawer-nav a.bg-secondary span,
#mpa-drawer-nav a.active-drawer-link span {
  color: #ffffff !important;
}

/* ==========================================================================
   Responsive & Performance Enhancements
   ========================================================================== */

/* Universal anti-overflow and text wrapping */
h1, h2, h3, h4, h5, h6, p, span, a, article {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Responsive media constraint */
img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* Smooth Infinite Breaking News Marquee */
@keyframes mpaMarquee {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

.animate-marquee {
  display: inline-block !important;
  white-space: nowrap !important;
  animation: mpaMarquee 28s linear infinite !important;
  will-change: transform;
}

.animate-marquee:hover {
  animation-play-state: paused !important;
}
