/* =============================================================
   WITCHERY MMO — PRE-GAME UX PASS
   Aligns splash / login / main-menu / creation-entry / class-picker /
   questionnaire / character creation / selection / first-skill / story-intro
   with public_website/styles.css tokens + game art immersion.

   Tokens mirror public_website :root so both surfaces stay in sync.
   Loaded after styles.css (see witchery.html).
   ============================================================= */

:root {
  --gradient-card: linear-gradient(135deg, rgba(10, 6, 30, 0.9), rgba(40, 20, 60, 0.85));
  --gradient-accent: linear-gradient(135deg, var(--color-accent-purple), var(--color-accent-gold));
  --color-border: rgba(138, 103, 255, 0.3);
  --color-card-bg: rgba(20, 10, 35, 0.8);
  --pregame-max: 640px;
}

/* ---------- Immersive backdrops: game art, not flat gradient ---------- */
#splash-screen.screen,
#login-screen.screen,
#main-menu.screen,
#creation-entry.screen,
#class-picker.screen,
#backstory-questionnaire.screen,
#character-creation.screen,
#character-selection.screen,
#first-skill-choice.screen,
#first-weapon-choice.screen,
#quick-stat-alloc.screen,
#story-intro.screen {
  background:
    linear-gradient(135deg, rgba(10, 6, 18, 0.88) 0%, rgba(26, 15, 46, 0.82) 55%, rgba(13, 10, 26, 0.9) 100%),
    url('../environment/causeway_1.jpeg') center / cover no-repeat fixed,
    linear-gradient(135deg, #0a0612 0%, #1a0f2e 50%, #0d0a1a 100%);
  background-attachment: fixed, fixed, scroll;
  overflow-y: auto;
  overflow-x: hidden;
}

#splash-screen.screen.active,
#login-screen.screen.active,
#main-menu.screen.active {
  justify-content: center;
  align-items: flex-start;
}

#splash-screen .splash-container,
#login-screen .menu-container,
#main-menu .menu-container,
#creation-entry .creation-entry-box,
#character-selection .party-container,
#story-intro .story-intro-container {
  margin: auto;
}

/* Floating ambient orbs (same language as public_website hero) */
#login-screen.screen::before,
#main-menu.screen::before,
#creation-entry.screen::before {
  content: '';
  position: fixed;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(138, 103, 255, 0.14), transparent);
  border-radius: 50%;
  top: -200px;
  right: -200px;
  pointer-events: none;
  animation: pregame-float 8s ease-in-out infinite;
}

#login-screen.screen::after,
#main-menu.screen::after {
  content: '';
  position: fixed;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(218, 165, 32, 0.12), transparent);
  border-radius: 50%;
  bottom: -100px;
  left: -100px;
  pointer-events: none;
  animation: pregame-float 10s ease-in-out infinite reverse;
}

@keyframes pregame-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(40px); }
}

/* Splash backdrop: real Giant's Causeway photography (set on
   #splash-screen.screen above). No circular orb pseudo-elements here —
   cropped radial blobs read as AI artifacts, so depth comes from a
   full-bleed vignette only. */
#splash-screen .splash-container {
  background: transparent;
}

#splash-screen.screen::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(5, 3, 12, 0.6) 100%);
}

/* ---------- Shared brand header (mirrors public_website hero) ---------- */
.pregame-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.pregame-eyebrow {
  font-family: var(--font-title);
  font-size: 0.78rem;
  color: var(--color-accent-purple);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
  opacity: 0.9;
}

.pregame-title {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--color-text-secondary);
  text-shadow: 0 0 20px rgba(138, 103, 255, 0.6), 0 0 40px rgba(138, 103, 255, 0.3);
  margin-bottom: 0.4rem;
  letter-spacing: 0.08em;
  line-height: 1.05;
}

.pregame-subtitle {
  font-family: var(--font-title);
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  color: var(--color-accent-gold);
  font-style: italic;
  margin-bottom: 0.9rem;
}

.pregame-divider {
  width: 100px;
  height: 3px;
  background: var(--gradient-accent);
  margin: 0 auto 1rem;
  border-radius: 2px;
}

