/* ============================================================================
   CALIBER — Sign-in portal                                assets/caliber-portal.css

   Loads after caliber-aura.css (tokens, fields, gold buttons with the purple
   power-up). Adds a quiet portal behind the auth card: CSS only, transforms
   and opacity on the compositor, no JavaScript.

     .caliber-portal__glow    violet core, breathing slowly
     .caliber-portal__swirl   soft blurred vortex, turning
     .caliber-portal__ticks   gold sight-ring of ticks, barely moving
     .caliber-portal__ring    two thin light arcs, counter-rotating

   Restraint: everything below 30% opacity except the arc highlights, nothing
   faster than one turn per 22 s, no flashing. Reduced motion: still.
   ========================================================================= */

/* ------------------------------------------------------------------ ground */
html.caliber-auth-page,
html.caliber-auth-page body {
  background: var(--nx-bg) !important;
  color: var(--nx-text) !important;
  min-height: 100%;
}
html.caliber-auth-page body::before { content: none !important; }
/* :not(#_) outranks the home page's `html body main:not(#_)` charcoal fill,
   which would otherwise sit over the portal. */
html.caliber-auth-page main:not(#_) { position: relative; z-index: 1; background: transparent !important; }

/* ------------------------------------------------------------------ portal */
.caliber-portal {
  --p: min(108vmin, 980px);              /* portal diameter */
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.caliber-portal > * {
  position: absolute;
  left: 50%;
  top: 44%;
  aspect-ratio: 1;
  border-radius: 50%;
  translate: -50% -50%;
  will-change: transform;
}

/* violet core */
.caliber-portal__glow {
  width: calc(var(--p) * 1.15);
  background: radial-gradient(closest-side,
    rgba(136, 87, 195, .30) 0%,
    rgba(77, 41, 112, .22) 42%,
    rgba(77, 41, 112, .08) 64%,
    transparent 100%);
  animation: caliber-portal-breathe 9s ease-in-out infinite alternate;
}

/* soft vortex: a few arms of light, masked to a band, blurred, turning */
.caliber-portal__swirl {
  width: calc(var(--p) * .92);
  background: conic-gradient(from 0deg,
    transparent 0 8%,
    rgba(189, 160, 227, .16) 16%,
    transparent 30%,
    rgba(136, 87, 195, .20) 44%,
    transparent 58%,
    rgba(243, 220, 166, .08) 72%,
    transparent 86%);
  -webkit-mask-image: radial-gradient(closest-side, transparent 30%, #000 50%, #000 72%, transparent 100%);
          mask-image: radial-gradient(closest-side, transparent 30%, #000 50%, #000 72%, transparent 100%);
  filter: blur(22px);
  animation: caliber-portal-spin 48s linear infinite;
}

/* gold sight-ring: fine ticks every 6 degrees, a heavier one every 30 */
.caliber-portal__ticks {
  width: calc(var(--p) * .70);
  background:
    repeating-conic-gradient(rgba(230, 198, 129, .38) 0 .5deg, transparent .5deg 30deg),
    repeating-conic-gradient(rgba(230, 198, 129, .16) 0 .35deg, transparent .35deg 6deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px), #000 100%, transparent 100%);
          mask-image: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px), #000 100%, transparent 100%);
  opacity: .7;
  animation: caliber-portal-spin 140s linear infinite reverse;
}

/* thin arcs: a full faint circle with a travelling highlight */
.caliber-portal__ring {
  -webkit-mask-image: radial-gradient(closest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px), #000 100%, transparent 100%);
          mask-image: radial-gradient(closest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px), #000 100%, transparent 100%);
}
.caliber-portal__ring--outer {
  width: calc(var(--p) * .80);
  background: conic-gradient(from 0deg,
    rgba(189, 160, 227, .10) 0deg,
    rgba(189, 160, 227, .70) 36deg,
    rgba(243, 220, 166, .55) 58deg,
    rgba(189, 160, 227, .10) 120deg,
    rgba(189, 160, 227, .10) 360deg);
  filter: drop-shadow(0 0 6px rgba(136, 87, 195, .55));
  animation: caliber-portal-spin 22s linear infinite;
}
.caliber-portal__ring--inner {
  width: calc(var(--p) * .60);
  background: conic-gradient(from 180deg,
    rgba(136, 87, 195, .10) 0deg,
    rgba(189, 160, 227, .55) 50deg,
    rgba(136, 87, 195, .10) 130deg,
    rgba(136, 87, 195, .10) 360deg);
  filter: drop-shadow(0 0 5px rgba(136, 87, 195, .5));
  animation: caliber-portal-spin 34s linear infinite reverse;
}

@keyframes caliber-portal-spin { to { transform: rotate(1turn); } }
@keyframes caliber-portal-breathe {
  from { opacity: .72; transform: scale(.97); }
  to   { opacity: 1;   transform: scale(1.03); }
}

/* ------------------------------------------------------------- home link */
html.caliber-auth-page .caliber-access-home {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px !important;
  border-radius: 999px;
  border: 1px solid var(--nx-line-2) !important;
  background: rgba(16, 18, 23, .78) !important;
  color: var(--nx-gold) !important;
  font: 600 13px/1 var(--font-body) !important;
  letter-spacing: .04em !important;
  text-transform: none !important;
  text-decoration: none;
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  transition: border-color var(--cta-out), box-shadow var(--cta-out), color var(--cta-out);
}
html.caliber-auth-page .caliber-access-home:hover {
  color: var(--nx-gold-bright) !important;
  border-color: rgba(var(--cta-lav), .55) !important;
  box-shadow: 0 0 14px rgba(var(--cta-violet), .35);
}
html.caliber-auth-page .caliber-access-home:focus-visible { outline: 2px solid var(--cta-focus); outline-offset: 3px; }

/* --------------------------------------------------------------- the card
   Graphite glass: opaque enough for crisp text, translucent enough that the
   portal light reads around and faintly through it. */
html.caliber-auth-page #authView { background: transparent !important; }
html.caliber-auth-page #authView > .card:not(#_) {
  position: relative;
  margin: clamp(76px, 12vh, 132px) auto 48px !important;
  padding: clamp(22px, 4vw, 34px) !important;
  background: linear-gradient(180deg, rgba(21, 23, 29, .86), rgba(14, 16, 21, .92)) !important;
  border: 1px solid var(--nx-line) !important;
  border-radius: 18px !important;
  box-shadow:
    0 1px 0 0 rgba(243, 220, 166, .08) inset,
    0 0 0 1px rgba(230, 198, 129, .05),
    0 30px 90px -30px rgba(77, 41, 112, .9),
    0 24px 60px -30px rgba(0, 0, 0, .9) !important;
  -webkit-backdrop-filter: blur(14px) saturate(115%);
          backdrop-filter: blur(14px) saturate(115%);
}
/* a hairline of portal light along the card's top edge */
html.caliber-auth-page #authView > .card:not(#_)::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: -1px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(189, 160, 227, .75), rgba(243, 220, 166, .6), transparent);
}

/* Tabs: a quiet segmented control; the active side is gold. */
html.caliber-auth-page #authView .tabs {
  margin: 0 0 24px !important;
  padding: 4px !important;
  gap: 4px !important;
  border-radius: 12px !important;
  background: rgba(11, 13, 16, .8) !important;
  border: 1px solid var(--nx-line) !important;
}
html.caliber-auth-page #authView .tabs button {
  min-height: 44px;
  border-radius: 9px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: var(--nx-muted) !important;
  font: 600 14px/1 var(--font-body) !important;
  letter-spacing: .01em !important;
  text-transform: none !important;
  transition: color var(--cta-out), background var(--cta-out), border-color var(--cta-out);
}
html.caliber-auth-page #authView .tabs button:hover { color: var(--nx-text) !important; }
html.caliber-auth-page #authView .tabs button.active {
  color: var(--cta-ink) !important;
  -webkit-text-fill-color: var(--cta-ink);
  background: linear-gradient(180deg, var(--cta-gold-hi), var(--cta-gold) 60%, var(--cta-gold-lo)) !important;
  border-color: rgba(185, 140, 73, .9) !important;
}
html.caliber-auth-page #authView .tabs button:focus-visible { outline: 2px solid var(--cta-focus); outline-offset: 2px; }

