/* ==========================================================================
   SHOTFORM — DESIGN TOKENS
   ========================================================================== */
:root {
  /* Color */
  --bg: #0A0A0D;
  --bg-elevated: #131316;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --ember: #FF6B4A;
  --ember-deep: #B91C1C;
  --ember-bright: #FF3B30;
  --court: #E8A33D;

  --text-primary: #F5F3F0;
  --text-secondary: #A8A8B3;
  --text-tertiary: #6C6C76;

  --danger: #FF6B6B;
  --success: #3DDC97;

  --grad-ember: linear-gradient(135deg, var(--ember) 0%, var(--ember-deep) 100%);
  --grad-ember-soft: linear-gradient(135deg, rgba(255,107,74,0.18) 0%, rgba(185,28,28,0.12) 100%);

  /* Type */
  --font-display: "Sora", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Layout */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-full: 999px;
  --max-width: 480px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 180ms;
  --dur-med: 360ms;
  --dur-slow: 620ms;
}

@font-face {
  font-family: "Sora";
  src: local("Sora");
  font-display: swap;
}

/* ==========================================================================
   RESET
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  height: 100vh;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }

::selection { background: var(--ember); color: #fff; }

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ==========================================================================
   AMBIENT BACKDROP
   ========================================================================== */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}

.glow--one {
  width: 60vh;
  height: 60vh;
  top: -20vh;
  right: -18vh;
  background: radial-gradient(circle, rgba(255,107,74,0.55) 0%, rgba(255,107,74,0) 70%);
  animation: drift-one 16s var(--ease-in-out) infinite alternate;
}

.glow--two {
  width: 55vh;
  height: 55vh;
  bottom: -22vh;
  left: -16vh;
  background: radial-gradient(circle, rgba(185,28,28,0.5) 0%, rgba(185,28,28,0) 70%);
  animation: drift-two 19s var(--ease-in-out) infinite alternate;
}

@keyframes drift-one {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-6%, 8%) scale(1.12); }
}
@keyframes drift-two {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(8%, -6%) scale(1.08); }
}

/* faint court arc line etched into the backdrop, for texture */
.court-lines {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 118%, transparent 0%, transparent 38.5%, rgba(255,255,255,0.05) 39%, rgba(255,255,255,0.05) 39.6%, transparent 40%);
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .glow--one, .glow--two { animation: none; }
}

/* ==========================================================================
   LOADER
   ========================================================================== */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity var(--dur-slow) var(--ease-out), visibility var(--dur-slow);
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader__ball {
  width: 44px;
  height: 44px;
  animation: spin-bounce 1.1s var(--ease-in-out) infinite;
}

@keyframes spin-bounce {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(0.85); }
  100% { transform: rotate(360deg) scale(1); }
}

/* ==========================================================================
   APP SHELL / SCREENS
   ========================================================================== */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

/* Each screen is a discrete, full-viewport page. Only the active one is
   interactive; screens crossfade/slide between one another rather than the
   document scrolling from one to the next. If a screen's own content is
   taller than the viewport, that screen scrolls internally. */
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: max(28px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen.is-page-entering { animation: page-in var(--dur-slow) var(--ease-out) forwards; }
.screen.is-page-leaving { animation: page-out var(--dur-med) var(--ease-in-out) forwards; pointer-events: none; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes page-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-12px) scale(0.99); }
}

/* Centered, max-width column that holds each screen's actual content.
   Kept separate from .screen so full-bleed decoration (confetti canvas,
   completion glow) can still span the entire screen. */
.screen__inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--max-width);
  min-height: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

.screen__inner--center {
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* ==========================================================================
   WELCOME SCREEN
   ========================================================================== */
.screen--welcome .screen__inner {
  justify-content: center;
  align-items: stretch;
}

.welcome__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  opacity: 0;
  animation: fade-in-up var(--dur-slow) var(--ease-out) 80ms forwards;
}

.brand__mark { width: 30px; height: 30px; display: block; }
.brand__mark svg { width: 100%; height: 100%; }

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.welcome__title {
  font-size: clamp(34px, 9vw, 46px);
  line-height: 1.08;
  opacity: 0;
  animation: fade-in-up var(--dur-slow) var(--ease-out) 220ms forwards;
}