.pregame-lede {
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--color-text-primary);
  max-width: 46ch;
  margin: 0 auto;
}

.pregame-first-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  justify-content: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--color-text-primary);
  opacity: 0.9;
}

.pregame-first-steps strong { color: var(--color-accent-gold); }
.pregame-step-sep { color: var(--color-accent-purple); opacity: 0.6; }

/* ---------- Choice screens: room for a 3-up card row ----------
   A row of 3 skill/weapon cards is 3×220px + 2×20px gaps = 700px. The
   shared 560px card width wrapped the third card onto a clipped second
   row (it read as pushed off-screen on desktop). */
#first-weapon-choice .first-skill-container,
#first-skill-choice .first-skill-container {
  width: min(800px, calc(100vw - 2rem));
  max-width: 800px;
}
/* ---------- Cards: match public_website feature-card language ---------- */
#login-screen .menu-container,
#main-menu .menu-container,
.splash-content,
#creation-entry .creation-entry-box,
#character-selection .party-container,
.first-skill-container,
#quick-stat-alloc .first-skill-container,
.story-intro-container .story-content {
  background: var(--gradient-card) !important;
  border: 1px solid var(--color-border) !important;
  border-top: 3px solid var(--color-accent-gold) !important;
  border-radius: 15px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  backdrop-filter: blur(6px);
  width: min(560px, calc(100vw - 2rem));
  max-width: var(--pregame-max);
}

#main-menu .menu-container { width: min(620px, calc(100vw - 2rem)); }
#creation-entry .creation-entry-box { width: min(880px, calc(100vw - 2rem)); max-width: 880px; }
#class-picker .class-picker-wrapper { width: min(960px, calc(100vw - 2rem)); margin: auto; }
.splash-content { width: min(600px, calc(100vw - 2rem)); }

/* The hero CTA already has its ::before ribbon; our explicit section label
   would duplicate it, so hide the ribbon now that the label exists. */
.menu-hero-cta::before { display: none !important; }
#main-menu .menu-hero-cta { padding: 16px 0 10px; }

/* Section labels inside cards */
.pregame-section-label {
  font-family: var(--font-title);
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(138, 103, 255, 0.75);
  text-align: center;
  margin: 1.25rem 0 0.6rem;
}

/* ---------- Splash upgrades ---------- */
.splash-content .pregame-title { font-size: clamp(2.6rem, 8vw, 4rem); }
.splash-photo {
  width: 100%;
  height: 180px;
  border-radius: 10px;
  overflow: hidden;
  margin: 1rem 0 1.25rem;
  border: 1px solid var(--color-border);
}
.splash-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.05);
}
.pregame-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 0.25rem;
}
.pregame-stat { display: flex; flex-direction: column; align-items: center; }
.pregame-stat-num {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent-gold);
  line-height: 1;
}
.pregame-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-top: 0.2rem;
}
.pregame-stat-divider { color: var(--color-accent-purple); opacity: 0.5; }

/* ---------- Login form: readability first ---------- */
#login-screen .menu-container {
  text-align: left;
  padding: 2rem 2rem 1.5rem;
}

#login-screen .pregame-brand { margin-bottom: 1.25rem; }

/* ---------- Federated-first hierarchy ---------- */
/* Provider buttons lead; the username forms live collapsed below. */
#social-signin { margin-bottom: 0.25rem; }

.social-heading {
  text-align: center;
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  opacity: 0.85;
  margin: 0 0 0.75rem;
}

.legacy-auth {
  margin-top: 1rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.25rem;
}

.legacy-auth > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  cursor: pointer;
  text-align: center;
  font-size: 0.92rem;
  color: var(--color-text-primary);
  opacity: 0.8;
  border-radius: 8px;
}

/* display:flex suppresses the native disclosure marker — use our own. */
.legacy-auth > summary::after {
  content: '▸';
  font-size: 0.8em;
  color: var(--color-accent-gold);
  transition: transform 0.15s ease;
}

.legacy-auth[open] > summary::after { transform: rotate(90deg); }

.legacy-auth > summary:hover { opacity: 1; color: var(--color-accent-gold); }

.legacy-auth-body { padding-top: 0.75rem; }

