/* =========================================================
   Twilio Unified Experience Framework - Stylesheet
   Proprietary Architectural Design System
   ========================================================= */

:root {
  --tw-brand-blue: #0263e0;
  --tw-brand-blue-hover: #0052bd;
  --tw-brand-blue-active: #00439d;
  --tw-brand-red: #ef223a;
  
  --tw-bg-dark-center: #072a5a;
  --tw-bg-dark-mid: #041938;
  --tw-bg-dark-edge: #010a17;
  
  --tw-text-primary: #121c2d;
  --tw-text-secondary: #566479;
  --tw-text-subtle: #8891aa;
  --tw-text-legal-link: #4ba0f5;
  --tw-text-legal-dim: #8fa4c4;
  
  --tw-border-default: #cbd5e1;
  --tw-border-field: #8891aa;
  --tw-border-accent: #0263e0;
  
  --tw-card-radius: 16px;
  --tw-font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--tw-font-stack);
  color: var(--tw-text-primary);
  background-color: var(--tw-bg-dark-edge);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: radial-gradient(ellipse at 50% 35%, var(--tw-bg-dark-center) 0%, var(--tw-bg-dark-mid) 50%, var(--tw-bg-dark-edge) 100%) fixed;
  overflow-x: hidden;
}

/* =========================================================
   Transitions & Keyframe Sequences
   ========================================================= */

