/* ==========================================================================
   Ghandour Global Group — Base stylesheet
   Design tokens, reset, header/nav, shared components, footer, accessibility.
   Loaded on every page before the page-specific stylesheet.
   ========================================================================== */

/* ==========================================================================
   Ghandour Global Group — Global Stylesheet
   Design tokens sourced from GGG Brand Guidelines v01 (2025).
   The visual layer here is intentionally minimal placeholder styling;
   it will be replaced/extended once the final UI design is provided.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens (brand)
   -------------------------------------------------------------------------- */
:root {
  /* Primary colors */
  --color-blue: #0040e0;        /* Blue — primary brand color */
  --color-blue-black: #010b1b;  /* Blue Black — primary dark */

  /* Secondary colors */
  --color-dark-blue: #0c316b;   /* Dark Blue (RGB 12,49,107 per guidelines) */
  --color-green: #1fcc1f;       /* Green accent */

  /* Neutrals */
  --color-white: #ffffff;
  --color-grey-050: #f5f7fc;
  --color-grey-200: #dde3ee;
  --color-grey-600: #56607a;

  /* Typography — Montserrat primary, Poppins secondary */
  --font-primary: "Montserrat", "Segoe UI", Arial, sans-serif;
  --font-secondary: "Poppins", "Segoe UI", Arial, sans-serif;

  /* Layout */
  --container-max: 1140px;
  --space-section: clamp(3rem, 8vw, 5.5rem);
  --radius: 12px;
  /* Real height of .site-header (js/main.js measures and overrides this
     exactly, including its 1px bottom border) — every sticky offset
     below reads from here instead of a hardcoded guess, so content
     never sits a pixel or two under the header. */
  --header-h: 73px;

  /* ------------------------------------------------------------------
     Motion system. Durations/eases below name values that were already
     the most common choice somewhere on the site (grep-audited) rather
     than inventing new numbers, so wiring an existing rule to a token
     is a rename, not a visual change. --ease-standard and --ease-spring
     are the two curves new/refined work should reach for: --ease-spring
     is reserved for a small number of one-shot confirmation moments
     (card first-reveal, success states) per design direction - it is
     not meant to become the default for continuous/looping motion.
     ------------------------------------------------------------------ */
  --duration-instant: 120ms;
  --duration-fast: 150ms;
  --duration-quick: 180ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;
  --duration-slower: 600ms;

  --ease-linear: linear;
  /* Alias for the plain "ease" keyword, distinct from --ease-out/--ease-in-out
     below - kept separate so existing bare `ease` transitions can be
     retargeted to a token without silently swapping in a different curve. */
  --ease-default: ease;
  --ease-out: ease-out;
  --ease-in-out: ease-in-out;
  /* The calm "settle" curve - already the most-used content-reveal
     easing site-wide (Industries page transitions/animations). */
  --ease-standard: cubic-bezier(0.65, 0, 0.35, 1);
  /* Reserved for one-shot moments only - see note above. This is the exact
     curve every card/panel "pop-in" reveal across Melon360, eMagine,
     Electrify Arabia and WattsWhere already used independently (verified:
     none of its usages are on a looping `animation`, only one-shot
     `transition`-driven reveals) - tokenized below without changing the
     value, so nothing regresses visually, and any future spring use has one
     name to reach for instead of a 13th hand-typed copy of this curve. */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ------------------------------------------------------------------
     Surface tokens: one blue glow, one green accent glow (per brand
     direction), a small blur scale matching the 4 blur radii already in
     use across the site, a radius scale building on --radius above, and
     the header's z-index promoted to a named layer.
     ------------------------------------------------------------------ */
  --glow-blue: 0 14px 28px rgba(0, 64, 224, 0.35);
  --glow-green: 0 14px 28px rgba(31, 204, 31, 0.35);

  --shadow-sm: 0 4px 10px rgba(1, 6, 16, 0.28);
  --shadow-md: 0 16px 32px rgba(1, 6, 16, 0.36);
  --shadow-lg: 0 30px 54px rgba(1, 6, 16, 0.4);
  /* Deeper ambient drop shadow shared by the "console" panels (Melon360,
     eMagine, Electrify Arabia, WattsWhere, Industries, Contact) - a
     distinct size/color from --shadow-lg, not a redundant near-copy of it. */
  --shadow-console: 0 34px 64px rgba(0, 0, 0, 0.38);

  --blur-xs: 3px;
  --blur-sm: 5px;
  --blur-md: 6px;
  --blur-lg: 8px;

  --radius-sm: 8px;
  --radius-md: var(--radius);
  --radius-lg: 20px;
  /* The same 6 console panels above also share this radius exactly -
     named here instead of six copies of the bare number. */
  --radius-xl: 22px;
  --radius-pill: 999px;

  --z-header: 100;
  --z-overlay: 200;
}

