/* ==========================================================================
   Layout — header, navigation, drawer, footer, page heroes, sections, grids
   ========================================================================== */

/* ---------------------------------------------------------------- header */
/* Placeholder replaced by the real header (layout.js): reserving its height means the page
   never jumps when the header appears. The home page uses a fixed overlay header instead. */
div[data-component='header'] { height: var(--header-h); }
div[data-component='header'][data-overlay] { height: 0; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13, 16, 21, 0.72);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.site-header.is-scrolled { background: rgba(11, 14, 19, 0.92); border-bottom-color: var(--border); }
.site-header--overlay { position: fixed; inset-inline: 0; background: linear-gradient(180deg, rgba(9, 11, 15, 0.75), rgba(9, 11, 15, 0)); backdrop-filter: none; -webkit-backdrop-filter: none; }
.site-header--overlay.is-scrolled { background: rgba(11, 14, 19, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--heading);
  flex-shrink: 0;
}
.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--c-beige);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--c-ivory);
  position: relative;
}
.brand__mark::after {
  content: '';
  position: absolute;
  inset-inline-end: -5px;
  bottom: -5px;
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 1px;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-family: var(--font-display); font-size: 1.2rem; letter-spacing: 0.01em; }
html[lang='ar'] .brand__name { font-weight: 700; font-size: 1.15rem; }
.brand__tag { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.22em; color: var(--text-dim); text-transform: uppercase; }

.main-nav { display: none; align-items: center; gap: var(--sp-1); margin-inline-start: var(--sp-4); }
.main-nav__link,
.main-nav__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 var(--sp-3);
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.main-nav__link:hover,
.main-nav__trigger:hover,
.main-nav__trigger[aria-expanded='true'] { color: var(--heading); background: rgba(244, 238, 227, 0.05); }
.main-nav__link[aria-current='page'] { color: var(--heading); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.main-nav__trigger svg { width: 14px; height: 14px; transition: transform var(--dur-fast) var(--ease); }
.main-nav__trigger[aria-expanded='true'] svg { transform: rotate(180deg); }

.nav-item { position: relative; }
.mega {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: -12px;
  min-width: 300px;
  max-width: min(640px, 90vw);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
}
.mega.is-open { opacity: 1; visibility: visible; transform: none; }
.mega__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--sp-4); }
.mega__group-title { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-2); color: var(--heading); font-weight: 600; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.mega__group-title:hover { background: rgba(244, 238, 227, 0.05); }
.mega__link { display: block; padding: 6px var(--sp-2); color: var(--text-muted); font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.mega__link:hover { color: var(--heading); background: rgba(244, 238, 227, 0.05); }
.mega__footer { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }

.header-actions { display: flex; align-items: center; gap: var(--sp-2); margin-inline-start: auto; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.icon-btn:hover { color: var(--heading); background: rgba(244, 238, 227, 0.06); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn__dot {
  position: absolute;
  top: 7px;
  inset-inline-end: 7px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.2);
}
.lang-switch button {
  min-width: 36px;
  height: 28px;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.lang-switch button[aria-pressed='true'] { background: var(--c-ivory); color: var(--c-ink-900); }

.user-menu { position: relative; }
.user-menu__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-3) 0 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: var(--fs-sm);
}
html[dir='rtl'] .user-menu__btn { padding: 0 4px 0 var(--sp-3); }
.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-navy-600);
  color: var(--c-ivory);
  font-weight: 600;
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 230px;
  padding: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 120;
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 40px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: start;
}
.menu__item:hover { background: rgba(244, 238, 227, 0.06); color: var(--heading); }
.menu__item svg { width: 18px; height: 18px; color: var(--text-muted); }
.menu__sep { height: 1px; margin: var(--sp-2) 0; background: var(--border); }
.menu__head { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-2); }

.nav-toggle { display: inline-grid; }

/* ---------------------------------------------------------------- mobile drawer */
/* Mounted directly under <body> (never inside the blurred header). Slides in from the
   inline-end side — where the menu button sits — in both LTR and RTL. */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  justify-content: flex-end;
  visibility: hidden;
  pointer-events: none;
  /* keep the panel visible while it slides out, then hide it */
  transition: visibility 0s linear var(--dur-slow);
}
.drawer.is-open { visibility: visible; pointer-events: auto; transition-delay: 0s; }
.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer__panel {
  position: relative;
  width: min(380px, 88vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 50% at 100% 0%, rgba(34, 53, 85, 0.45), transparent 60%),
    var(--surface);
  border-inline-start: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  will-change: transform;
}
html[dir='rtl'] .drawer__panel { transform: translateX(-100%); }
.drawer.is-open .drawer__panel { transform: none; }

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--header-h);
  padding: 0 var(--sp-4) 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
html[dir='rtl'] .drawer__head { padding: 0 var(--sp-5) 0 var(--sp-4); }
.drawer__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-4) var(--sp-4) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.drawer__search { position: relative; display: flex; align-items: center; margin-bottom: var(--sp-3); }
.drawer__search > svg { position: absolute; inset-inline-start: 14px; width: 18px; height: 18px; color: var(--text-dim); pointer-events: none; }
.drawer__search .input { min-height: 46px; padding-inline-start: 42px; border-radius: var(--radius-pill); font-size: var(--fs-sm); }

.drawer__nav { display: flex; flex-direction: column; gap: 2px; }
.drawer__nav:empty { display: none; }
.drawer__label {
  margin: var(--sp-5) var(--sp-3) var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-dim);
}
html[lang='ar'] .drawer__label { font-family: var(--font-body); font-size: var(--fs-xs); text-transform: none; letter-spacing: 0; }