/* Headings and copy */
html.caliber-auth-page #authView h2 {
  margin: 0 0 8px;
  font-family: var(--font-head) !important;
  font-size: clamp(30px, 4vw, 38px) !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  letter-spacing: .02em !important;
  text-transform: uppercase;
  color: var(--nx-text) !important;
}
html.caliber-auth-page #authView form > p {
  margin: 0 0 22px;
  font: 400 16px/1.6 var(--font-body);
  color: var(--nx-muted) !important;
}

/* Fields */
html.caliber-auth-page #authView .field { gap: 8px; margin-bottom: 16px; }
/* Two-column create form: a wrapped label must not push its field out of line. */
html.caliber-auth-page #authView .grid { align-items: end; column-gap: 14px; }
html.caliber-auth-page #authView .field .label {
  font-family: var(--font-body) !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  letter-spacing: .2em !important;
  color: var(--nx-gold) !important;
}
html.caliber-auth-page #authView :is(input, select, textarea) {
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-ctl) !important;
  background: rgba(11, 13, 16, .85) !important;
  border: 1px solid rgba(230, 198, 129, .22) !important;
  color: var(--nx-text) !important;
  font: 400 16px/1.2 var(--font-body) !important;   /* 16px: no zoom-on-focus on iOS */
  transition: border-color var(--cta-out), box-shadow var(--cta-out);
}
html.caliber-auth-page #authView :is(input, select, textarea):hover { border-color: rgba(230, 198, 129, .38) !important; }
html.caliber-auth-page #authView :is(input, select, textarea):focus {
  outline: none;
  border-color: var(--nx-gold) !important;
  box-shadow: 0 0 0 3px rgba(230, 198, 129, .16), 0 0 18px -4px rgba(var(--cta-violet), .55) !important;
}

