/**
 * DEFCON Level, Ads & Mobile Safety
 * Advertisement placements, enhanced mobile responsive, print styles, responsive images, image lightbox, error page lists, mobile performance, webview/Telegram safe modes, and universal mobile safeguards.
 *
 * Part of the Defcon site CSS (builds on engine base theme).
 * Load order managed by config/site.php → site_css array.
 */

/* ================================================================
   ADVERTISEMENTS - Non-annoying placement
   ================================================================ */
/* Base ad container - single space unit before and after */
.ad-container {
  margin: var(--space-4) 0;
  /* Single space unit (1rem = 16px) before and after */
  text-align: center;
  overflow: visible;
  position: relative;
  z-index: 1;
  width: 100%;
  /* Ensure container has width for AdSense */
  min-width: 300px;
  /* Prevent zero-width error in AdSense */
  min-height: 100px;
  /* Reserve space to prevent CLS */
  display: block;
  /* Ensure block display */
  padding: 0;
  /* No padding - spacing comes from margin only */
  box-sizing: border-box;
}

/* Ad label (optional, controlled in admin settings) */
.ad-label {
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Engagement badges (Popular / Trending / Hot / New) */
.engagement-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 12px;
  border: 1px solid transparent;
}

.engagement-badge-compact {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.55);
  color: #f8fafc;
}

.alert-card .alert-card-header .engagement-badge,
.raised-alert-card .alert-card-header .engagement-badge,
.alert-press-card .alert-press-header .engagement-badge {
  margin-left: 0.5rem;
  background: rgba(15, 23, 42, 0.55);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.2);
}

.engagement-badge-popular {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: #ef4444;
}

.engagement-badge-trending {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border-color: #22c55e;
}

.engagement-badge-hot {
  background: rgba(251, 146, 60, 0.15);
  color: #fb923c;
  border-color: #fb923c;
}

