/* ======================================================================
   registration.css — Registration popup modal
   Loaded on index.html + legal pages (js/registration.js builds the DOM).
   Uses the site design tokens from styles.css (--color-*, --font-*).
   Breakpoints match responsive.css: 1024 / 768 / 560.
   ====================================================================== */

/* ----- overlay ----- */

.reg-overlay {
  position: fixed;
  inset: 0;
  z-index: 210; /* above lightbox (200), header (100), mobile menu (90) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: rgba(9, 10, 12, 0.82);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.reg-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* ----- modal shell ----- */

.reg-modal {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: calc(100dvh - 48px);
  background: var(--color-white);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  transform: translateY(14px) scale(0.985);
  transition: transform 0.22s ease;
}

.reg-overlay.is-open .reg-modal {
  transform: translateY(0) scale(1);
}

/* ----- header band ----- */

.reg-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  background: var(--color-dark);
  color: var(--color-white);
  border-bottom: 4px solid var(--color-red);
  flex-shrink: 0;
}

.reg-modal__eyebrow {
  margin: 0 0 4px;
  font-family: var(--font-condensed);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--color-red);
}

.reg-modal__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-white);
  line-height: 1;
}

.reg-modal__close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: transparent;
  color: var(--color-white);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.reg-modal__close svg {
  width: 18px;
  height: 18px;
}

.reg-modal__close:hover,
.reg-modal__close:focus-visible {
  background: var(--color-red);
  border-color: var(--color-red);
}

/* ----- scrollable body ----- */

.reg-modal__body {
  overflow-y: auto;
  padding: 22px 28px 26px;
  background: var(--color-beige);
  overscroll-behavior: contain;
}

.reg-fieldset {
  margin: 0 0 16px;
  padding: 20px 22px 22px;
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: 8px;
  min-width: 0; /* lets grid children shrink */
}

.reg-fieldset:last-of-type {
  margin-bottom: 0;
}

.reg-fieldset__legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  font-family: var(--font-condensed);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-ink);
}

.reg-fieldset__legend::before {
  content: "";
  width: 22px;
  height: 3px;
  background: var(--color-red);
}

/* ----- field grid ----- */

.reg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  margin-top: 16px;
}

.reg-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.reg-field--full {
  grid-column: 1 / -1;
}

.reg-field__label {
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-ink);
}

.reg-field__hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--color-text-light);
}

.reg-field__error {
  margin: 6px 0 0;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-red);
  min-height: 0;
}

.reg-field__error:empty {
  display: none;
}

/* ----- inputs ----- */

.reg-input {
  width: 100%;
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--color-ink);
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.reg-input::placeholder {
  color: #b9bcc2;
}

.reg-input:hover {
  border-color: #c9cbd0;
}

.reg-input:focus {
  border-color: var(--color-red);
  box-shadow: 0 0 0 3px rgba(216, 32, 39, 0.14);
}

.has-error .reg-input,
.has-error .reg-select {
  border-color: var(--color-red);
}

.reg-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355585e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
  padding-right: 36px;
}

/* ----- segmented radio groups (gender / type / age group) ----- */

.reg-segment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reg-segment__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.reg-segment__label {
  padding: 9px 18px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.reg-segment__label:hover {
  border-color: var(--color-red);
  color: var(--color-ink);
}

.reg-segment__input:checked + .reg-segment__label {
  color: var(--color-white);
  background: var(--color-dark);
  border-color: var(--color-dark);
}

.reg-segment__input:focus-visible + .reg-segment__label {
  outline: 3px solid var(--color-red);
  outline-offset: 2px;
}

.has-error .reg-segment__label {
  border-color: rgba(216, 32, 39, 0.55);
}

/* ----- file uploads ----- */

.reg-file__drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 14px;
  text-align: center;
  border: 1.5px dashed #c9cbd0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.reg-file__drop:hover,
.reg-file__drop:focus-visible,
.reg-file:focus-within .reg-file__drop {
  border-color: var(--color-red);
  background: rgba(216, 32, 39, 0.04);
  outline: none;
}

.reg-file__drop svg {
  width: 26px;
  height: 26px;
  color: var(--color-text-light);
}

.reg-file__drop:hover svg,
.reg-file:focus-within .reg-file__drop svg {
  color: var(--color-red);
}

.reg-file__cta {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-ink);
}

.reg-file__hint {
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--color-text-light);
}

.has-error .reg-file__drop {
  border-color: var(--color-red);
}

.reg-file__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px 12px;
  font-size: 0.8rem;
  background: #f2f7f2;
  border: 1px solid #d5e5d5;
  border-radius: 6px;
}

