/* ==========================================================================
   register-scene.css
   Registration page: orange environment, Three.js canvas layer, glass card.
   Shared visual values live in the :root block below.
   ========================================================================== */

:root {
  --brand: #FF7C00;
  --brand-dark: #E06400;
  --brand-deep: #C25600;
  --ink: #1F2933;
  --ink-soft: #52606D;
  --ink-faint: #7B8794;
  --surface: #FFFFFF;
  --danger: #C62828;
  --ok: #2E7D32;
  --radius-card: 22px;
  --radius-field: 10px;

  /* pointer parallax, written by register-scene.js. 0 until then. */
  --mx: 0;
  --my: 0;
}

html, body { height: 100%; }

body.reg-page {
  margin: 0;
  font-family: "Mada", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  background: radial-gradient(125% 95% at 50% 38%,
              #FF9838 0%, #FF7C00 46%, #E06400 80%, #C05400 100%);
}

/* ------------------------------------------------------------ scene layer */

.scene-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;   /* never intercepts form interaction */
  overflow: hidden;
}

/* the WebGL canvas, injected by the scene module */
.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  opacity: 0;
  transition: opacity .8s ease;
}
body.webgl-on .scene-canvas { opacity: 1; }

/* environment: glow, grid, vignette, grain. Pure CSS, always present, and it
   doubles as the backdrop for the no-WebGL fallback. */
.env-glow {
  position: absolute;
  left: 50%; top: 50%;
  width: 980px; height: 980px;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side,
              rgba(255,255,255,0.30), rgba(255,255,255,0.09) 46%, transparent 72%);
  animation: glow-breathe 27s ease-in-out infinite;
}
@keyframes glow-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.84; }
}

.env-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 74px 74px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 22%, #000 70%);
          mask-image: radial-gradient(circle at 50% 50%, transparent 22%, #000 70%);
}

.env-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(88,34,0,0.26) 100%);
}

.env-grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------- static (no-WebGL) scene */
/* Shown until the Three.js scene reports its first frame; stays forever when
   WebGL is unavailable, so the page always has a financial composition. */

.scene-fallback {
  position: absolute;
  inset: 0;
  transition: opacity .6s ease;
}
body.webgl-on .scene-fallback { opacity: 0; }

.fb-left, .fb-right { position: absolute; }
.fb-left  { left: clamp(8px, 3vw, 60px); bottom: 5vh; }
.fb-right { right: clamp(8px, 3vw, 60px); top: 7vh; }
.fb-left svg, .fb-right svg {
  display: block;
  filter: drop-shadow(0 20px 26px rgba(105,42,0,0.30));
}
.fb-bars  { width: clamp(190px, 19vw, 300px); }
.fb-coins { width: clamp(105px, 10vw, 150px); margin: -28px 0 0 clamp(115px, 12vw, 195px); }
.fb-pie   { width: clamp(140px, 13vw, 205px); margin-left: clamp(55px, 7vw, 120px); }
.fb-dash  { width: clamp(180px, 17vw, 265px); margin-top: -22px; }

/* the fallback hides on narrow screens exactly like the 3D clusters do */
@media (max-width: 1100px) {
  .fb-left, .fb-right { display: none; }
  .env-glow { width: 620px; height: 620px; }
}

/* ------------------------------------------------------------ page layout */

.reg-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;          /* survives the mobile keyboard opening */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  box-sizing: border-box;
  perspective: 1000px;
}

/* -------------------------------------------------------------- the glass */

.reg-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  box-sizing: border-box;
  padding: 38px 34px 30px;
  border-radius: var(--radius-card);
  border: 1px solid rgba(255,255,255,0.55);
  /* warm-white, ~84% -> a little denser than the login card: more fields to read */
  background: linear-gradient(158deg, rgba(255,250,244,0.88), rgba(255,245,234,0.80));
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
          backdrop-filter: blur(24px) saturate(1.25);
  box-shadow:
    0 34px 80px rgba(92,38,0,0.32),
    0 4px 16px rgba(92,38,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.7);
  /* max 4px shift / 1deg tilt, driven by the scene's damped pointer values */
  transform:
    translate3d(calc(var(--mx) * 4px), calc(var(--my) * 3px), 0)
    rotateY(calc(var(--mx) * 1deg))
    rotateX(calc(var(--my) * -1deg));
  animation: card-in .7s cubic-bezier(.22,1,.36,1) 1.05s backwards;
}

