/**
 * PHY Global Component Styles
 *
 * Loaded on every front-end page via wp_enqueue_style( 'phy-global-components' ).
 * Contains: Mission Control fixed bar, To-Top button, smooth-scroll.
 *
 * A2 FIX: Shared CSS custom properties consolidated into :root so they cascade
 * correctly and accessibility tools can override them at the document level.
 * Per-component declarations of these same variables removed from all PHY CSS files.
 *
 * DO NOT add page-specific styles here. Use phy-post.css or phy-archive.css.
 *
 * @package    Ahmed Alshamsy
 * @since      2.0.0
 */

/* =============================================================================
   CSS CUSTOM PROPERTIES — :root (A2 FIX)
   Shared variables used across phy-global.css, phy-post.css, phy-archive.css.
   Declaring here at :root allows browser/OS accessibility overrides to cascade.
   Component-specific values (e.g. --text-muted) remain scoped to their component.
   ============================================================================= */

:root {
  /* PALETTE: Blue / Red / Gold — القيم المعتمدة الموثّقة في style.css (TOKEN NOTE).
     كانت هنا قيم الهوية القديمة (أخضر + ذهب باهت #C5A059/#D4AF37) فتغلب القيم الصحيحة؛
     و--primary-teal كانت غير معرّفة أصلًا فتبطل كل قاعدة تستخدمها. */
  --teal-rgb:     21, 65, 147;
  --teal-dark:    #154193;
  --teal-mid:     #1A4FAE;
  --primary-teal: #154193;
  --teal-text:    #154193; /* Protocol card & component headings */
  --gold:         #F5B301;
  --gold-light:   #F4D06F;
  --text:         #1B2748;
}

/* =============================================================================
   BODY PADDING — CWV3 FIX (Cumulative Layout Shift)
   The fixed 70px mission control bar covers the bottom of page content on
   single posts. Padding is scoped to .phy-has-mission-bar, which is added via
   PHP body_class filter only on is_single() pages — the only pages where the
   full bar renders. Without this class scope, pages that use .phy-totop-only
   (height: 0) would show blank space under the footer.
   ============================================================================= */

.phy-has-mission-bar {
  padding-bottom: 70px; /* Match .phy-full-bar height */
}

@media (max-width: 600px) {
  .phy-has-mission-bar {
    padding-bottom: 60px; /* Match the 60px bar height at mobile breakpoint */
  }
}

/* =============================================================================
   MISSION CONTROL BAR — Fixed bottom navigation
   ============================================================================= */

#phy-mission-control {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
}

/* Full bar — single post pages */
.phy-full-bar {
  height: 70px;
  background: rgba(5, 11, 36, 0.98);
  border-top: 2px solid var(--gold-light);
  box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(12px); /* A5 FIX: vendor prefix for Android/Firefox */
          backdrop-filter: blur(12px);
}

/* To-Top only — all other pages (bar collapses, only button floats) */
.phy-totop-only {
  height: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
          backdrop-filter: none !important;
  pointer-events: none;
}

/* Control container */
.phy-control-container {
  display: flex;
  width: 100%;
  max-width: 800px;
  justify-content: space-between;
  align-items: center;
  height: 70px;
  padding: 0 15px;
  position: relative;
}

.phy-totop-only .phy-control-container {
  justify-content: flex-end;
  pointer-events: none;
}

/* Individual nav items */
.phy-control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  color: #cfdcf7; /* ≥ 10:1 contrast against #050B24 — passes WCAG AA/AAA */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1;
  height: 100%;
  pointer-events: auto;
}

/* To-Top button specifics */
.phy-totop-only .phy-totop-btn {
  flex: 0 0 50px;
  height: 50px;
  background: rgba(10, 18, 58, 0.55);
  border: 1px solid var(--gold-light);
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  /* UA reset — <button> adds padding, system font, and no cursor by default */
  padding: 0;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
          appearance: none;
}

/* To-Top button inside the FULL BAR (single post) — compact icon, no circle */
.phy-full-bar .phy-totop-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 6px;
  padding: 0;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
          appearance: none;
  box-shadow: none;
  /* Do not grow to fill bar height like the nav items */
  align-self: center;
  margin: 0;
}

/* Icons and labels */
.phy-icon svg {
  width: 22px;
  height: 22px;
}

.phy-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Hover states */
.phy-control-item:hover {
  color: var(--gold-light);
  background: linear-gradient(to top, rgba(212, 175, 55, 0.12), transparent);
}

.phy-control-item:hover .phy-icon svg {
  filter: drop-shadow(0 0 8px var(--gold-light));
  transform: translateY(-3px);
}

/* Keyboard focus indicator — WCAG 2.4.7 */
.phy-control-item:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
  border-radius: 4px;
  color: var(--gold-light);
}

/* Highlight item (Download/Assets) */
.highlight-item .phy-icon svg {
  color: #f7e08a;
}

/* =============================================================================
   SMOOTH SCROLL — respects prefers-reduced-motion (WCAG 2.3.3 best practice)
   ============================================================================= */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 600px) {
  .phy-full-bar {
    height: 60px;
  }

  .phy-control-container {
    height: 60px;
  }

  .phy-icon svg {
    width: 18px;
    height: 18px;
  }

  .phy-label {
    font-size: 8px;
  }
}

/* ── SKIP NAVIGATION LINK ─────────────────────────────────────
   Visually hidden until focused by keyboard navigation.
   WCAG 2.4.1 — Bypass Blocks (Level A)
   ─────────────────────────────────────────────────────────── */
.phy-skip-link {
  position: absolute;
  top: -100px;
  left: 6px;
  z-index: 999999;
  padding: 10px 20px;
  background: var(--teal-dark);
  color: var(--gold-light) !important;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  transition: top 0.15s ease;
}
.phy-skip-link:focus {
  top: 0;
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}