/* Empty provider slots collapse so the social row never leaves gaps when
   only some of Apple/Google/Discord/Steam are configured. (The slot divs
   are byte-empty until their provider renders into them.) */
.apple-signin-container:not(:has(.native-apple-btn)):has(#appleid-signin:empty),
.google-signin-container:has(#google-signin:empty),
.discord-signin-container:has(#discord-signin:empty),
.steam-signin-container:has(#steam-signin:empty) {
  display: none;
}

.login-tabs {
  margin: 0 0 1.25rem !important;
  gap: 0.5rem !important;
  background: rgba(10, 6, 30, 0.6);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.35rem;
}

.login-tab {
  border: none !important;
  border-radius: 8px !important;
  min-height: 48px;
  font-size: 0.85rem !important;
  box-shadow: none !important;
  white-space: nowrap;
  line-height: 1.2;
}

.login-tab.active {
  background: linear-gradient(180deg, var(--color-purple-dark) 0%, #2a1846 100%) !important;
  border: 1px solid var(--color-accent-purple) !important;
  color: var(--color-text-secondary) !important;
}

.login-tab:focus-visible,
.pregame-brand a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-accent-gold-light);
  outline-offset: 2px;
}

#login-screen .form-group { margin-bottom: 1rem; }

#login-screen .form-group label {
  display: block;
  text-align: left;
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-gold);
  margin-bottom: 0.45rem;
}

#login-screen .form-group label .optional-hint {
  color: var(--color-text-primary);
  opacity: 0.6;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85em;
}

#login-screen input[type="text"],
#login-screen input[type="password"],
#character-creation input[type="text"],
#character-creation select {
  width: 100%;
  font-size: 16px; /* prevents iOS zoom */
  padding: 0.8rem 1rem;
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: rgba(10, 6, 30, 0.7);
  color: #f4e4c1;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#login-screen input:focus,
#character-creation input:focus,
#character-creation select:focus {
  border-color: var(--color-accent-gold);
  box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.25);
  outline: none;
}

#login-screen input::placeholder { opacity: 0.45; }

.form-help {
  font-size: 0.85rem;
  opacity: 0.75;
  margin-top: 0.4rem;
  line-height: 1.5;
}

.remember-me-row { margin: 0.25rem 0 1rem; }
.remember-me-label {
  display: inline-flex !important;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--color-text-primary) !important;
  cursor: pointer;
  min-height: 44px;
  font-family: var(--font-body) !important;
  font-weight: 400 !important;
}
.remember-me-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent-gold);
  cursor: pointer;
}

/* Primary buttons: match public_website .btn-hero-primary */
#login-screen .primary-action-btn,
#main-menu .primary-action-btn,
.splash-button,
.class-picker-actions .primary-action-btn,
#class-picker .primary-action-btn {
  background: var(--color-accent-gold) !important;
  color: #0a0612 !important;
  font-weight: 700 !important;
  border-top: 1px solid #f4c430 !important;
  border-bottom: 3px solid #8b6914 !important;
  border-left: 1px solid #8b6914 !important;
  border-right: 1px solid #8b6914 !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 20px rgba(218, 165, 32, 0.4) !important;
  text-shadow: none !important;
  min-height: 52px;
  width: 100%;
  max-width: 400px;
  transition: background 0.2s, transform 0.1s !important;
}

#login-screen .primary-action-btn:hover,
#main-menu .primary-action-btn:hover,
.splash-button:hover:not(:disabled) {
  background: var(--color-accent-gold-light) !important;
  box-shadow: 0 6px 30px rgba(218, 165, 32, 0.6) !important;
  transform: translateY(-2px);
}

#login-screen .primary-action-btn:active,
#main-menu .primary-action-btn:active {
  transform: translateY(1px) !important;
  border-bottom-width: 1px !important;
}

/* Secondary buttons: match .btn-hero-secondary */
#main-menu .secondary-action-btn,
#character-selection .back-button,
.first-skill-footer .back-button {
  background: transparent !important;
  color: var(--color-text-secondary) !important;
  border: 2px solid var(--color-border) !important;
  border-radius: 4px !important;
  min-height: 48px;
  text-shadow: none !important;
  box-shadow: none !important;
}
#main-menu .secondary-action-btn:hover,
#character-selection .back-button:hover {
  border-color: var(--color-accent-gold) !important;
  color: var(--color-accent-gold) !important;
  transform: none !important;
}

