/*
(c) Spacehubs Africa. All rights reserved.
Licensed under the Proprietary License found in the LICENSE file
in the root directory of this source tree.
*/

/* ── Pan-African palette ───────────────────────────────────────────────────
   The --color-sha-* custom properties consumed via var(--color-sha-*) in this
   file (and across the app) are no longer declared here. They are rendered
   into an inline <style> in <head> — before this file loads — by the
   {% palette_root_style %} template tag (sh_database/templatetags/custom_filters.py),
   which reads the single canonical source: palette/tokens.json.

   To add or change a colour: edit palette/tokens.json only. tailwind.config.js
   reads it directly at build time; base.html/conference.css get it from
   {% palette_root_style %}/{% palette_theme_vars %}; entity_taxonomy.py and
   sha_palette.js (via an embedded JSON blob) read it through Python. Nothing
   else needs to change by hand.
────────────────────────────────────────────────────────────────────────── */
/* ── Typeface ───────────────────────────────────────────────────────────────
   Inter, self-hosted (CSP font-src allows SELF only — no external CDN). The
   variable woff2 covers weights 100–900 in one file. The Tailwind `font-sans`
   stack (tailwind.config.js + base.html @theme mirror) lists Inter first; this
   body rule guarantees it applies even before/independent of the compiled CSS.
────────────────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-variable.260c81a4759b.woff2") format('woff2');
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji';
}

:root {
  color-scheme: light;

  --surface:                 #ffffff;
  --surface-raised:          #ffffff;
  --surface-muted:           #f8fafc;
  --surface-subtle:          #f1f5f9;
  --surface-disabled:        #f3f4f6;
  --surface-inverse:         #111827;
  --text-primary:            #0f172a;
  --text-secondary:          #334155;
  --text-muted:              #64748b;
  --text-subtle:             #68778d;
  --text-disabled:           #9ca3af;
  --text-inverse:            #ffffff;
  --border:                  #e2e8f0;
  --border-subtle:           #f1f5f9;
  --border-strong:           #7e8fa4;
  --border-input:            #d1d5db;
  --focus-ring:              color-mix(in srgb, var(--color-sha-indigo) 20%, transparent);
  --focus-ring-strong:       color-mix(in srgb, var(--color-sha-indigo) 30%, transparent);
  --overlay-surface:         color-mix(in srgb, var(--surface) 78%, transparent);
  --overlay-inverse-soft:    color-mix(in srgb, var(--surface-inverse) 4%, transparent);
  --overlay-inverse-muted:   color-mix(in srgb, var(--surface-inverse) 5%, transparent);
  --overlay-inverse:         color-mix(in srgb, var(--surface-inverse) 45%, transparent);
  --overlay-inverse-strong:  color-mix(in srgb, var(--surface-inverse) 65%, transparent);
  --shadow-xs:               color-mix(in srgb, var(--surface-inverse) 2%, transparent);
  --shadow-sm:               color-mix(in srgb, var(--surface-inverse) 4%, transparent);
  --shadow-md:               color-mix(in srgb, var(--surface-inverse) 10%, transparent);
  --shadow-lg:               color-mix(in srgb, var(--surface-inverse) 18%, transparent);
  --shadow-xl:               color-mix(in srgb, var(--surface-inverse) 28%, transparent);
  --scrollbar-thumb:         color-mix(in srgb, var(--surface-inverse) 28%, transparent);
  --scrollbar-thumb-hover:   color-mix(in srgb, var(--surface-inverse) 42%, transparent);
}

html.dark {
  color-scheme: dark;

  --surface:                 #0f172a;
  --surface-raised:          #1e293b;
  --surface-muted:           #0b1120;
  --surface-subtle:          #1e293b;
  --surface-disabled:        #374151;
  --surface-inverse:         #f8fafc;
  --text-primary:            #f1f5f9;
  --text-secondary:          #cbd5e1;
  --text-muted:              #94a3b8;
  --text-subtle:             #64748b;
  --text-disabled:           #6b7280;
  --text-inverse:            #0f172a;
  --border:                  #334155;
  --border-subtle:           #1e293b;
  --border-strong:           #475569;
  --border-input:            #4b5563;
  --focus-ring:              color-mix(in srgb, var(--color-sha-indigo) 30%, transparent);
  --focus-ring-strong:       color-mix(in srgb, var(--color-sha-indigo) 40%, transparent);
  --overlay-surface:         color-mix(in srgb, var(--surface) 82%, transparent);
  --overlay-inverse-soft:    color-mix(in srgb, var(--surface-inverse) 8%, transparent);
  --overlay-inverse-muted:   color-mix(in srgb, var(--surface-inverse) 12%, transparent);
  --overlay-inverse:         color-mix(in srgb, var(--surface-inverse) 45%, transparent);
  --overlay-inverse-strong:  color-mix(in srgb, var(--surface-inverse) 65%, transparent);
  --shadow-xs:               color-mix(in srgb, black 18%, transparent);
  --shadow-sm:               color-mix(in srgb, black 25%, transparent);
  --shadow-md:               color-mix(in srgb, black 50%, transparent);
  --shadow-lg:               color-mix(in srgb, black 60%, transparent);
  --shadow-xl:               color-mix(in srgb, black 70%, transparent);
  --scrollbar-thumb:         color-mix(in srgb, var(--surface-inverse) 18%, transparent);
  --scrollbar-thumb-hover:   color-mix(in srgb, var(--surface-inverse) 32%, transparent);
}

/* ── SHA palette opacity utilities ─────────────────────────────────────────
   Tailwind cannot apply opacity modifiers to CSS-variable color values, so
   opacity variants are defined here via color-mix(). The solid sha-* classes
   (bg/text/border) are generated by Tailwind using var(--color-sha-*) and
   automatically pick up dark-mode overrides from html.dark { ... } above. */

