/* Daily Ausaf Kashmir — live results screen
   Built to the approved front-end reference: white masthead, gold breaking
   band, headline block over the polling-day photo, white candidate cards. */

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 30%, #0C2647 0%, #04101F 82%) fixed;
  font-family: var(--body);
  /* Let the page scroll vertically when the poster is taller than the screen.
     Horizontal scroll is never wanted — the stage is centered. */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}

/* The viewport fills the window and centres the poster. When the scaled
   poster is taller than the window the whole page scrolls (align-items
   keeps the top reachable via `safe`, and the wrapper reserves real height). */
#viewport {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: safe center;
  padding: clamp(8px, 2vw, 28px);
  padding-top: max(clamp(8px, 2vw, 28px), env(safe-area-inset-top));
  padding-bottom: max(clamp(8px, 2vw, 28px), env(safe-area-inset-bottom));
  box-sizing: border-box;
}
/* On phones/tablets the poster fills the width and anchors to the top like a
   normal page, so there's no awkward gap above the masthead; any spare room
   falls below as the navy backdrop. Wide screens keep it centred. */
/* On phones/tablets the poster still fills the width, but we centre it
   vertically so any leftover room splits evenly top and bottom as an
   intentional broadcast letterbox — no large empty void under the frame.
   `safe` keeps the top reachable (and the page scrolls) when the poster is
   taller than the screen, e.g. a phone held sideways. */
@media (max-width: 899px) {
  #viewport { align-items: safe center; }
}

/* Reserves the *scaled* footprint of the stage so flexbox centring and
   document scroll-height are both correct. JS sets its width/height. */
#scale-wrap {
  position: relative;
  flex: none;
  width: 1080px; height: 1350px;   /* overwritten by JS: 1080*s x 1350*s */
}

/* Fixed 1080x1350 canvas (Instagram 4:5), scaled to any screen from the
   top-left corner so the wrapper footprint above stays accurate.
   Everything inside is authored in real export pixels. */
#stage {
  width: 1080px; height: 1350px;
  transform-origin: top left;
  position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  background: linear-gradient(180deg, #123262 0%, #0C2249 45%, #071938 100%);
}

/* photo sits behind the headline block only, fading into the navy */
#stage-bg {
  position: absolute;
  top: 168px; left: 0; right: 0; height: 620px;
  background-size: cover; background-position: center 30%;
  opacity: .3;
  filter: saturate(.75);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 55%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 55%, transparent 100%);
  z-index: 0;
}

.nav, .ticker, .headline, .cards, .turnout, .strip, .foot, .winner, .empty-state {
  position: relative;
  z-index: 2;
}

/* ---------------- Masthead ---------------- */
.nav {
  background: #fff;
  display: flex; align-items: center; gap: 24px;
  padding: 18px 32px;
  border-bottom: 4px solid #F5B816;
}
.logo-plaque {
  display: flex; align-items: center; gap: 18px;
  background: #0C2249; border-radius: 12px; padding: 12px 20px;
}
.logo-plaque img { height: 46px; width: auto; display: block; }
.logo-plaque .rule { width: 2px; height: 34px; background: rgba(255,255,255,.28); }

