*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-app);
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: 90px; /* leave room for floating navbar */
  min-height: 100vh;
  background:
    radial-gradient(720px circle at 12% 0%, rgba(28, 159, 212, 0.10), transparent 55%),
    radial-gradient(640px circle at 88% 18%, rgba(13, 100, 180, 0.08), transparent 55%),
    radial-gradient(800px circle at 50% 95%, rgba(80, 140, 230, 0.08), transparent 60%),
    var(--color-bg);
  background-attachment: fixed;
}

h1, h2, h3 {
  margin: 0 0 var(--space-2) 0;
  font-weight: 700;
  letter-spacing: 0.01em;
}

p { margin: 0; }

button {
  font-family: var(--font-app);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: var(--font-app);
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--space-6) + env(safe-area-inset-top, 0px)) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  animation: page-fade-in 0.4s ease-out;
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.app-header h1 {
  font-size: 1.5rem;
  margin: 0;
  background: linear-gradient(90deg, #1C9FD4, #0d6a94);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.header-logout:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.header-logout [data-lucide] {
  width: 14px;
  height: 14px;
}

.today-chip {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), var(--shadow-card-inset);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.section-eyebrow {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.muted { color: var(--color-text-muted); font-size: 0.875rem; }

[data-lucide] { width: 20px; height: 20px; }

/* Lightweight entrance animation - opacity + transform only (compositor-
   friendly, no layout cost), staggered per section. */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card,
.summary-card,
.graph-month-block {
  animation: fade-in-up 0.55s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.summary-card-row > *:nth-child(1) { animation-delay: 0s; }
.summary-card-row > *:nth-child(2) { animation-delay: 0.08s; }
.summary-card-row > *:nth-child(3) { animation-delay: 0.16s; }

/* Each #graphs-root child is a plain wrapper div (set via
   document.createElement in app.js); the animated `.card` lives one level
   deeper inside it, so the stagger targets that descendant directly. */
#graphs-root > *:nth-child(1) .card { animation-delay: 0.1s; }
#graphs-root > *:nth-child(2) .card { animation-delay: 0.22s; }
#graphs-root > *:nth-child(3) .card { animation-delay: 0.34s; }

#stats-root > *:nth-child(1) { animation-delay: 0.1s; }
#stats-root > *:nth-child(2) { animation-delay: 0.22s; }
#stats-root > *:nth-child(3) { animation-delay: 0.34s; }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-3);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  opacity: 0.5;
}

.footer-heart { color: var(--sholat-4); }
.footer-dot { opacity: 0.4; }

@keyframes view-exit-forward {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-56px); }
}

@keyframes view-exit-back {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(56px); }
}

@keyframes view-enter-forward {
  from { opacity: 0; transform: translateX(56px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes view-enter-back {
  from { opacity: 0; transform: translateX(-56px); }
  to   { opacity: 1; transform: translateX(0); }
}

.view-exit-forward {
  animation: view-exit-forward 0.16s ease-in forwards;
  pointer-events: none;
}

.view-exit-back {
  animation: view-exit-back 0.16s ease-in forwards;
  pointer-events: none;
}

.view-enter-forward {
  animation: view-enter-forward 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-enter-back {
  animation: view-enter-back 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="light"] body {
  background:
    radial-gradient(720px circle at 12% 0%, rgba(28, 159, 212, 0.07), transparent 55%),
    radial-gradient(640px circle at 88% 18%, rgba(13, 100, 180, 0.05), transparent 55%),
    radial-gradient(800px circle at 50% 95%, rgba(80, 140, 230, 0.05), transparent 60%),
    var(--color-bg);
  background-attachment: fixed;
}

/* Theme toggle button - mirrors .header-logout style */
.header-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.header-theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.header-theme-toggle [data-lucide] {
  width: 14px;
  height: 14px;
}

.ptr-indicator {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  color: var(--color-text-muted);
  transition: opacity 0.15s ease;
}

.ptr-indicator [data-lucide] {
  width: 20px;
  height: 20px;
}

.ptr-indicator--spinning [data-lucide] {
  animation: ptr-spin 0.6s linear infinite;
}

@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .page, .card, .summary-card, .graph-month-block, .modal-sheet, #navbar-root,
  .view-exit-forward, .view-exit-back, .view-enter-forward, .view-enter-back {
    animation: none !important;
  }
}