.text-gradient {
  background: var(--grad-ember);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome__subtitle {
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 34ch;
  opacity: 0;
  animation: fade-in-up var(--dur-slow) var(--ease-out) 380ms forwards;
}

.welcome__content .btn--large {
  margin-top: 22px;
  opacity: 0;
  animation: slide-up-in var(--dur-slow) var(--ease-out) 560ms forwards;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up-in {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  padding: 15px 22px;
  border-radius: var(--radius-full);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
  user-select: none;
  -webkit-user-select: none;
}

.btn:active { transform: scale(0.96); }

.btn--primary {
  background: var(--grad-ember);
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(255, 59, 48, 0.55);
}

.btn--primary:hover { box-shadow: 0 10px 30px -6px rgba(255, 59, 48, 0.7); }

.btn--primary:disabled {
  opacity: 0.4;
  box-shadow: none;
  pointer-events: none;
}

.btn--large { width: 100%; padding: 17px 24px; font-size: 16px; }
.btn--full { width: 100%; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background var(--dur-fast), transform var(--dur-fast), opacity var(--dur-fast);
  flex-shrink: 0;
}

.icon-btn:active { transform: scale(0.9); }
.icon-btn:hover { background: var(--surface-strong); }

.icon-btn:disabled { opacity: 0; pointer-events: none; }

/* ==========================================================================
   QUIZ HEADER + SIGNATURE ARC PROGRESS
   ========================================================================== */
.quiz__header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.arc-progress { flex: 1; height: 40px; }
.arc-progress__svg { width: 100%; height: 100%; overflow: visible; }

#arcFill {
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  transition: stroke-dashoffset var(--dur-slow) var(--ease-in-out);
}

#arcBall {
  transition: transform var(--dur-slow) var(--ease-in-out);
  filter: drop-shadow(0 0 6px rgba(255, 107, 74, 0.8));
}

.quiz__step-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
  min-width: 34px;
  text-align: right;
}

/* ==========================================================================
   QUIZ BODY / QUESTIONS
   ========================================================================== */
.quiz__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 0 40px;
  position: relative;
}

.question {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.question.is-entering { animation: q-in var(--dur-med) var(--ease-out) forwards; }
.question.is-leaving-back { animation: q-out-right var(--dur-fast) var(--ease-in-out) forwards; }
.question.is-leaving-forward { animation: q-out-left var(--dur-fast) var(--ease-in-out) forwards; }
.question.is-entering-back { animation: q-in-back var(--dur-med) var(--ease-out) forwards; }

@keyframes q-in {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes q-in-back {
  from { opacity: 0; transform: translateX(-28px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes q-out-left {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-28px); }
}
@keyframes q-out-right {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(28px); }
}

.question__eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ember);
}

.question__title {
  font-size: clamp(24px, 6.5vw, 30px);
  line-height: 1.18;
}

.question__hint {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-top: -12px;
}

/* ==========================================================================
   GLASS INPUT CARDS
   ========================================================================== */
.field {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-md);
  padding: 4px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.field:focus-within {
  border-color: var(--ember);
  background: var(--surface-strong);
}

.field input[type="text"],
.field input[type="number"] {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 16px 16px;
  font-size: 18px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
}

.field input::placeholder { color: var(--text-tertiary); font-weight: 500; }

/* Compound field (height ft/in, weight number+unit) */
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.field-row .field input { text-align: center; }

.field__suffix {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 13px;
  padding-right: 14px;
  font-weight: 600;
}

.field--with-suffix { display: flex; align-items: center; }
.field--with-suffix input { flex: 1; }

/* Unit toggle (lbs / kg) */
.toggle-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px;
  gap: 4px;
}

.toggle-group__opt {
  flex: 1;
  text-align: center;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
}

.toggle-group__opt.is-active {
  background: var(--grad-ember);
  color: #fff;
}

/* ==========================================================================
   SLIDER FIELD (e.g. age)
   ========================================================================== */
.slider-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 2px 2px;
}

.slider-field__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 58px;
  line-height: 1;
  text-align: center;
  background: var(--grad-ember);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transition: transform var(--dur-fast) var(--ease-out);
}

.slider-field__value.is-pulsing { transform: scale(1.1); }

