/* ── NORA Mini App Styles ── v3 ──────────────────────── */
:root {
  --bg: var(--tg-theme-bg-color, #0f0f23);
  --bg-surface: var(--tg-theme-secondary-bg-color, #1a1a2e);
  --fg: var(--tg-theme-text-color, #e0e0e0);
  --hint: var(--tg-theme-hint-color, #8888aa);
  --link: var(--tg-theme-link-color, #6c5ce7);
  --btn-bg: var(--tg-theme-button-color, #6c5ce7);
  --btn-fg: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #1a1a2e);
  --accent-green: #00cc88;
  --accent-orange: #ffaa00;
  --accent-red: #ff4757;
  --radius: 14px;
  --radius-sm: 10px;

  /* v3 — Semantic */
  --success: #00cc88;
  --warning: #ffaa00;
  --danger: #ff4757;
  --info: #5b8def;

  /* v3 — Glass */
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-strong: rgba(255, 255, 255, 0.10);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: 16px;

  /* v3 — Tab states */
  --tab-needs-action: linear-gradient(135deg, rgba(255,170,0,0.15), rgba(255,100,0,0.08));
  --tab-complete: linear-gradient(135deg, rgba(0,204,136,0.15), rgba(0,255,136,0.08));
  --tab-dormant: transparent;

  /* v3 — Typography scale */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-hero: 2.5rem;

  /* v3 — Shadows */
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --shadow-glow-green: 0 0 20px rgba(0, 204, 136, 0.25), 0 0 4px rgba(0, 204, 136, 0.15);
  --shadow-glow-amber: 0 0 20px rgba(255, 170, 0, 0.25), 0 0 4px rgba(255, 170, 0, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  /* Subtle gradient mesh background */
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(0, 204, 136, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(91, 141, 239, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

#app { max-width: 480px; margin: 0 auto; padding: 12px 16px 80px; }

/* ── Ripple Effect (global) ──────────────────────────── */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0);
  animation: rippleAnim 0.5s ease-out;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ── Header ──────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 14px;
}
header h1 {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--btn-bg) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.admin-header-btn {
  background: rgba(30, 30, 60, 0.65);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--hint);
  font-size: var(--text-xs);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.admin-header-btn:active { opacity: 0.6; }
.admin-header-btn.active-admin {
  border-color: var(--btn-bg);
  color: var(--btn-fg);
  background: var(--btn-bg);
}
#streak-badge {
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  background: rgba(30, 30, 60, 0.75);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ── Navigation ──────────────────────────────────────── */
nav {
  display: flex;
  gap: 4px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.nav-btn {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--hint);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.nav-btn.active {
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.35);
}

/* ── Views ───────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── View Transitions (slide left/right) ─────────────── */
#views-container {
  position: relative;
  overflow: hidden;
}
.view-page {
  display: none;
}
.view-page.active-page {
  display: block;
  position: relative;
}
/* Incoming page overlays during slide */
.view-page.sliding-in {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  z-index: 2;
}
/* Active page being slid out */
.view-page.active-page.slide-out-left,
.view-page.active-page.slide-out-right {
  position: relative;  /* keep container height */
  z-index: 1;
}
.view-page.slide-in-right {
  animation: slideInRight var(--slide-duration, 0.35s) cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.view-page.slide-in-left {
  animation: slideInLeft var(--slide-duration, 0.35s) cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.view-page.slide-out-right {
  animation: slideOutRight var(--slide-duration, 0.35s) cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.view-page.slide-out-left {
  animation: slideOutLeft var(--slide-duration, 0.35s) cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0.3; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0.3; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}
@keyframes slideOutLeft {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(-100%); opacity: 0; }
}

/* ── Prompt Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px;
  width: min(90vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-elevated);
}
.modal-title {
  font-size: var(--text-base);
  font-weight: 600;
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  color: var(--fg);
  font-family: inherit;
  font-size: var(--text-base);
  transition: border-color 0.2s;
}
.modal-input:focus {
  outline: none;
  border-color: var(--btn-bg);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}
.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-actions .action-btn {
  min-width: 0;
  flex: 1;
  padding: 10px 8px;
  font-size: var(--text-sm);
}

/* ── Iris Loading Overlay ────────────────────────────── */
#iris-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #1a1a2e);
}
#iris-overlay.open {
  pointer-events: none;
}
#iris-overlay.done {
  display: none;
}
#iris-logo {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 8px;
  background: linear-gradient(135deg, var(--btn-bg, #6c5ce7) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: irisPulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(108, 92, 231, 0.4));
}
#iris-overlay.open #iris-logo {
  animation: irisLogoFade 0.25s ease-out forwards;
}

/* The app gets revealed through an expanding circle clip */
#app.iris-revealing {
  clip-path: circle(0% at 50% 40%);
  animation: irisReveal 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes irisPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.05); }
}
@keyframes irisLogoFade {
  to { opacity: 0; transform: scale(1.4); }
}
@keyframes irisReveal {
  0%   { clip-path: circle(0% at 50% 40%); }
  100% { clip-path: circle(100% at 50% 40%); }
}

/* ── Loading ─────────────────────────────────────────── */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 40%;
  gap: 12px;
  color: var(--hint);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--btn-bg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress Bar ────────────────────────────────────── */
#progress-bar-wrap {
  position: relative;
  height: 28px;
  background: rgba(30, 30, 60, 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
#progress-bar {
  height: 100%;
  border-radius: 14px;
  background: linear-gradient(90deg, #00cc88, #00e09a, #6c5ce7);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  box-shadow: 0 0 12px rgba(0, 204, 136, 0.4);
  position: relative;
}
#progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
#progress-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--text-xs);
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  letter-spacing: 0.5px;
}

/* ── Action Buttons ──────────────────────────────────── */
.action-btn {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}
.action-btn:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(108, 92, 231, 0.2);
}
.action-btn.secondary {
  background: rgba(30, 30, 60, 0.7);
  color: var(--fg);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
.action-btn.secondary.active {
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}
.action-btn.danger {
  background: linear-gradient(135deg, #ff4757, #d63031);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
}
.action-btn.danger:active { box-shadow: none; }
.action-btn:disabled { opacity: 0.35; pointer-events: none; }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 20px;
  background: rgba(30, 30, 60, 0.8);
  border: 1px solid var(--glass-border);
  color: var(--fg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-elevated);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* ── Welcome Overlay ─────────────────────────────────── */
#welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
}
#welcome-overlay.closing {
  animation: fadeOut 0.3s ease forwards;
}
.welcome-box {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px 22px;
  width: min(88vw, 360px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-elevated);
  animation: celebPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.welcome-title {
  font-size: var(--text-xl);
  font-weight: 800;
  text-align: center;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--btn-bg) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.welcome-feature {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.welcome-feature-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.welcome-feature-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.welcome-feature-title {
  font-weight: 700;
  font-size: var(--text-sm);
}
.welcome-feature-desc {
  font-size: var(--text-xs);
  color: var(--hint);
  line-height: 1.4;
}
.welcome-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.welcome-btn:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(108, 92, 231, 0.2);
}
