/* ═══════════════════════════════════════════════════════════
   SHARED COMPONENTS — Modal, Toast, Tab Bar

   Uses CSS custom properties from style-*.css files,
   so appearance adapts automatically to all 12 combinations.
   ═══════════════════════════════════════════════════════════ */


/* ══════════════════════════════════════════════════════════
   CARD INNER — content layer above shine/tint pseudo-elements

   Phase 0 .card uses ::before (shine, z:1) and ::after (tint, z:0).
   Without a stacking context on the content wrapper, children
   paint at z:auto and get muted by the semi-transparent shine.
   ══════════════════════════════════════════════════════════ */

.card-inner {
  position: relative;
  z-index: 2;
}


/* ══════════════════════════════════════════════════════════
   MODAL / BOTTOM SHEET
   ══════════════════════════════════════════════════════════ */

/* Backdrop overlay */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--dur-normal) ease,
    visibility var(--dur-normal) ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Sheet panel — slides up from bottom */
.modal-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 910;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--glass-bg-strong, rgba(255, 255, 255, 0.18));
  backdrop-filter: blur(var(--blur-modal, 40px)) var(--saturation, saturate(180%));
  -webkit-backdrop-filter: blur(var(--blur-modal, 40px)) var(--saturation, saturate(180%));
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.16));
  border-bottom: none;
  border-radius: var(--r-modal, 32px) var(--r-modal, 32px) 0 0;
  box-shadow: var(--shadow-modal, 0 -16px 48px rgba(0, 0, 0, 0.3));
  padding-bottom: var(--safe-bottom, 0px);

  /* Start off-screen */
  transform: translateY(100%);
  visibility: hidden;
  transition:
    transform var(--dur-slower) var(--ease-spring),
    visibility var(--dur-slower) ease;
  will-change: transform;
}

.modal-sheet.open {
  transform: translateY(0);
  visibility: visible;
}

/* Shine overlay — adapts via --shine from active style */
.modal-sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--shine, none);
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* Drag handle */
.modal-handle {
  display: flex;
  justify-content: center;
  padding: var(--sp-12) 0 var(--sp-4);
  cursor: grab;
}

.modal-handle::before {
  content: '';
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: var(--text-muted);
}

/* Content area */
.modal-content {
  position: relative;
  z-index: 1;
  padding: var(--sp-8) var(--sp-20) var(--sp-24);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-bottom: var(--sp-12);
}

.modal-body {
  font-size: var(--text-body);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
}

/* Modal actions row */
.modal-actions {
  display: flex;
  gap: var(--sp-10);
  margin-top: var(--sp-20);
}

.modal-actions > * {
  flex: 1;
}


/* ══════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ══════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: calc(var(--sp-16) + var(--safe-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  width: calc(100% - var(--sp-32));
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-10);
  padding: var(--sp-12) var(--sp-16);
  border-radius: var(--r-card, 22px);
  background: var(--glass-bg-strong, rgba(255, 255, 255, 0.18));
  backdrop-filter: blur(var(--blur-card, 30px)) var(--saturation, saturate(180%));
  -webkit-backdrop-filter: blur(var(--blur-card, 30px)) var(--saturation, saturate(180%));
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.16));
  box-shadow:
    var(--shadow-card, 0 6px 20px rgba(0, 0, 0, 0.15)),
    var(--edge-light, none);
  pointer-events: auto;

  /* Enter animation */
  animation: toastIn var(--dur-slow) var(--ease-spring) forwards;
}

.toast.exiting {
  animation: toastOut var(--dur-normal) var(--ease-sharp) forwards;
}

.toast-icon {
  flex-shrink: 0;
  font-size: 20px;
  display: flex;
}

.toast-message {
  flex: 1;
  font-size: var(--text-body-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  line-height: var(--lh-normal);
}

.toast-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-tertiary);
  cursor: pointer;
  transition:
    background var(--dur-fast) ease,
    color var(--dur-fast) ease;
}

.toast-close:active {
  transform: scale(0.9);
}

@media (hover: hover) {
  .toast-close:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
  }
}

/* Semantic variants — colored left accent */
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.danger  { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

.toast.success .toast-icon { color: var(--success); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.danger  .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--info); }


/* ══════════════════════════════════════════════════════════
   TAB BAR — Bottom Navigation
   ══════════════════════════════════════════════════════════ */

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 800;
  display: flex;
  align-items: stretch;
  background: var(--glass-bg-strong, rgba(255, 255, 255, 0.14));
  backdrop-filter: blur(var(--blur-nav, 60px)) var(--saturation, saturate(180%));
  -webkit-backdrop-filter: blur(var(--blur-nav, 60px)) var(--saturation, saturate(180%));
  border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.16));
  box-shadow: var(--shadow-nav, 0 -4px 20px rgba(0, 0, 0, 0.15));
  padding-bottom: var(--safe-bottom, 0px);
}

/* Shine overlay for tab bar */
.tab-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 0;
}

.tab-item {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-4) var(--sp-6);
  color: var(--text-muted);
  font-size: var(--text-caption-sm);
  font-weight: var(--fw-medium);
  transition:
    color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-spring);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.tab-item:active {
  transform: scale(0.92);
}

.tab-icon {
  font-size: 24px;
  display: flex;
  position: relative;
}

/* Active state — accent color + glow */
.tab-item.active {
  color: var(--accent-primary);
}

/* Active glow indicator — dot under icon */
.tab-item.active .tab-icon::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px 2px rgba(var(--accent-primary-rgb, 74, 158, 255), 0.4);
  animation: scalePop var(--dur-normal) var(--ease-spring);
}

.tab-label {
  line-height: 1;
}

@media (hover: hover) {
  .tab-item:not(.active):hover {
    color: var(--text-tertiary);
  }
}


/* ══════════════════════════════════════════════════════════
   BACKDROP-FILTER FALLBACKS
   ══════════════════════════════════════════════════════════ */

@supports not (backdrop-filter: blur(1px)) {
  .modal-backdrop {
    background: rgba(0, 0, 0, 0.7);
  }

  .modal-sheet {
    background: var(--bg-elevated);
  }

  .toast {
    background: var(--bg-elevated);
  }

  .tab-bar {
    background: var(--bg-elevated);
  }
}
