/* ===== HSC Palette (from the logo) ===== */
:root {
  --hsc-sky: #B9D9F7;
  /* light sky blue */
  --hsc-blue: #2E78BA;
  /* mid royal blue */
  --hsc-dark: #0E3A6A;
  /* deep navy */
  --hsc-line: #7BB5E6;
  /* soft divider blue */
  --hsc-yellow: #FFD600;
  /* sun yellow */

  --bg: #f7fbff;
  --text: #0E3A6A;
  --muted: #335c87b0;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(14, 58, 106, .10);
  --radius: 16px;

  /* Buttons / accents */
  --accent: var(--hsc-blue);
  --accent-strong: #215e94;
  --accent-contrast: #ffffff;
}

/* ===== Reset / base ===== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(46, 120, 186, .10), transparent),
    radial-gradient(900px 500px at 95% -15%, rgba(185, 217, 247, .55), transparent),
    var(--bg);
}

/* Default (English) stack – keep yours */
:root{
  --font-en: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-ar: "Tajawal", "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", Tahoma, sans-serif;
}

/* Use Arabic font when the document is RTL */
:root[dir="rtl"] body{
  font-family: var(--font-ar);
  letter-spacing: 0;               /* Arabic usually shouldn’t be tracked */
  word-spacing: .02em;
}

/* Keep headings bold and crisp in Arabic */
:root[dir="rtl"] h1, 
:root[dir="rtl"] h2, 
:root[dir="rtl"] h3{
  font-weight: 800;                /* matches the Tajawal 800 you loaded */
}

.logo {
  display: block;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .12));
}

.titles h1 {
  margin: 0;
  font-weight: 800;
  color: var(--hsc-dark);
  letter-spacing: .3px;
}

.titles p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 600;
}

/* ===== Layout ===== */
.container {
  max-width: 980px;
  margin: 22px auto;
  padding: 0 16px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--hsc-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

h2 {
  margin: 0 0 10px;
  color: var(--hsc-dark);
}

/* ===== Form ===== */
.form label {
  font-weight: 700;
  color: var(--hsc-dark);
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 6px;
}

input {
  appearance: none;
  background: #f4f9ff;
  border: 2px solid var(--hsc-line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1.05rem;
  color: var(--hsc-dark);
  outline: none;
}

input:focus {
  border-color: var(--hsc-blue);
  box-shadow: 0 0 0 3px rgba(46, 120, 186, .18);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.primary:active {
  transform: translateY(1px);
}

/* ===== Result pill ===== */
.result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, .6), rgba(255, 255, 255, .6)),
    linear-gradient(90deg, var(--hsc-blue), var(--hsc-sky));
  border: 2px solid var(--hsc-blue);
  color: var(--hsc-dark);
  font-weight: 800;
  position: relative;
}

.result::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  pointer-events: none;
  border: 2px solid var(--hsc-yellow);
  opacity: .75;
}