/* --------------------------------------------------------------------------
   2. Base / reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-secondary);
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-blue-black);
  background: var(--color-white);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-primary);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.6em;
  color: var(--color-blue-black);
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
h3 { font-size: 1.15rem; }

p {
  margin: 0 0 1em;
}

a {
  color: var(--color-blue);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* js/motion-utils.js's pauseWhenOffscreen() toggles this on a page's hero
   stage while it is scrolled out of view, so the always-on decorative loops
   inside it (orbit rings, pulses, scans) stop consuming compositor/GPU time
   until it scrolls back in. The per-scene "only animate the active one"
   pairs already in this file (e.g. .subsidiary-world.is-active
   .charging-pulse) live in unrelated subtrees and are unaffected.
   !important is deliberate and necessary here, not a specificity shortcut:
   nearly every animated element sets the `animation` shorthand, which
   implicitly resets animation-play-state to "running" as part of the
   shorthand - since those per-element rules are equal-specificity to this
   one class + universal selector and sit later in the file, a plain
   declaration here would lose the cascade to every single one of them. */
.is-idle,
.is-idle * {
  animation-play-state: paused !important;
}

/* --------------------------------------------------------------------------
   2b. Page transitions (progressive enhancement)

   Opts every same-origin navigation between pages into the browser's
   native cross-document View Transition: the outgoing page crossfades
   into the incoming one instead of a hard cut. Pure CSS, no JS - browsers
   that don't support the `@view-transition` at-rule (Safari, Firefox as
   of this writing) simply ignore it and navigate exactly as before, so
   there's no fallback branch to maintain and no risk of a broken
   in-between state. Nothing here can delay navigation: the transition is
   a visual overlay the browser paints during a swap that happens either
   way, not a JS-timed "wait, then navigate" pattern.
   -------------------------------------------------------------------------- */
@view-transition {
  navigation: auto;
}

/* Root crossfade only - short and subtle, and deliberately not tagging
   individual elements with view-transition-name, which would risk a
   header/hero "morphing" between two pages where that element's size or
   position differs, instead of the plain fade this is meant to be. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--duration-base);
  animation-timing-function: var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   3. Layout helpers
   -------------------------------------------------------------------------- */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.section {
  padding-block: var(--space-section);
}

/* Shared dark "flow" scaffolding: every page's first section is a
   `class="home-flow X-flow"` pair - this bare rule (the dark gradient +
   faint grid overlay) is what every page actually renders, while the
   page-specific X-flow class in each page stylesheet layers its own
   accent-tinted radial gradients on top via ::after. */