.reg-file__name {
  font-weight: 600;
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

.reg-file__size {
  color: var(--color-text-light);
  white-space: nowrap;
}

.reg-file__remove {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.reg-file__remove svg {
  width: 13px;
  height: 13px;
}

.reg-file__remove:hover,
.reg-file__remove:focus-visible {
  background: var(--color-red);
  color: var(--color-white);
}

/* ----- declaration checkboxes ----- */

.reg-check {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: start;
  padding: 4px 0;
}

.reg-check + .reg-check {
  margin-top: 12px;
}

.reg-check__input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--color-red);
  cursor: pointer;
}

.reg-check__label {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--color-text);
}

.reg-check__label a {
  color: var(--color-red);
  font-weight: 600;
}

.reg-check .reg-field__error {
  grid-column: 2;
}

/* ----- footer: fee + submit ----- */

.reg-modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: var(--color-white);
  border-top: 1px solid var(--color-line);
  flex-shrink: 0;
}

.reg-fee {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.reg-fee__amount {
  font-family: var(--font-condensed);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-ink);
}

.reg-fee__note {
  font-size: 0.72rem;
  letter-spacing: 0.4px;
  color: var(--color-text-light);
}

.reg-modal__submit {
  flex-shrink: 0;
  min-width: 200px;
}

/* ----- notices (top of modal body: rate limits, gateway problems) ----- */

.reg-notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  font-size: 0.84rem;
  line-height: 1.5;
  border-radius: 6px;
  background: #fdf1f1;
  border: 1px solid #f2c7c9;
  color: #8f1620;
}

.reg-notice--ok {
  background: #eef7f0;
  border-color: #cfe6d5;
  color: #1c5c2e;
}

/* ----- locked form (OTP step active) ----- */

.reg-modal__body.reg-form-locked {
  opacity: 0.55;
  pointer-events: none;
}

/* ----- submit button loading state ----- */

.reg-modal__submit.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.reg-modal__submit.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: reg-spin 0.7s linear infinite;
}

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

/* ----- OTP verification section ----- */

.reg-otp {
  flex-shrink: 0;
  padding: 18px 28px 20px;
  background: var(--color-white);
  border-top: 3px solid var(--color-red);
}

.reg-otp__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.reg-otp__title {
  margin: 0 0 2px;
  font-family: var(--font-condensed);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-ink);
}

.reg-otp__sent {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-text);
}

.reg-otp__sent strong {
  color: var(--color-ink);
  word-break: break-all;
}

.reg-otp__edit {
  flex-shrink: 0;
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-red);
  background: none;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.reg-otp__edit:hover,
.reg-otp__edit:focus-visible {
  border-color: var(--color-red);
  background: var(--color-red);
  color: var(--color-white);
}

.reg-otp__cells {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  max-width: 340px;
}

.reg-otp__cell {
  width: 100%;
  aspect-ratio: 3 / 4;
  min-width: 0;
  max-width: 52px;
  text-align: center;
  font-family: var(--font-condensed);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-ink);
  background: var(--color-beige);
  border: 1.5px solid var(--color-line);
  border-radius: 8px;
  outline: none;
  caret-color: var(--color-red);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.reg-otp__cell:focus {
  border-color: var(--color-red);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(216, 32, 39, 0.14);
}

.reg-otp__cell.is-bad {
  border-color: var(--color-red);
  animation: reg-shake 0.3s ease;
}

@keyframes reg-shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.reg-otp__status {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  line-height: 1.45;
}

.reg-otp__status--info { color: var(--color-text); }
.reg-otp__status--ok { color: #1c5c2e; font-weight: 600; }
.reg-otp__status--error { color: var(--color-red); font-weight: 600; }

.reg-otp__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.reg-otp__expiry {
  font-size: 0.78rem;
  color: var(--color-text-light);
}

.reg-otp__resend {
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-ink);
  background: var(--color-chip);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.reg-otp__resend:hover:not(:disabled),
.reg-otp__resend:focus-visible:not(:disabled) {
  background: var(--color-red);
  color: var(--color-white);
}

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

/* ----- responsive ----- */

@media (max-width: 768px) {
  .reg-overlay {
    padding: 14px;
  }

  .reg-modal {
    max-height: calc(100dvh - 28px);
    border-radius: 8px;
  }

  .reg-modal__head {
    padding: 16px 18px;
  }

  .reg-modal__body {
    padding: 16px 18px 20px;
  }

  .reg-grid {
    grid-template-columns: 1fr; /* stack every field */
    gap: 14px;
  }

  .reg-modal__foot {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 18px;
  }

  .reg-otp {
    padding: 14px 18px 16px;
  }

  .reg-fee {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }

  .reg-modal__submit {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .reg-overlay {
    padding: 0;
    align-items: stretch;
  }

  .reg-modal {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  .reg-fieldset {
    padding: 16px;
  }
}

/* ----- reduced motion ----- */

@media (prefers-reduced-motion: reduce) {
  .reg-overlay,
  .reg-modal {
    transition: none;
  }

  .reg-otp__cell.is-bad,
  .reg-modal__submit.is-loading::after {
    animation: none;
  }
}