/* warm orange environmental reflection, shifts with the pointer */
.reg-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(58% 38% at calc(76% + var(--mx) * 8%) 0%, rgba(255,158,64,0.17), transparent 70%),
    radial-gradient(48% 32% at calc(18% + var(--mx) * -6%) 100%, rgba(255,124,0,0.09), transparent 70%);
}
/* surface grain */
.reg-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* glow behind the card, separating it from the scene */
.reg-card-glow {
  position: absolute;
  inset: -40px -30px -30px;
  border-radius: 40px;
  background: radial-gradient(closest-side, rgba(255,236,210,0.34), transparent 78%);
  z-index: -1;
  pointer-events: none;
}

/* no backdrop-filter (older Firefox): fall back to a near-opaque warm card */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .reg-card { background: rgba(255,252,248,0.97); }
}

/* one-off light sweep during the entrance */
.card-sweep {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}
.card-sweep::before {
  content: "";
  position: absolute;
  top: -20%; bottom: -20%; left: 0;
  width: 42%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.32), transparent);
  transform: translateX(-160%) skewX(-14deg);
  animation: sweep 1.15s ease-in-out 1.6s forwards;
}
@keyframes sweep { to { transform: translateX(340%) skewX(-14deg); } }

@keyframes card-in {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* --------------------------------------------------------------- masthead */

.reg-head {
  text-align: center;
  margin-bottom: 24px;
  animation: rise-in .5s ease-out 1.25s backwards;
}
.reg-head img { width: 52px; height: 52px; margin-bottom: 10px; }
.reg-brand {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--brand-deep);
}
.reg-head h1 {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 700;
  color: var(--ink);
}
.reg-head p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ alert */

.reg-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 10px;
  font-size: 13.5px;
  background: #FDECEA;
  border: 1px solid #F5C6C0;
  color: var(--danger);
}
.reg-alert i { margin-top: 2px; flex: none; }
.reg-alert span[style] { color: var(--danger) !important; }

/* ----------------------------------------------------------- field groups */

.reg-group {
  border: 0;
  padding: 0;
  margin: 0 0 4px;
  min-width: 0;              /* lets fieldset children shrink inside grid */
  animation: rise-in .5s ease-out backwards;
}
.reg-group-1 { animation-delay: 1.35s; }
.reg-group-2 { animation-delay: 1.45s; }
.reg-group-3 { animation-delay: 1.55s; }

.reg-legend {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid rgba(160,110,60,0.16);
  padding-bottom: 7px;
}

.reg-row { display: grid; grid-template-columns: 1fr; gap: 0 16px; }

.reg-field { margin-bottom: 16px; min-width: 0; }
.reg-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.reg-optional {
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 12px;
}

.reg-input-wrap { position: relative; }
.reg-input-wrap .fld-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #8A94A0;
  font-size: 14px;
  pointer-events: none;
}

