/* ==========================================================================
   Noisebox Anthems: tie-break ranking page
   Look and feel taken from anthems-page/styles.css (the voting page): same
   palette, type, header, cards, sticky submit bar and submit sequence.
   Fonts are vendored in vendor/fonts (see its README), not loaded from Google.
   ========================================================================== */

@font-face { font-family: 'Overpass'; font-weight: 400; font-display: swap; src: url('vendor/fonts/overpass-400.ttf') format('truetype'); }
@font-face { font-family: 'Overpass'; font-weight: 600; font-display: swap; src: url('vendor/fonts/overpass-600.ttf') format('truetype'); }
@font-face { font-family: 'Overpass'; font-weight: 700; font-display: swap; src: url('vendor/fonts/overpass-700.ttf') format('truetype'); }
@font-face { font-family: 'Nothing You Could Do'; font-weight: 400; font-display: swap; src: url('vendor/fonts/nothing-you-could-do-400.ttf') format('truetype'); }
@font-face { font-family: 'Special Elite'; font-weight: 400; font-display: swap; src: url('vendor/fonts/special-elite-400.ttf') format('truetype'); }

:root {
  --primary: #FF914D;
  --secondary: #BB2F5D;
  --accent: #4B0056;
  --peach: #FFC5A1;
  --ink: #161616;
  --paper: #FFFBF6;
  --paper-dim: #F6EDE4;
  --line: #E7D9CB;
  --ok: #2E7D5B;

  --font-display: 'archive', 'Special Elite', 'Georgia', serif;
  --font-hand: 'Nothing You Could Do', cursive;
  --font-body: 'Overpass', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-accent: var(--font-body);

  --header-h: 108px;
  --header-h-shrink: 68px;
  --submit-h: 84px;

  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255, 251, 246, .85), rgba(255, 251, 246, .85)),
    url('assets/NA4_background.webp') center/cover no-repeat fixed,
    var(--paper);
  color: var(--ink);
  line-height: 1.55;
  padding-bottom: calc(var(--submit-h) + 12px);
}

img { max-width: 100%; display: block; }

/* ---------- Sticky header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: #DB2F1F url('assets/NA4_background.webp') center/420px repeat;
  color: var(--paper);
  padding: 0 clamp(16px, 4vw, 40px);
  transition: height .28s var(--ease), box-shadow .28s var(--ease);
  overflow-anchor: none;
  will-change: height;
}
.site-header.is-scrolled {
  height: var(--header-h-shrink);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.site-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  max-width: 1180px;
  height: 100%;
  margin: 0 auto;
}
.site-header__brand {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  pointer-events: none;
}
.site-header__logo {
  height: 170px;
  width: auto;
  transition: height .28s var(--ease);
  will-change: height;
}
.site-header.is-scrolled .site-header__logo { height: 120px; }

.site-header__meta {
  text-align: right;
  font-size: 13px;
  opacity: .9;
  display: none;
  background: rgba(22, 22, 22, .55);
  padding: 9px 14px 7px;
  border-radius: 10px;
}
@media (min-width: 640px) { .site-header__meta { display: block; } }
.site-header__meta strong { color: var(--primary); }

/* ---------- Intro ---------- */

.intro {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 48px) clamp(16px, 4vw, 40px) 8px;
  text-align: center;
}
.intro__eyebrow {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(30px, 5vw, 42px);
  color: var(--secondary);
  margin: 0 0 6px;
  line-height: 1.2;
}
.intro__headline {
  font-family: var(--font-display);
  font-size: clamp(18px, 3vw, 23px);
  line-height: 1.2;
  color: var(--accent);
  margin: 0 0 14px;
}
.intro p { margin: 0 0 12px; }
.nowrap { white-space: nowrap; }
.intro__how {
  font-size: 14px;
  color: #4a3f36;
}
/* Inline with the text, so on a phone it stays at the start of the
   sentence instead of wrapping onto a line of its own. */
.intro__how svg { display: inline; vertical-align: -2px; margin-right: 6px; color: var(--secondary); }

/* ---------- The ranking list ---------- */

