/* ==========================================================================
   CATEGORY 4: Transitions & Layout Morphing (Demos 23–28)
   Styles for Sliding Pill Tabs, Shared-Element Morph, FLIP Grid Reorder,
   Smooth Grid Accordion, Elastic Bottom Sheet, and Page Curtain Wipe.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shared Stage Container for Category 4
   -------------------------------------------------------------------------- */
.cat4-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1.25rem;
  background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.3) 0%, rgba(11, 13, 18, 0.75) 100%);
  user-select: none;
  font-family: inherit;
}

/* Category 4 mini toolbar */
.cat4-controls {
  position: absolute;
  bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 20;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  padding: 0.25rem 0.6rem;
}

.cat4-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all calc(0.2s / var(--speed-mult, 1)) ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.cat4-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

.cat4-btn:active {
  transform: translateY(0);
}

.cat4-btn.active {
  background: #6366f1;
  border-color: #818cf8;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

/* --------------------------------------------------------------------------
   Demo 23: Sliding Pill Tabs
   -------------------------------------------------------------------------- */
.demo-pill-tabs-wrap {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.pill-nav-container {
  position: relative;
  display: inline-flex;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  padding: 0.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pill-glider {
  position: absolute;
  top: 0.25rem;
  bottom: 0.25rem;
  left: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(129, 140, 248, 0.15) 100%);
  border: 1px solid rgba(129, 140, 248, 0.6);
  border-radius: 9999px;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.35);
  pointer-events: none;
  will-change: transform, width;
  transition: transform calc(var(--duration, 0.38s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.2, 0.9, 0.3, 1.2)),
              width calc(var(--duration, 0.32s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.2, 0.9, 0.3, 1));
}

.pill-tab-item {
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: color calc(0.25s / var(--speed-mult, 1)) ease;
  white-space: nowrap;
}

.pill-tab-item:hover {
  color: #f8fafc;
}

.pill-tab-item.active {
  color: #ffffff;
}

.pill-panels-viewport {
  width: 100%;
  position: relative;
  min-height: 90px;
  overflow: hidden;
}

.pill-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  opacity: 0;
  transform: translate3d(25px, 0, 0);
  pointer-events: none;
  transition: opacity calc(var(--duration, 0.32s) / var(--speed-mult, 1)) ease,
              transform calc(var(--duration, 0.35s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.16, 1, 0.3, 1));
}

.pill-panel.active {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  pointer-events: auto;
  position: relative;
}

.pill-panel.exit-left {
  opacity: 0;
  transform: translate3d(-25px, 0, 0);
}

.pill-panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pill-panel-desc {
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* --------------------------------------------------------------------------
   Demo 24: Shared-Element Morph
   -------------------------------------------------------------------------- */
.demo-morph-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.morph-compact-card {
  width: 250px;
  padding: 1rem 1.15rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(99, 102, 241, 0.15);
  cursor: pointer;
  transition: transform calc(0.25s / var(--speed-mult, 1)) ease,
              border-color calc(0.25s / var(--speed-mult, 1)) ease,
              box-shadow calc(0.25s / var(--speed-mult, 1)) ease;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.morph-compact-card:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(129, 140, 248, 0.6);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(99, 102, 241, 0.3);
}

.morph-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.morph-card-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.morph-card-icon {
  font-size: 1.3rem;
}

.morph-card-title {
  font-size: 1rem;
  font-weight: 800;
  color: #f8fafc;
}

.morph-card-desc {
  font-size: 0.74rem;
  color: #94a3b8;
  line-height: 1.4;
}

.morph-action-hint {
  font-size: 0.7rem;
  color: #818cf8;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Detail Expanded Card (FLIP element) */
.morph-detail-card {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: #0d121f;
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 16px;
  padding: 1.25rem;
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 35px rgba(99, 102, 241, 0.25);
  z-index: 15;
  transform-origin: top left;
  will-change: transform, opacity;
}

.morph-detail-card.active {
  display: flex;
}

.morph-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.6rem;
}

.morph-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all calc(0.2s / var(--speed-mult, 1)) ease;
}

.morph-close-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: #ef4444;
}

.morph-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.morph-stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}

.morph-stat-label {
  font-size: 0.65rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.morph-stat-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: #38bdf8;
  margin-top: 0.15rem;
}

/* --------------------------------------------------------------------------
   Demo 25: FLIP Grid Reorder
   -------------------------------------------------------------------------- */
.demo-flip-grid-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.flip-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

.flip-pill-btn {
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all calc(0.2s / var(--speed-mult, 1)) ease;
}

.flip-pill-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #ffffff;
}

.flip-pill-btn.active {
  background: #6366f1;
  border-color: #818cf8;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.flip-items-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
}

.flip-grid-item {
  position: relative;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  will-change: transform, opacity;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  cursor: default;
}

.flip-grid-item.is-hidden {
  display: none;
}

.flip-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flip-item-icon {
  font-size: 1.1rem;
}

.flip-item-tag {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  text-transform: uppercase;
}