.engagement-badge-new {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info, #3b82f6);
  border-color: var(--info, #3b82f6);
}

.engagement-badge-staff-pick {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border-color: #8b5cf6;
}

.engagement-badge-featured {
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.engagement-badge-hub {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: #10b981;
}

/* Admin toggle switches (shared) */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toggle-label-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.toggle-text {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.3;
}

.toggle-group .form-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.toggle-switch-wrapper {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-switch-wrapper input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  width: 56px;
  height: 30px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  transition: all 0.2s ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.toggle-switch-wrapper input:checked+.toggle-switch {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: rgba(16, 185, 129, 0.3);
}

.toggle-switch-wrapper input:checked+.toggle-switch::after {
  transform: translateX(26px);
}

.toggle-switch-wrapper:hover .toggle-switch {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.toggle-switch-wrapper:hover input:checked+.toggle-switch {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(16, 185, 129, 0.2);
}

@media (max-width: 768px) {
  .toggle-switch {
    width: 52px;
    height: 28px;
  }

  .toggle-switch::after {
    width: 20px;
    height: 20px;
  }

  .toggle-switch-wrapper input:checked+.toggle-switch::after {
    transform: translateX(22px);
  }
}

/* Engagement cron status */
.cron-status {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-secondary);
  display: grid;
  gap: 0.3rem;
}

.cron-status-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.cron-status-value {
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.cron-status-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .cron-status {
    padding: 0.8rem 0.9rem;
  }

  .cron-status-value {
    font-size: 0.85rem;
  }

  .cron-status-note {
    font-size: var(--text-xs);
  }
}

.ad-container::before {
  display: none;
}

/* Also hide the entire container if it's empty (no ad loaded) */
.ad-container:empty {
  display: none;
}

/* Reduce AdSense internal spacing if present */
.ad-container ins.adsbygoogle {
  display: block !important;
  margin: 0 auto;
  /* Center the ad element */
  padding: 0;
  text-align: center;
  /* Center inline content */
}

/* Center all AdSense wrapper divs and iframes */
.ad-container ins.adsbygoogle>div,
.ad-container ins.adsbygoogle iframe,
.ad-container ins.adsbygoogle>* {
  margin: 0 auto;
  display: block;
}

/* Center AdSense-injected wrapper divs (they often contain the actual ad) */
/* This ensures smaller square ads are centered */
.ad-container>div[id*="google"],
.ad-container>div[class*="google"],
.ad-container>div[class*="ads"] {
  margin: 0 auto;
  display: block;
}

/* Remove ALL spacing from AdSense iframe/content for in-article ads */
.ad-container.ad-in-article ins.adsbygoogle,
.ad-container.ad-in-article ins.adsbygoogle iframe,
.ad-container.ad-in-article ins.adsbygoogle>* {
  margin: 0 auto;
  padding: 0;
  display: block;
}

/* Ad type classes - NO additional margins (base container handles spacing) */
.ad-display {
  padding: var(--space-2) 0;
  /* Minimal padding for background */
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  /* Margin handled by base .ad-container */
}

.ad-infeed {
  padding: 0;
  /* No padding - in-feed ads blend naturally */
  /* Margin handled by base .ad-container */
}

.ad-in-article {
  padding: 0;
  /* No padding */
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  /* Margin handled by base .ad-container */
}

/* Subscription CTA Box - NOT an advertisement */
.subscription-cta-box,
.cta-box {
  margin-top: var(--space-6);
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border-radius: 12px;
  text-align: center;
  /* Ensure it never gets ad styling */
  position: relative;
}

.subscription-cta-box::before,
.cta-box::before {
  display: none;
  /* Never show "Advertisement" label */
}

/* In-article ads - maintain single space unit spacing */
/* Based on Stack Overflow solution: https://stackoverflow.com/questions/33073203/how-to-remove-white-space-adsense-below-adsense-ads */
.ad-container.ad-in-article {
  /* Keep base margin from .ad-container (single space unit) */
  padding: 0;
  /* No padding */
  line-height: 1;
  /* Changed from 0 to 1 - line-height: 0 can cause AdSense width calculation issues */
  height: auto;
  /* Force container to collapse to content height */
  min-height: 0;
  /* Remove any min-height that might add spacing */
  width: 100%;
  /* Ensure AdSense can calculate width */
  display: block;
  /* Ensure block display for width calculation */
  overflow: visible;
  /* Allow full ad render (no clipping) */
  position: relative;
  /* Help with overflow containment */
}

/* Remove bottom margin from "Advertisement" label for in-article ads */
.ad-container.ad-in-article::before {
  margin-bottom: 0;
  /* No gap below the label */
  line-height: 1;
}

/* Aggressive override for AdSense internal elements - try to remove ALL spacing */
/* Target the ins element directly to prevent AdSense from reserving extra space */
.ad-container.ad-in-article ins.adsbygoogle {
  margin: 0 !important;
  padding: 0;
  display: block !important;
  width: 100% !important;
  /* Ensure AdSense can calculate width */
  line-height: 1;
  /* Changed from 0 - helps with width calculation */
  height: auto !important;
  /* Allow height to adjust to actual ad size */
  max-height: none;
  /* Remove any max-height restrictions */
  overflow: visible;
  /* Allow full ad render (no clipping) */
}

.ad-container.ad-in-article ins.adsbygoogle iframe,
.ad-container.ad-in-article ins.adsbygoogle>*,
.ad-container.ad-in-article ins.adsbygoogle>div,
.ad-container.ad-in-article ins.adsbygoogle>span {
  margin: 0 auto;
  /* Center all child elements */
  padding: 0;
  display: block;
  line-height: 1;
  /* Changed from 0 */
}

/* Target AdSense containers more aggressively - similar to anchor ad fix approach */
/* Force collapse of any AdSense wrapper elements that might be adding spacing */
.ad-container.ad-in-article ins.adsbygoogle[data-ad-status],
.ad-container.ad-in-article ins.adsbygoogle[data-ad-status="filled"],
.ad-container.ad-in-article ins.adsbygoogle[data-ad-status="unfilled"] {
  margin-bottom: 0;
  padding-bottom: 0;
  height: auto;
  min-height: 0;
}

/* Target any AdSense wrapper divs that might be adding spacing */
/* AdSense often injects wrapper divs - target all possible nested structures */
.ad-container.ad-in-article>div,
.ad-container.ad-in-article>div>div,
.ad-container.ad-in-article>div>div>div,
.ad-container.ad-in-article div[id*="google"],
.ad-container.ad-in-article div[class*="google"],
.ad-container.ad-in-article div[class*="ads"] {
  margin: 0 auto;
  /* Center wrapper divs */
  padding: 0;
  display: block;
  /* Ensure block display for centering */
}

/* Target AdSense iframe directly - often the culprit for spacing */
/* Based on Stack Overflow: AdSense reserves space for larger ads, iframe can have extra height */
.ad-container.ad-in-article iframe {
  margin: 0 auto;
  /* Center the iframe */
  padding: 0;
  display: block;
  vertical-align: top;
  height: auto;
  /* Allow iframe to size to actual ad content */
  max-height: none;
  /* Allow ad to render at full size */
  overflow: visible;
  /* Allow full ad render, overflow:hidden clips ads */
}

/* AdSense ad elements should not be forcibly hidden (policy compliance). */

/* NEW APPROACH: Use JavaScript to dynamically adjust container height after ad loads */
/* This targets the actual rendered ad content and removes any reserved space */
.ad-container.ad-in-article[data-ad-loaded="true"] {
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Target the actual ad content div that AdSense creates */
.ad-container.ad-in-article>div[id*="google_ads_iframe"],
.ad-container.ad-in-article>div[class*="google_ads_iframe"] {
  margin: 0 auto;
  /* Center the ad content div */
  padding: 0;
  display: block;
  height: auto;
  overflow: visible;
}

/* In-article ads border styling - maintain consistent spacing */
.ad-container.ad-in-article {
  border-bottom: 1px solid var(--border-subtle);
  /* Spacing handled by base .ad-container margin */
  overflow: visible;
  /* Allow full ad render, overflow:hidden clips ads */
}

/* Ensure normal spacing from paragraphs after in-article ads */
/* Content spacing around ads - single space unit */
.alert-content .ad-container.ad-in-article+p,
.alert-content p+.ad-container {
  margin-top: var(--space-4);
  /* Single space unit after content before ad */
}

.alert-content .ad-container+p {
  margin-top: var(--space-4);
  /* Single space unit after ad before content */
}

.ad-multiplex {
  padding: 0;
  /* No padding */
  /* Margin handled by base .ad-container */
}

.ad-horizontal {
  padding: var(--space-2) 0;
  /* Minimal padding for background */
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  /* Margin handled by base .ad-container */
}

.ad-sidebar {
  padding: var(--space-2);
  /* Minimal padding */
  background: var(--bg-tertiary);
  border-radius: 8px;
  /* Margin handled by base .ad-container */
}

/* Block AdSense pop-up/overlay ads (vignette, anchor, etc.) */
/* These selectors target ONLY specific Google ad overlay patterns */
/* IMPORTANT: Be very specific to avoid breaking legitimate content */
#google_vignette,
div[id="google_vignette"],
div[id^="google_vignette_"],
div.google-vignette-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 0 !important;
  height: 0 !important;
}

/* Note: Removed overly aggressive selectors that were blocking scroll */
/* The JavaScript in main.php handles other overlay ads more safely */

/* Home layout ad spacing - rely on flex gap instead of margins */
.home-layout .ad-container {
  margin: 0;
}

/* Hide ads on print */
@media print {
  .ad-container {
    display: none;
  }
}

/* ================================================================
   ENHANCED MOBILE RESPONSIVENESS
   ================================================================ */

/* Tablet (768px and below) - Major layout adjustments */
@media (max-width: 768px) {

  /* Hero sections - centered layout */
  .home-hero,
  .current-hero {
    text-align: center;
    padding: var(--space-4);
  }

  .hero-content {
    align-items: center;
  }

  /* Navigation improvements */
  .navbar-menu {
    padding: var(--space-4);
    gap: var(--space-2);
  }

  .navbar-link {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
  }

  /* Dropdown menus - full width on mobile */
  .dropdown-menu {
    position: static;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
    margin-top: var(--space-2);
    background: var(--bg-tertiary);
  }

  .mega-menu {
    position: static;
    width: 100%;
    padding: var(--space-3);
  }

  .mega-menu-content {
    flex-direction: column;
    gap: var(--space-4);
  }

  .commands-grid-mini {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Cards - stack properly */
  .current-grid,
  .support-grid,
  .quick-links-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Watch cards - full width */
  .watch-card {
    padding: var(--space-4);
  }

  .watch-card h3 {
    font-size: var(--text-lg);
  }

  .watch-card ul {
    padding-left: var(--space-4);
  }

  /* Tables - horizontal scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Buttons - full width in hero areas */
  .hero-actions {
    flex-direction: column;
    width: 100%;
    gap: var(--space-3);
  }

  .hero-actions .btn {
    width: 100%;
    text-align: center;
  }

  /* Current page snapshot */
  .current-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3) 0;
  }

  .current-list li .pill {
    align-self: flex-start;
  }

  /* Command cards */
  .command-card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .command-preview-card {
    padding: var(--space-3);
  }

  .command-preview-card h4 {
    font-size: var(--text-sm);
  }

  /* Alert cards - proper stacking */
  .alert-card-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Level display */
  .level-badge-container {
    flex-direction: column;
    text-align: center;
    gap: var(--space-3);
  }

  /* Explore grid - single column on tablet */
  .explore-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

/* Small mobile (480px and below) - Fine-tuning */
@media (max-width: 480px) {

  /* Even smaller headings */
  h1 {
    font-size: 1.375rem;
    line-height: 1.3;
  }

  h2 {
    font-size: 1.125rem;
  }

  /* Container padding */
  .container {
    padding: 0 var(--space-3);
  }

  /* Force all grids to single column on small mobile */
  /* Exceptions: .command-symbol-grid and .regional-menu-links keep compact layout */
  .explore-grid,
  .quick-links-grid,
  .command-card-grid,
  .commands-grid,
  .commands-grid-enhanced,
  [class*="-grid"]:not(.command-symbol-grid):not(.regional-menu-links) {
    grid-template-columns: 1fr !important;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  /* Cards should be full width */
  .explore-card,
  .quick-link-card,
  .command-card,
  .feature-card {
    width: 100%;
    max-width: 100%;
  }

  /* Badge images */
  .hero-badge-img,
  .current-badge-img {
    max-width: 100px;
    max-height: 100px;
    width: auto;
    height: auto;
  }

  .hero-level-info,
  .current-badge {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
  }

  /* Command cards - single column on very small screens */
  .command-card-grid {
    grid-template-columns: 1fr;
  }

  /* Blips - stacked layout */
  .blip {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-3);
  }

  .blip-logo {
    margin-bottom: var(--space-2);
    width: 40px;
    height: 40px;
  }

  .blip-text {
    font-size: var(--text-sm);
  }

  /* Watch cards - tighter spacing */
  .watch-card {
    padding: var(--space-3);
  }

  .watch-card ul li {
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
  }

  /* Snapshot list */
  .current-list {
    font-size: var(--text-sm);
  }

  /* Pill badges */
  .pill {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
  }

  /* Buttons - proper sizing */
  .btn {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    min-height: 44px;
  }

  /* Footer */
  .footer {
    padding: var(--space-6) 0;
  }

  .footer-grid {
    gap: var(--space-4);
  }

  /* Share buttons */
  .share-buttons {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .share-btn {
    width: 44px;
    height: 44px;
  }

  /* Explore cards - full width on small mobile */
  .explore-card {
    padding: var(--space-4);
  }

  .explore-card h3 {
    font-size: var(--text-lg);
  }

  .home-cta-box .btn {
    width: 100%;
  }
}

/* Extra small screens (360px and below) */
@media (max-width: 360px) {
  h1 {
    font-size: 1.25rem;
  }

  .container {
    padding: 0 var(--space-2);
  }

  .level-big-number {
    font-size: 3rem;
  }

  /* Tighter card padding */
  .current-card,
  .watch-card,
  .faq-item {
    padding: var(--space-3);
  }

  /* Navbar - tighter */
  .navbar-logo {
    font-size: var(--text-sm);
  }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {

  .navbar,
  .footer,
  .share-section,
  .breaking-banner {
    display: none;
  }

  body {
    background: white;
    color: black;
  }
}

/* Command logo overlay rules consolidated in page-ported.css */

/* ================================================================
   RESPONSIVE IMAGES IN ALERT CONTENT
   ================================================================ */
/* === DUPLICATE WARNING (S566) ===
   The .alert-content img rules below are ALSO in public/css/content.css
   (canonical, loaded on alert detail pages). When editing image styles
   for alert pages, edit content.css, NOT this file. The duplicate here
   is preserved for non-alert pages that ALSO load this file via
   config/site.php site_css array. Don't assume edits here affect alert
   pages. === */
.alert-content img,
.alert-content-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.75rem 0;
  /* Tighter spacing - reduced from 1.5rem */
  display: block;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* === Image alignment classes (TinyMCE image-properties → "Class") ===
   Verified S566 via workbench.py render. The TinyMCE editor exposes
   these in the image dialog; the CSS below is what makes them actually
   work (previously the classes existed in the editor but had no CSS,
   so picking them was a no-op). */
.alert-content img.img-original {
  width: auto;
  max-width: 100%;
  margin: 1rem auto;
  display: block;
}
.alert-content img.img-full {
  width: 100%;
  max-width: 100%;
  margin: 1rem 0;
  display: block;
}
.alert-content img.img-center {
  display: block;
  margin: 1rem auto;
  max-width: 100%;
}
.alert-content img.img-left {
  float: left;
  margin: 0.25rem 1rem 0.5rem 0;
  max-width: 50%;
}
.alert-content img.img-right {
  float: right;
  margin: 0.25rem 0 0.5rem 1rem;
  max-width: 50%;
}
/* Clear floats from text-wrap images so following blocks don't collide. */
.alert-content p::after,
.alert-content figure::after { content: ""; display: table; clear: both; }

.alert-content img:hover,
.alert-content-image:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

/* Center images in paragraphs */
.alert-content p:has(img),
.alert-content>img {
  text-align: center;
  margin: 1rem 0;
  /* Reduced from 2rem */
}

.alert-content p img {
  margin: 0 auto;
}

/* Mobile: Even tighter image spacing */
@media (max-width: 768px) {

  .alert-content img,
  .alert-content-image {
    margin: 0.5rem 0;
    border-radius: 6px;
  }

  .alert-content p:has(img),
  .alert-content>img {
    margin: 0.5rem 0;
  }

  /* Editor image wrappers on mobile */
  .alert-content .editor-image-wrapper,
  .alert-content figure.editor-image-wrapper {
    margin: 0.5rem auto;
  }
}

/* IMAGE LIGHTBOX, Moved to engine plugin: plugins/image-lightbox/assets/image-lightbox.css */

/* ================================================================
   ERROR PAGES - Alert Lists
   ================================================================ */
.error-alerts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.error-alert-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: var(--space-2) var(--space-4);
  align-items: start;
  padding: var(--space-4);
  background: var(--bg-card);
  border-radius: 8px;
  border-left: 4px solid var(--accent-primary);
  transition: all var(--transition);
}

.error-alert-item:hover {
  background: var(--bg-tertiary);
  transform: translateX(4px);
}

.error-alert-title {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.error-alert-title a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-lg);
  line-height: 1.4;
}

.error-alert-title a:hover {
  text-decoration: underline;
  color: var(--text-primary);
}

.error-alert-meta {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  display: flex;
  gap: var(--space-3);
  align-items: center;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.error-alert-meta time {
  color: var(--text-muted);
}

.error-alert-command {
  padding: 0.2rem 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.error-alert-command a {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: var(--text-xs);
}

.error-alert-command a:hover {
  text-decoration: underline;
}

.error-alert-excerpt {
  grid-column: 1 / -1;
  grid-row: 2 / 3;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.6;
  margin: 0;
}

/* Responsive for error page alerts */
@media (max-width: 768px) {
  .error-alert-item {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: var(--space-2);
  }

  .error-alert-title {
    grid-column: 1;
    grid-row: 1;
  }

  .error-alert-meta {
    grid-column: 1;
    grid-row: 2;
    flex-wrap: wrap;
  }

  .error-alert-excerpt {
    grid-column: 1;
    grid-row: 3;
  }

  .error-alert-title a {
    font-size: var(--text-base);
  }
}

/* ================================================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   Reduce animations and transforms to prevent freezing in WebViews
   ================================================================ */

/* Reduce motion for users who prefer it */
@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;
  }

  /* Specifically disable infinite pulse animations */
  .raised-badge,
  .raised-badge-nav,
  .breaking-badge {
    animation: none;
  }

  /* Also apply on mobile devices (tablets + large phones in landscape) */
  @media (max-width: 1024px) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }

    .raised-badge,
    .raised-badge-nav,
    .breaking-badge {
      animation: none;
    }
  }
}

/* Specifically target problematic transforms on mobile */
@media (max-width: 768px) {

  .regional-menu-link:hover,
  .command-card:hover,
  .alert-card:hover,
  .feature-card:hover {
    transform: none !important;
  }

  /* Disable parallax effects */
  [style*="transform: translateY"],
  [style*="transform: translateX"] {
    transform: none !important;
  }

  /* scroll-behavior: auto already handled by the combined reduced-motion media query above */
}

/* ================================================================
   WEBVIEW-SAFE MODE
   Extra safeguards for in-app browsers (Telegram, Instagram, etc.)
   Applied via (hover: none) which targets touch devices
   ================================================================ */
@media (hover: none) {

  /* Kill animations on ad units in WebViews */
  .ad-unit,
  .ad-unit *,
  .ad-unit *::before,
  .ad-unit *::after {
    animation: none !important;
    transition: none !important;
  }

  /* Remove all transforms that could cause repaints */
  .navbar-link,
  .regional-menu-link,
  .command-card,
  .alert-card,
  .feature-card,
  .explore-card,
  .quick-link-card {
    transform: none !important;
    will-change: auto !important;
  }

  /* Prevent hover effects on ad elements */
  .ad-unit:hover,
  .ad-unit *:hover {
    transform: none !important;
    box-shadow: none !important;
  }
}

/* ================================================================
   TELEGRAM IN-APP BROWSER SAFE MODE
   Disables backdrop-filter, complex animations, and fixed
   background-attachment that cause rendering issues in Telegram.
   Class applied server-side via engine/core/head.php detection.
   ================================================================ */
.telegram-browser .share-header-bar,
.telegram-browser .navbar {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--bg-primary);
}

