/* karaa-web/public/karaa-brand.css
 *
 * The Karaa brand layer for the xwui style system. This is NOT app styling —
 * it only customises xwui theme tokens (the supported customisation surface):
 * brand identity, and the per-theme page gradient (xwui has no gradient config
 * key, so a token override is the idiomatic way). Every value is composed from
 * xwui's own accent/background tokens, so it follows the active accent + the
 * light/dark `color` automatically. No component styling lives here.
 */

:root {
  --brand-name: 'Karaa';
  --brand-logo-url: '/logos/karaa-logo-english.svg';
  --brand-icon-set: 'material-icons';

  /* A proper Arabic + Latin webfont. !important wins over xwui's font token. */
}

/* ── Frosted-glass panels (hero filter bar + discover hero) ──────────────────
   These tokens were REFERENCED (home.css) but never DEFINED, so every glass
   panel fell back to a fixed white — staying white in dark mode. Define them
   theme-aware here: a translucent light panel in light, a translucent dark
   panel in dark, so the frosted look follows the theme. */
:root {
  --glass-bg-heavy: rgba(255, 255, 255, 0.55);
  --glass-blur: blur(14px);
  --glass-border: 1px solid rgba(255, 255, 255, 0.45);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
  /* App-background + hairline-border tokens: referenced across the page
     gradients, header and chips but never defined, so their light fallbacks
     rendered everywhere and never flipped. Define them = the body colour so
     section gradients and chips track the theme. */
  --bg-app: #f6f8f7;
  --border-light: #e2e8e4;
}
html[data-theme='dark'],
html[data-theme='night'] {
  --glass-bg-heavy: rgba(22, 24, 29, 0.62);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --bg-app: #0d0f12;
  --border-light: rgba(255, 255, 255, 0.1);
}
/* Per-language base font (self-hosted, see public/fonts.css). English = Inter,
   Arabic = IBM Plex Sans Arabic; each keeps the other as fallback so mixed
   Latin/Arabic runs always resolve. !important keeps it over xwui's token. */
html {
  --font-family:
    'Inter', 'IBM Plex Sans Arabic', 'Segoe UI', system-ui, sans-serif !important;
}
html[lang='ar'],
html[dir='rtl'] {
  --font-family:
    'IBM Plex Sans Arabic', 'Inter', 'Segoe UI', system-ui, sans-serif !important;
}

/* ── Royal green ──────────────────────────────────────────────────────────
   xwui's `emerald` accent is a bright mint (#10b981). Karaa uses a deeper,
   jewel-toned ROYAL GREEN. We keep accent="emerald" (so xwui loads a real
   accent file — no 404) and override its tokens here; !important beats the
   accent stylesheet xwui injects at runtime. The page gradient + buttons read
   these tokens, so the whole theme follows. Applies in light AND dark (both
   Karaa presets use accent="emerald"). */
/* Karaa colors now live in the xwui "karaa" accent + brand (theme/accents/
   karaa.css), selected via data-accent="karaa". No !important overrides. */
:root {
  /* Page gradient, composed from xwui tokens. Light default. */
  --karaa-page-gradient:
    radial-gradient(
      1200px 600px at 100% -10%,
      var(--accent-primary-light) 0%,
      transparent 60%
    ),
    radial-gradient(
      1000px 500px at -10% 10%,
      var(--accent-primary-soft) 0%,
      transparent 55%
    ),
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--accent-primary) 8%, var(--bg-app)) 0%,
      var(--bg-app) 45%,
      var(--bg-primary) 100%
    );
}

/* Light themes (default + explicit light). */
html[data-theme='light'] {
  --karaa-page-gradient:
    radial-gradient(
      1200px 600px at 100% -10%,
      var(--accent-primary-light) 0%,
      transparent 60%
    ),
    radial-gradient(
      900px 520px at -8% 8%,
      var(--accent-primary-soft) 0%,
      transparent 55%
    ),
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--accent-primary) 9%, #ffffff) 0%,
      var(--bg-app) 48%,
      #ffffff 100%
    );
}