.bg-sha-indigo-bg\/30  { background-color: color-mix(in srgb, var(--color-sha-indigo-bg) 30%, transparent) !important; }
.bg-sha-indigo-bg\/40  { background-color: color-mix(in srgb, var(--color-sha-indigo-bg) 40%, transparent) !important; }
.bg-sha-indigo-bg\/60  { background-color: color-mix(in srgb, var(--color-sha-indigo-bg) 60%, transparent) !important; }
.bg-sha-indigo-bg\/75  { background-color: color-mix(in srgb, var(--color-sha-indigo-bg) 75%, transparent) !important; }
.bg-sha-indigo-bg\/80  { background-color: color-mix(in srgb, var(--color-sha-indigo-bg) 80%, transparent) !important; }
.bg-sha-gold-bg\/40    { background-color: color-mix(in srgb, var(--color-sha-gold-bg) 40%, transparent) !important; }
.bg-sha-gold-bg\/60    { background-color: color-mix(in srgb, var(--color-sha-gold-bg) 60%, transparent) !important; }
.bg-sha-gold-bg\/70    { background-color: color-mix(in srgb, var(--color-sha-gold-bg) 70%, transparent) !important; }
.bg-sha-red-bg\/60     { background-color: color-mix(in srgb, var(--color-sha-red-bg) 60%, transparent) !important; }
.bg-sha-teal-bg\/40    { background-color: color-mix(in srgb, var(--color-sha-teal-bg) 40%, transparent) !important; }
.bg-sha-teal-bg\/60    { background-color: color-mix(in srgb, var(--color-sha-teal-bg) 60%, transparent) !important; }
.bg-sha-purple-bg\/60  { background-color: color-mix(in srgb, var(--color-sha-purple-bg) 60%, transparent) !important; }
.bg-sha-orange-bg\/40  { background-color: color-mix(in srgb, var(--color-sha-orange-bg) 40%, transparent) !important; }
.bg-sha-orange-bg\/60  { background-color: color-mix(in srgb, var(--color-sha-orange-bg) 60%, transparent) !important; }
.bg-sha-rose-bg\/80    { background-color: color-mix(in srgb, var(--color-sha-rose-bg) 80%, transparent) !important; }

/* Contextual rail accent — set via data-accent on a rail root so rail chrome
   themes from the shared SHA token pipeline instead of a hardcoded indigo.
   Per-category rules (companies/agencies/academia/...) are rendered
   server-side from entity_taxonomy.py's CATEGORY_ACCENT by the
   category_rail_accent_style template tag (see templates/base.html) instead
   of being hand-authored here, so they can't drift from the taxonomy.
   This is only the fallback for a data-accent value with no category rule. */
