/**
 * Interactive Exploded Mattress Structure Styles
 * Scoped to .mattress-layers-section
 */

:root {
  --brand: #295f98;
  --brand-hover: #204b79;
  --brand-glow: rgba(41, 95, 152, 0.75);
  --brand-subtle: rgba(41, 95, 152, 0.08);
  --stage-aspect: 1448 / 1086;
}

.mattress-layers-section {
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 50%, #ffffff 100%);
  position: relative;
  overflow: hidden;
}

/* Stage Wrapper */
.mattress-stage-wrapper {
  position: relative;
  background: radial-gradient(circle at 50% 55%, rgba(41, 95, 152, 0.06) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 1.5rem;
  padding: 1.5rem 1rem;
}

@media (min-width: 768px) {
  .mattress-stage-wrapper {
    padding: 2rem 1.5rem;
  }
}

/* Visual Stage */
.mattress-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--stage-aspect);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.stage-ambient-glow {
  position: absolute;
  top: 15%;
  left: 10%;
  right: 10%;
  bottom: 15%;
  background: radial-gradient(ellipse at center, rgba(41, 95, 152, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
  filter: blur(28px);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.5s ease;
}

/* Layer Items as Accessible Buttons */
.mattress-layer-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  display: block;
  transform: translateY(var(--assembled-y, 0%));
  transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.35s ease,
              opacity 0.35s ease;
  will-change: transform, filter, opacity;
}

.mattress-layer-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* Teaser State (subtle 15-20px peek) */
.mattress-stage.is-teaser .mattress-layer-item {
  transform: translateY(var(--teaser-y, 0%));
}

/* Exploded State (full 5-layer separation) */
.mattress-stage.is-exploded .mattress-layer-item {
  transform: translateY(var(--exploded-y, 0%));
}

/* Hover effect on layers */
.mattress-layer-item:hover {
  filter: drop-shadow(0 0 12px rgba(41, 95, 152, 0.5)) brightness(1.02);
}

/* Focus Visible for Keyboard Navigation */
.mattress-layer-item:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 4px;
  border-radius: 12px;
  filter: drop-shadow(0 0 18px var(--brand-glow));
}

/* Active Layer State */
.mattress-layer-item.is-active {
  filter: drop-shadow(0 0 20px var(--brand-glow)) drop-shadow(0 8px 16px rgba(18, 32, 51, 0.2)) brightness(1.05);
  z-index: 40 !important;
}

.mattress-stage.is-exploded .mattress-layer-item.is-active {
  transform: translateY(var(--exploded-y, 0%)) scale(1.02);
}

.mattress-stage.is-assembled .mattress-layer-item.is-active {
  transform: translateY(var(--assembled-y, 0%)) scale(1.02);
}

/* Dim Inactive Layers when one is active */
.mattress-stage.has-active .mattress-layer-item:not(.is-active) {
  opacity: 0.45;
  filter: grayscale(0.25) contrast(0.95);
}

.mattress-stage.has-active .mattress-layer-item:not(.is-active):hover {
  opacity: 0.8;
  filter: none;
}

/* Floating Indicator Chip on layers */
.layer-indicator-chip {
  position: absolute;
  top: 48%;
  left: 3%;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(41, 95, 152, 0.2);
  box-shadow: 0 4px 12px rgba(18, 32, 51, 0.1);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--dark, #122033);
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.mattress-stage.is-exploded .layer-indicator-chip {
  opacity: 0.9;
  transform: translateX(0);
}

.mattress-layer-item.is-active .layer-indicator-chip {
  opacity: 1;
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.chip-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(41, 95, 152, 0.12);
  color: var(--brand);
  font-size: 0.72rem;
}

.mattress-layer-item.is-active .chip-num {
  background: #ffffff;
  color: var(--brand);
}

/* Controls Bar */
.stage-controls-bar {
  background: #ffffff;
  border: 1px solid rgba(18, 32, 51, 0.08);
  border-radius: 1rem;
  padding: 0.85rem 1.25rem;
}

.mattress-toggle-btn {
  background: var(--brand);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.6rem;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
}

.mattress-toggle-btn:hover {
  background: var(--brand-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(41, 95, 152, 0.25) !important;
}

.mattress-toggle-btn.is-active {
  background: #ffffff;
  color: var(--brand);
  border: 2px solid var(--brand);
}

.mattress-toggle-btn.is-active:hover {
  background: var(--brand-subtle);
  color: var(--brand);
}

/* Information Panel */
.mattress-info-panel {
  background: #ffffff;
  border-color: rgba(41, 95, 152, 0.12) !important;
  box-shadow: 0 20px 45px rgba(18, 32, 51, 0.06);
  min-height: 440px;
  display: flex;
  flex-direction: column;
}

/* Layer Tab Nav */
.layer-tab-btn {
  background: #f4f6fa;
  border: 1px solid rgba(18, 32, 51, 0.08);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.25s ease;
}

.layer-tab-btn:hover {
  background: #eaeff8;
  color: var(--brand);
  border-color: rgba(41, 95, 152, 0.25);
}

.layer-tab-btn.is-active {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(41, 95, 152, 0.25);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.07);
  font-size: 0.72rem;
}

.layer-tab-btn.is-active .tab-badge {
  background: #ffffff;
  color: var(--brand);
}

/* Info Cards Content */
.mattress-info-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.layer-info-card {
  animation: fadeInLayer 0.35s ease forwards;
}

@keyframes fadeInLayer {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.info-badge-intro,
.info-badge-step {
  display: inline-block;
  background: var(--brand-subtle);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.info-badge-category {
  display: inline-block;
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

/* Benefit and Spec Boxes */
.benefit-highlight-box {
  background: #f0f6ff;
  border-left: 4px solid var(--brand);
}

.benefit-label {
  color: var(--brand);
  letter-spacing: 0.05em;
  font-size: 0.74rem;
}

.benefit-text {
  font-size: 1rem;
  line-height: 1.5;
}

.spec-highlight-box {
  background: #f8fafc;
  border-left: 4px solid #94a3b8;
}

.spec-label {
  color: #64748b;
  letter-spacing: 0.05em;
  font-size: 0.74rem;
}

.spec-text {
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Intro Checklist Rows */
.intro-layer-row {
  background: #f8fafc;
  border: 1px solid rgba(18, 32, 51, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.intro-layer-row:hover,
.intro-layer-row:focus-visible {
  background: #eef4ff;
  border-color: rgba(41, 95, 152, 0.3);
  transform: translateX(4px);
  outline: none;
}

.layer-row-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.75rem;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .mattress-layer-item,
  .mattress-toggle-btn,
  .layer-tab-btn,
  .intro-layer-row,
  .layer-info-card,
  .stage-ambient-glow {
    transition: none !important;
    animation: none !important;
  }
}

/* Mobile & Tablet Adjustments */
@media (max-width: 991.98px) {
  .mattress-stage-wrapper {
    padding: 1rem 0.5rem;
  }

  .layer-indicator-chip {
    display: none; /* Hide floating chips on mobile to prevent clutter */
  }

  .stage-controls-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .mattress-toggle-btn {
    justify-content: center;
    width: 100%;
  }

  .stage-helper-hint {
    justify-content: center;
  }

  .mattress-info-panel {
    min-height: auto;
  }
}
