/*!
Theme: Glory
File: assets/css/root.css
Purpose:
- Global tokens (colors, radii, shadows, motion)
- Base element defaults
- Accessibility helpers
- Layout helpers (container, skip-link)
Notes:
- Header spacing is applied ONLY when the fixed theme header exists (via :has(#siteHeader)).
- Admin bar + safe-area offsets are handled via CSS vars.
*/

/* ==========================================================================
   0) Modern CSS sanity
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

 html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce){
  html { scroll-behavior: auto; }
}

/* Make native controls match theme in modern browsers */
:root { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

/* ==========================================================================
   1) Design tokens
   ========================================================================== */
:root{
  /* Layout */
  --container: 1200px;
  --gutter: 2rem;
  --header-h: 78px;
  /* Responsive header height (smaller on narrow screens) */
  --header-h-sm: 64px;

  /* Radii */
  --radius: 18px;
  --radius-sm: 14px;

  /* Motion */
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 520ms;
  --ease: cubic-bezier(.2,.8,.2,1);

  /* Fonts
     - English: system stack
     - Arabic/RTL: Cairo (enqueue conditionally), with safe fallbacks
  */
  --font-sans-en: "Segoe UI", system-ui, -apple-system, "Segoe UI Variable", Roboto, Helvetica, Arial, sans-serif;
  --font-sans-ar: "Cairo", "Noto Kufi Arabic", "Tahoma", "Arial", sans-serif;

  /* Safe-area support (iOS notch) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* WP admin bar height (fallback); JS may override with exact height */
  --wp-admin-bar-h: 0px;

  /* Computed: top offset for fixed header */
  --site-header-top: calc(var(--wp-admin-bar-h) + var(--safe-top));

  /* Light theme colors */
  --bg: #ffffff;
  --text: #0f172a;
  --muted: rgba(15,23,42,.68);

  --border: rgba(15,23,42,.12);
  --chip: rgba(15,23,42,.06);

  /* Brand */
  --brand: rgb(8, 77, 59);
  --brand2: rgb(16, 185, 129);
  --glory-accent: var(--brand);
  --glory-accent-2: var(--brand2);

  /* Effects */
  --shadow: 0 18px 54px rgba(0,0,0,.14);
  --shadow2: 0 10px 26px rgba(0,0,0,.10);

  --overlay: rgba(15,23,42,.55);

  /* Focus ring (used by .focus-ring helper) */
  --ring: rgba(8,77,59,.35);
  --focus: var(--ring);

  /* Glass surfaces */
  --glass: rgba(255,255,255,.72);
  --glass-strong: rgba(255,255,255,.86);
  --surface: var(--glass);
}

html[data-theme="dark"]{
  --bg: #0b1220;
  --text: #e6e8ef;
  --muted: rgba(230,232,239,.70);

  --border: rgba(230,232,239,.16);
  --chip: rgba(230,232,239,.10);

  --brand: rgb(52, 211, 153);
  --brand2: rgb(16, 185, 129);
  --glory-accent: var(--brand);
  --glory-accent-2: var(--brand2);

  --shadow: 0 22px 70px rgba(0,0,0,.40);
  --shadow2: 0 12px 36px rgba(0,0,0,.30);

  --overlay: rgba(0,0,0,.65);
  --ring: rgba(52,211,153,.35);
  --focus: var(--ring);

  --glass: rgba(15,27,51,.70);
  --glass-strong: rgba(15,27,51,.82);
  --surface: var(--glass);
}

/* Arabic / RTL font switch */
html[lang="ar"] body,
html[dir="rtl"] body{
  font-family: var(--font-sans-ar);
}

/* ==========================================================================
   2) Base element defaults
   ========================================================================== */
body{
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;

  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: clamp(0.9375rem, 1.8vw + 0.5rem, 1rem);

  font-family: var(--font-sans-en);
  font-weight: 400;

  /* IMPORTANT:
     Do NOT apply header padding globally.
     We add it only when #siteHeader exists (see section 4).
  */
  padding-top: 0;
}

/* Lock scroll when safety modals are open */
body.glory-modal-open{
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

/* Responsive images site-wide */
img{
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}
a{ color: inherit; text-decoration: none; }

button, select, input, textarea{ font: inherit; }
button{ -webkit-tap-highlight-color: transparent; }

/* Reduce jank from layout shifts in some pages */
main{ display: block; }

/* ==========================================================================
   3) Accessibility helpers
   ========================================================================== */
.sr-only,
.screen-reader-text{
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Consistent keyboard focus */
.focus-ring:focus-visible{
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 999px;
}

/* Skip link (template-parts/components/skip-link.php) */
.glory-skip-link{
  position: fixed;
  inset-inline-start: 1rem;
  top: calc(.6rem + var(--site-header-top));
  padding: .55rem .9rem;

  background: var(--glass-strong);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow2);

  transform: translateY(-170%);
  transition: transform var(--dur) var(--ease);

  z-index: 9999;
}
.glory-skip-link:focus{ transform: translateY(0); }

/* ==========================================================================
   4) Fixed header layout safety
   ========================================================================== */
/* Admin bar compatibility (fallback). JS may set --wp-admin-bar-h precisely. */
body.admin-bar{ --wp-admin-bar-h: 32px; }
@media (max-width: 782px){
  body.admin-bar{ --wp-admin-bar-h: 46px; }
}

/* Responsive header height: smaller on narrow screens */
@media (max-width: 600px){
  :root{ --header-h: var(--header-h-sm); }
}

/* Fixed header top offset (also respects safe-area). */
.site-header{ top: var(--site-header-top); }

/* Apply body top padding ONLY if theme header exists.
   - Avoids whitespace on Elementor Canvas or pages that intentionally omit header.
   - Uses :has() so it’s automatic (no PHP body_class needed).
*/
body:has(#siteHeader){
  padding-top: calc(var(--header-h, 78px) + var(--site-header-top));
}
body:has(#siteHeader):has(.glory-front){
  padding-top: 0;
}

/* Optional: if you want a class-based fallback, you can add has-glory-header too:
   body.has-glory-header { padding-top: calc(var(--header-h) + var(--site-header-top)); }
*/

/* Global header behavior overrides */
body.glory-header-overlay:has(#siteHeader){
  padding-top: 0;
}
body.glory-header-solid:has(#siteHeader){
  padding-top: calc(var(--header-h) + var(--site-header-top));
}

/* ==========================================================================
   5) Layout helper
   ========================================================================== */
.container,
.glory-container{
  width: min(var(--container), calc(100% - var(--gutter)));
  margin-inline: auto;
}

/* ==========================================================================
   5b) Rank Math breadcrumbs (SEO)
   ========================================================================== */
.glory-breadcrumbs{
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.glory-breadcrumbs .glory-container{
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.glory-breadcrumbs a{
  color: var(--text);
  text-decoration: none;
}
.glory-breadcrumbs a:hover{
  text-decoration: underline;
}
.glory-breadcrumbs .rank-math-breadcrumb{
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

/* Breadcrumbs: responsive and overflow-safe */
.glory-breadcrumbs .glory-container{
  min-width: 0;
  overflow-wrap: break-word;
}
@media (max-width: 520px){
  .glory-breadcrumbs{
    padding: 0.4rem 0;
    font-size: 0.8125rem;
  }
  .glory-breadcrumbs .glory-container{ gap: 0.2rem; }
}

/* ==========================================================================
   6) Utility: Back to top (floating)
   ========================================================================== */
.glory-to-top{
  position: fixed;
  inset-inline-start: 1rem;
  bottom: max(1rem, var(--safe-bottom));

  width: 54px;
  height: 54px;

  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--glass-strong, rgba(255,255,255,.88));
  color: var(--text);
  box-shadow: var(--shadow2, 0 10px 26px rgba(0,0,0,.12));

  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 1800;

  opacity: 0;
  transform: translateY(10px) scale(.96);
  pointer-events: none;

  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.glory-to-top.is-visible{
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.glory-to-top:hover{
  background: var(--glass, rgba(255,255,255,.72));
  transform: translateY(-1px) scale(1.01);
}

.glory-to-top:focus-visible{
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.glory-to-top__icon{
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
}

.glory-to-top__icon svg{
  width: 22px;
  height: 22px;
  fill: currentColor;
  opacity: .95;
}

.glory-to-top__progress{
  position: absolute;
  inset: 8px;
  transform: rotate(-90deg);
  z-index: 1;
}

.glory-to-top__track,
.glory-to-top__bar{
  fill: none;
  stroke-width: 4;
}

.glory-to-top__track{
  stroke: rgba(15,23,42,.14);
}
html[data-theme="dark"] .glory-to-top__track{
  stroke: rgba(230,232,239,.18);
}

.glory-to-top__bar{
  stroke: currentColor;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  opacity: .9;
}

/* ==========================================================================
   7) Reduced motion override (global)
   ========================================================================== */
@media (prefers-reduced-motion: reduce){
  *{
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
  }
}