.rank-list {
  list-style: none;
  max-width: 760px;
  margin: 10px auto 0;
  padding: 0 clamp(16px, 4vw, 40px) 24px;
  position: relative;
}

.rank-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 6px;
  margin-bottom: 10px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
@media (pointer: fine) { .rank-card { cursor: grab; } }
.rank-card:hover { box-shadow: 0 10px 24px rgba(22,22,22,.08); }

/* Above the cut: the presenter's own Top 13. */
.rank-card.is-in {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary) inset;
}
.rank-card.is-out { background: rgba(255, 255, 255, .7); }
.rank-card.is-out .rank-thumb { opacity: .75; }

.rank-card.is-dragging {
  z-index: 5;
  cursor: grabbing;
  box-shadow: 0 18px 40px rgba(22,22,22,.22), 0 0 0 2px var(--secondary) inset;
  border-color: var(--secondary);
  transition: border-color .2s var(--ease);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

.rank-grip {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 52px;
  border: 0;
  padding: 0;
  background: none;
  color: #B9A898;
  border-radius: 8px;
  cursor: grab;
  /* The grip is the touch drag handle: claim the gesture so dragging it
     doesn't scroll the page. The rest of the card still scrolls normally. */
  touch-action: none;
}
.rank-grip:hover, .rank-card.is-dragging .rank-grip { color: var(--secondary); }
.rank-grip:focus-visible { outline: 2px solid var(--secondary); outline-offset: 1px; }

.rank-num {
  flex: 0 0 auto;
  width: 38px;
  text-align: center;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  padding-top: 6px;
  color: var(--secondary);
}
.rank-card.is-out .rank-num { color: #B9A898; }

.rank-thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper-dim);
}
.rank-thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

.rank-meta { flex: 1; min-width: 0; }
.rank-artist {
  font-weight: 700;
  font-size: 15.5px;
  margin: 0 0 2px;
  overflow-wrap: break-word;
}
.rank-title {
  margin: 0;
  font-size: 14px;
  color: #4a3f36;
  overflow-wrap: break-word;
}

.rank-moves {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rank-move {
  display: grid;
  place-items: center;
  width: 36px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .12s var(--ease);
}
.rank-move:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); }
.rank-move:active:not(:disabled) { transform: scale(.92); }
.rank-move:focus-visible { outline: 2px solid var(--secondary); outline-offset: 1px; }
.rank-move:disabled { opacity: .3; cursor: default; }

/* The cut: where the presenter's Top 13 ends. */
.rank-cut {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 20px;
  color: var(--secondary);
  pointer-events: none;
}
.rank-cut::before, .rank-cut::after {
  content: "";
  flex: 1;
  height: 0;
  border-top: 3px dashed var(--secondary);
}
.rank-cut__label {
  text-align: center;
  line-height: 1.15;
}
.rank-cut__label strong {
  display: block;
  font-family: var(--font-hand);
  font-size: 30px;
  line-height: 1.1;
}
.rank-cut__label span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #4a3f36;
}

.page-version {
  text-align: center;
  font-size: 12px;
  color: #8a7a6c;
  margin: 0 0 12px;
}

/* Narrow phones: smaller thumbs so the artist and title keep their room. */
@media (max-width: 420px) {
  .rank-card { gap: 7px; padding-right: 6px; }
  .rank-thumb { flex-basis: 48px; width: 48px; height: 48px; }
  .rank-num { width: 30px; font-size: 26px; }
  .rank-grip { width: 24px; }
  .rank-artist { font-size: 14.5px; }
  .rank-title { font-size: 13px; }
}

/* Screen-reader-only live announcements of moves. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Sticky submit bar ---------- */

.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: var(--submit-h);
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  box-shadow: 0 -8px 24px rgba(0,0,0,.18);
}
.submit-bar__inner {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  padding: 0 clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vw, 16px);
}
.submit-bar__name { flex: 1 1 160px; min-width: 0; }