.telegram-browser .hero-section {
  background-attachment: scroll;
}

.telegram-browser * {
  animation-duration: 0s !important;
  transition-duration: 0.1s !important;
}

/* ================================================================
   UNIVERSAL MOBILE SAFEGUARDS
   Ensure page renders correctly on ALL mobile browsers
   ================================================================ */
@media screen and (max-width: 1024px) {

  /* Prevent body from being pushed off screen */
  html,
  body {
    position: relative;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  /* Ensure content is always visible */
  body>* {
    position: relative;
    z-index: 1;
  }

  /* Prevent any absolute/fixed elements from breaking layout */
  .container {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
}

/* Extra small screens (320px and below) */
@media screen and (max-width: 320px) {

  /* Ensure minimum readable font sizes, 18px floor for Journey/Mediavine */
  body {
    font-size: 18px;
  }

  /* Prevent content overflow */
  .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Ensure images don't overflow */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* Safe area insets for notched phones (iPhone X+, etc.) */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  .navbar {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/* ================================================================
   Journey/Mediavine CCPA "Do Not Sell", restyle as subtle footer link
   Injected by their CMP script. Cannot remove, so integrate visually.
   ================================================================ */
#consumer-privacy-footer-wrapper {
  position: static !important;
  display: block !important;
  background: none !important;
  border: none !important;
  padding: 8px 0 !important;
  margin: 0 !important;
  text-align: center !important;
  width: 100% !important;
}

.consumer-privacy-footer-btn {
  all: unset !important;
  color: #64748b !important;
  font-size: 12px !important;
  font-family: system-ui, sans-serif !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  cursor: pointer !important;
  padding: 4px 0 !important;
  display: inline !important;
  background: none !important;
  border: none !important;
}

.consumer-privacy-footer-btn:hover {
  color: #0ea5e9 !important;
  text-decoration: underline !important;
}

