/* ==========================================================================
   Wstore Player — Pairing portal styles
   Design tokens mirror the Android app (dark navy, OLED dark, content-first).
   ========================================================================== */

:root {
  /* Color tokens */
  --color-bg: #0B1020;
  --color-surface: #131A2E;
  --color-surface-raised: #1B2440;
  --color-accent: #3D7BFF;
  --color-accent-hover: #5B91FF;
  --color-text: #F8FAFC;
  --color-text-muted: #9AA4BD;
  --color-border: #263055;
  --color-error: #EF4444;
  --color-success: #22C55E;

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Inter", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-base: 16px;
  --line-height: 1.5;

  /* Shape & spacing */
  --radius-card: 16px;
  --radius-input: 10px;
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.45);

  /* Motion */
  --transition: 180ms ease-out;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --------------------------------------------------------------------------
   Page layout — single centered card on the dark background
   -------------------------------------------------------------------------- */
.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  gap: 20px;
}

.card {
  width: 100%;
  max-width: 420px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 32px 24px;
}

@media (min-width: 480px) {
  .card {
    padding: 40px 32px;
  }
}

/* --------------------------------------------------------------------------
   Brand wordmark
   -------------------------------------------------------------------------- */
.brand {
  margin-bottom: 24px;
}

.brand__logo {
  color: var(--color-accent);
  display: block;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.card__header {
  margin-bottom: 24px;
}

.card__title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card__subtitle {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* --------------------------------------------------------------------------
   Form & fields
   -------------------------------------------------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field__label {
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.field__input {
  width: 100%;
  min-height: 48px; /* >= 44px touch target */
  padding: 12px 14px;
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field__input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.field__input:hover {
  border-color: #324070;
}

/* Code input: uppercase, letter-spaced, tabular/monospaced figures */
.field__input--code {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  letter-spacing: 0.5em;
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  padding-left: calc(14px + 0.25em); /* visually offset the trailing letter-spacing */
}

.field__hint {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* Password field: input + toggle button side by side */
.field__password {
  position: relative;
  display: flex;
  align-items: center;
}

.field__password .field__input {
  padding-right: 48px; /* room for the toggle */
}

.field__toggle {
  position: absolute;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition);
}

.field__toggle:hover {
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Inline / form errors (never color-only — paired with icon or "Error:" text)
   -------------------------------------------------------------------------- */
.field__error {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-error);
}

/* "Error:" prefix so meaning isn't conveyed by color alone */
.field__error::before {
  content: "Error: ";
  font-weight: 600;
}

.field__input--invalid {
  border-color: var(--color-error);
}

.form__error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-input);
  color: var(--color-error);
  font-size: 0.875rem;
  font-weight: 500;
}

.form__error .icon {
  flex-shrink: 0;
  margin-top: 1px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-input);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition),
    opacity var(--transition);
}

.btn--primary {
  background-color: var(--color-accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background-color: var(--color-accent-hover);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Loading spinner inside the button (hidden unless .is-loading) */
.btn__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading .btn__spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Success state (replaces the form)
   -------------------------------------------------------------------------- */
.success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0;
  animation: fade-in var(--transition);
}

.success__icon {
  color: var(--color-success);
  margin-bottom: 16px;
}

.success__title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
}

.success__text {
  margin: 0;
  color: var(--color-text-muted);
}

.success__status {
  margin: 16px 0 0;
  color: var(--color-success);
  font-size: 0.875rem;
  font-weight: 500;
}

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

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.page__footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.page__footer p {
  margin: 0;
}

/* --------------------------------------------------------------------------
   Focus rings — visible 2px accent ring on all interactive elements
   -------------------------------------------------------------------------- */
.field__input:focus-visible,
.field__toggle:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-color: var(--color-accent);
}

/* Remove default outline only where we replace it with focus-visible */
.field__input:focus:not(:focus-visible),
.field__toggle:focus:not(:focus-visible),
.btn:focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   Reduced motion — disable transitions/animations for users who ask
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