.nav-right { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.menu-btn {
  display: flex; align-items: center; gap: 12px;
  background: none; border: 0; cursor: pointer; padding: 0;
  font-family: var(--urdu); font-size: 34px; font-weight: 700;
  color: #0C2249;
}
.menu-btn .bars { display: grid; gap: 5px; }
.menu-btn .bars i { display: block; width: 30px; height: 4px; background: #0C2249; border-radius: 2px; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: #EDF1F6; border-radius: 999px; padding: 9px 18px; width: 300px;
}
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-family: var(--urdu); font-size: 22px; color: #0C2249;
  text-align: right; direction: rtl;
}
.search input::placeholder { color: #8496AE; }
.search svg { width: 20px; height: 20px; fill: #6E829D; flex: none; }

/* jump menu */
.menu-panel {
  position: absolute; top: 128px; right: 32px; z-index: 40;
  width: 420px; max-height: 620px; overflow: auto;
  background: #fff; border-radius: 14px; padding: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.menu-panel button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; cursor: pointer; text-align: right;
  padding: 12px 14px; border-radius: 10px;
  font-family: var(--urdu); font-size: 22px; color: #10233F;
}
.menu-panel button:hover { background: #EDF3FB; }
.menu-panel button b { font-family: var(--urdu); font-size: 20px; font-weight: 700; color: #1D4E8C; }
.menu-panel .none { padding: 14px; color: #6E829D; font-size: 20px; font-family: var(--urdu); text-align: center; }

/* ---------------- Breaking band ---------------- */
.ticker {
  display: flex; align-items: stretch;
  flex-direction: row-reverse;
  height: 68px;
  background: #0A1C3A;
  border-bottom: 2px solid rgba(245,184,22,.5);
  overflow: hidden;
}
.ticker-label {
  flex: none; display: flex; align-items: center; padding: 0 24px;
  font-family: var(--urdu); font-size: 26px; font-weight: 700;
  color: #F5B816;
  white-space: nowrap;
}
.ticker-track { flex: 1; overflow: hidden; display: flex; align-items: center; }
.ticker-run {
  display: flex; flex: none; width: max-content; align-items: center; gap: 0;
  white-space: nowrap; will-change: transform;
  animation: scroll-left var(--ticker-dur, 26s) linear infinite;
}
.ticker-item {
  font-family: var(--urdu); font-size: 26px; font-weight: 600;
  color: #fff;
}
.ticker-item::after {
  content: "|"; color: rgba(245,184,22,.8); margin: 0 26px; font-weight: 400;
}
@keyframes scroll-left { from { transform: translateX(-50%); } to { transform: translateX(0); } }

/* ---------------- Headline ---------------- */
.headline { padding: 28px 48px 14px; text-align: center; }
.headline h1.urdu-title {
  margin: 0;
  font-family: var(--urdu); font-size: 58px; font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 6px 24px rgba(0,0,0,.55);
  text-wrap: balance;
}
.headline h1 .bar { color: #F5B816; font-weight: 600; margin: 0 10px; }
.headline .urdu.sub-zone {
  font-family: var(--urdu); font-size: 32px; line-height: 1.6; color: #FFD766; margin-top: 2px;
}
.headline .slide-label {
  margin-top: 10px;
  font-family: var(--urdu); font-size: 26px; font-weight: 700;
  color: #DCE7F5;
}
.headline .slide-label b { color: #fff; }
.headline .slide-label span { color: #F5B816; font-weight: 400; margin: 0 8px; }

/* ---------------- Turnout line ---------------- */
.turnout {
  display: flex; justify-content: center; gap: 0;
  margin: 0 48px 12px;
  border-top: 1px solid rgba(255,255,255,.16);
  border-bottom: 1px solid rgba(255,255,255,.16);
}
.turnout div { padding: 7px 26px; text-align: center; }
/* With the male/female split there are five cells — tighten so they fit the
   frame cleanly and stay on one line. */
.turnout.turnout-wide { margin-left: 32px; margin-right: 32px; }
.turnout.turnout-wide div { padding: 7px 14px; }
.turnout.turnout-wide .k { font-size: 17px; }
.turnout.turnout-wide .v { font-size: 22px; }
.turnout div + div { border-left: 1px solid rgba(255,255,255,.16); }
.turnout .k {
  font-family: var(--urdu); font-size: 19px; color: #9DB3D0;
}
.turnout .v {
  font-family: var(--numeric); font-variant-numeric: tabular-nums;
  font-size: 24px; font-weight: 600; color: #fff; line-height: 1.15;
}
.turnout .v.accent { color: #F5B816; }

/* ---------------- Candidate cards ---------------- */
.cards {
  flex: 1;
  min-height: 0;                 /* take only the space between the fixed bands… */
  overflow: hidden;              /* …never grow and shove the strip/footer off-screen */
  display: flex; flex-direction: column; justify-content: center; align-items: stretch;
  padding: 4px 40px 14px;
}
/* the card stack — scaled by the display script to fit the region above */
.cards-inner {
  width: 100%;
  display: flex; flex-direction: column; justify-content: center;
  gap: 18px;
  transform-origin: center center;
}

.cand {
  display: flex; align-items: stretch; gap: 20px;
  background: #fff; border-radius: 18px; padding: 12px;
  color: #10233F;
  box-shadow: 0 14px 30px rgba(0,0,0,.42);
  animation: card-in .5s var(--ease) both;
}
.cand:nth-child(2) { animation-delay: .08s; }
.cand:nth-child(3) { animation-delay: .16s; }
@keyframes card-in { from { opacity: 0; transform: translateY(24px); } }

.cand-photo {
  width: 150px; flex: none; align-self: stretch;
  border-radius: 12px; object-fit: cover; object-position: top center;
  background: #DCE4EF;
  display: grid; place-items: center;
  font-family: var(--display); font-size: 50px; font-weight: 700; color: #7D91AC;
}

.cand-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cand-badge {
  align-self: flex-end;
  font-family: var(--urdu); font-size: 24px; font-weight: 700;
  padding: 3px 22px; border-radius: 999px; margin-bottom: 5px;
}
/* The candidate's NAME is the hero of the card. It is auto-fitted by the
   display script so the full name always shows on one clean line (no clipped
   "…"), then given a rank-coloured accent underline below so the eye lands on
   it first. Size here is the starting/maximum; the script only shrinks it if a
   very long name would otherwise run past the card. */
.cand-name {
  margin-top: auto;
  position: relative;
  font-family: var(--urdu); font-size: 62px; font-weight: 700;
  line-height: 1.32;
  letter-spacing: -.004em;
  color: #0B1E3A;
  padding-bottom: 12px;
  white-space: nowrap; overflow: hidden;   /* JS keeps it fitted; this only guards */
}
/* accent bar under the name — strong at the right (where RTL Urdu begins),
   fading out to the left. Colour is set per rank below. */
.cand-name::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  height: 5px; width: 100%; border-radius: 3px;
  background: linear-gradient(270deg, #9DB3D0 0%, rgba(157,179,208,0) 78%);
}
.cand-foot {
  margin-top: auto;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
}
.mini {
  display: block;
  font-family: var(--urdu); font-size: 21px; font-weight: 600;
  color: #55698A;
}
.party-line { display: flex; align-items: center; gap: 11px; margin-top: 2px; }
/* Uniform flag chip — every party flag is normalised to 3:2, so this fixed
   rounded rectangle shows them all at exactly the same size. */
.party-flag {
  width: 54px; height: 36px; border-radius: 6px; flex: none; overflow: hidden;
  display: grid; place-items: center;
  font-family: var(--urdu); font-size: 16px; font-weight: 700; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.25);
}
.party-flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.party-name {
  font-family: var(--urdu); font-size: 28px; font-weight: 700;
  color: #10233F;
}
.votes-col { text-align: right; flex: none; }
.votes-col .value {
  font-family: var(--display); font-size: 42px; font-weight: 800;
  letter-spacing: .01em; line-height: 1.05; color: #10233F;
  font-variant-numeric: tabular-nums;
}
.votes-col .pct { font-family: var(--display); font-size: 20px; font-weight: 600; color: #55698A; }

.share {
  height: 6px; border-radius: 4px; background: #E7EDF5; margin-top: 7px; overflow: hidden;
}
.share i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .9s var(--ease); }

/* leading */
.cand.is-lead {
  background: linear-gradient(180deg, #FFFFFF 60%, #E8FBEE 100%);
  box-shadow: 0 0 0 4px #3DD46A, 0 0 46px rgba(61,212,106,.55), 0 14px 34px rgba(0,0,0,.4);
}
.cand.is-lead .cand-badge { background: #2FB457; color: #fff; }
.cand.is-lead .share i { background: #2FB457; }

/* trailing */
.cand.is-second { box-shadow: 0 0 0 3px #F5C518, 0 14px 30px rgba(0,0,0,.42); }
.cand.is-second .cand-badge { background: #F5C518; color: #241A05; }
.cand.is-second .share i { background: #F5C518; }

/* standard */
.cand.is-third .cand-badge { display: none; }
.cand.is-third .share i { background: #9DB3D0; }

/* ---------------- Winner takeover ---------------- */
.winner {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 0 60px 16px; text-align: center;
}
/* foreground content, scaled by the display script to fit the frame */
.winner-inner {
  position: relative; z-index: 2; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; transform-origin: center center;
}
.winner-rays {
  position: absolute; width: 1200px; height: 1200px;
  background: repeating-conic-gradient(from 0deg, rgba(245,197,24,.12) 0deg 6deg, transparent 6deg 18deg);
  animation: spin 60s linear infinite;
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 60%);
  mask-image: radial-gradient(circle, #000 18%, transparent 60%);
}
@keyframes spin { to { transform: rotate(360deg); } }
.winner-burst {
  position: absolute; width: 880px; height: 880px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,197,24,.3) 0%, rgba(47,180,87,.16) 44%, transparent 68%);
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.07); opacity: .78; } }
.winner-kicker, .mubarak, .winner-card, .winner-declared { position: relative; z-index: 2; }

.winner-kicker {
  font-family: var(--urdu); font-size: 30px; font-weight: 700;
  color: #F5C518;
}
.mubarak {
  font-family: var(--urdu); font-size: 104px; line-height: 1.55; color: #fff;
  text-shadow: 0 0 44px rgba(245,197,24,.65);
  animation: pop-in .65s var(--ease) both;
}
@keyframes pop-in { from { opacity: 0; transform: scale(.88); } }

.winner-card {
  display: flex; align-items: center; gap: 26px;
  background: #fff; color: #10233F; border-radius: 20px; padding: 20px 30px 20px 20px;
  box-shadow: 0 0 0 5px #F5C518, 0 22px 50px rgba(0,0,0,.5);
  margin-top: 6px;
  animation: pop-in .65s .1s var(--ease) both;
}
.winner-photo {
  width: 220px; height: 240px; border-radius: 14px; object-fit: cover; object-position: top center;
  background: #DCE4EF; display: grid; place-items: center;
  font-family: var(--display); font-size: 72px; font-weight: 700; color: #7D91AC; flex: none;
}
.winner-info { text-align: right; }
.winner-name {
  font-family: var(--urdu); font-size: 56px; font-weight: 700;
  line-height: 1.4;
}
.winner-row { display: flex; align-items: flex-end; gap: 44px; margin-top: 12px; }
.winner-declared {
  margin-top: 16px;
  font-family: var(--urdu); font-size: 28px; font-weight: 700;
  color: #3DD46A;
}

.confetti { position: absolute; inset: 0; overflow: hidden; z-index: 3; pointer-events: none; }
.confetti i { position: absolute; top: -30px; width: 12px; height: 20px; opacity: .9; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(1420px) rotate(720deg); } }

/* ---------------- Results strip ---------------- */
.strip {
  height: 92px;
  background: #0A1C3A;
  border-top: 3px solid #F5B816;
  display: flex; align-items: center; gap: 20px; padding: 0 32px;
  overflow: hidden;
}
.strip-tag {
  flex: none; max-width: 220px;
  font-family: var(--urdu); font-size: 21px; font-weight: 700; line-height: 1.4;
  background: #F5B816; color: #10233F; padding: 7px 13px; border-radius: 7px;
  text-align: center;
}
.strip-body {
  flex: 1; display: flex; align-items: center; gap: 14px; overflow: hidden;
  animation: strip-in .45s var(--ease);
}
@keyframes strip-in { from { opacity: 0; transform: translateX(26px); } }
.seat-chip {
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 6px 13px; border-radius: 9px;
  background: rgba(255,255,255,.09); border-left: 5px solid var(--chip, #9DB3D0);
}
.seat-chip .p { font-family: var(--urdu); font-size: 23px; font-weight: 700; }
.seat-chip .n { font-family: var(--numeric); font-size: 29px; font-weight: 800; color: #F5C518; }
.seat-chip .prev { font-family: var(--urdu); font-size: 18px; color: #9DB3D0; }
.strip-stat { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.strip-stat .k { font-family: var(--urdu); font-size: 22px; color: #9DB3D0; }
.strip-stat .v { font-family: var(--numeric); font-variant-numeric: tabular-nums; font-size: 29px; font-weight: 600; color: #fff; }
.strip-sep { width: 2px; height: 36px; background: rgba(255,255,255,.16); flex: none; }

/* ---------------- Footer ---------------- */
.foot {
  display: flex; align-items: center; gap: 26px;
  padding: 16px 32px 18px;
  background: #061733;
  border-top: 1px solid rgba(255,255,255,.12);
}
.foot-brand { flex: none; display: flex; align-items: center; gap: 14px; }
.foot-brand img { height: 40px; }
.foot-contact { flex: 1; min-width: 0; border-left: 2px solid rgba(255,255,255,.18); padding-left: 22px; }
.foot-contact .k {
  font-family: var(--urdu); font-size: 20px; font-weight: 700;
  color: #F5B816;
}
.foot-contact .row {
  font-size: 19px; color: #DCE7F5; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.foot-contact .row[dir="rtl"] { font-family: var(--urdu); font-size: 20px; }
.foot-social { flex: none; text-align: right; }
.foot-social .k {
  font-family: var(--urdu); font-size: 19px; font-weight: 700;
  color: #F5B816;
}
.foot-social .handle { font-family: var(--display); font-size: 26px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.foot-social .icons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 7px; }
.foot-social .icons span {
  width: 34px; height: 34px; border-radius: 50%; background: #fff;
  display: grid; place-items: center;
}
.foot-social .icons svg { width: 19px; height: 19px; fill: #061733; }

/* ---------------- Progress + pips ---------------- */
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(255,255,255,.1); z-index: 5; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3DD46A, #F5B816); }

.pips { position: absolute; top: 182px; right: 40px; display: flex; gap: 6px; z-index: 5; }
.pips b { width: 22px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); }
.pips b.on { background: #F5B816; }

/* ---------------- Operator controls (outside the export frame) ---------------- */
.controls {
  position: fixed; top: 14px; right: 14px; display: flex; gap: 8px; z-index: 50;
  opacity: .12; transition: opacity .25s;
}
.controls:hover, .controls:focus-within { opacity: 1; }
.controls a, .controls button {
  font-family: var(--urdu); font-size: 15px; color: #fff;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none;
  min-height: 30px; display: inline-flex; align-items: center;
}
.controls a:hover, .controls button:hover { background: rgba(255,255,255,.26); }
.controls :focus-visible { outline: 2px solid #F5B816; outline-offset: 2px; }

/* Touch devices have no hover state, so the fade-until-hover trick above
   would leave these buttons almost invisible and hard to tap. Keep them
   legible with a real tap target instead. */
@media (hover: none), (pointer: coarse) {
  .controls { opacity: .8; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); gap: 6px; }
  .controls a, .controls button { padding: 9px 12px; font-size: 12.5px; min-height: 36px; background: rgba(4,16,31,.55); }
}
@media (max-width: 480px) {
  .controls { left: 0; right: 0; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); justify-content: center; }
}

.empty-state { flex: 1; display: grid; place-items: center; text-align: center; padding: 60px; }
.empty-state h2 {
  font-family: var(--urdu); font-size: 48px; font-weight: 700;
  line-height: 1.5; margin: 0 0 12px;
}
.empty-state p { font-size: 24px; font-family: var(--urdu); color: #9DB3D0; margin: 0; line-height: 1.6; }

/* ============================================================
   NAME HIGHLIGHT — make the candidate's name the visual hero
   (added for the live broadcast: leading name in green, runner-up
   in gold, each with a matching accent underline and soft glow)
   ============================================================ */

/* Leading candidate — green hero name */
.cand.is-lead .cand-name {
  color: #0A7C3E;
  text-shadow: 0 2px 20px rgba(47,180,87,.28);
}
.cand.is-lead .cand-name::after {
  height: 6px;
  background: linear-gradient(270deg, #2FB457 0%, #3DD46A 38%, rgba(61,212,106,0) 88%);
  box-shadow: 0 2px 14px rgba(47,180,87,.5);
}

/* Runner-up — gold accent name */
.cand.is-second .cand-name { color: #0B1E3A; }
.cand.is-second .cand-name::after {
  height: 5px;
  background: linear-gradient(270deg, #E7A70E 0%, #F5C518 42%, rgba(245,197,24,0) 90%);
}

/* Winner takeover — the name is already large; give it the same gold accent
   and let the fit-script guarantee it never runs past the card. */
.winner-name {
  position: relative;
  padding-bottom: 12px;
  white-space: nowrap;
  text-shadow: 0 3px 22px rgba(0,0,0,.35);
}
.winner-name::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  height: 6px; width: 100%; border-radius: 3px;
  background: linear-gradient(270deg, #F5C518 0%, #FFD766 40%, rgba(245,197,24,0) 90%);
  box-shadow: 0 2px 16px rgba(245,197,24,.45);
}

/* ============================================================
   OBS / capture snap — when the window matches the poster's aspect
   ratio (a dedicated browser source or full-screen), the fit script
   adds .snap so the frame fills edge-to-edge with no padding, rounded
   corners or shadow, giving a clean recording. Normal browsing is
   unaffected (the class is only added at a near-exact aspect match).
   ============================================================ */
body.snap #viewport { padding: 0; }
body.snap #stage { border-radius: 0; box-shadow: none; }
