/* =========================================================
   overlays.css — modals, bottom sheets, full-screen overlays
   ========================================================= */

#overlay-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
#overlay-root > * {
  pointer-events: auto;
}

/* Backdrop */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* -------- Bottom sheet (mobile primary pattern) -------- */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 90vh;
  background: var(--bg-elevated);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.25, 1);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.sheet-title {
  font-size: 17px;
  font-weight: 600;
}
.sheet-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
}

.sheet-body {
  padding: 8px 16px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sheet-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* -------- Full-screen overlay (e.g. post detail) -------- */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  animation: fade-in 0.18s ease-out;
}
.fullscreen-overlay__header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
}
.fullscreen-overlay__back {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen-overlay__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* -------- Loading state -------- */
.loading-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Desktop: cap sheet width and center */
@media (min-width: 768px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(480px, 92vw);
    border-radius: var(--radius-lg);
    max-height: 80vh;
  }
  .fullscreen-overlay {
    inset: 24px;
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
}
