/* ==========================================================================
   OTHMAN RIYADH® — GLOBAL PERSISTENT STICKY HEADER
   Master Design System & Brand Palette Integration
   Graphik Arabic & Graphik
   Glassmorphism, High-Performance Scroll Transitions & Full Accessibility
   ========================================================================== */

:root {
  --global-header-height: 74px;
}

@media (max-width: 640px) {
  :root {
    --global-header-height: 62px;
  }
}

/* Ensure anchor navigation never hides section headings behind the header */
html {
  scroll-padding-top: calc(var(--global-header-height, 74px) + 16px);
}

/* Subpages receive top compensation padding so content starts cleanly below header */
body.has-global-header.is-subpage {
  padding-top: var(--global-header-height, 74px);
}

@media (max-width: 640px) {
  body.has-global-header.is-subpage {
    padding-top: var(--global-header-height, 62px);
  }
}

/* ==========================================================================
   Global Header Master Component
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100%;
  box-sizing: border-box;
  padding: 24px 0;
  background-color: transparent;
  border-bottom: 1px solid transparent;
  box-shadow: none;
  transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              backdrop-filter 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              -webkit-backdrop-filter 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrolled State (Homepage after scrolling) and Subpage Base State */
.site-header.scrolled,
.site-header.is-subpage {
  padding: 14px 0;
  background-color: rgba(8, 8, 17, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

@media (max-width: 640px) {
  .site-header {
    padding: 16px 0;
  }
  .site-header.scrolled,
  .site-header.is-subpage {
    padding: 12px 0;
  }
}

/* Header Inner Grid Alignment */
.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(16px, 2.5vw, 32px);
  width: 100%;
}

@media (max-width: 959px) {
  .header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}

/* ==========================================================================
   Brand Logo
   ========================================================================== */
.brand-presence {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  justify-self: start;
  outline: none;
}

.brand-logo-pure {
  height: 42px;
  width: auto;
  max-width: 175px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
  transition: transform var(--transition-fast, 0.2s),
              opacity var(--transition-fast, 0.2s),
              filter var(--transition-fast, 0.2s);
}

.brand-presence:hover .brand-logo-pure,
.brand-presence:focus-visible .brand-logo-pure {
  transform: scale(1.04);
  opacity: 0.95;
  filter: drop-shadow(0 4px 14px rgba(245, 197, 66, 0.35));
}

@media (max-width: 640px) {
  .brand-logo-pure {
    height: 34px;
    max-width: 140px;
  }
}

/* ==========================================================================
   Desktop Navigation Links
   ========================================================================== */
.header-nav {
  display: none;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: clamp(16px, 2vw, 32px);
}

@media (min-width: 960px) {
  .header-nav {
    display: flex;
  }
}

.header-nav-link {
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  color: rgba(248, 250, 252, 0.78);
  transition: color var(--transition-fast, 0.2s);
  position: relative;
  padding: 6px 0;
  white-space: nowrap;
  text-decoration: none;
  outline: none;
}

.header-nav-link:hover,
.header-nav-link:focus-visible {
  color: var(--accent-gold, #f5c542);
}

.header-nav-link.active {
  color: var(--accent-gold, #f5c542);
  font-weight: 600;
}

.header-nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-gold, #f5c542);
  transition: width var(--transition-fast, 0.2s);
  border-radius: var(--radius-full, 9999px);
}

.header-nav-link:hover::after,
.header-nav-link:focus-visible::after,
.header-nav-link.active::after {
  width: 100%;
}

/* ==========================================================================
   Header Actions (Language Toggle, Pill Contact CTA, Mobile Toggle)
   ========================================================================== */
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 12px;
}

/* Glassmorphism Language Switch Button */
.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-full, 9999px);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: #ffffff;
  transition: all var(--transition-fast, 0.2s);
  cursor: pointer;
  box-sizing: border-box;
  text-decoration: none;
  outline: none;
}

.lang-switch-btn:hover,
.lang-switch-btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(245, 197, 66, 0.45);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35), 0 0 16px rgba(245, 197, 66, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
  color: #ffffff;
}

.lang-indicator {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold, #f5c542);
}

/* Pill Contact CTA Button */
.header-cta-pill {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 42px;
  padding: 0 6px 0 20px;
  border-radius: var(--radius-full, 9999px);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast, 0.2s);
  box-sizing: border-box;
  white-space: nowrap;
  outline: none;
}

html[dir="rtl"] .header-cta-pill {
  padding: 0 20px 0 6px;
}

@media (min-width: 768px) {
  .header-cta-pill {
    display: inline-flex;
  }
}

.header-cta-pill .cta-pill-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--accent-gold, #f5c542);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast, 0.2s);
  flex-shrink: 0;
}