@keyframes twSlideInRight {
  0% {
    opacity: 0;
    transform: translateX(42px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes twSlideOutLeft {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-42px);
  }
}

@keyframes twCardEnter {
  0% {
    opacity: 0;
    transform: scale(0.96) translateY(18px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes twNavSlideDown {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.tw-anim-slide-in-right {
  animation: twSlideInRight 0.48s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tw-anim-slide-out-left {
  animation: twSlideOutLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.tw-anim-card-enter {
  animation: twCardEnter 0.52s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tw-anim-nav-enter {
  animation: twNavSlideDown 0.46s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Inline Spinner for Buttons */
.tw-button-busy {
  position: relative;
  pointer-events: none;
  opacity: 0.95;
}

.tw-button-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: twButtonSpin 0.65s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

@keyframes twButtonSpin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   Viewport & Stage Layout
   ========================================================= */

.tw-nexus-viewport {
  width: 100%;
  min-height: 100vh;
  position: relative;
}

.tw-stage-surface {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.tw-stage-surface.tw-surface-active {
  display: block;
}

.tw-stage-center-dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
}

/* =========================================================
   Surface Panel Pod Component (Stages 1 & 2)
   ========================================================= */

.tw-panel-pod {
  background: #ffffff;
  border-radius: var(--tw-card-radius);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.38), 0 2px 6px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 512px;
  padding: 46px 48px 44px 48px;
  position: relative;
  z-index: 10;
}

.tw-brandmark-slot {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}

.tw-brandmark-asset {
  height: 34px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}

.tw-headline-title {
  text-align: center;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--tw-text-primary);
  margin-bottom: 24px;
  line-height: 1.2;
}

.tw-headline-sub {
  text-align: center;
  font-size: 14px;
  color: var(--tw-text-secondary);
  margin-top: -14px;
  margin-bottom: 26px;
  line-height: 1.4;
}

/* Form Layout */
.tw-form-orchestrator {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.tw-input-row {
  margin-bottom: 24px;
  width: 100%;
}

.tw-input-primitive {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--tw-text-primary);
  background-color: #ffffff;
  border: 1px solid var(--tw-border-field);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tw-input-primitive::placeholder {
  color: #718096;
  font-size: 15px;
}

.tw-input-primitive:focus {
  border-color: var(--tw-border-accent);
  box-shadow: 0 0 0 1px var(--tw-border-accent);
}

/* Actions & Buttons */
.tw-cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
  user-select: none;
}

.tw-cta-button:active {
  transform: translateY(1px);
}

.tw-cta-primary {
  background-color: var(--tw-brand-blue);
  color: #ffffff;
}

.tw-cta-primary:hover {
  background-color: var(--tw-brand-blue-hover);
}

.tw-action-dock-center {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}

.tw-cta-compact {
  height: 40px;
  padding: 0 28px;
  border-radius: 4px;
  font-size: 15px;
  min-width: 112px;
}

.tw-cta-expanded {
  width: 100%;
  height: 44px;
  border-radius: 4px;
  font-size: 15px;
  margin-top: 24px;
  margin-bottom: 20px;
}

/* Hyperlinks */
.tw-link-brand {
  color: var(--tw-brand-blue);
  text-decoration: none;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.tw-link-brand:hover {
  color: var(--tw-brand-blue-hover);
  text-decoration: underline;
}

.tw-weight-semibold {
  font-weight: 600;
}

.tw-weight-medium {
  font-weight: 500;
}

.tw-text-underlined {
  text-decoration: underline;
}

/* Divider Ribbon ("or") */
.tw-divider-ribbon {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  width: 100%;
}

.tw-divider-rule {
  flex: 1;
  height: 1px;
  background-color: #e2e8f0;
}

.tw-divider-glyph {
  padding: 0 16px;
  font-size: 14px;
  color: #718096;
}

.tw-account-invitation {
  text-align: center;
  margin-bottom: 6px;
}

/* =========================================================
   Stage 2 Outlined Floating Field & Secret Field
   ========================================================= */

.tw-floating-boundary {
  position: relative;
  margin-bottom: 18px;
  width: 100%;
}

.tw-floating-indicator {
  position: absolute;
  top: -8px;
  left: 12px;
  background: #ffffff;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--tw-brand-blue);
  z-index: 2;
  pointer-events: none;
}

.tw-input-floating.tw-border-highlight {
  border: 2px solid var(--tw-brand-blue);
  font-size: 15px;
  color: var(--tw-text-primary);
  height: 44px;
}

/* Secret Field Mask Toggle */
.tw-secret-boundary {
  position: relative;
  display: flex;
  align-items: center;
}

.tw-secret-boundary .tw-input-primitive {
  padding-right: 44px;
}

.tw-secret-toggle-action {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  color: #566479;
}

.tw-secret-toggle-action:hover {
  color: #121c2d;
}

.tw-glyph-eye.tw-element-collapsed {
  display: none;
}

/* =========================================================
   Cloudflare Turnstile Integrity Shield Pod
   ========================================================= */

.tw-turnstile-pod {
  display: flex;
  align-items: center;
  background-color: #f8fafc;
  border: 1px solid var(--tw-border-default);
  border-radius: 4px;
  height: 52px;
  padding: 0 16px;
  margin-bottom: 18px;
  user-select: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.tw-turnstile-pod:hover {
  background-color: #f1f5f9;
}

.tw-turnstile-state {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.tw-turnstile-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid #d1d5db;
  border-top-color: var(--tw-brand-blue);
  border-radius: 50%;
  animation: twTurnstileSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes twTurnstileSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.tw-caption-muted {
  color: var(--tw-text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.tw-turnstile-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tw-turnstile-badge-icon svg {
  animation: twPopBadge 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.tw-turnstile-check-vector {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: twDrawCheck 0.35s ease-out 0.12s forwards;
}

@keyframes twPopBadge {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes twDrawCheck {
  to { stroke-dashoffset: 0; }
}

.tw-turnstile-caption {
  font-size: 14px;
  font-weight: 500;
  color: var(--tw-text-primary);
}

.tw-recovery-channel-row {
  margin-bottom: 2px;
  text-align: left;
}

.tw-recovery-channel-row a {
  font-size: 14px;
}

.tw-signup-invitation-dock {
  text-align: center;
  font-size: 14px;
  color: #334155;
  display: flex;
  justify-content: center;
  gap: 5px;
}

/* =========================================================
   Legal Compliance Constellation Footers
   ========================================================= */

.tw-footer-constellation {
  margin-top: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--tw-text-legal-dim);
  line-height: 1.8;
  z-index: 10;
}

.tw-footer-link {
  color: var(--tw-text-legal-link);
  text-decoration: underline;
  transition: color 0.15s ease;
}

.tw-footer-link:hover {
  color: #93c5fd;
}

.tw-footer-delimit {
  margin: 0 6px;
  color: #475569;
  font-size: 11px;
}

.tw-footer-compliance-row {
  margin-top: 6px;
}

.tw-footer-attribution {
  margin-top: 6px;
  color: var(--tw-text-legal-dim);
}

/* =========================================================
   Stage 3: Dispatch & MFA Challenge Architecture
   ========================================================= */

.tw-portal-top-banner {
  width: 100%;
  height: 62px;
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 36px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tw-portal-logo-anchor {
  display: flex;
  align-items: center;
}

.tw-topbar-brandmark {
  height: 26px;
  width: auto;
}

.tw-mfa-arena-dock {
  min-height: calc(100vh - 62px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.tw-mfa-split-canvas {
  background: #ffffff;
  border-radius: var(--tw-card-radius);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.38), 0 2px 6px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 960px;
  min-height: 480px;
  display: grid;
  grid-template-columns: 360px 1fr;
  overflow: hidden;
  align-items: center;
  padding: 30px 40px 30px 20px;
}

.tw-mfa-artwork-quadrant {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 20px 40px;
}

.tw-envelope-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 250px;
}

.tw-envelope-asset {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.08));
}

.tw-mfa-interactive-quadrant {
  padding: 20px 20px 20px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tw-mfa-primary-header {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--tw-text-primary);
  margin-bottom: 16px;
}

.tw-mfa-dispatch-directive {
  font-size: 15px;
  line-height: 1.55;
  color: #334155;
  margin-bottom: 14px;
  max-width: 480px;
}

.tw-mfa-dispatch-directive strong {
  color: var(--tw-text-primary);
  font-weight: 600;
}

.tw-support-dock {
  margin-bottom: 26px;
}

.tw-support-hyperlink {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--tw-brand-blue);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.tw-support-hyperlink:hover {
  text-decoration: underline;
}

.tw-external-vector {
  margin-left: 2px;
}

.tw-code-intake-module {
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.tw-code-legend {
  font-size: 14px;
  font-weight: 500;
  color: var(--tw-text-primary);
  margin-bottom: 8px;
}

.tw-code-primitive {
  width: 270px;
  height: 44px;
  border: 1px solid #718096;
  border-radius: 6px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--tw-text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tw-code-primitive:focus {
  border-color: var(--tw-brand-blue);
  box-shadow: 0 0 0 2px rgba(2, 99, 224, 0.25);
}

.tw-challenge-command-strip {
  display: flex;
  align-items: center;
  gap: 22px;
}

.tw-cta-verify {
  height: 40px;
  padding: 0 26px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.tw-countdown-chronometer {
  display: flex;
  align-items: center;
}

.tw-countdown-label {
  font-size: 14px;
  color: var(--tw-text-secondary);
}

.tw-countdown-label span {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.tw-resend-trigger {
  background: none;
  border: none;
  color: var(--tw-brand-blue);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.tw-resend-trigger:hover {
  text-decoration: underline;
  color: var(--tw-brand-blue-hover);
}

.tw-element-collapsed {
  display: none !important;
}

/* Feedback Notification Toast */
.tw-toast-feedback {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  max-width: 320px;
  animation: twPopBadge 0.25s ease-in;
}

/* =========================================================
   Responsive Breakpoints
   ========================================================= */

@media (max-width: 860px) {
  .tw-mfa-split-canvas {
    grid-template-columns: 1fr;
    padding: 36px 24px;
    max-width: 520px;
  }

  .tw-mfa-artwork-quadrant {
    padding: 0 0 20px 0;
  }

  .tw-mfa-interactive-quadrant {
    padding: 10px 0 0 0;
  }
}

@media (max-width: 540px) {
  .tw-panel-pod {
    padding: 36px 24px 32px 24px;
    border-radius: 12px;
  }

  .tw-code-primitive {
    width: 100%;
  }
}