.slider-field__track-wrap { padding: 18px 2px 4px; }

input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--ember) 0%,
    var(--ember) var(--fill, 50%),
    var(--surface-strong) var(--fill, 50%),
    var(--surface-strong) 100%
  );
  outline: none;
  cursor: pointer;
  touch-action: pan-y;
}

input[type="range"].slider:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 6px;
}

input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad-ember);
  border: 3px solid var(--bg);
  box-shadow: 0 4px 16px -2px rgba(255, 59, 48, 0.65), 0 0 0 1px var(--border-strong);
  transition: transform var(--dur-fast) var(--ease-out);
}

input[type="range"].slider::-webkit-slider-thumb:active { transform: scale(1.18); }

input[type="range"].slider::-moz-range-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-strong);
}

input[type="range"].slider::-moz-range-progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--grad-ember);
}

input[type="range"].slider::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad-ember);
  border: 3px solid var(--bg);
  box-shadow: 0 4px 16px -2px rgba(255, 59, 48, 0.65);
  transition: transform var(--dur-fast) var(--ease-out);
}

input[type="range"].slider::-moz-range-thumb:active { transform: scale(1.18); }

.slider-field__scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  font-family: var(--font-display);
  padding: 0 1px;
}

/* ==========================================================================
   OPTION GRID (single / multi select choice buttons)
   ========================================================================== */
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.option-grid.is-list { grid-template-columns: 1fr; }

.option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-primary);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast), background var(--dur-fast);
}

.option:active { transform: scale(0.97); }

.option.is-selected {
  border-color: var(--ember);
  background: var(--grad-ember-soft);
}

.option__check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.option.is-selected .option__check {
  background: var(--grad-ember);
  border-color: transparent;
}

.option__check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity var(--dur-fast), transform var(--dur-fast);
}

.option.is-selected .option__check svg { opacity: 1; transform: scale(1); }

/* radio-style circular check for single-select */
.option-grid.is-radio .option__check { border-radius: var(--radius-full); }

/* Days-of-week calendar picker */
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-pill {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-secondary);
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}

.day-pill:active { transform: scale(0.92); }

.day-pill.is-selected {
  background: var(--grad-ember);
  border-color: transparent;
  color: #fff;
}

.day-pill__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.day-pill.is-selected .day-pill__dot { opacity: 1; }

/* ==========================================================================
   FOOTER / ERRORS
   ========================================================================== */
.quiz__footer {
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-message {
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  animation: shake 320ms var(--ease-in-out);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ==========================================================================
   COMPLETE SCREEN
   ========================================================================== */
.screen--complete {
  overflow: hidden;
}

.complete__glow {
  position: absolute;
  width: 70vh;
  height: 70vh;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,74,0.35) 0%, rgba(255,107,74,0) 68%);
  filter: blur(40px);
  animation: pulse-glow 2.6s var(--ease-in-out) infinite;
  pointer-events: none;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

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

.complete__content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}

.check-wrap { margin-bottom: 14px; }

.check-svg { width: 84px; height: 84px; }

.check-circle {
  stroke-dasharray: 226;
  stroke-dashoffset: 226;
  animation: draw-circle 700ms var(--ease-out) forwards;
}

.check-mark {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: draw-check 420ms var(--ease-out) 620ms forwards;
}

@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}
@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

.complete__title {
  font-size: 30px;
  opacity: 0;
  animation: fade-in-up var(--dur-med) var(--ease-out) 900ms forwards;
}

.complete__subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  opacity: 0;
  animation: fade-in-up var(--dur-med) var(--ease-out) 1020ms forwards;
}

.profile-summary {
  margin-top: 24px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  opacity: 0;
  animation: fade-in-up var(--dur-med) var(--ease-out) 1140ms forwards;
}

.profile-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13.5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.profile-summary__row:last-child { border-bottom: none; }

.profile-summary__label {
  color: var(--text-tertiary);
  font-weight: 600;
  flex-shrink: 0;
}

.profile-summary__value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (min-width: 560px) {
  .screen { padding-top: 48px; }
  .welcome__content { gap: 20px; }
}

@media (max-height: 680px) {
  .quiz__body { padding: 12px 0 24px; }
  .question { gap: 16px; }
}

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