[data-accent] {
  --rail-accent:        var(--color-sha-indigo);
  --rail-accent-bg:     var(--color-sha-indigo-bg);
  --rail-accent-border: var(--color-sha-indigo-border);
  --rail-accent-text:   var(--color-sha-indigo-text);
}

.bg-surface { background-color: var(--surface); }
.bg-surface\/55 { background-color: color-mix(in srgb, var(--surface) 55%, transparent); }
.bg-surface\/95 { background-color: color-mix(in srgb, var(--surface) 95%, transparent); }
.bg-surface-raised { background-color: var(--surface-raised); }
.bg-surface-muted { background-color: var(--surface-muted); }
.bg-surface-subtle { background-color: var(--surface-subtle); }
.bg-surface-disabled { background-color: var(--surface-disabled); }
.bg-surface-inverse { background-color: var(--surface-inverse); }
.hover\:bg-surface-muted:hover { background-color: var(--surface-muted); }
.hover\:bg-surface-subtle:hover { background-color: var(--surface-subtle); }
.hover\:bg-sha-indigo-bg:hover { background-color: var(--color-sha-indigo-bg); }
/* Hand-written like the hover rule above: in dev, Tailwind runs via the
   @tailwindcss/browser CDN (see base.html use_tailwind_browser), which wraps
   generated utilities in native @layer blocks. Per the cascade spec, ANY
   unlayered rule beats a layered one regardless of specificity — so without
   this, the plain .bg-surface/.text-muted/.border-border rules above always
   win over peer-checked:*, and selected pills never visibly highlight in
   dev even though the compiled prod stylesheet (no @layer) gets it right. */
.peer:checked ~ .peer-checked\:bg-sha-indigo-bg { background-color: var(--color-sha-indigo-bg); }
.peer:checked ~ .peer-checked\:border-sha-indigo-border { border-color: var(--color-sha-indigo-border); }
.peer:checked ~ .peer-checked\:text-sha-indigo-text { color: var(--color-sha-indigo-text); }
.peer:focus-visible ~ .peer-focus-visible\:ring-2 { box-shadow: 0 0 0 2px var(--color-sha-indigo); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-disabled { color: var(--text-disabled); }
.text-inverse { color: var(--text-inverse); }
.hover\:text-secondary:hover { color: var(--text-secondary); }
.hover\:text-muted:hover { color: var(--text-muted); }
.border-border { border-color: var(--border); }
.border-border-subtle { border-color: var(--border-subtle); }
.border-border-strong { border-color: var(--border-strong); }
.border-input { border-color: var(--border-input); }
.divide-border > :not([hidden]) ~ :not([hidden]) { border-color: var(--border); }
.divide-border-strong > :not([hidden]) ~ :not([hidden]) { border-color: var(--border-strong); }
.ring-border { --tw-ring-color: var(--border); }
.ring-border-strong { --tw-ring-color: var(--border-strong); }
.placeholder-muted::placeholder { color: var(--text-subtle); }

.site-footer {
  border-top: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--surface-raised);
  position: relative;
}

.site-footer::before {
  background: var(--color-sha-indigo);
  content: "";
  height: 2px;
  inset-block-start: -1px;
  inset-inline-start: max(1rem, calc((100vw - 1536px) / 2 + 1.5rem));
  position: absolute;
  width: min(9rem, calc(100vw - 2rem));
}

.footer-link,
.footer-link-subtle {
  color: var(--text-muted);
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.footer-link:hover,
.footer-link:focus-visible,
.footer-link-subtle:hover,
.footer-link-subtle:focus-visible {
  color: var(--text-primary);
  text-decoration: underline;
}

.footer-link:focus-visible,
.footer-link-subtle:focus-visible {
  outline: 2px solid var(--color-sha-indigo);
  outline-offset: 3px;
  border-radius: 4px;
}

.footer-social-link {
  align-items: center;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text-muted);
  display: inline-flex;
  height: 1.75rem;
  justify-content: center;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  width: 1.75rem;
}