.reg-input,
.reg-select {
  width: 100%;
  height: 50px;
  box-sizing: border-box;
  padding: 0 13px 0 40px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(160,110,60,0.30);
  border-radius: var(--radius-field);
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
.reg-input::placeholder { color: #8A94A0; }

.reg-input:focus,
.reg-select:focus {
  outline: none;
  background: rgba(255,255,255,0.94);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,124,0,0.22);
}

/* hide number spinners: `hp` stays type=number (server builds "+CC"+hp) */
.reg-input[type=number]::-webkit-outer-spin-button,
.reg-input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.reg-input[type=number] { -moz-appearance: textfield; }

/* the country select keeps its own chevron */
.reg-select {
  padding-left: 13px;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A94A0' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}

.reg-field.has-error .reg-input,
.reg-field.has-error .reg-select {
  border-color: var(--danger);
  animation: field-nudge .3s ease-out;
}
@keyframes field-nudge {
  0%, 100% { transform: translateX(0); }
  30%      { transform: translateX(-4px); }
  60%      { transform: translateX(4px); }
  80%      { transform: translateX(-2px); }
}

.fld-error {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--danger);
  overflow-wrap: break-word;   /* long server messages wrap, never overflow */
}
.fld-error:empty { display: none; }
.fld-error span[style] { color: var(--danger) !important; }

/* password show/hide */
.toggle-pass {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #8A94A0;
  font-size: 15px;
  cursor: pointer;
  border-radius: 8px;
}
.toggle-pass:hover { color: var(--ink-soft); }
.toggle-pass:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.has-toggle { padding-right: 48px; }

/* live password requirements — mirrors the server regex, nothing more */
.pw-rules {
  margin: -6px 0 16px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.pw-rules li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-faint);
  transition: color .15s;
}
.pw-rules li::before {
  content: "";
  width: 12px; height: 12px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: transparent;
  transition: background .15s, border-color .15s;
}
.pw-rules li.ok { color: var(--ok); }
.pw-rules li.ok::before {
  background: var(--ok);
  border-color: var(--ok);
  /* a checkmark, so state is not signalled by colour alone */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.8' stroke='%23000' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat,
           linear-gradient(#000, #000);
  -webkit-mask-composite: xor;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.8' stroke='%23000' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat;
}

/* ----------------------------------------------------------------- button */

.btn-register {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-field);
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 8px 22px rgba(198,88,0,0.30);
  transition: background .15s, box-shadow .15s, transform .12s;
  animation: rise-in .5s ease-out 1.65s backwards;
}
.btn-register:hover { background: var(--brand-dark); }
.btn-register:active { background: var(--brand-deep); transform: translateY(1px); }
.btn-register:focus-visible { outline: 3px solid rgba(255,124,0,0.45); outline-offset: 2px; }
.btn-register:disabled { opacity: .75; cursor: not-allowed; box-shadow: none; }

/* ----------------------------------------------------------------- footer */

.reg-footer {
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(160,110,60,0.18);
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  animation: rise-in .5s ease-out 1.75s backwards;
}
.reg-footer a {
  color: var(--brand-deep);
  font-weight: 600;
  text-decoration: none;
}
.reg-footer a:hover, .reg-footer a:focus {
  color: var(--brand-dark);
  text-decoration: underline;
}

/* ----------------------------------------------------------------- states */

/* success: the scene recedes, the card eases forward */
body.scene-exit .scene-layer {
  opacity: 0;
  transform: scale(.965);
  transition: opacity .5s ease, transform .5s ease;
}
body.scene-exit .reg-card {
  transform: translateY(-4px) scale(1.012);
  transition: transform .5s ease;
}

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

/* two columns only once the card is genuinely wide enough to keep fields
   readable (~275px each). DOM order is unchanged, so tab order is too. */
@media (min-width: 900px) {
  .reg-card { max-width: 640px; padding: 42px 40px 34px; }
  .reg-row-2 { grid-template-columns: 1fr 1fr; }
  .reg-row-phone { grid-template-columns: 150px 1fr; }
}

@media (max-width: 420px) {
  .reg-card { padding: 26px 18px 22px; border-radius: 18px; }
  .reg-head h1 { font-size: 21px; }
  .pw-rules { gap: 4px 10px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .env-glow,
  .card-sweep::before,
  .reg-head, .reg-group, .btn-register, .reg-footer,
  .reg-field.has-error .reg-input,
  .reg-field.has-error .reg-select {
    animation: none;
  }
  .reg-card { animation: fade-in .4s ease-out backwards; }
  .scene-canvas { transition: opacity .3s ease; }
  body.scene-exit .scene-layer,
  body.scene-exit .reg-card { transition: opacity .3s ease; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } }
