/* ==========================================================================
   Gym World — design tokens
   ========================================================================== */

:root {
  --font-display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --font-sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Cormorant Garamond", "Times New Roman", serif;
  --font-meme: "Roboto Condensed", Impact, "Arial Narrow", "Arial Black", sans-serif;

  --login-bg: #07080a;
  --login-text: #f3f3f1;
  --login-muted: #a3a59f;
  --login-line: rgba(243, 243, 241, 0.14);
  --login-card: rgba(12, 13, 16, 0.72);
  --login-input: rgba(255, 255, 255, 0.045);
  --deny: #e35d5d;

  --analysis-bg: #173047;
  --analysis-label: #8ea3b7;
  --analysis-track: rgba(233, 238, 243, 0.16);
  --analysis-fill: #c5d2de;
  --analysis-pct: #c5d2de;

  --night: #0b1724;
  --night-text: #e9eef3;
  --night-mute: #8ea3b7;
  --night-soft: #c5d2de;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --screen-ms: 780ms;

  --pad: clamp(1.25rem, 4vw, 2.75rem);
}

/* ==========================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

html {
  background: var(--login-bg);
}

body {
  font-family: var(--font-sans);
  color: var(--login-text);
  background: var(--login-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body[data-stage="login"] {
  color-scheme: dark;
}

body[data-stage="analysis"] {
  color-scheme: dark;
  background: var(--analysis-bg);
}

body[data-stage="reveal"],
body[data-stage="finale"] {
  color-scheme: dark;
  background: var(--night);
}

img {
  max-width: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 0.9rem;
  background: #fff;
  color: #111;
  border-radius: 6px;
}

.skip-link:focus {
  top: 1rem;
}

/* ==========================================================================
   Screen framework
   ========================================================================== */

.screen {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity var(--screen-ms) var(--ease-out),
    transform var(--screen-ms) var(--ease-out),
    visibility var(--screen-ms);
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.screen-finale.is-active {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Screen 1 — Login
   ========================================================================== */

.screen-login {
  display: flex;
  flex-direction: column;
  color: var(--login-text);
}

.login-bg {
  position: absolute;
  inset: -6%;
  background:
    url("../assets/hero.jpg") center / cover no-repeat,
    #101114;
  transform: scale(1.04);
  animation: kenburns 32s var(--ease-soft) infinite alternate;
}

.login-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(20, 22, 26, 0.15), transparent 48%),
    linear-gradient(180deg, rgba(7, 8, 10, 0.62) 0%, rgba(7, 8, 10, 0.78) 42%, rgba(7, 8, 10, 0.92) 100%);
}

.login-grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  pointer-events: none;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.login-header,
.login-main,
.login-footer {
  position: relative;
  z-index: 1;
}

.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(var(--pad) - 0.2rem) var(--pad) 0;
}

.brand-mark__name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.38rem 0.7rem 0.38rem 0.55rem;
  border: 1px solid var(--login-line);
  border-radius: 999px;
  color: var(--login-muted);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.03);
}

.portal-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b7f06a;
  box-shadow: 0 0 0 4px rgba(183, 240, 106, 0.12);
}

.login-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem var(--pad) 1.25rem;
}

.login-intro {
  text-align: center;
  max-width: 36rem;
  margin-bottom: 1.75rem;
}

.login-kicker {
  margin: 0 0 0.7rem;
  color: var(--login-muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.login-brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 11vw, 6.4rem);
  font-weight: 400;
  line-height: 0.86;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.login-welcome {
  margin: 1.05rem 0 0;
  color: #d8d9d4;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.login-card {
  width: min(100%, 420px);
  padding: 1.45rem 1.4rem 1.2rem;
  border: 1px solid var(--login-line);
  border-radius: 18px;
  background: var(--login-card);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(22px) saturate(1.2);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  margin-bottom: 1rem;
}

.field label {
  color: #c9cbc4;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  padding: 0.82rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: var(--login-input);
  color: var(--login-text);
  outline: none;
  transition:
    border-color 180ms var(--ease-soft),
    box-shadow 180ms var(--ease-soft),
    background 180ms var(--ease-soft);
}

.field input::placeholder {
  color: #6f726c;
}

.field input:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.field input:focus {
  border-color: rgba(243, 243, 241, 0.55);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 4px rgba(243, 243, 241, 0.08);
}

.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.92rem 1rem;
  border: 0;
  border-radius: 10px;
  background: #f4f4f0;
  color: #111;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    transform 180ms var(--ease-soft),
    background 180ms var(--ease-soft),
    box-shadow 180ms var(--ease-soft);
}

.login-btn:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.login-btn:disabled {
  cursor: wait;
}

.login-btn.is-shaking {
  animation: shake 0.5s ease-in-out, deny-flash 0.5s ease-in-out;
}