/* Honeypot: in the DOM and out of the tab order rather than display:none,
   since some bots skip fields hidden that way. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.name-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 15px 16px 11px;
  border-radius: 14px;
  border: 1px solid rgba(255, 251, 246, .25);
  background: rgba(255, 251, 246, .08);
  color: var(--paper);
  text-overflow: ellipsis;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.name-input::placeholder { color: rgba(255, 251, 246, .5); }
.name-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 251, 246, .14);
}
.name-input.is-error {
  border-color: var(--secondary);
  animation: name-shake .32s var(--ease);
}
@keyframes name-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.submit-btn {
  font-family: var(--font-accent);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  background: var(--primary);
  color: var(--ink);
  cursor: pointer;
  transition: background .2s var(--ease), transform .15s var(--ease), opacity .2s var(--ease);
}
.submit-btn:hover { background: var(--secondary); color: #fff; transform: translateY(-1px); }

@media (max-width: 480px) {
  :root { --submit-h: 128px; }
  .submit-bar { height: auto; padding: 12px 0; }
  .submit-bar__inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .submit-bar__name { flex: 0 0 auto; }
  .submit-btn { width: 100%; text-align: center; }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--submit-h) + 16px);
  transform: translate(-50%, 12px);
  background: var(--secondary);
  color: #fff;
  padding: 11px 18px 9px;
  border-radius: 14px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Submit sequence (spinner + result box) ---------- */

body[data-state="submitting"],
body[data-state="result-success"],
body[data-state="result-error"] {
  background-image:
    linear-gradient(rgba(255, 251, 246, .5), rgba(255, 251, 246, .5)),
    url('assets/NA4_background.webp');
}
body[data-state="submitting"] main,
body[data-state="submitting"] .submit-bar,
body[data-state="result-success"] main,
body[data-state="result-success"] .submit-bar,
body[data-state="result-success"] .site-header,
body[data-state="result-error"] main,
body[data-state="result-error"] .submit-bar,
body[data-state="result-error"] .site-header {
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s var(--ease);
}

.state-scrim {
  position: fixed;
  inset: 0;
  background: #DB2F1F url('assets/NA4_background.webp') center/420px repeat;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s var(--ease);
  z-index: 80;
}
body[data-state="result-success"] .state-scrim,
body[data-state="result-error"] .state-scrim { opacity: 1; }

.submit-spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border: 7px solid rgba(255, 251, 246, .35);
  border-top-color: var(--paper);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
  animation: submit-spin 0.9s linear infinite;
  z-index: 90;
}
body[data-state="submitting"] .submit-spinner { opacity: 1; }
@keyframes submit-spin { to { transform: rotate(360deg); } }

.result-box {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  transform: translate(-50%, -46%);
  background: var(--paper);
  border-radius: 20px;
  padding: 26px 24px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s var(--ease), transform .4s var(--ease);
  z-index: 90;
}
.result-box.is-shown {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
.result-box__logo { width: 150px; margin: -6px auto 6px; }
.result-box__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  margin: 0 0 8px;
  color: var(--accent);
}
.result-box--error .result-box__title { font-weight: normal; font-size: 22px; color: var(--secondary); }
.result-box__message { margin: 0 0 14px; line-height: 1.5; }

.result-box__list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  text-align: left;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.result-box__list li {
  display: flex;
  gap: 10px;
  padding: 5px 2px 3px;
  border-bottom: 1px solid var(--line);
}
.result-box__list li.is-out { color: #8a7a6c; }
.result-box__list li.is-out b { color: #B9A898; }
.result-box__list li.result-box__cut {
  justify-content: center;
  border-bottom: 2px dashed var(--secondary);
  font-family: var(--font-hand);
  font-size: 17px;
  color: var(--secondary);
  padding: 6px 0 2px;
}
.result-box:focus { outline: none; }
.result-box__list b {
  flex: 0 0 22px;
  text-align: right;
  font-family: var(--font-hand);
  color: var(--secondary);
  font-size: 17px;
  line-height: 1.2;
}

.result-box__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.result-box__links button {
  font-family: var(--font-accent);
  font-weight: 600;
  font-size: 14px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 10px 18px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.result-box__links button:hover { background: var(--secondary); transform: translateY(-1px); }