.drawer__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 50px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.drawer__link::-webkit-details-marker { display: none; }
.drawer__link > svg { width: 20px; height: 20px; color: var(--text-dim); flex-shrink: 0; }
.drawer__link > span { flex: 1; min-width: 0; }
.drawer__link:hover, .drawer__link:active { background: rgba(244, 238, 227, 0.06); color: var(--heading); }
.drawer__link[aria-current='page'] { background: rgba(244, 238, 227, 0.07); color: var(--heading); }
.drawer__link[aria-current='page']::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.drawer__link[aria-current='page'] > svg { color: var(--c-beige); }
.drawer__chev { width: 18px !important; height: 18px !important; transition: transform var(--dur) var(--ease); }
.drawer__group[open] > .drawer__link { color: var(--heading); }
.drawer__group[open] .drawer__chev { transform: rotate(180deg); }

.drawer__sub {
  display: flex;
  flex-direction: column;
  margin: 2px 0 var(--sp-2);
  border-inline-start: 1px solid var(--border);
  margin-inline-start: calc(var(--sp-3) + 9px);
  padding-inline-start: var(--sp-4);
}
.drawer__sublink {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 42px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.drawer__sublink svg { color: var(--text-dim); }
.drawer__sublink:hover, .drawer__sublink:active { color: var(--heading); background: rgba(244, 238, 227, 0.05); }
.drawer__sublink--head { color: var(--heading); font-weight: 600; margin-top: var(--sp-1); }
.drawer__sublink--all { color: var(--c-beige); }

.drawer__foot {
  flex-shrink: 0;
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) calc(var(--sp-4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(9, 11, 15, 0.35);
}
.drawer__lang { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.drawer__auth { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.drawer__auth .btn { min-height: 46px; }

/* Page behind an open drawer does not scroll (drawer body uses overscroll-behavior: contain) */
body.is-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer__panel, .drawer__backdrop { transition: none; }
}

/* ---------------------------------------------------------------- footer */
.site-footer {
  position: relative;
  margin-top: auto;
  padding: var(--sp-16) 0 var(--sp-8);
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.site-footer__grid { display: grid; gap: var(--sp-10); grid-template-columns: 1fr; }
.site-footer__brand p { max-width: 36ch; margin-top: var(--sp-4); }
.site-footer h3 { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-dim); margin-bottom: var(--sp-4); }
html[lang='ar'] .site-footer h3 { font-family: var(--font-body); font-size: var(--fs-sm); text-transform: none; }
.site-footer__links { display: grid; gap: var(--sp-2); }
.site-footer__links a:hover { color: var(--heading); }
.site-footer__bottom {
  margin-top: var(--sp-12);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-6);
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}
.social { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.social a { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 50%; color: var(--text-muted); }
.social a:hover { color: var(--heading); border-color: var(--c-beige); }
.social svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- page hero (inner pages) */
.page-hero {
  position: relative;
  padding: calc(var(--sp-12) + 1vw) 0 var(--sp-12);
  background:
    var(--contours) center / 700px repeat,
    radial-gradient(120% 140% at 85% 0%, rgba(34, 53, 85, 0.65) 0%, rgba(13, 16, 21, 0) 60%),
    linear-gradient(180deg, var(--c-navy-900), var(--bg));
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.page-hero__media { position: absolute; inset: 0; z-index: 0; }
.page-hero__media img { width: 100%; height: 100%; object-fit: cover; opacity: 0.32; filter: grayscale(0.35) contrast(1.05); }
.page-hero__media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 19, 34, 0.55) 0%, var(--bg) 100%); }
.page-hero > .container { position: relative; z-index: 1; }
.page-hero h1 { margin-top: var(--sp-3); font-size: var(--fs-4xl); }
.page-hero__lead { margin-top: var(--sp-4); max-width: 62ch; color: var(--text-muted); font-size: var(--fs-lg); }
.page-hero__meta { margin-top: var(--sp-5); display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); }
.page-hero__coords { position: absolute; inset-inline-end: var(--gutter); bottom: var(--sp-5); z-index: 1; font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.18em; color: var(--text-dim); }

/* ---------------------------------------------------------------- sections */
.section { position: relative; padding: var(--section-y) 0; }
.section--tight { padding: calc(var(--section-y) * 0.6) 0; }
.section--deep { background: var(--bg-deep); }
.section--navy { background: linear-gradient(180deg, var(--c-navy-900), var(--c-navy-950)); }
.section--paper { color: var(--paper-ink); }
.section + .section:not(.section--paper):not(.section--navy):not(.section--deep) { padding-top: 0; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4) var(--sp-8);
  margin-bottom: var(--sp-10);
}
.section-head__text { max-width: 60ch; }
.section-head h2 { margin-top: var(--sp-3); }
.section-head p { margin-top: var(--sp-3); color: var(--text-muted); }
.section--paper .section-head p { color: var(--paper-ink-muted); }

/* ---------------------------------------------------------------- grids */
.grid { display: grid; gap: var(--grid-gap, var(--sp-6)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 272px), 1fr)); }
.grid--wide-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.grid--tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: repeat(2, 1fr); }

/* Scroll rail for mobile carousels */
.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(82%, 300px);
  gap: var(--sp-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--sp-3);
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }

/* Two-column page body (scenario page, checkout) */
.split { display: grid; gap: var(--sp-10); grid-template-columns: 1fr; align-items: start; }
.split__aside { position: relative; }