.footer-social-link:hover,
.footer-social-link:focus-visible {
  background-color: var(--surface-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.footer-social-link:focus-visible {
  outline: 2px solid var(--color-sha-indigo);
  outline-offset: 2px;
}

.sha-shadow-soft { box-shadow: 0 10px 30px var(--shadow-sm); }
.sha-shadow-indigo-soft { box-shadow: 0 10px 30px color-mix(in srgb, var(--color-sha-indigo) 8%, transparent); }
.sha-shadow-indigo-text-soft { box-shadow: 0 10px 30px color-mix(in srgb, var(--color-sha-indigo-text) 8%, transparent); }
.sha-text-shadow-inverse { text-shadow: 0 1px 1px var(--overlay-inverse); }

/* iOS Safari auto-zooms when a focused field's font-size is < 16px. Force a
   16px minimum on small screens across all text-entry controls. The !important
   is needed to override Tailwind utility classes (e.g. text-sm) and component
   classes (.form-input) that set a smaller size on these inputs. */
@media (max-width: 639px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Keep scrollbars subtle but still easy to grab. */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
    border-radius: 999px;
    cursor: pointer;
}

/* ── Theme-switch transitions ───────────────────────────────────────────────
   Only active during the ~300 ms window when nav.js adds sha-transitioning to
   <html>. Scoping to that class avoids repainting on every user interaction. */
html.sha-transitioning *,
html.sha-transitioning *::before,
html.sha-transitioning *::after {
    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        fill 0.2s ease,
        stroke 0.2s ease !important;
}

/* While the cookie consent banner occupies the bottom of the viewport, hide
   bottom-anchored floating UI (the mobile command bars) so the two don't
   overlap. The body class is toggled by the consent banner script. */
body.sha-consent-open .database-mobile-command-bar,
body.sha-consent-open .analytics-mobile-command-bar,
body.sha-consent-open .collaboration-mobile-command-bar,
body.sha-consent-open .country-mobile-command-bar {
    display: none;
}

/* Shared shape for the fixed bottom "command bar" mobile nav pattern (see
   .database-mobile-command-bar in data_tables.css and
   .analytics-mobile-command-bar in analytics/analysis_tools_shell.css).
   Each page still supplies its own z-index (they sit at different depths
   relative to that page's own overlays/sheets), grid-template-columns
   (button count differs), and colors/border/background/shadow (page-specific
   surface + accent tokens) — only the structural shape is shared here.

   display:grid is scoped to below Tailwind's lg breakpoint (1024px) to match
   the lg:hidden utility each page puts on its <nav>. base.css loads after
   tailwind.generated.css, so an unscoped display here would beat lg:hidden's
   equal-specificity rule at desktop widths via source order. */
.sha-mobile-command-bar {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: max(0.75rem, env(safe-area-inset-left));
    gap: 0.35rem;
    border-radius: 0.375rem;
    padding: 0.35rem;
    backdrop-filter: blur(14px);
}

@media (max-width: 1023.98px) {
    .sha-mobile-command-bar {
        display: grid;
    }
}

.sha-mobile-command-bar__button {
    display: inline-flex;
    min-width: 0;
    min-height: 3rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    font-size: 0.72rem;
    font-weight: 800;
}

.sha-mobile-command-bar__button i {
    font-size: 1rem;
}

/* ── Shared bottom-sheet chrome ──────────────────────────────────────────
   Drag handle + header (icon/eyebrow/title + close) for every command-bar
   sheet across database, analytics, collaboration hub, and country detail —
   both rail-based sheets (_rail_shell_sheet_header.html) and the bespoke
   form-relocation sheets (database's #filterForm/#sectionFilterCard,
   collaboration hub's #collaborationFilterForm). One visual identity for
   every mobile sheet in the app instead of a per-page bespoke header.
   Themed via the [data-accent] rail-accent variables (base.css above) where
   the sheet root carries data-accent; the bespoke filter sheets fall back
   to indigo via the var() defaults since they have no rail accent. */
.sha-sheet__handle {
    width: 2.75rem;
    height: 0.3125rem;
    margin: 0.25rem auto 1rem;
    border-radius: 9999px;
    background: var(--border-strong);
}

.sha-sheet__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.875rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.sha-sheet__heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.sha-sheet__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: var(--rail-accent-bg, var(--color-sha-indigo-bg));
    color: var(--rail-accent-text, var(--color-sha-indigo-text));
    font-size: 1.05rem;
}

.sha-sheet__titles {
    min-width: 0;
}

.sha-sheet__eyebrow {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rail-accent-text, var(--color-sha-indigo-text));
}