.header-cta-pill:hover,
.header-cta-pill:focus-visible {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(245, 197, 66, 0.5);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 24px rgba(245, 197, 66, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

.header-cta-pill:hover .cta-pill-arrow,
.header-cta-pill:focus-visible .cta-pill-arrow {
  background: rgba(245, 197, 66, 0.25);
  border-color: var(--accent-gold, #f5c542);
  color: var(--accent-gold, #f5c542);
  transform: scale(1.08) rotate(45deg);
}

html[dir="rtl"] .header-cta-pill .cta-pill-arrow svg {
  transform: scaleX(-1);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full, 9999px);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-primary, #f8fafc);
  transition: all var(--transition-fast, 0.2s);
  cursor: pointer;
  outline: none;
}

@media (min-width: 960px) {
  .mobile-menu-toggle {
    display: none;
  }
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(245, 197, 66, 0.4);
  color: var(--accent-gold, #f5c542);
}

/* ==========================================================================
   Mobile Drawer Navigation Overlay
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 85%;
  max-width: 360px;
  background-color: #0c0c16;
  border-left: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
  z-index: 2001;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px 24px;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  overflow-y: auto;
  right: 0;
  left: auto;
  transform: translateX(100%);
}

html[dir="rtl"] .mobile-drawer {
  left: 0;
  right: auto;
  border-left: none;
  border-right: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
  transform: translateX(-100%);
}

.drawer-backdrop.active .mobile-drawer {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
}

.drawer-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
  color: var(--text-primary, #f8fafc);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
  outline: none;
}

.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent-gold, #f5c542);
  border-color: rgba(245, 197, 66, 0.4);
}

.drawer-nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
  color: var(--text-primary, #f8fafc);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 500;
  transition: color 0.2s, padding-inline-start 0.2s;
}

.drawer-nav-item:hover,
.drawer-nav-item:focus-visible {
  color: var(--accent-gold, #f5c542);
  padding-inline-start: 6px;
}

.drawer-nav-item.active {
  color: var(--accent-gold, #f5c542);
  font-weight: 600;
}

html[dir="rtl"] .drawer-arrow {
  transform: scaleX(-1);
}

.drawer-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle, rgba(165, 180, 252, 0.1));
}

.drawer-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-full, 9999px);
  background: var(--accent-gold, #f5c542);
  color: #080811;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.drawer-cta-btn:hover {
  background: #ffd666;
  transform: translateY(-1px);
}

/* ==========================================================================
   Page Integration (Subpage Sticky Navs Alignment)
   ========================================================================== */
/* On Portfolio Archive page, sticky controls bar sticks below global header */
.v2-controls-wrapper {
  position: sticky;
  top: var(--global-header-height, 74px) !important;
  z-index: 50;
}

/* On Case Study pages, secondary sticky nav sticks below global header */
.v2-cs-nav {
  position: sticky;
  top: var(--global-header-height, 74px) !important;
  z-index: 100;
}

@media (max-width: 640px) {
  .v2-controls-wrapper {
    top: var(--global-header-height, 62px) !important;
  }
  .v2-cs-nav {
    top: var(--global-header-height, 62px) !important;
  }
}

/* ==========================================================================
   Light Mode Theme Overrides
   ========================================================================== */
[data-theme="light"] .site-header.scrolled,
[data-theme="light"] .site-header.is-subpage,
.light-mode .site-header.scrolled,
.light-mode .site-header.is-subpage {
  background-color: rgba(248, 250, 252, 0.94);
  border-bottom-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .header-nav-link,
.light-mode .header-nav-link {
  color: #475569;
}

[data-theme="light"] .header-nav-link:hover,
[data-theme="light"] .header-nav-link.active,
.light-mode .header-nav-link:hover,
.light-mode .header-nav-link.active {
  color: #b45309;
}

[data-theme="light"] .header-nav-link::after,
.light-mode .header-nav-link::after {
  background-color: #b45309;
}

[data-theme="light"] .lang-switch-btn,
.light-mode .lang-switch-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1e293b;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .lang-switch-btn:hover,
.light-mode .lang-switch-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(180, 83, 9, 0.35);
  color: #1e293b;
}

[data-theme="light"] .lang-indicator,
.light-mode .lang-indicator {
  color: #b45309;
}

[data-theme="light"] .header-cta-pill,
.light-mode .header-cta-pill {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1e293b;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .header-cta-pill .cta-pill-arrow,
.light-mode .header-cta-pill .cta-pill-arrow {
  background: rgba(180, 83, 9, 0.1);
  border-color: rgba(180, 83, 9, 0.25);
  color: #b45309;
}

[data-theme="light"] .mobile-menu-toggle,
.light-mode .mobile-menu-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1e293b;
}

[data-theme="light"] .mobile-drawer,
.light-mode .mobile-drawer {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .drawer-close-btn,
.light-mode .drawer-close-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #1e293b;
}

[data-theme="light"] .drawer-nav-item,
.light-mode .drawer-nav-item {
  color: #1e293b;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .drawer-nav-item:hover,
[data-theme="light"] .drawer-nav-item.active,
.light-mode .drawer-nav-item:hover,
.light-mode .drawer-nav-item.active {
  color: #b45309;
}
