/* Hallmark · macrostructure: Workbench (auth form) · tone: luxury B2B · anchor hue: #CCA030 gold
 * Genre: modern-minimal · Theme: custom · Paper: light/white · Accent: oklch(71% 0.14 78)
 * Fonts: DM Serif Display (brand) + Switzer (UI) · Enrichment: none · Mobile: responsive 320–1280px
 * States: default · hover · focus · active · disabled · loading · error · success ✓
 */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: clip; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; border: none; }
fieldset { border: none; padding: 0; }
legend { float: left; width: 100%; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Paper — warm off-white anchored to gold hue 78 */
  --color-bg:            oklch(95% 0.010 78);
  --color-paper:         oklch(99.5% 0.003 78);
  --color-paper-2:       oklch(97% 0.006 78);
  --color-paper-3:       oklch(93% 0.009 78);

  /* Ink — warm-tinted near-black */
  --color-ink:           oklch(15% 0.008 60);
  --color-ink-2:         oklch(38% 0.007 60);
  --color-ink-3:         oklch(57% 0.005 60);

  /* Rule */
  --color-rule:          oklch(89% 0.007 78);
  --color-rule-2:        oklch(80% 0.010 78);

  /* Accent — exact brand gold #CCA030 */
  --color-accent:        #CCA030;
  --color-accent-hover:  oklch(63% 0.14 78);
  --color-accent-active: oklch(57% 0.14 78);
  --color-accent-fg:     oklch(99% 0.003 78);
  --color-accent-subtle: oklch(97.5% 0.022 78);
  --color-accent-border: oklch(84% 0.07 78);

  /* Error */
  --color-error:         oklch(52% 0.19 25);
  --color-error-bg:      oklch(98.5% 0.018 25);
  --color-error-border:  oklch(82% 0.08 25);

  /* Success */
  --color-success:       oklch(50% 0.15 150);
  --color-success-bg:    oklch(98.5% 0.018 150);
  --color-success-border:oklch(82% 0.07 150);

  /* Focus */
  --color-focus:         #CCA030;

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Switzer', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Text scale — perfect fourth (×1.333) */
  --text-xs:   0.694rem;   /* ~11px */
  --text-sm:   0.813rem;   /* ~13px */
  --text-base: 0.9375rem;  /* 15px  */
  --text-md:   1rem;       /* 16px  */
  --text-lg:   1.125rem;   /* 18px  */
  --text-xl:   1.375rem;   /* 22px  */
  --text-2xl:  1.75rem;    /* 28px  */

  /* Spacing — 4pt base */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radii */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.06);
  --shadow-md: 0 4px 8px oklch(0% 0 0 / 0.07), 0 1px 3px oklch(0% 0 0 / 0.04);
  --shadow-lg: 0 12px 28px oklch(0% 0 0 / 0.09), 0 3px 8px oklch(0% 0 0 / 0.04);
  --shadow-xl: 0 24px 48px oklch(0% 0 0 / 0.11), 0 6px 14px oklch(0% 0 0 / 0.05);

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --dur-fast: 100ms;
  --dur-base: 180ms;
  --dur-slow: 300ms;
}

/* ── Base ───────────────────────────────────────────────────── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-ink);
  background: #0c0904; /* dark fallback behind Lightfall canvas */
  line-height: 1.6;
  min-height: 100dvh;
}

/* ── Auth shell ─────────────────────────────────────────────── */
.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  position: relative;
  z-index: 2;
  background: transparent;
}

/* ── Auth card ──────────────────────────────────────────────── */
.auth-card {
  background: var(--color-paper);
  border-radius: var(--radius-xl);
  box-shadow:
    0 32px 72px rgba(0, 0, 0, 0.60),
    0 10px 28px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(204, 160, 48, 0.14);
  width: 100%;
  max-width: 520px;
  padding: var(--space-10);
}

/* ── Brand ──────────────────────────────────────────────────── */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  text-align: center;
}

.auth-logo {
  height: 64px;
  width: auto;
  object-fit: contain;
}

