/**
 * Zwarah "shell" UI — same palette as PWA install prompt (slate + gold).
 * Use for modals, toasts, flash messages, in-app notifications.
 */
:root {
  --zwarah-shell-overlay-bg: rgba(15, 23, 42, 0.55);
  --zwarah-shell-card-bg: #1e293b;
  --zwarah-shell-card-border: rgba(250, 204, 21, 0.5);
  --zwarah-shell-card-radius: 20px;
  --zwarah-shell-card-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  --zwarah-shell-title: #facc15;
  --zwarah-shell-text: #e2e8f0;
  --zwarah-shell-text-muted: #cbd5e1;
  --zwarah-shell-primary: #facc15;
  --zwarah-shell-primary-text: #0f172a;
  --zwarah-shell-secondary-border: rgba(148, 163, 184, 0.45);
  --zwarah-shell-close-bg: rgba(148, 163, 184, 0.2);
}

/* ——— PWA install / dialogs (used by static/js/pwa.js) ——— */
.zwarah-shell-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: var(--zwarah-shell-overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.zwarah-shell-dialog-card {
  position: relative;
  max-width: min(440px, calc(100vw - 32px));
  width: 100%;
  background: var(--zwarah-shell-card-bg);
  border: 2px solid var(--zwarah-shell-card-border);
  border-radius: var(--zwarah-shell-card-radius);
  padding: clamp(22px, 5vw, 36px);
  padding-top: clamp(40px, 8vw, 48px);
  box-shadow: var(--zwarah-shell-card-shadow);
  text-align: center;
  font-family: inherit;
}

.zwarah-shell-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--zwarah-shell-close-bg);
  color: var(--zwarah-shell-text);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif;
  padding: 0;
}

.zwarah-shell-title {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 800;
  color: var(--zwarah-shell-title);
  margin-bottom: 12px;
  line-height: 1.35;
}

.zwarah-shell-subtitle {
  margin: 0 0 24px;
  font-size: clamp(1rem, 3.2vw, 1.1rem);
  color: var(--zwarah-shell-text);
  line-height: 1.55;
}

/* App alert/confirm (zwarah-dialog.js) — above PWA install (10050), below update banner (10060) */
.zwarah-app-dialog-overlay {
  z-index: 10056;
}

.zwarah-shell-dialog-message {
  margin: 0 0 24px;
  font-size: clamp(1rem, 3.2vw, 1.08rem);
  color: var(--zwarah-shell-text);
  line-height: 1.6;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
}

.zwarah-shell-btn {
  width: 100%;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.3;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.zwarah-shell-btn-primary {
  border: none;
  padding: 16px 22px;
  font-size: 1.15rem;
  background: var(--zwarah-shell-primary);
  color: var(--zwarah-shell-primary-text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.zwarah-shell-btn-secondary {
  margin-top: 12px;
  border: 2px solid var(--zwarah-shell-secondary-border);
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  background: transparent;
  color: var(--zwarah-shell-text-muted);
  line-height: 1.35;
}

.zwarah-shell-update-banner {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10060;
  max-width: min(420px, calc(100vw - 24px));
  padding: 14px 18px;
  border-radius: var(--zwarah-shell-card-radius);
  background: var(--zwarah-shell-card-bg);
  color: var(--zwarah-shell-text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  box-shadow: var(--zwarah-shell-card-shadow);
  border: 2px solid var(--zwarah-shell-card-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.zwarah-shell-update-banner button {
  border: none;
  border-radius: 12px;
  padding: 8px 16px;
  font-weight: 800;
  cursor: pointer;
  background: var(--zwarah-shell-primary);
  color: var(--zwarah-shell-primary-text);
  font-family: inherit;
}

/* ——— Game toasts (centered) ——— */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--zwarah-shell-card-bg);
  border: 2px solid var(--zwarah-shell-card-border);
  border-radius: var(--zwarah-shell-card-radius);
  padding: 18px 22px;
  color: var(--zwarah-shell-title);
  font-weight: 700;
  font-size: 1rem;
  z-index: 10000;
  box-shadow: var(--zwarah-shell-card-shadow);
  animation: zwarahShellToastIn 0.3s ease-out;
  box-sizing: border-box;
  min-width: 0;
  max-width: min(400px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toast-message {
  line-height: 1.55;
  color: var(--zwarah-shell-text);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(250, 204, 21, 0.55);
  width: 100%;
  transform-origin: left;
  animation: zwarahShellToastProgress linear forwards;
}

@keyframes zwarahShellToastProgress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.5);
}

.toast.success .toast-message {
  color: var(--accent-green, #22c55e);
}

.toast.success .toast-progress {
  background: rgba(34, 197, 94, 0.65);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast.error .toast-message {
  color: var(--accent-red, #ef4444);
}

.toast.error .toast-progress {
  background: rgba(239, 68, 68, 0.65);
}

.toast.warning {
  border-color: rgba(245, 158, 11, 0.5);
}

.toast.warning .toast-message {
  color: var(--accent-orange, #f59e0b);
}

.toast.warning .toast-progress {
  background: rgba(245, 158, 11, 0.65);
}

.toast.info {
  border-color: rgba(59, 130, 246, 0.5);
}

.toast.info .toast-message {
  color: var(--accent-blue, #3b82f6);
}

.toast.info .toast-progress {
  background: rgba(59, 130, 246, 0.65);
}

@keyframes zwarahShellToastIn {
  from {
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes zwarahShellToastOut {
  from {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
  }
}

.toast.hide {
  animation: zwarahShellToastOut 0.3s ease-in forwards;
}

@media (max-width: 768px) {
  .toast {
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: auto;
    max-width: calc(100% - 24px);
    margin: 0 12px;
  }
}

/* ——— Flask flash messages (override modern.css when loaded after) ——— */
.flash-modern {
  padding: 1.1rem 1.5rem;
  border-radius: var(--zwarah-shell-card-radius) !important;
  font-weight: 600;
  box-shadow: var(--zwarah-shell-card-shadow) !important;
  background: var(--zwarah-shell-card-bg) !important;
  border: 2px solid var(--zwarah-shell-card-border) !important;
  color: var(--zwarah-shell-text) !important;
  animation: zwarahShellToastIn 0.3s ease-out;
}

.flash-modern::before {
  width: 0;
  display: none;
}

.flash-success {
  border-color: rgba(34, 197, 94, 0.5) !important;
  color: var(--accent-green, #22c55e) !important;
}

.flash-error {
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: var(--accent-red, #ef4444) !important;
}

.flash-info {
  border-color: rgba(59, 130, 246, 0.5) !important;
  color: var(--accent-blue, #3b82f6) !important;
}