.login-help {
  margin: 0.95rem 0 0;
  color: var(--login-muted);
  font-size: 0.78rem;
  text-align: center;
}

.login-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 0.7rem;
  padding: 0 var(--pad) calc(var(--pad) - 0.15rem);
  color: #8d9088;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.login-footer__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #5c5f58;
}

/* ==========================================================================
   Error modal
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.62);
  backdrop-filter: blur(10px);
  animation: fade-in 280ms var(--ease-soft) both;
}

.modal__panel {
  position: relative;
  width: min(100%, 420px);
  padding: 2rem 1.7rem 1.55rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: #141518;
  color: #f3f3f1;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: modal-in 420ms var(--ease-out) both;
}

.modal__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border: 1px solid rgba(227, 93, 93, 0.35);
  border-radius: 50%;
  color: #f0a0a0;
  background: rgba(227, 93, 93, 0.08);
}

.modal__eyebrow {
  margin: 0 0 0.55rem;
  color: #b9bbb4;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.modal__title {
  margin: 0;
  font-size: clamp(1.15rem, 3.2vw, 1.38rem);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.modal__hint {
  margin: 0.7rem 0 0;
  color: #9a9c96;
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal__btn {
  width: 100%;
  margin-top: 1.4rem;
  padding: 0.86rem 1rem;
  border: 0;
  border-radius: 10px;
  background: #f4f4f0;
  color: #111;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition:
    transform 180ms var(--ease-soft),
    background 180ms var(--ease-soft);
}

.modal__btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.modal__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ==========================================================================
   Screen 2 — Analysis
   ========================================================================== */

.screen-analysis {
  display: grid;
  place-items: center;
  background: var(--analysis-bg);
}

.analysis {
  width: min(440px, 78vw);
  text-align: center;
}

.analysis-label {
  margin: 0 0 1.15rem;
  color: var(--analysis-label);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.progress {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--analysis-track);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--analysis-fill);
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.35s linear infinite;
}

.analysis-pct {
  margin: 0.85rem 0 0;
  color: var(--analysis-pct);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* ==========================================================================
   Screen 3 — Reveal
   ========================================================================== */

.screen-reveal {
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(46, 78, 112, 0.28), transparent 52%),
    var(--night);
  color: var(--night-text);
  padding: var(--pad);
}

.reveal {
  width: min(720px, 100%);
  text-align: center;
}

.reveal-kicker,
.reveal-verify,
.reveal-rule,
.reveal-headline,
.reveal-note,
.reveal-btn {
  opacity: 0;
}

.screen-reveal.is-active .reveal-kicker {
  animation: rise 800ms var(--ease-out) 180ms both;
}

.screen-reveal.is-active .reveal-verify {
  animation: rise 800ms var(--ease-out) 1400ms both;
}

.screen-reveal.is-active .reveal-rule {
  animation: rule 900ms var(--ease-out) 2400ms both;
}

.screen-reveal.is-active .reveal-headline {
  animation: rise 1000ms var(--ease-out) 3200ms both;
}

.screen-reveal.is-active .reveal-note {
  animation: rise 800ms var(--ease-out) 4600ms both;
}

.screen-reveal.is-active .reveal-note--heart {
  animation: rise 800ms var(--ease-out) 5100ms both;
}

.screen-reveal.is-active .reveal-btn {
  animation: rise 800ms var(--ease-out) 6000ms both;
}

.reveal-kicker {
  margin: 0;
  color: var(--night-mute);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.reveal-verify {
  margin: 1.15rem 0 0;
  color: var(--night-soft);
  font-size: clamp(1.02rem, 2.4vw, 1.22rem);
  font-weight: 400;
  line-height: 1.55;
}

.reveal-rule {
  width: 72px;
  height: 1px;
  margin: 1.7rem auto 0;
  background: rgba(233, 238, 243, 0.28);
  transform-origin: center;
}

.reveal-headline {
  margin: 1.7rem 0 0;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 6.2vw, 3.55rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.reveal-note {
  margin: 1.25rem 0 0;
  color: var(--night-soft);
  font-size: clamp(1.02rem, 2.3vw, 1.22rem);
  line-height: 1.6;
}

.reveal-note--heart {
  margin-top: 0.35rem;
}

.reveal-btn {
  margin-top: 2.1rem;
  padding: 0.9rem 2.4rem;
  border: 0;
  border-radius: 999px;
  background: #f4f4f0;
  color: #111;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
  transition:
    transform 220ms var(--ease-out),
    box-shadow 220ms var(--ease-out),
    background 220ms var(--ease-soft);
}

.screen-reveal.is-ready .reveal-btn {
  pointer-events: auto;
}

.reveal-btn:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.reveal-btn:focus-visible {
  outline: 2px solid #f4f4f0;
  outline-offset: 4px;
}

/* ==========================================================================
   Screen 4 — Finale
   ========================================================================== */

.screen-finale {
  display: grid;
  align-content: start;
  justify-items: center;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(46, 78, 112, 0.28), transparent 52%),
    var(--night);
  color: var(--night-text);
  padding: clamp(4.5rem, 16vh, 8rem) var(--pad) calc(var(--pad) + 1.4rem);
}

.letter {
  width: min(780px, 100%);
  text-align: center;
}

.letter-line {
  margin: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px);
  filter: blur(8px);
  transition:
    opacity 1.15s var(--ease-out),
    transform 1.15s var(--ease-out),
    filter 1.15s var(--ease-out),
    max-height 1.15s var(--ease-out),
    margin 1.15s var(--ease-out);
}

