/* Brand palette — matching xstitchtracker.com */
:root {
  --color-primary: #96879d;
  --color-primary-dark: #7a6b82;
  --color-secondary: #929673;
  --color-accent: #b1b3b2;
  --color-bg: #d8c7c0;
  --color-surface: #e4e4dd;
  --color-text: #2d2d2d;
  --color-text-muted: #666666;
  --color-card-bg: #2d2534;
  --radius: 10px;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-2) var(--space-4);
}

header h1 {
  font-size: 2.4rem;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

header p {
  color: var(--color-text-muted);
  margin-top: 0;
}

[hidden] {
  display: none !important;
}

/* Region selector — large tap targets, no form chrome */
#region-selector {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  padding: var(--space-3) 0;
}

.region-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 96px;
  padding: var(--space-2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--color-surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.region-option .flag {
  font-size: 2rem;
}

.region-option:hover,
.region-option:focus-visible {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(150, 135, 157, 0.2);
}

/* Persistent "change region" affordance */
#change-region {
  display: inline-block;
  margin-top: var(--space-1);
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--color-text-muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

#other-region-note {
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: var(--space-2);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* Questions Q1–Q5 */
#questions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.question label,
.question > p {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

.question .note {
  font-weight: 400;
  color: var(--color-text-muted);
}

.question input[type='range'] {
  width: 100%;
  accent-color: var(--color-primary);
}

.question .ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.question output {
  font-weight: 600;
  color: var(--color-primary-dark);
}

/* Q2 yes/no toggle */
.toggle-group {
  display: inline-flex;
  gap: var(--space-1);
}

.toggle-option {
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-option[aria-pressed='true'] {
  background: var(--color-primary);
  color: #fff;
}

/* Live results panel */
#results-panel {
  margin-top: var(--space-3);
}

#results-headline {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--color-text);
}

#results-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}

#badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}

.badge {
  display: inline-block;
  padding: 0.3rem var(--space-2);
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.badge-ufo {
  background: var(--color-secondary);
}

#comparison-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.card-fallback-message {
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  color: var(--color-text);
}

/* CTA buttons */
.cta-button {
  display: inline-block;
  margin-top: var(--space-2);
  padding: 0.6rem var(--space-3);
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s;
}

.cta-button:hover,
.cta-button:focus-visible {
  background: var(--color-primary-dark);
}

.cta-button-secondary {
  display: inline-block;
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-primary-dark);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cta-button-secondary:hover,
.cta-button-secondary:focus-visible {
  background: var(--color-primary);
  color: #fff;
}

#email-gate {
  margin-top: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.email-gate-heading {
  margin: 0 0 var(--space-1);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-text);
}

.email-gate-copy {
  margin: 0 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

#email-gate-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

#email-gate-input {
  flex: 1 1 220px;
  padding: var(--space-1);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  background: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--color-text);
}

#email-gate-input:focus {
  outline: none;
  border-color: var(--color-primary-dark);
}

.email-gate-error {
  margin: var(--space-1) 0 0;
  color: #b91c1c;
  font-size: 0.85rem;
}

.email-gate-consent {
  margin: var(--space-2) 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.card-confirmation {
  margin-top: var(--space-2);
  color: var(--color-secondary);
  font-weight: 600;
}

/* Below-results CTA */
.below-results-cta {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Disclaimers footer */
.disclaimers {
  max-width: 720px;
  margin: var(--space-4) auto var(--space-3);
  padding: 0 var(--space-2);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.disclaimer {
  margin: var(--space-2) 0 0;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Responsive — mobile (max-width: 480px) */
@media (max-width: 480px) {
  main {
    padding: 1rem 0.75rem 2rem;
  }

  header h1 {
    font-size: 1.8rem;
  }

  #email-gate-form {
    flex-direction: column;
  }

  #email-gate-input {
    flex: none;
    width: 100%;
  }

  .cta-button,
  .cta-button-secondary {
    display: block;
    width: 100%;
    text-align: center;
  }


}

/* Responsive — tablet (481px–768px) */
@media (min-width: 481px) and (max-width: 768px) {
  #email-gate-form {
    flex-wrap: wrap;
  }
}

/* Card results with share buttons */
#card-images {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.card-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.card-result img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}

.share-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  width: 100%;
}

.share-btn {
  display: block;
  padding: 0.65rem var(--space-3);
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}

.share-btn:hover,
.share-btn:focus-visible {
  background: var(--color-primary-dark);
}

.share-btn--secondary {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0.25rem 0;
  cursor: pointer;
  text-align: center;
}

.share-btn--secondary:hover,
.share-btn--secondary:focus-visible {
  color: var(--color-text);
}

.share-feedback {
  margin: var(--space-1) 0 0;
  font-size: 0.85rem;
  color: var(--color-secondary);
  font-weight: 500;
}

/* Results card templates — rendered off-screen, captured by html2canvas */
.card-offscreen {
  position: absolute;
  top: 0;
  left: -99999px;
  pointer-events: none;
}

.result-card {
  width: 1080px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 100px 80px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.result-card--square {
  height: 1080px;
}

.result-card--story {
  height: 1920px;
}

.card-logo {
  width: 480px;
  height: auto;
  margin-bottom: 56px;
}

.card-headline {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 48px;
  font-weight: 500;
  margin: 0 0 32px;
  line-height: 1.3;
  color: var(--color-text);
}

.card-value {
  display: block;
  font-size: 72px;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-top: 8px;
}

.card-tier-badge {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 38px;
  font-weight: 600;
  color: var(--color-secondary);
  margin: 0 0 56px;
}

.card-stats {
  list-style: none;
  margin: 0 0 56px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 32px;
  color: var(--color-text-muted);
}

.card-flavour {
  max-width: 820px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 30px;
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 0 72px;
}

.card-footer {
  font-size: 22px;
  color: var(--color-text-muted);
  margin: 0;
}

.result-card--story .card-footer {
  font-size: 30px;
}

/* Share modal */
.share-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.share-modal-overlay--visible {
  opacity: 1;
}

.share-modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.share-modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem 0.5rem;
}

.share-modal__heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--color-text);
}

.share-modal__preview-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.share-modal__thumb {
  width: 90px;
  flex-shrink: 0;
  border-radius: calc(var(--radius) / 2);
  display: block;
}

.share-modal__caption-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.share-modal__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-modal__caption {
  background: var(--color-bg);
  border-radius: calc(var(--radius) / 2);
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
}

.share-modal__fb-btn {
  background: #1877f2;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

.share-modal__fb-btn:hover {
  background: #166fe5;
}

.share-modal__ig-btn {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

.share-modal__ig-btn:hover {
  filter: brightness(1.1);
}

.share-modal__thumb--story {
  width: auto;
  height: 110px;
}

.share-modal__hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
  margin: -0.25rem 0 0;
}

.share-modal__copy-link {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  align-self: center;
}

/* Toast notification */
.toast {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: var(--color-primary-dark);
  color: #fff;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 1000;
  transition: transform 0.25s ease;
  width: max-content;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

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

.toast a {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
}