.auth-brand-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-ink);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.auth-tagline {
  font-size: var(--text-sm);
  color: var(--color-ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ── Divider ────────────────────────────────────────────────── */
.brand-divider {
  width: 32px;
  height: 2px;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
  margin: 0 auto;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--color-rule);
  margin-bottom: var(--space-8);
}

.auth-tab {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink-3);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition:
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.auth-tab:hover { color: var(--color-ink); }

.auth-tab.active {
  color: var(--color-ink);
  border-bottom-color: var(--color-accent);
}

.auth-tab:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ── Form ───────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-section + .form-section {
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-rule);
}

/* ── Account type pills ─────────────────────────────────────── */
.type-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.type-pill {
  position: relative;
  cursor: pointer;
  display: inline-flex;
}

.type-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.type-pill-label {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-rule-2);
  background: var(--color-paper);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}

@media (hover: hover) {
  .type-pill:hover .type-pill-label {
    border-color: var(--color-accent-border);
    color: var(--color-ink);
  }
}

.type-pill:has(input:checked) .type-pill-label {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  color: var(--color-ink);
  font-weight: 600;
  box-shadow: 0 0 0 3px oklch(71% 0.14 78 / 0.10);
}

.type-pill input:focus-visible ~ .type-pill-label {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* ── Field ──────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  line-height: 1.3;
}

.field-required {
  color: var(--color-accent);
  font-size: var(--text-xs);
  margin-left: 1px;
}

.field-optional {
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  font-weight: 400;
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  line-height: 1.5;
}

.field-hint.is-error   { color: var(--color-error); }
.field-hint.is-success { color: var(--color-success); }

/* ── Input ──────────────────────────────────────────────────── */
.input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  background: var(--color-paper-2);
  border: 1.5px solid var(--color-rule);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-ink);
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.input::placeholder { color: var(--color-ink-3); }

@media (hover: hover) {
  .input:hover:not(:disabled):not(:read-only) {
    border-color: var(--color-rule-2);
  }
}

.input:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-paper);
  box-shadow: 0 0 0 3px oklch(71% 0.14 78 / 0.12);
}

.input.is-error {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

.input.is-success {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input:read-only {
  background: var(--color-paper-3);
  color: var(--color-ink-2);
  cursor: default;
}

/* OTP code input */
.otp-input {
  letter-spacing: 0.3em;
  font-weight: 600;
  font-size: var(--text-lg);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* State input (2-letter) */
.input-state {
  text-transform: uppercase;
}

/* ── Input + button row ─────────────────────────────────────── */
.input-btn-row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.input-btn-row .input { flex: 1; min-width: 0; }

/* ── Password toggle wrapper ────────────────────────────────── */
.input-with-toggle {
  position: relative;
}

.input-with-toggle .input { padding-right: 44px; }

.toggle-btn {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ink-3);
  transition: color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) {
  .toggle-btn:hover { color: var(--color-ink); }
}

.toggle-btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -4px;
  border-radius: var(--radius-md);
}

.toggle-btn svg { width: 18px; height: 18px; pointer-events: none; }

/* ── Address row ────────────────────────────────────────────── */
.address-city-row {
  display: grid;
  grid-template-columns: 1fr 72px 88px;
  gap: var(--space-3);
}

/* ── OTP row ────────────────────────────────────────────────── */
.otp-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.otp-row .otp-input { flex: 1; min-width: 0; }

/* ── Email verified badge ───────────────────────────────────── */
.email-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-success);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-pill);
  padding: 2px 10px 2px 8px;
  white-space: nowrap;
}

.email-verified-badge svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ── Additional contact rows ────────────────────────────────── */
.additional-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.removable-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.removable-row .input { flex: 1; min-width: 0; }

.remove-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ink-3);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

@media (hover: hover) {
  .remove-btn:hover {
    color: var(--color-error);
    background: var(--color-error-bg);
  }
}

.remove-btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.remove-btn svg { width: 15px; height: 15px; pointer-events: none; }

/* ── Buttons ────────────────────────────────────────────────── */

/* Primary — gold fill */
.btn-primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  padding: 0 var(--space-8);
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 2px 10px oklch(71% 0.14 78 / 0.28);
  transition:
    background var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  overflow: hidden;
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled):not([aria-busy="true"]) {
    background: var(--color-accent-hover);
    box-shadow: 0 4px 18px oklch(71% 0.14 78 / 0.38);
    transform: translateY(-1px);
  }
}

