/* ============================================================
   SaudiOne Tourism Theme - Base Styles
   Brand Identity: Saudi Green + Desert Gold on Deep Navy
   All colors driven by CSS custom properties set from admin.
   ============================================================ */

:root {
  /* --- Green Palette --- */
  --so-primary: #087F72;
  --so-primary-dark: #05635A;
  --so-primary-light: #10A899;
  --so-mint-glow: #BFE7E1;
  --so-pale-green: #E6F4F2;

  /* --- Gold / Sand Palette --- */
  --so-secondary: #FF725E;
  --so-secondary-dark: #D9482F;
  --so-secondary-light: #FFD9D2;
  --so-diriyah-tan: #E9A08F;
  --so-sand-light: #FFF7ED;

  /* --- Navy Palette --- */
  --so-deep-navy: #162B3A;
  --so-royal-navy: #1F3B4D;
  --so-twilight: #2E5468;

  /* --- Neutrals --- */
  --so-cloud: #F8F9FA;
  --so-ash: #E8E6E1;
  --so-stone: #9B9689;
  --so-charcoal: #3A3A38;
  --so-near-black: #1A1A18;
  --so-white: #ffffff;

  /* --- Semantic Mappings --- */
  --so-header-bg: #162B3A;
  --so-header-text: #ffffff;
  --so-footer-bg: #162B3A;
  --so-footer-text: #9B9689;
  --so-body-bg: #ffffff;
  --so-body-text: #1A1A18;

  /* --- Legacy aliases (for components that reference old names) --- */
  --so-accent-blue: #2E5468;
  --so-accent-gold: #FF725E;
  --so-gray-50: #F8F9FA;
  --so-gray-100: #F8F9FA;
  --so-gray-200: #E8E6E1;
  --so-gray-300: #E8E6E1;
  --so-gray-500: #9B9689;
  --so-gray-700: #3A3A38;
  --so-gray-900: #1A1A18;

  /* --- Typography --- */
  --so-font-sans: 'Inter', 'Tajawal', system-ui, -apple-system, sans-serif;
  --so-font-heading: 'Space Grotesk', 'Tajawal', system-ui, -apple-system, sans-serif;
  --so-font-arabic: 'Tajawal', sans-serif;

  /* Type Scale: Display 48px, H1 36px, H2 28px, H3 22px, Body 16px, Caption 13px */
  --so-font-size-base: 16px;
  --so-font-size-display: 3rem;       /* 48px */
  --so-font-size-h1: 2.25rem;         /* 36px */
  --so-font-size-h2: 1.75rem;         /* 28px */
  --so-font-size-h3: 1.375rem;        /* 22px */
  --so-font-size-body: 1rem;          /* 16px */
  --so-font-size-caption: 0.8125rem;  /* 13px */

  --so-line-height-base: 1.6;

  /* --- Spacing --- */
  --so-spacing-xs: 0.25rem;
  --so-spacing-sm: 0.5rem;
  --so-spacing-md: 1rem;
  --so-spacing-lg: 1.5rem;
  --so-spacing-xl: 2rem;
  --so-spacing-2xl: 3rem;

  /* --- Radii --- */
  --so-radius-sm: 0.375rem;
  --so-radius-md: 0.75rem;
  --so-radius-lg: 0.75rem;
  --so-radius-xl: 1rem;
  --so-radius-full: 9999px;

  /* --- Shadows --- */
  --so-shadow-sm: 0 1px 2px rgba(22,43,58, 0.06);
  --so-shadow-md: 0 4px 6px -1px rgba(22,43,58, 0.1);
  --so-shadow-lg: 0 10px 15px -3px rgba(22,43,58, 0.1);
}

/* --- RTL: swap to Arabic font --- */
[dir="rtl"] :root {
  --so-font-sans: 'Tajawal', 'Inter', system-ui, -apple-system, sans-serif;
  --so-font-heading: 'Tajawal', 'Space Grotesk', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--so-font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--so-font-sans);
  line-height: var(--so-line-height-base);
  color: var(--so-body-text);
  background: var(--so-body-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[dir="rtl"] body {
  direction: rtl;
}

a {
  color: var(--so-primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--so-primary-dark);
}

/* Image loading placeholder — shimmer animation until loaded */
@keyframes so-img-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

img {
  max-width: 100%;
  height: auto;
  content-visibility: auto;
}

/* Lazy-loaded images get a shimmer placeholder */
img[loading="lazy"] {
  background: linear-gradient(
    90deg,
    var(--so-cloud, #f0f0f0) 25%,
    var(--so-ash, #e0e0e0) 50%,
    var(--so-cloud, #f0f0f0) 75%
  );
  background-size: 200% 100%;
  animation: so-img-shimmer 1.5s ease-in-out infinite;
  min-height: 80px;
}

/* Remove shimmer once image is loaded (CSS :not can't detect load,
   so we use a tiny JS in saudione.js to add a class, but as a
   fallback the shimmer is invisible once the image paints over it) */
img[loading="lazy"].so-img-loaded {
  background: none;
  animation: none;
  min-height: auto;
}

/* Card image containers — ensure placeholder fills the space */
.so-card__image {
  background: linear-gradient(
    90deg,
    var(--so-cloud, #f0f0f0) 25%,
    var(--so-ash, #e0e0e0) 50%,
    var(--so-cloud, #f0f0f0) 75%
  );
  background-size: 200% 100%;
  animation: so-img-shimmer 1.5s ease-in-out infinite;
  min-height: 120px;
  border-radius: var(--so-radius-md, 0.5rem) var(--so-radius-md, 0.5rem) 0 0;
}

/* Stop shimmer on card once image is inside and loaded */
.so-card__image:has(img.so-img-loaded),
.so-card__image:has(img[src]) {
  animation: none;
}

/* Detail page gallery placeholder */
.so-detail__gallery,
.so-news__hero-image {
  background: var(--so-cloud, #f3f4f6);
  min-height: 200px;
  border-radius: 12px;
}

/* Reduced motion: disable shimmer */
@media (prefers-reduced-motion: reduce) {
  img[loading="lazy"],
  .so-card__image {
    animation: none;
    background: var(--so-cloud, #f0f0f0);
  }
}

/* Optimize rendering for off-screen content */
.region-content > *:nth-child(n+3) {
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

/* Optimize font rendering */
@font-face {
  font-display: swap;
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  font-family: var(--so-font-heading);
  font-weight: 700;
  line-height: 1.3;
  color: var(--so-body-text);
}
h1 { font-size: var(--so-font-size-h1); }
h2 { font-size: var(--so-font-size-h2); }
h3 { font-size: var(--so-font-size-h3); }
h4 { font-size: 1.25rem; }

/* Display heading utility */
.so-display {
  font-size: var(--so-font-size-display);
  font-weight: 700;
  line-height: 1.1;
}

/* Caption utility */
.so-caption {
  font-size: var(--so-font-size-caption);
  color: var(--so-stone);
}