/* Primary action: full width at the foot of the form. */
html.caliber-auth-page #authView form .btn.primary { width: 100%; margin-top: 8px; }

/* Create-account steps and notices in the same card. */
html.caliber-auth-page #authView .onboarding-steps span {
  font: 600 11px/1 var(--font-body) !important;
  letter-spacing: .12em !important;
  border-color: var(--nx-line) !important;
  color: var(--nx-muted) !important;
}
html.caliber-auth-page #authView .onboarding-steps span.active {
  border-color: var(--nx-gold) !important;
  color: var(--nx-gold) !important;
  background: rgba(230, 198, 129, .07) !important;
}
html.caliber-auth-page #authView .notice {
  border-left-color: var(--nx-gold) !important;
  background: rgba(230, 198, 129, .06) !important;
  color: var(--nx-muted) !important;
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 680px) {
  .caliber-portal { --p: 150vmin; }
  .caliber-portal > * { top: 64%; }      /* frame the card from below on phones */
  .caliber-portal__swirl { filter: blur(16px); }
  html.caliber-auth-page #authView > .card:not(#_) {
    width: calc(100% - 28px) !important;
    margin-top: 72px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .caliber-portal > * { animation: none !important; }
}
@media (prefers-contrast: more) {
  .caliber-portal__swirl, .caliber-portal__glow { display: none; }
}

/* v87: the required Terms / Privacy acceptance in the create form. The field rule above sizes every
   input as a 48px text box; the checkbox keeps its own size, a dark native box and a gold tick. */
html.caliber-auth-page #authView .caliber-terms-accept { align-items: flex-start; gap: 12px; margin: 4px 0 18px; color: var(--nx-muted); font: 400 15px/1.55 var(--font-body); }
html.caliber-auth-page #authView .caliber-terms-accept input[type="checkbox"] {
  flex: none;
  width: 18px; height: 18px; min-height: 0;
  margin: 2px 0 0; padding: 0;
  border: 0 !important; border-radius: 4px !important;
  background: none !important; box-shadow: none !important;
  accent-color: var(--nx-gold);
  color-scheme: dark;
  cursor: pointer;
}
html.caliber-auth-page #authView .caliber-terms-accept input[type="checkbox"]:focus-visible { outline: 2px solid var(--cta-focus) !important; outline-offset: 3px; }
html.caliber-auth-page #authView .caliber-terms-accept a { color: var(--nx-gold); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
html.caliber-auth-page #authView .caliber-terms-accept a:hover { color: var(--nx-gold-bright); }