.sha-sheet__title {
    margin: 0.1rem 0 0;
    font-size: 1.1rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--text-primary);
}

.sha-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 9999px;
    background: var(--surface-subtle);
    color: var(--text-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.sha-sheet__close:hover {
    background: var(--border);
    color: var(--text-secondary);
}

/* Shared "row-as-card" look for mobile section/tab picker sheets — used by
   entity/collab hub's Sections list (nav_tab_button.html's "sheet" variant).
   Country detail no longer has an equivalent sheet (its mobile command bar
   jumps straight to the active tab's charts instead of picking a tab), but
   this stays the single source of truth if another such sheet is added. */
.sha-sheet-card {
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Single-layout rails (collaborationRail, countryRail, chartsPane) render
   their content_template once and reuse it for both the desktop sidebar and
   the mobile sheet. The content carries its own eyebrow/title (needed on
   desktop, where the .sha-sheet__* chrome header is lg:hidden) — mark it
   .rail-inline-header so it can be suppressed below the desktop breakpoint,
   where .sha-sheet__header already shows the same title and stacking both
   would repeat the heading twice. */
@media (max-width: 1023.98px) {
    [data-rail-managed] .rail-inline-header {
        display: none;
    }
}

@media (min-width: 1024px) {
    .sha-rail-page [data-rail-managed] {
        max-height: calc(100vh - 4rem);
    }

    .sha-rail-page__content {
        overflow-y: visible;
    }
}

/* Auth pages + empty states use this as a subtle background wash. */
.gradient-bg {
    background:
        radial-gradient(1200px circle at 20% 10%, color-mix(in srgb, var(--color-sha-indigo) 10%, transparent), transparent 40%),
        radial-gradient(900px circle at 80% 30%, color-mix(in srgb, var(--color-sha-sky) 10%, transparent), transparent 40%),
        linear-gradient(180deg, var(--surface-muted), var(--surface) 40%);
}

.hover-opacity-85:hover {
    opacity: 0.85;
}

.hover-bg-sha-indigo-text:hover {
    background-color: var(--color-sha-indigo-text);
}

.sha-green-cta {
    background-color: var(--color-sha-green);
}

.sha-green-cta:hover {
    background-color: var(--color-sha-green-text);
}

.sha-gold-cta {
    background-color: var(--color-sha-gold);
}

.sha-gold-cta:hover {
    background-color: var(--color-sha-gold-text);
}

/* ── Mobile nav drawer ──────────────────────────────────────────────────────
   The drawer overlay (#mobileNavDrawer) is toggled via the `hidden` class by
   the shared initDropdown() helper. These animations play each time the panel
   is revealed (display:none → block restarts CSS animations). The panel sits on
   the inline-end side, so it slides in from the end; RTL flips the direction. */
@keyframes sha-drawer-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
@keyframes sha-drawer-in-rtl {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}
@keyframes sha-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.sha-drawer-panel { animation: sha-drawer-in 0.22s ease-out; will-change: transform; }
[dir="rtl"] .sha-drawer-panel { animation-name: sha-drawer-in-rtl; }
.sha-drawer-backdrop { animation: sha-fade-in 0.22s ease-out; }

@media (prefers-reduced-motion: reduce) {
    .sha-drawer-panel, .sha-drawer-backdrop { animation: none; }
}

/* Arabic (ar) RTL overrides
   The <html dir="rtl"> attribute is set by base.html when LANGUAGE_CODE == 'ar'.
   Browsers handle inline text direction automatically. These rules fix the
   structural elements that use physical (left/right) CSS properties.
*/

/* Desktop user-menu dropdown: re-anchor to the left edge in RTL */
[dir="rtl"] #user-menu {
    right: auto;
    left: 0;
}

/* ── Shared component styles ────────────────────────────────────────────────── */

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); transition: .2s; border-radius: 9999px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 2px; top: 2px; background: var(--surface); transition: .2s; border-radius: 9999px; box-shadow: 0 1px 2px color-mix(in srgb, var(--surface-inverse) 20%, transparent); }
.switch input:checked + .slider { background: var(--color-sha-indigo); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* Toggle switch: small size, for dense menus/lists */
.switch--sm { width: 32px; height: 18px; }
.switch--sm .slider:before { height: 14px; width: 14px; }
.switch--sm input:checked + .slider:before { transform: translateX(14px); }
[dir="rtl"] .switch--sm input:checked + .slider:before { transform: translateX(-14px); }

/* Toggle switch: teal accent, for a second toggle alongside the default indigo one */
.switch--teal input:checked + .slider { background: var(--color-sha-teal); }

/* amCharts export menu */
.am5-exporting-menu { z-index: 1000 !important; background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: 8px !important; padding: 4px !important; box-shadow: 0 10px 15px -3px var(--shadow-md) !important; }
.am5-exporting-icon { width: 24px !important; height: 24px !important; padding: 4px !important; opacity: 0.6 !important; transition: opacity 0.2s !important; }
.am5-exporting-icon:hover { opacity: 1 !important; background: var(--surface-subtle) !important; border-radius: 4px !important; }
.am5-exporting-list { list-style: none !important; margin: 0 !important; padding: 0 !important; }
.am5-exporting-item { padding: 8px 12px !important; font-size: 13px !important; color: var(--text-muted) !important; cursor: pointer !important; border-radius: 4px !important; }
.am5-exporting-item:hover { background: var(--color-sha-indigo-bg) !important; color: var(--color-sha-indigo) !important; }

/* ── RTL overrides ──────────────────────────────────────────────────────────── */

/* Toggle switch knob: start from the right side */
[dir="rtl"] .slider:before {
    left: auto;
    right: 2px;
}

/* Toggle switch: knob slides left (negative) in RTL */
[dir="rtl"] input:checked + .slider:before {
    transform: translateX(-18px);
}

/* Form text inputs: right-align text for Arabic */
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="search"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

/* ── Skeleton Screens ───────────────────────────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton {
    background-color: var(--surface-disabled);
    border-radius: 0.75rem;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    position: relative;
    overflow: hidden;
}

/* Specific skeleton variants */
.skeleton-chart { min-height: 10rem; width: 100%; }
.skeleton-card { min-height: 10rem; width: 100%; }

/* For amCharts containers: hide skeleton once .loaded is added */
.chart-skeleton {
    background-color: var(--surface-muted);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    border-radius: 0.5rem;
}

.chart-skeleton.loaded {
    background-color: transparent;
    animation: none;
}

/* ── Chart container heights: viewport-relative with a desktop cap ───────
   Replaces fixed h-80/h-96/h-120 so a single chart can't eat the whole
   viewport on a phone. Caps match the old fixed heights they replace. */
.chart-frame {
    width: 100%;
    height: 55vh;
    max-height: 24rem;
    min-height: 14rem;
}

.chart-frame--sm { max-height: 20rem; }
.chart-frame--lg { max-height: 30rem; }

@media (min-width: 640px) {
    .chart-frame { height: 45vh; }
}

/* ── Premium lock overlay (country detail + analytics) ─────────────────── */
.premium-lock-overlay {
    position: absolute; inset: 0; z-index: 20;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 3.5rem;
}
.premium-lock-overlay-bg {
    position: absolute; inset: 0;
    background: var(--overlay-surface);
    backdrop-filter: blur(3px);
    border-radius: 0.75rem;
}
.premium-lock-card {
    position: relative; z-index: 10;
    text-align: center;
    background: var(--surface-raised);
    border: 1px solid var(--color-sha-gold-border);
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px color-mix(in srgb, var(--surface-inverse) 8%, transparent), 0 8px 10px -6px color-mix(in srgb, var(--surface-inverse) 5%, transparent);
    padding: 2rem 2rem 1.75rem;
    max-width: 22rem;
    margin: 0 1rem;
}
.premium-lock-icon {
    display: flex; align-items: center; justify-content: center;
    width: 3.5rem; height: 3.5rem;
    border-radius: 9999px;
    background: var(--color-sha-gold-bg);
    border: 1px solid var(--color-sha-gold-border);
    margin: 0 auto 1rem;
}
.premium-lock-skeleton-bg {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2.5rem;
    pointer-events: none;
    user-select: none;
    filter: blur(3px);
    opacity: 0.25;
}
.tab-content-blurred {
    pointer-events: none;
    user-select: none;
    filter: blur(3px);
    opacity: 0.2;
}

/* ── Chart-upsell card: single consolidated component ───────────────────────
   Shared across country tabs and the database overview upsell. Two tiers via
   modifier classes: --premium (paywall, gold/crown) and --free (sign-in,
   indigo). Palette tokens only; no fabricated chart previews. */
.premium-teaser {
    border: 1px solid transparent; border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
}
.premium-teaser__body { display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 640px) {
  .premium-teaser__body { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
}
.premium-teaser__eyebrow { font-size: 0.8125rem; font-weight: 600; margin: 0 0 0.35rem; }
.premium-teaser__title { font-size: 1.25rem; line-height: 1.25; font-weight: 700; color: var(--text-primary); margin: 0; }
.premium-teaser__desc { margin: 0.5rem 0 0; font-size: 0.875rem; color: var(--text-secondary); max-width: 44rem; }
.premium-teaser__chips { list-style: none; margin: 0.9rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.premium-teaser__chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.65rem; border-radius: 9999px;
    font-size: 0.75rem; font-weight: 500;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
}
.premium-teaser__chip-icon { font-size: 0.6875rem; }
.premium-teaser__context { margin: 0.9rem 0 0; font-size: 0.75rem; opacity: 0.85; }
.premium-teaser__cta {
    display: inline-flex; align-items: center; flex-shrink: 0;
    color: var(--text-inverse);
    padding: 0.6rem 1.1rem; border-radius: 0.6rem;
    font-size: 0.875rem; font-weight: 600; text-decoration: none;
    white-space: nowrap; transition: opacity 0.15s;
}
.premium-teaser__cta:hover { opacity: 0.9; }

/* Premium tier — gold (paywall → Upgrade) */
.premium-teaser--premium { background: linear-gradient(135deg, var(--color-sha-gold-bg), var(--surface) 72%); border-color: var(--color-sha-gold-border); }
.premium-teaser--premium .premium-teaser__eyebrow { color: var(--color-sha-gold-text); }
.premium-teaser--premium .premium-teaser__chip-icon { color: var(--color-sha-gold); }
.premium-teaser--premium .premium-teaser__context { color: var(--color-sha-gold-text); }
.premium-teaser--premium .premium-teaser__cta { background: var(--color-sha-gold); }

/* Free tier — indigo (sign-in → Free Member) */
.premium-teaser--free { background: linear-gradient(135deg, var(--color-sha-indigo-bg), var(--surface) 72%); border-color: var(--color-sha-indigo-border); }
.premium-teaser--free .premium-teaser__eyebrow { color: var(--color-sha-indigo-text); }
.premium-teaser--free .premium-teaser__chip-icon { color: var(--color-sha-indigo); }
.premium-teaser--free .premium-teaser__context { color: var(--color-sha-indigo-text); }
.premium-teaser--free .premium-teaser__cta { background: var(--color-sha-indigo); }

/* Stacked/narrow variant — for rails (lg:w-96). Vertical body, full-width CTA,
   never switches to the side-by-side layout regardless of viewport width. */
.premium-teaser--stacked { padding: 1.25rem; }
.premium-teaser--stacked .premium-teaser__body { flex-direction: column; align-items: stretch; gap: 1rem; }
.premium-teaser--stacked .premium-teaser__title { font-size: 1.125rem; }
.premium-teaser--stacked .premium-teaser__cta { width: 100%; justify-content: center; }

/* ── Ranked bar rows ── used in chartsPane, collab rail, country rail */
.chart-rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border-radius: 0.5rem;
  padding: 0.375rem 0.5rem;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

a.chart-rank-row:hover,
a.chart-rank-row:focus {
  background: var(--rail-accent-bg, var(--surface-subtle));
  outline: none;
}

a.chart-rank-row:focus-visible {
  box-shadow: 0 0 0 3px var(--focus-ring-strong);
}

.chart-rank-label {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-rank-label--media {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.chart-rank-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.chart-rank-share,
.chart-rank-index {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.chart-rank-value {
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.chart-rank-bar {
  height: 0.25rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  margin-top: 0.375rem;
}

.chart-rank-fill {
  display: block;
  height: 100%;
  min-width: 0.25rem;
  border-radius: inherit;
  background: var(--color-sha-indigo);
}

.chart-rank-empty {
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
}