.btn-primary:active:not(:disabled):not([aria-busy="true"]) {
  background: var(--color-accent-active);
  transform: translateY(0);
  box-shadow: 0 2px 8px oklch(71% 0.14 78 / 0.20);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* Loading state — spinner via ::after, hide text */
.btn-primary[aria-busy="true"] {
  pointer-events: none;
}

.btn-primary[aria-busy="true"] .btn-label {
  visibility: hidden;
}

.btn-primary[aria-busy="true"]::after,
.btn-secondary[aria-busy="true"]::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

/* Secondary — outlined */
.btn-secondary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--space-5);
  background: var(--color-paper);
  color: var(--color-ink);
  border: 1.5px solid var(--color-rule-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition:
    background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
  overflow: hidden;
}

@media (hover: hover) {
  .btn-secondary:hover:not(:disabled):not([aria-busy="true"]) {
    background: var(--color-paper-3);
    border-color: var(--color-accent-border);
  }
}

.btn-secondary:active:not(:disabled) {
  background: var(--color-paper-3);
}

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

.btn-secondary:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.btn-secondary[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.7;
}

.btn-secondary[aria-busy="true"] .btn-label {
  visibility: hidden;
}

/* Ghost dashed — "Add another" */
.btn-ghost-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  height: 38px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  border: 1.5px dashed var(--color-rule-2);
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  transition:
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out);
}

@media (hover: hover) {
  .btn-ghost-add:hover {
    color: var(--color-accent);
    border-color: var(--color-accent-border);
    background: var(--color-accent-subtle);
  }
}

.btn-ghost-add:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.btn-ghost-add svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Spin animation ─────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Form error block ───────────────────────────────────────── */
.form-error {
  padding: var(--space-4);
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-error);
  line-height: 1.5;
}

.form-error ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-error li::before {
  content: '— ';
  opacity: 0.7;
}

/* ── Switch link ────────────────────────────────────────────── */
.form-switch-note {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-ink-3);
}

.link-btn {
  color: var(--color-accent);
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (hover: hover) {
  .link-btn:hover { opacity: 0.8; }
}

.link-btn:focus-visible {
  outline: 2px solid var(--color-focus);
  border-radius: 2px;
  outline-offset: 2px;
}

/* ── Form legend ────────────────────────────────────────────── */
.form-legend {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-ink-2);
  margin-bottom: var(--space-2);
  display: block;
  width: 100%;
  clear: both;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--color-ink);
  color: var(--color-paper);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
  max-width: calc(100vw - var(--space-8));
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error { background: var(--color-error); }

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

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 560px) {
  .auth-shell {
    align-items: flex-start;
    padding: var(--space-4) var(--space-4);
  }

  .auth-card {
    padding: var(--space-8) var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow:
      0 20px 48px rgba(0, 0, 0, 0.55),
      0 6px 18px rgba(0, 0, 0, 0.30),
      0 0 0 1px rgba(204, 160, 48, 0.12);
  }
}

@media (max-width: 420px) {
  .address-city-row {
    grid-template-columns: 1fr;
  }

  .input-btn-row {
    flex-direction: column;
  }

  .input-btn-row .btn-secondary {
    width: 100%;
    height: 44px;
  }

  .otp-row {
    flex-direction: column;
  }

  .otp-row .btn-secondary {
    width: 100%;
  }
}

@media (max-width: 340px) {
  .auth-card {
    padding: var(--space-6) var(--space-4);
  }
}

/* ── Balatro canvas background ───────────────────────────────── */
#balatro-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Inventory viewer ───────────────────────────────────────── */
body.inv-page {
  background: var(--color-bg);
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  background: var(--color-paper);
  border-bottom: 1.5px solid var(--color-rule);
  flex-shrink: 0;
}

.inv-header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.inv-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.inv-brand-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-ink);
}

.inv-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.inv-user-name {
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  font-weight: 500;
}

.inv-header-actions .btn-secondary {
  height: 36px;
  padding: 0 var(--space-4);
}

.inv-frame {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
}

@media (max-width: 560px) {
  .inv-header {
    padding: var(--space-3) var(--space-4);
  }

  .inv-brand-name,
  .inv-user-name {
    display: none;
  }
}