.home-flow {
  position: relative;
  overflow: clip;
  background:
    radial-gradient(circle at 74% 12%, rgba(31, 204, 31, 0.16), transparent 25rem),
    radial-gradient(circle at 18% 40%, rgba(0, 64, 224, 0.2), transparent 30rem),
    linear-gradient(180deg, #010b1b 0%, #07152f 38%, #04070f 68%, #010b1b 100%);
  color: var(--color-white);
}

.home-flow::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(180deg, transparent, #000 14%, #000 84%, transparent);
}

/* --------------------------------------------------------------------------
   4. Header / navigation

   Every page opens on a dark .home-flow hero directly under the header
   (its gradient's top stop is #010b1b, i.e. --color-blue-black exactly).
   The header stays position: sticky - a real transparent/overlaying
   header would need the hero pulled up behind it via negative margin,
   which risks nudging every scroll-progress rect.top calculation across
   the site's pinned flow/globe/strategy sections. Matching the header's
   idle background to that same dark color instead gets the seamless,
   integrated look with zero layout change: no visible seam, hero reads
   as continuing straight through the header. Once scrolled past the
   hero it picks up its own tinted-glass surface (see .is-scrolled below),
   so the header doesn't introduce a second surface language.
   Because both states are always dark, nav/brand text stays on
   light-on-dark colors throughout rather than flipping color per section.
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--color-blue-black);
  border-bottom: 1px solid transparent;
  transition:
    background var(--duration-slow) var(--ease-standard),
    border-color var(--duration-slow) var(--ease-standard),
    box-shadow var(--duration-slow) var(--ease-standard);
}

.site-header.is-scrolled {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 38%),
    rgba(4, 11, 27, 0.72);
  backdrop-filter: blur(var(--blur-md)) saturate(160%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-sm);
}

@media (prefers-reduced-transparency: reduce) {
  .site-header.is-scrolled {
    background: var(--color-blue-black);
    backdrop-filter: none;
  }
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  transition: min-height var(--duration-slow) var(--ease-standard);
}

.site-header.is-scrolled .header-inner {
  min-height: 60px;
}

/* Text-based brand mark placeholder — swap for the official logo image
   (assets/img/) once exported. Min logo width per guidelines: 100px. */
.brand {
  font-family: var(--font-primary);
  font-weight: 700;
  text-decoration: none;
  color: var(--color-white);
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.brand span {
  display: block;
  font-weight: 500;
  font-size: 0.72em;
  /* Light-blue tint already used for blue accents on dark surfaces
     (see .particle-flow span) — brand blue itself is too low-contrast
     against the always-dark/transparent header. */
  color: #7aa0ff;
}

.site-nav ul {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  position: relative;
  font-family: var(--font-primary);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.82);
  padding-block: 0.5rem;
  transition: color var(--duration-fast) var(--ease-default);
}

/* Glowing underline sweeps in on hover / current page */
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0.15rem;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--color-blue);
  box-shadow: 0 0 8px rgba(0, 64, 224, 0.7);
  transition: right var(--duration-base) var(--ease-default);
}

.site-nav a:hover::after,
.site-nav a:focus::after,
.site-nav a[aria-current="page"]::after {
  right: 0;
}

.site-nav a:hover,
.site-nav a:focus,
.site-nav a[aria-current="page"] {
  color: var(--color-white);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-default),
    border-color var(--duration-fast) var(--ease-default);
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Hamburger → close: three lines that collapse/rotate into an X, driven
   directly off aria-expanded instead of a second JS-managed class - the
   button's accessible state and its visual state can't drift apart. */
.nav-toggle-box {
  position: relative;
  display: block;
  width: 20px;
  height: 14px;
}

.nav-toggle-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--color-white);
  transition:
    transform var(--duration-base) var(--ease-standard),
    opacity var(--duration-fast) var(--ease-default),
    top var(--duration-base) var(--ease-standard);
}