/* Dark themes (deep teal-black → slate). */
html[data-theme='dark'],
html[data-theme='night'] {
  --karaa-page-gradient:
    radial-gradient(
      1200px 620px at 100% -10%,
      color-mix(in srgb, var(--accent-primary) 24%, transparent) 0%,
      transparent 60%
    ),
    radial-gradient(
      1000px 560px at -10% 6%,
      color-mix(in srgb, var(--accent-primary) 14%, transparent) 0%,
      transparent 55%
    ),
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--accent-primary) 14%, #05080b) 0%,
      var(--bg-app) 46%,
      var(--bg-secondary) 100%
    );
}

/* Apply the page background from the xwui --bg-gradient STYLE TOKEN (defined in
   xwui's per-theme colour files; themeable + accent-aware). We no longer compose
   our own gradient here — karaa just consumes the token, with the old
   --karaa-page-gradient kept only as a fallback for older xwui builds. */
html,
body {
  min-height: 100%;
  margin: 0 !important;
  /* xwui's base sheet sets body { padding: 20px }; it loads after this file, so
     !important is needed to keep the app full-bleed. */
  padding: 0 !important;
}
body {
  min-height: 100vh;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family);
}

#app {
  background: transparent;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* Karaa wordmark — PNG via xwui-logo `src` (see karaa-logo.ts). Sizing lives in
   header.css / footer.css; favicon uses /karaa-logo.svg (English SVG). */

/* ── Glass backgrounds — neutral base + an accent-tinted aurora ──────────────
   Both karaa presets use data-style="glass", so these two selectors cover all
   states. The double-attribute specificity (0,2,3) beats xwui's own glass
   gradient regardless of injection order. The blobs use var(--accent-primary-rgb)
   (fallback = brand tangerine) so the whole backdrop FOLLOWS the admin's accent
   instead of a hardcoded green wash. */

html[data-style='glass'][data-theme='dark'] body {
  background: #0d0f12;
}
html[data-style='glass'][data-theme='dark'] body::before {
  background:
    radial-gradient(62% 52% at 7% 14%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.22), transparent 65%),
    radial-gradient(50% 44% at 90% 7%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.16), transparent 64%),
    radial-gradient(66% 56% at 76% 90%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.13), transparent 68%),
    radial-gradient(44% 40% at 14% 86%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.10), transparent 65%),
    radial-gradient(40% 36% at 50% 52%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.07), transparent 70%),
    linear-gradient(165deg, #0b0d10 0%, #0d0f12 50%, #0a0c0f 100%);
  filter: blur(55px) saturate(1.4);
}

html[data-style='glass'][data-theme='light'] body {
  background: #f7f8fa;
}
html[data-style='glass'][data-theme='light'] body::before {
  background:
    radial-gradient(62% 52% at 7% 14%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.16), transparent 65%),
    radial-gradient(50% 44% at 90% 7%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.12), transparent 64%),
    radial-gradient(66% 56% at 76% 90%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.10), transparent 68%),
    radial-gradient(44% 40% at 14% 86%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.08), transparent 65%),
    radial-gradient(40% 36% at 50% 52%, rgba(var(--accent-primary-rgb, 242, 74, 26), 0.06), transparent 70%),
    linear-gradient(165deg, #fafbfc 0%, #f7f8fa 60%, #ffffff 100%);
  filter: blur(50px) saturate(1.4);
}

/* Gradient text — xwui-typography with color="gradient" adds .xw-gradient-text.
   Royal Green dark: bright mint → teal → gold. Light: deep forest → amber. */