.letter-line.is-visible {
  max-height: 16em;
  overflow: visible;
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

.letter-line.is-visible + .letter-line.is-visible {
  margin-top: 1.55rem;
}

.letter-line--lead,
.letter-line--aside,
.letter-line--soft,
.letter-line--last {
  font-family: var(--font-meme);
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  line-height: 1.08;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 #000, 5px 5px 0 rgba(0, 0, 0, 0.45);
}

.letter-line--lead {
  font-size: clamp(1.95rem, 5.4vw, 3.3rem);
}

.letter-line--aside,
.letter-line--soft,
.letter-line--last {
  font-size: clamp(1.32rem, 3.7vw, 2.05rem);
}

.finale-angry {
  display: inline-block;
  margin-left: 0.08em;
  transform-origin: 70% 80%;
}

.letter-line--lead.is-visible .finale-angry {
  animation: wiggle 1.35s ease-in-out infinite;
}

.finale-stack {
  width: min(860px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.poll {
  --step: 0;
  width: 100%;
  margin-top: 2.4rem;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 800ms var(--ease-out),
    transform 800ms var(--ease-out);
}

.poll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.poll-question {
  margin: 0 0 1.1rem;
  color: var(--night-soft);
  font-size: clamp(1.05rem, 2.6vw, 1.35rem);
  font-weight: 600;
}

.poll-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(0.55rem, 2vw, 1rem);
  width: 100%;
}

.poll-yes,
.poll-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: calc(50% - 0.4rem);
  height: 3.4rem;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow: hidden;
  cursor: pointer;
  transition:
    width 280ms var(--ease-out),
    height 280ms var(--ease-out),
    font-size 280ms var(--ease-out),
    padding 280ms var(--ease-out),
    background 180ms var(--ease-soft);
}

.poll-yes {
  background: #f4f4f0;
  color: #111;
  padding: 0.45rem 0.6rem;
}

.poll-no {
  background: #e8c36a;
  color: #1a1208;
  padding: 0.45rem 0.6rem;
}

.poll-yes:hover {
  background: #fff;
}

.poll-no:hover {
  background: #f3d27a;
}

.poll-yes:focus-visible,
.poll-no:focus-visible {
  outline: 2px solid #f4f4f0;
  outline-offset: 3px;
}

.poll.is-won .poll-yes,
.poll.is-won .poll-no {
  pointer-events: none;
}

.win {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--pad);
}

.win[hidden] {
  display: none;
}

.win-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.win-message {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 18ch;
  padding: 1.1rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(11, 23, 36, 0.82);
  color: #fff;
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  backdrop-filter: blur(10px);
  animation: rise 500ms var(--ease-out) both;
}

/* ==========================================================================
   Motion
   ========================================================================== */

@keyframes kenburns {
  from {
    transform: scale(1.04);
  }
  to {
    transform: scale(1.12);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-7px);
  }
  36% {
    transform: translateX(7px);
  }
  54% {
    transform: translateX(-5px);
  }
  72% {
    transform: translateX(4px);
  }
  88% {
    transform: translateX(-2px);
  }
}

@keyframes deny-flash {
  40%,
  60% {
    box-shadow: 0 0 0 1px rgba(227, 93, 93, 0.7), 0 0 0 6px rgba(227, 93, 93, 0.12);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rule {
  from {
    opacity: 0;
    transform: scaleX(0.2);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  28% {
    transform: rotate(-14deg);
  }
  56% {
    transform: rotate(10deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .login-bg {
    animation: none;
  }

  .progress-fill::after {
    display: none;
  }

  .letter-line {
    filter: none;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .login-header {
    align-items: flex-start;
  }

  .portal-badge {
    letter-spacing: 0.08em;
    font-size: 0.62rem;
  }

  .login-card {
    padding: 1.2rem 1.05rem 1.05rem;
  }

  .login-footer {
    padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  }
}

@media (max-height: 740px) and (max-width: 900px) {
  .login-brand {
    font-size: clamp(2.6rem, 12vw, 4.2rem);
  }

  .login-intro {
    margin-bottom: 1.1rem;
  }
}