/* Status pill */
.connection-status,
#login-screen .connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  font-size: 0.88rem;
  opacity: 0.9;
}
.connection-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent-gold);
  opacity: 0.7;
  flex-shrink: 0;
}

.pregame-footnote {
  text-align: center;
  font-size: 0.88rem;
  opacity: 0.75;
  margin-top: 1rem;
  line-height: 1.6;
}
.pregame-footnote a { color: #c9b1ff; }

/* ---------- Realm picker (login screen) ---------- */
.realm-picker {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.88rem;
}
.realm-current { opacity: 0.9; margin-bottom: 0.5rem; }
.realm-current #realm-name { color: var(--color-accent-gold); font-weight: 600; }
.realm-buttons { display: flex; gap: 0.5rem; justify-content: center; }
.realm-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: inherit;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  min-height: 44px;
  cursor: pointer;
  font-size: 0.88rem;
}
.realm-btn.active, .realm-btn:hover {
  border-color: var(--color-accent-gold);
  color: var(--color-accent-gold);
}
.realm-btn.primary {
  background: var(--color-accent-gold);
  border-color: var(--color-accent-gold);
  color: #1a1206;
  font-weight: 700;
}
.realm-custom-row { margin-top: 0.75rem; }
.realm-custom-row label { display: block; margin-bottom: 0.25rem; opacity: 0.85; }
.realm-custom-row input[type="text"] { width: 100%; max-width: 340px; }
.realm-custom-actions { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.5rem; }

/* ---------- Main menu hierarchy ---------- */
#main-menu .menu-container { padding: 2rem 2rem 1.5rem; }
#main-menu .pregame-brand .pregame-title { font-size: clamp(1.8rem, 5vw, 2.4rem); }

.active-character-panel {
  background: var(--color-card-bg) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 12px !important;
  border-top: 1px solid var(--color-border) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}
.active-char-header {
  font-family: var(--font-title);
  font-size: 0.75rem !important;
  letter-spacing: 0.15em;
  color: var(--color-accent-gold) !important;
}

.menu-hero-cta {
  background: linear-gradient(180deg, rgba(10, 30, 10, 0.4) 0%, transparent 100%) !important;
  border-top: 1px solid rgba(74, 222, 128, 0.3) !important;
  border-bottom: 1px solid rgba(74, 222, 128, 0.2) !important;
  border-radius: 8px !important;
}
.menu-hero-cta::before { color: rgba(74, 222, 128, 0.65) !important; }
.explore-btn:disabled { opacity: 0.55; }
.menu-cta-hint {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-top: 0.5rem;
}

/* ---------- Creation flow polish (light touch, keep JS intact) ---------- */
.creation-entry-box,
.class-picker-content,
.questionnaire-card,
.creation-container,
.first-skill-container,
.party-container {
  border-radius: 15px;
}
.creation-entry-title,
.class-picker-title,
.first-skill-heading {
  color: var(--color-text-secondary);
  text-shadow: 0 0 15px rgba(138, 103, 255, 0.5);
}
.creation-entry-lore,
.class-picker-subtitle,
.first-skill-subtitle {
  color: var(--color-text-primary);
  opacity: 0.9;
  line-height: 1.65;
}
.creation-path-card,
.class-picker-card,
.first-skill-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.creation-path-card:hover,
.class-picker-card:hover,
.first-skill-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  #login-screen .menu-container,
  #main-menu .menu-container,
  .splash-content,
  #creation-entry .creation-entry-box {
    width: 100%;
    max-width: 100%;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }
  .login-tab { font-size: 0.78rem !important; padding: 10px 8px; }
  .splash-photo { height: 140px; }
  #login-screen .primary-action-btn,
  #main-menu .primary-action-btn {
    max-width: none;
  }
  .pregame-first-steps { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  #login-screen.screen::before,
  #login-screen.screen::after,
  #main-menu.screen::before,
  #main-menu.screen::after,
  .splash-container::before,
  .splash-container::after {
    animation: none !important;
  }
}