html[data-style='glass'][data-theme='dark'] .xw-gradient-text {
  background: linear-gradient(130deg, #4ade80 0%, #10b981 42%, #d4af37 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
html[data-style='glass'][data-theme='light'] .xw-gradient-text {
  background: linear-gradient(130deg, #065f46 0%, #047857 42%, #b45309 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Layout scaffolding (token-driven only; widgets are all xwui) ──
   The deployed xwui layout components can't take dynamically-created children,
   so structure uses these classes. Every colour/space token comes from the
   active xwui theme — nothing hardcoded but neutral structural metrics. */

.karaa-page {
  /* --karaa-max is the shared *body* content width (karaa-tokens.css).
     Heroes/banners stay full-bleed outside this clamp (home) or opt out
     via zone rules (sell). */
  width: 100%;
  max-width: var(--karaa-max, 1240px);
  margin-inline: auto;
  padding: var(--spacing-lg, 24px) var(--spacing-lg, 24px)
    var(--spacing-2xl, 48px);
  box-sizing: border-box;
  min-width: 0;
}
/* Shared constrained column for content sitting inside a full-bleed hero */
.karaa-container {
  width: 100%;
  max-width: var(--karaa-max, 1240px);
  margin-inline: auto;
  padding-inline: var(--spacing-lg, 24px);
  box-sizing: border-box;
  min-width: 0;
}
@media (max-width: 720px) {
  .karaa-container {
    padding-inline: var(--spacing-md, 14px);
  }
}
.karaa-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(var(--karaa-min, 240px), 1fr)
  );
  gap: var(--karaa-gap, var(--spacing-lg, 18px));
  align-items: stretch;
}
.karaa-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--karaa-gap, var(--spacing-md, 12px));
}
.karaa-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--karaa-gap, var(--spacing-md, 14px));
}
.karaa-card-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm, 8px);
}
.karaa-surface {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm, 10px);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  border: var(--border-width-thin, 1px) solid var(--border-color);
  border-radius: var(--radius-lg, 14px);
  padding: var(--spacing-lg, 18px);
  align-content: stretch;
}
.xwui-stack {
  width: 100%;
}
.xwui-box-surface {
  height: stretch;
}
/* xwui-card handles elevation, radius, padding and hover — .karaa-card removed.
   Stretch the photo inside xwui-card so the <img> fills the aspect-ratio host.
   xwui-image sets container.style.aspectRatio on connect (source fixed); the CSS
   below ensures the inner wrapper chain and img fill that height (light DOM). */
xwui-card xwui-image {
  width: 100%;
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
}
xwui-card xwui-image[style*='aspect-ratio'],
xwui-card xwui-image[style*='aspect-ratio'] .xwui-image-container,
xwui-card xwui-image[style*='aspect-ratio'] .xwui-image-wrapper {
  height: 100%;
  overflow: hidden;
}
xwui-card xwui-image[style*='aspect-ratio'] img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sticky app bar — a themed glass surface holding xwui widgets. */
.karaa-appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md, 12px);
  padding: var(--spacing-sm, 10px) var(--spacing-lg, 22px);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border-block-end: var(--border-width-thin, 1px) solid var(--border-color);
}

@media (max-width: 720px) {
  .karaa-appbar {
    padding: var(--spacing-sm, 8px) var(--spacing-md, 12px);
  }
  .karaa-page {
    padding: var(--spacing-md, 14px) var(--spacing-md, 14px)
      var(--spacing-2xl, 40px);
  }
}

/* ── Map overrides ────────────────────────────────────────────────────────────
   Map tiles must always have sharp (zero) corners. The xwui-map component applies
   --radius-md internally and the mapEl helper previously added --radius-lg via
   inline style; both are overridden here with !important so no theme switch
   or token change can re-introduce rounded tiles. */
xwui-map,
xwui-map .xwui-map {
  border-radius: 0 !important;
  overflow: hidden !important;
}

/* xwui utilities.css applies `img { border-radius: var(--radius-photo) }` globally.
   That rule catches every Leaflet tile <img>, making each tile individually rounded.
   WHY !important: the global img rule is a low-specificity utility with no !important,
   but `xwui-map img` has the same specificity (0,0,2) — !important is the only safe
   way to guarantee the override survives any injection-order variation. */
