@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../assets/fonts/cormorant-garamond-medium-italic.ttf') format('truetype');
  font-style: italic;
  font-weight: 500;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --color-night: #090706;
  --color-white: #fffaf4;
  --color-ice: #deefff;
  --color-fire: #ff542f;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--color-night) url('../assets/vote-background-live.jpg') center / cover no-repeat fixed;
  color: var(--color-white);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root[data-choice="ice"] { background: #101419 url('../assets/results/ice.jpg') center / cover no-repeat fixed; }
:root[data-choice="fire"] { background: #190300 url('../assets/results/fire.jpg') center / cover no-repeat fixed; }
.voting-panel { position: absolute; inset: 0; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100svh;
  display: grid;
  place-items: center;
}

.vote-screen {
  container-type: inline-size;
  position: relative;
  isolation: isolate;
  /* Fill phones edge to edge without stretching artwork or cropping buttons. */
  width: 100%;
}
.vote-heading {
  position: absolute;
  z-index: 1;
  top: 15.5%;
  left: 4%;
  width: 92%;
  margin: 0;
  color: #fffaf4;
  font: italic 500 clamp(28px, 10cqw, 58px)/1.12 'Cormorant Garamond', Georgia, serif;
  letter-spacing: -.025em;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 12px #000b;
}

/* Keep controls readable on wide screens; the independent backdrop fills gaps. */
@media (min-width: 768px), (orientation: landscape) {
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .vote-screen {
    width: min(100%, max(320px, calc((100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 853 / 1844)));
    max-width: 600px;
  }
}

.vote-screen__background {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 853 / 1844;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.vote-screen__motion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  object-fit: cover;
}
.vote-screen__motion.is-playing { opacity: 1; }
.vote-foreground {
  position: absolute;
  z-index: 1;
  left: calc(var(--x) * 100% / 480);
  top: calc(var(--y) * 100% / 1024);
  width: calc(var(--w) * 100% / 480);
  height: calc(var(--h) * 100% / 1024);
  pointer-events: none;
  user-select: none;
}
.vote-button {
  position: absolute;
  z-index: 2;
  /* Coordinates measured against the original 853 × 1844 image, not its preview. */
  top: 46.5293%;
  height: 8.1345%;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  color: var(--color-white);
  background: transparent;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.vote-button--ice {
  left: 4.5721%; width: 43.0246%; --choice-glow: var(--color-ice);
}
.vote-button--fire {
  left: 53.1067%; width: 42.7902%; --choice-glow: var(--color-fire);
}

@media (hover: hover) {
  .vote-button:not(:disabled):hover { box-shadow: 0 0 22px var(--choice-glow); }
}

.vote-button:not(:disabled):active { filter: brightness(1.12); }
.vote-button:disabled { cursor: default; }
.vote-button:focus-visible { outline: 3px solid var(--color-white); outline-offset: 5px; }
.vote-button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--choice-glow), 0 0 25px var(--choice-glow); }

.vote-button__check {
  position: absolute;
  right: 5%;
  top: -10px;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  font: 700 16px/1 system-ui, sans-serif;
  background: var(--choice-glow);
  color: var(--color-night);
  opacity: 0;
  transform: scale(.7);
  transition: transform 160ms ease;
}

.vote-button[aria-pressed="true"] .vote-button__check { opacity: 1; transform: scale(1); }

/* Confirmation is a real text button, revealed only after a selection. */
.confirm-button {
  position: absolute;
  z-index: 2;
  top: 62%;
  left: 14%;
  width: 72%;
  min-height: 52px;
  border: 1px solid #ffffff85;
  border-radius: 999px;
  padding: 12px 16px;
  color: var(--color-white);
  font: italic 500 clamp(25px, 7.2cqw, 40px)/1.2 'Cormorant Garamond', Georgia, serif;
  background: linear-gradient(135deg, #ffffff18, #ffffff05), #080809b8;
  backdrop-filter: blur(8px);
  animation: confirm-appear 240ms ease-out both;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 160ms ease, background-color 160ms ease;
}
.confirm-button:not(:disabled) { box-shadow: 0 0 16px #ffffff30, inset 0 0 0 1px #ffffff45; }
.confirm-button:not(:disabled):active { background-color: #ffffff18; }
.confirm-button:focus-visible { outline: 3px solid var(--color-white); outline-offset: 4px; }
.confirm-button:disabled { cursor: default; }
@media (hover: hover) {
  .confirm-button:not(:disabled):hover { background-color: #ffffff10; box-shadow: 0 0 22px #ffffff55; }
}

.vote-screen__status, .vote-screen__notice {
  position: absolute;
  z-index: 2;
  inset: 73% 5% auto;
  margin: 0;
  text-align: center;
  font: 14px/1.5 system-ui, sans-serif;
  text-shadow: 0 2px 8px #000;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@keyframes confirm-appear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.vote-result { position: absolute; inset: 0; z-index: 3; }
.vote-result.is-complete[data-choice="fire"] { background: #190300; }
.vote-result.is-complete[data-choice="ice"] { background: #101419; }
.vote-result__poster, .vote-result__video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 600ms ease; pointer-events: none;
}
.vote-result__video.is-visible, .vote-result.is-complete .vote-result__poster { opacity: 1; }
.vote-result__title {
  position: absolute; top: 40%; left: 5%; width: 90%; margin: 0;
  padding: 7cqw 4cqw;
  color: #fffaf4; font: 400 clamp(30px, 9.4cqw, 56px)/1.06 Georgia, 'Times New Roman', serif;
  text-align: center;
  border-radius: 999px;
  border: 2px solid var(--result-rim, #dfefff);
  background: linear-gradient(135deg, #ffffff18, #00000045), #080a0e96;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 8px var(--result-glow, #dfefff90), 0 0 32px var(--result-glow, #dfefff70), inset 0 0 20px #ffffff20;
  text-shadow: 0 2px 8px #000c;
  animation: confirm-appear 500ms ease-out both;
}
.vote-result[data-choice="fire"] { --result-rim: #ff8b54; --result-glow: #ff4b20a6; }
.vote-result[data-choice="ice"] { --result-rim: #effaff; --result-glow: #dcefffa6; }
.vote-result[data-choice="ice"] .vote-result__title {
  color: #111820;
  background: linear-gradient(130deg, #f6fbffd9, #c8d6e9bd 48%, #f5fbffde);
  text-shadow: 0 1px 1px #ffffffb3;
  box-shadow: 0 0 8px #f2fbff, 0 0 32px #dcefffaf, inset 0 0 18px #ffffff;
}
.vote-result__title span { display: block; }
.vote-result__title:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
  .vote-button, .vote-button__check, .confirm-button { transition: none; }
  .confirm-button, .vote-result__title { animation: none; }
  .vote-result__poster, .vote-result__video { transition: none; }
}

/* Light catches the letterforms like brushed silver; no outline or bloom. */
.vote-heading span,
.confirm-button span {
  display: inline-block;
  padding: .08em .12em .18em;
  color: #fff4de;
  background: linear-gradient(174deg,
    #ffffff 0%, #f4eee1 23%, #c3b7a3 35%, #fff9ec 43%,
    #ffffff 49%, #d5c8b4 58%, #fbf1da 73%, #fffdf7 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 1px 1px #000d) drop-shadow(0 3px 5px #0008);
}
.vote-heading { letter-spacing: -.018em; }
.confirm-button { padding: 7px 12px; }
.vote-result__title { letter-spacing: -.025em; }
.vote-result[data-choice="fire"] .vote-result__title span {
  color: #fff0cb;
  background: linear-gradient(174deg, #fffdf1 12%, #ffdeb1 35%, #fff7de 48%, #eeb47e 61%, #fff0cb 85%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 2px 1px #391005);
}
.vote-result[data-choice="ice"] .vote-result__title span {
  color: #172838;
  text-shadow: 0 1px 0 #ffffff, 0 -1px 0 #788ea55c;
}
@media (forced-colors: active) {
  .vote-heading span, .confirm-button span,
  .vote-result[data-choice="fire"] .vote-result__title span {
    background: none;
    -webkit-text-fill-color: currentColor;
    filter: none;
  }
}