.result.bad {
  background:
    linear-gradient(0deg, rgba(255, 255, 255, .6), rgba(255, 255, 255, .6)),
    linear-gradient(90deg, #cf3a3a, #ff9a9a);
  border-color: #cf3a3a;
}

.hidden {
  display: none;
}

.helper {
  margin: 10px 0 0;
  color: var(--muted);
}

.helper code {
  background: #eef6ff;
  border: 1px solid var(--hsc-line);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ===== Details / notice ===== */
.details summary {
  margin-top: 10px;
  cursor: pointer;
  font-weight: 700;
  color: var(--hsc-blue);
}

.details p {
  margin: 6px 0 0;
  color: var(--muted);
}

.notice {
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px dashed var(--hsc-yellow);
  background: #fffde7;
  color: #6b5b00;
}

/* ===== Footer ===== */
.footer {
  max-width: 980px;
  margin: 20px auto 40px;
  padding: 0 16px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--hsc-line);
  padding-top: 12px;
}

/* Small screens */
@media (max-width: 520px) {
  .row {
    grid-template-columns: 1fr;
  }

  .logo {
    width: 72px;
    height: auto;
  }
}

/* --- ID explainer --- */
.id-help h3 {
  margin: 0 0 6px;
}

.id-help .muted {
  color: var(--muted);
  margin: 0 0 10px;
}

.id-figure {
  margin: 6px 0 0;
}

.id-demo {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.id-caption {
  margin-top: 8px;
  color: var(--muted);
  font-size: .95rem;
}

.id-caption code {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 2px 6px;
  border-radius: 6px;
}


/* === Candidates layout === */
.cand-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.candidate-grid {
  display: grid;
  gap: 14px;
  /* 4-up on wide, down to 2-up on small */
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .candidate-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .candidate-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.candidate-card {
  border: 1px solid var(--hsc-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease;
}

.candidate-card:hover {
  transform: translateY(-2px);
}

.candidate-media {
  margin: 0;
  display: block;
  background: #f3f7fd;
  aspect-ratio: 3 / 4;
  /* flyer friendly */
  overflow: hidden;
}

.candidate-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.candidate-meta {
  padding: 10px 12px 12px;
}

.candidate-name {
  margin: 0;
  font-size: 1.05rem;
  color: var(--hsc-dark);
  line-height: 1.2;
}

.candidate-bio {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .95rem;
}

.id-figure {
  max-width: 700px;
  margin-inline: auto;
  text-align: center;
}

.id-demo {
  display: block;
  max-width: 100%;
  height: auto;
  /* responsive scaling handled here */
}

.id-caption {
  font-size: 0.95rem;
  color: #ddd;
  margin-top: 0.5rem;
}

.id-figure[dir="ltr"], .id-figure[dir="ltr"] * {
  direction: ltr;
}


/* Countdown pill */
.election-countdown{
  display:inline-flex; align-items:center; gap:10px;
  background:#f0f6ff; color: var(--hsc-blue, #2E78BA);
  border-radius:999px; padding:6px 12px;
  box-shadow:0 2px 6px rgba(0,0,0,.08);
  font-weight:600; font-size:.95rem;
}
.election-countdown .cd-label{ opacity:.9; margin-right:2px; }
.election-countdown .cd-part{
  display:inline-flex; align-items:baseline; gap:4px;
  background:#ffffff; border-radius:10px; padding:2px 8px;
  border:1px solid #dbe7fb;
}
.election-countdown .cd-num{ font-variant-numeric: tabular-nums; }
.election-countdown .cd-t{ font-size:.8em; opacity:.8; }


/* Optional Arabic font stack if you want crisper Arabic */
@font-face{
  font-family:"CairoUI";
  src: local("Cairo"); /* or host a WOFF2 later */
  font-display: swap;
}

/* =========================
   HERO (final, canonical)
   ========================= */
header.hero{
  border-bottom: 4px solid var(--hsc-yellow);
  background:
    linear-gradient(0deg, rgba(255,255,255,.85), rgba(255,255,255,.85)),
    linear-gradient(120deg, var(--hsc-sky), #e8f3ff);

  /* centered strip with two columns */
  display:grid;
  grid-template-columns: 1fr auto;          /* EN: main | side */
  grid-template-areas: "main side";
  align-items:start;
  gap:20px;
  max-width:980px;
  margin:0 auto;
  padding:24px 20px;
}

/* AR: flip columns → language left, main right */
:root[dir="rtl"] header.hero{
  grid-template-columns: auto 1fr;          /* AR: side | main */
  grid-template-areas: "side main";
}

header.hero .hero-col.main{
  grid-area: main;
  display:flex; flex-direction:column;
  gap:8px;
  text-align:start;
}

:root[dir="rtl"] header.hero .hero-col.main{
  text-align:right;
}

header.hero .hero-col.side{
  grid-area: side;
  align-self:start;
  justify-self:end;               /* EN: language on right */
}
:root[dir="rtl"] header.hero .hero-col.side{
  justify-self:start;             /* AR: language on left */
}

/* Clickable logo */
header.hero .hero-logo-link{
  display:inline-block;
  line-height:0;
  text-decoration:none;
}

/* Logo image */
header.hero .hero-logo{
  display:block;
  width:76px; height:auto;
  margin:2px 0 6px 0;
  filter:drop-shadow(0 6px 12px rgba(0,0,0,.12));
}

/* In AR, push logo (the link) to the far right edge */
:root[dir="rtl"] header.hero .hero-logo-link{
  margin-inline-start:auto;
}

/* Title & subtitle spacing */
header.hero h1{
  margin:0; line-height:1.1;
  font-weight:800; color:var(--hsc-dark);
  letter-spacing:.2px;
}
header.hero #eventTitle{
  margin:2px 0 0; color:var(--muted); font-weight:600;
}

/* responsive 16:9 player */
.yt-wrap{ position:relative; width:100%; padding-top:56.25%; border-radius:14px; overflow:hidden; background:#000; }
.yt-wrap iframe{ position:absolute; inset:0; width:100%; height:100%; border:0; }

/* Countdown room */
.election-countdown{ margin-top:6px; }

/* Mobile: stack; keep language at top-right */
@media (max-width:640px){
  header.hero{
    grid-template-columns: 1fr;
    grid-template-areas: "main" "side";
  }
  header.hero .hero-col.side{ justify-self:end; }
  header.hero .hero-logo{ width:68px; }
}

/* =========================
   Language dropdown (final)
   ========================= */
.lang-menu{ position:relative; }
.lang-toggle{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--hsc-line, #d9e0ea);
  background:#fff; padding:8px 12px; border-radius:12px;
  font-weight:700; cursor:pointer;
}
.lang-list{
  position:absolute; inset-inline-end:0; top:calc(100% + 6px);
  min-width:170px; padding:8px; margin:0; list-style:none;
  background:#fff; border:1px solid var(--hsc-line,#e4e8ee);
  border-radius:12px; box-shadow:0 10px 30px rgba(0,0,0,.08); z-index:50;
}
.lang-list[hidden]{ display:none; }
.lang-list button{
  width:100%; text-align:start; display:flex; align-items:center; gap:10px;
  background:transparent; border:0; padding:10px 8px; border-radius:10px; cursor:pointer;
}
.lang-list button:hover{ background:#f6f8fb; }

/* Open to the opposite side in RTL automatically */
:root[dir="rtl"] .lang-list{ inset-inline-start:0; inset-inline-end:auto; }

/* --- RTL: put language menu on the LEFT side --- */
:root[dir="rtl"] header.hero{
  /* side column on the left, main on the right */
  grid-template-columns: auto 1fr;
  grid-template-areas: "side main";
}

/* align the dropdown to the physical LEFT (inline-end in RTL) */
:root[dir="rtl"] header.hero .hero-col.side{
  justify-self: end !important;
}

/* on phones, also keep it on the left in AR */
@media (max-width:640px){
  :root[dir="rtl"] header.hero .hero-col.side{ justify-self: end !important; }
}

/* dropdown list should open inward (to the right) when it’s on the far left */
:root[dir="rtl"] .lang-list{
  inset-inline-start: 0;
  inset-inline-end: auto;
}

/* === FINAL OVERRIDE: force language dropdown to LEFT in Arabic === */
:root[dir="rtl"] header.hero .hero-col.side{
  grid-area: side;
  justify-self: start !important;        /* left edge of its grid column */
  margin-inline-end: auto !important;    /* push it to the left in RTL */
  margin-inline-start: 0 !important;
  display: block !important;             /* neutralize any flex tricks */
}

/* make the popup open inward from that left edge */
:root[dir="rtl"] .lang-list{
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
}

/* (optional) on small screens keep it left as well */
@media (max-width:640px){
  :root[dir="rtl"] header.hero .hero-col.side{ justify-self:start !important; }
}

/* --- Top bar --- */
.topbar{
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hsc-line, #e6edf6);
}
.topbar-inner{
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  justify-content: flex-end;   /* EN: right */
  align-items: center;
  gap: 8px;
}
/* AR: send it to the LEFT */
:root[dir="rtl"] .topbar-inner{ justify-content: flex-start; }

/* If the hero still has a lang menu, hide it */
header.hero .lang-menu{ display: none !important; }

/* Your existing language dropdown styles continue to work: */
.lang-menu{ position:relative; }
.lang-toggle{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--hsc-line, #d9e0ea);
  background:#fff; padding:8px 12px; border-radius:12px;
  font-weight:700; cursor:pointer;
}
.lang-list{
  position:absolute; inset-inline-end:0; top:calc(100% + 6px);
  min-width:170px; padding:8px; margin:0; list-style:none;
  background:#fff; border:1px solid var(--hsc-line,#e4e8ee);
  border-radius:12px; box-shadow:0 10px 30px rgba(0,0,0,.08); z-index:50;
}
.lang-list[hidden]{ display:none; }
.lang-list button{
  width:100%; text-align:start; display:flex; align-items:center; gap:10px;
  background:transparent; border:0; padding:10px 8px; border-radius:10px; cursor:pointer;
}
.lang-list button:hover{ background:#f6f8fb; }

/* Ensure rule list renders one bullet per line */
#howRules { 
  list-style: disc; 
  padding-inline-start: 1.25rem; 
  margin-top: .5rem;
}
#howRules li { 
  display: list-item; 
  margin: .35rem 0; 
}
#howRules li:first-child { font-weight: 700; }

/* Open list from the left in RTL automatically */
:root[dir="rtl"] .lang-list{ inset-inline-start:0; inset-inline-end:auto; }

/* Flags (use your existing ones; here’s a GB and EG inline) */
.flag{ width:18px; height:12px; border-radius:2px; background-size:cover; background-position:center; display:inline-block; }
.flag.flag-en{
  background-image:url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 36" width="36" height="24">\
  <rect width="60" height="36" fill="%23005BBB"/>\
  <path d="M0,0 60,36 M60,0 0,36" stroke="%23fff" stroke-width="10"/>\
  <path d="M0,0 60,36 M60,0 0,36" stroke="%23EF3340" stroke-width="6"/>\
  <rect x="25" width="10" height="36" fill="%23fff"/>\
  <rect y="13" width="60" height="10" fill="%23fff"/>\
  <rect x="27" width="6" height="36" fill="%23EF3340"/>\
  <rect y="15" width="60" height="6" fill="%23EF3340"/>\
</svg>');
}

.flag.flag-eg{ background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="36" height="24" viewBox="0 0 36 24"><rect width="36" height="24" fill="%23fff"/><rect width="36" height="8" y="0" fill="%23CE1126"/><rect width="36" height="8" y="16" fill="%23000000"/><circle cx="18" cy="12" r="2.2" fill="%23C8A400"/></svg>'); }