.nav-toggle-line:nth-child(1) { top: 0; }
.nav-toggle-line:nth-child(2) { top: 6px; }
.nav-toggle-line:nth-child(3) { top: 12px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; }

  .site-nav {
    position: absolute;
    inset-inline: 0;
    top: 100%;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 38%),
      rgba(4, 11, 27, 0.92);
    backdrop-filter: blur(var(--blur-md)) saturate(160%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    padding: 1rem 1.25rem 1.5rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition:
      opacity var(--duration-base) var(--ease-standard),
      transform var(--duration-base) var(--ease-standard),
      visibility 0s linear var(--duration-base);
  }

  .site-nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition:
      opacity var(--duration-base) var(--ease-standard),
      transform var(--duration-base) var(--ease-standard),
      visibility 0s linear 0s;
  }

  .site-nav ul {
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (prefers-reduced-transparency: reduce) {
  @media (max-width: 800px) {
    .site-nav {
      background: var(--color-blue-black);
      backdrop-filter: none;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .header-inner,
  .site-nav,
  .nav-toggle-line {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   5. Components
   -------------------------------------------------------------------------- */
.hero {
  background: linear-gradient(120deg, var(--color-blue-black), var(--color-dark-blue));
  color: var(--color-white);
  padding-block: clamp(4rem, 12vw, 8rem);
}

.hero h1 {
  color: var(--color-white);
  max-width: 20ch;
}

.hero p {
  max-width: 55ch;
  font-size: 1.1rem;
  opacity: 0.9;
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-blue);
  margin-bottom: 0.75rem;
}

.card {
  background: var(--color-white);
  border: 1px solid var(--color-grey-200);
  border-radius: var(--radius-md);
  padding: 1.75rem;
}

.card h3 a {
  color: inherit;
  text-decoration: none;
}

.card h3 a:hover {
  color: var(--color-blue);
}

.card p:last-child {
  margin-bottom: 0;
}

.btn {
  display: inline-block;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-pill);
  background: var(--color-blue);
  color: var(--color-white);
  border: 2px solid var(--color-blue);
  transition:
    background var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default),
    transform var(--duration-quick) var(--ease-default),
    box-shadow var(--duration-quick) var(--ease-default);
}

/* will-change is applied only while the button is actively transforming
   (hover/focus), not permanently on every button on every page - an
   always-on compositor layer promotion here was pure waste, since most
   buttons never move outside these two states. */
.btn:hover,
.btn:focus,
.btn:focus-visible {
  background: var(--color-dark-blue);
  border-color: var(--color-dark-blue);
  /* Subtle 3D lift-and-tilt on hover */
  transform: perspective(600px) translateY(-2px) rotateX(8deg);
  box-shadow: var(--glow-blue);
  will-change: transform;
}

/* Tactile press feedback: settles closer to flat and snaps back faster
   than the hover lift, so clicking/tapping reads as an actual press. */
.btn:active {
  transform: perspective(600px) translateY(0) rotateX(0deg) scale(0.98);
  transition-duration: var(--duration-instant);
}

.btn--ghost {
  background: transparent;
  color: var(--color-white);
  border-color: var(--color-white);
}

.btn--ghost:hover,
.btn--ghost:focus,
.btn--ghost:focus-visible {
  background: var(--color-white);
  color: var(--color-blue-black);
  border-color: var(--color-white);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 1.75rem;
}

.breadcrumb {
  font-size: 0.85rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.4rem;
  color: var(--color-grey-600);
}

.breadcrumb a {
  color: var(--color-grey-600);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-blue);
}

.lead {
  font-size: 1.15rem;
  max-width: 65ch;
}

/* --------------------------------------------------------------------------
   6. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--color-blue-black);
  color: var(--color-white);
  padding-block: 3rem 2rem;
  font-size: 0.95rem;
}

.site-footer a {
  color: var(--color-white);
}

.site-footer a:hover {
  color: var(--color-green);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 700px) {
  .footer-grid { grid-template-columns: 1fr; }
}

.footer-grid h3 {
  color: var(--color-white);
  font-size: 1rem;
}

.footer-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-grid li {
  margin-bottom: 0.5rem;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 1.5rem;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Generic fade-up reveal: elements tagged .fade-up rise into place when
   scrolled into view (js/main.js adds .in-view); siblings stagger. */
.fade-up {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.fade-up.in-view {
  opacity: 1;
  transform: none;
}

.fade-up.in-view + .fade-up.in-view { transition-delay: 0.12s; }
.fade-up.in-view + .fade-up.in-view + .fade-up.in-view { transition-delay: 0.24s; }
.fade-up.in-view + .fade-up.in-view + .fade-up.in-view + .fade-up.in-view { transition-delay: 0.36s; }

/* Footer columns fade up in sequence when scrolled into view
   (js/main.js adds .in-view) */
.site-footer .footer-grid > div,
.site-footer .footer-bottom {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.site-footer .footer-grid > div:nth-child(2) { transition-delay: 0.12s; }
.site-footer .footer-grid > div:nth-child(3) { transition-delay: 0.24s; }
.site-footer .footer-bottom { transition-delay: 0.36s; }

.site-footer.in-view .footer-grid > div,
.site-footer.in-view .footer-bottom {
  opacity: 1;
  transform: none;
}

.site-footer.in-view .footer-bottom {
  opacity: 0.8;
}

/* Shared across every page - moved out of what was a single
   page-spanning reduced-motion block in the pre-split stylesheet. */
@media (prefers-reduced-motion: reduce) {
  .btn:hover,
  .btn:focus,
  .btn:focus-visible,
  .btn:active { transform: none; }

  .site-footer .footer-grid > div,
  .site-footer .footer-bottom {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .site-footer .footer-bottom { opacity: 0.8; }

  .fade-up {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   12. Accessibility
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-blue);
  color: var(--color-white);
  padding: 0.75rem 1.25rem;
  z-index: 200;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--color-green);
  outline-offset: 2px;
}