.flip-item-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flip-item-metric {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: #818cf8;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Demo 26: Smooth Accordion (Zero-Jank Modern CSS Grid)
   -------------------------------------------------------------------------- */
.demo-accordion-list {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accordion-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color calc(0.3s / var(--speed-mult, 1)) ease,
              box-shadow calc(0.3s / var(--speed-mult, 1)) ease;
}

.accordion-card.is-open {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.12);
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.95rem;
  background: transparent;
  border: none;
  color: #f1f5f9;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.accordion-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  color: #818cf8;
  transition: transform calc(var(--duration, 0.35s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.34, 1.56, 0.64, 1));
}

.accordion-card.is-open .accordion-chevron {
  transform: rotate(180deg);
}

/* Modern CSS Grid Zero-Jank Expand/Collapse */
.accordion-grid-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows calc(var(--duration, 0.38s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.16, 1, 0.3, 1));
}

.accordion-card.is-open .accordion-grid-wrapper {
  grid-template-rows: 1fr;
}

.accordion-inner-content {
  overflow: hidden;
}

.accordion-text {
  padding: 0 0.95rem 0.85rem 0.95rem;
  font-size: 0.76rem;
  line-height: 1.5;
  color: #94a3b8;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity calc(var(--duration, 0.3s) / var(--speed-mult, 1)) ease,
              transform calc(var(--duration, 0.3s) / var(--speed-mult, 1)) ease;
}

.accordion-card.is-open .accordion-text {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Demo 27: Elastic Drawer / Bottom Sheet
   -------------------------------------------------------------------------- */
.demo-drawer-canvas {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 190px;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.drawer-preview-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.drawer-open-btn {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  border: none;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.5rem 1.1rem;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transition: all calc(0.2s / var(--speed-mult, 1)) ease;
}

.drawer-open-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(var(--duration, 0.35s) / var(--speed-mult, 1)) ease;
  z-index: 10;
}

.demo-drawer-canvas.is-drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.drawer-bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0e1424;
  border-top: 1px solid rgba(129, 140, 248, 0.4);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 0.6rem 1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 15;
  transform: translate3d(0, 105%, 0);
  will-change: transform;
  transition: transform calc(var(--duration, 0.52s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.175, 0.885, 0.32, 1.18));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
}

.demo-drawer-canvas.is-drawer-open .drawer-bottom-sheet {
  transform: translate3d(0, 0, 0);
}

.drawer-drag-handle {
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  margin: 0 auto;
  cursor: grab;
}

.drawer-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.drawer-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem 0.2rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.68rem;
  cursor: pointer;
  transition: all calc(0.18s / var(--speed-mult, 1)) ease;
}

.drawer-action-item:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Demo 28: Page Curtain / Wipe
   -------------------------------------------------------------------------- */
.demo-wipe-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 195px;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.wipe-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  gap: 0.5rem;
}

.wipe-scene.scene-a {
  background: radial-gradient(circle at 70% 30%, #1e1b4b 0%, #090d16 100%);
}

.wipe-scene.scene-b {
  background: radial-gradient(circle at 30% 70%, #064e3b 0%, #022c22 100%);
}

.wipe-scene-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.scene-a .wipe-scene-badge {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

.scene-b .wipe-scene-badge {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

.wipe-scene-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
}

.wipe-scene-metric {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: #cbd5e1;
}

/* Curtain Wipe Layers */
.curtain-layer {
  position: absolute;
  inset: 0;
  background: #6366f1;
  z-index: 10;
  pointer-events: none;
  transform: translate3d(-100%, 0, 0);
  will-change: transform, clip-path;
}

/* Style: Diagonal Wipe */
.demo-wipe-stage.wipe-diagonal .curtain-layer {
  transform: none;
  clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
  transition: clip-path calc(var(--duration, 0.65s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.77, 0, 0.175, 1));
}

.demo-wipe-stage.wipe-diagonal.wiping-in .curtain-layer {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.demo-wipe-stage.wipe-diagonal.wiping-out .curtain-layer {
  clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
}

/* Style: Horizontal Shutter */
.demo-wipe-stage.wipe-shutter .curtain-layer {
  transition: transform calc(var(--duration, 0.55s) / var(--speed-mult, 1)) var(--easing, cubic-bezier(0.77, 0, 0.175, 1));
}

.demo-wipe-stage.wipe-shutter.wiping-in .curtain-layer {
  transform: translate3d(0, 0, 0);
}

.demo-wipe-stage.wipe-shutter.wiping-out .curtain-layer {
  transform: translate3d(100%, 0, 0);
}

/* Reduced Motion Override for Category 4 */
.reduced-motion .pill-glider,
.reduced-motion .pill-panel,
.reduced-motion .morph-compact-card,
.reduced-motion .morph-detail-card,
.reduced-motion .flip-grid-item,
.reduced-motion .accordion-grid-wrapper,
.reduced-motion .accordion-chevron,
.reduced-motion .drawer-bottom-sheet,
.reduced-motion .curtain-layer {
  animation: none !important;
  transition: none !important;
  transform: none !important;
}