xwui-map img {
  border-radius: 0 !important;
}

/* WHY isolation:isolate: Leaflet's internal panes use z-index 200-700 in the
   DOM stacking context. Without isolation, those z-indexes compete globally and
   paint above the sticky header's mobile navigation drawer (z-index:50 stacking
   context). isolation:isolate creates a new stacking context for the map element,
   containing all Leaflet z-indexes inside it so they no longer compete globally. */
xwui-map {
  isolation: isolate;
}

/* ── Mobile navigation backdrop ──────────────────────────────────────────────
   Full-viewport dim+blur overlay shown whenever the mobile nav drawer opens.
   The header's built-in __scrim is position:fixed inside the header, but
   backdrop-filter on the header bar creates a CSS containing block that anchors
   fixed children to the header element — so the scrim only covers the ~60px
   header bar, not the page below it. This element sits OUTSIDE the header and
   is not affected by that containing-block issue.
   z-index:45 = below header (50) + its drawer/scrim, above the map (isolated,
   z-index:auto) and all page content. */
.karaa-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px) saturate(0.8);
  -webkit-backdrop-filter: blur(6px) saturate(0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
/* :has() is supported in Chrome 105+, Safari 15.4+, Firefox 121+.
   Shows the backdrop whenever the header scrim is open (i.e., mobile menu open). */
body:has(.xwui-bar-site-header__scrim.is-open) .karaa-menu-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ── Page-transition: loading overlay that fades out ──────────────────────────
   render() in main.ts appends new view content VISIBLE (no opacity:0), covered
   by a position:absolute loading overlay. Once all xwui custom elements have
   hydrated the overlay fades out, revealing the fully-ready page beneath.

   WHY NOT opacity:0 on the content wrapper (previous approach):
   Leaflet (and other canvas/WebGL components) reads container dimensions at
   connectedCallback time. When the container is inside an opacity:0 ancestor
   some browsers skip GPU texture upload for the compositing layer, so tiles
   fetch successfully but never paint — resulting in blank map tiles on reveal.
   An opaque overlay avoids that: the content is always "visible" to the GPU. */

/* <main id="karaa-content"> is the anchor for the absolutely-positioned overlay.
   min-height ensures the overlay has at least 60vh to render the spinner in,
   even before the actual page content is appended. */
#karaa-content {
  position: relative;
  min-height: 60vh;
}

/* Absolute overlay — covers the full content area, sits above the page content
   (z-index:5), blocks interaction while loading (pointer-events on body handles
   scroll but clicks don't reach the content). Matches the page background so the
   partially-rendered content below is completely hidden. */
/* ── Video showreel (AI-generated looping car clips, landing page) ───────── */
.karaa-showreel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.karaa-showreel__card {
  position: relative;
  border-radius: var(--radius-lg, 14px);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #111;
  display: block;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  transition: box-shadow 0.25s;
}
.karaa-showreel__card:hover {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}
.karaa-showreel__card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}
.karaa-showreel__card:hover video {
  transform: scale(1.04);
}
.karaa-showreel__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.15) 55%,
    transparent 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px 20px;
  gap: 3px;
  pointer-events: none;
}
.karaa-showreel__title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}
.karaa-showreel__sub {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
}
.karaa-showreel__cta {
  display: inline-block;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: auto;
}
@media (max-width: 860px) {
  .karaa-showreel {
    grid-template-columns: 1fr;
  }
}

/* The favorites nav link used to be icon-only with a CSS ::after hover
   tooltip here. The link has a real text label (+ count badge) now, so the
   tooltip was a floating ghost pill — and its Arabic content: string rendered
   as mojibake when the raw-served file's charset was misread. Removed
   (client request, 3rd report). Being a pseudo-element, it never appeared in
   DOM inspection — check pseudo styles when "invisible" UI appears on hover. */
