/* ============================================================
   AFIYAH INFINITY — ENHANCEMENT LAYER (v2)
   "Alive" feel: animated rings, live counters, Islamic geometry,
   premium micro-interactions, page transitions. Loaded after
   components.css so it can refine earlier rules.
   ============================================================ */

/* ---- Page entrance choreography ---- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.screen > *, .portal-main > * { animation: riseIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.screen > *:nth-child(1) { animation-delay: 0.02s; }
.screen > *:nth-child(2) { animation-delay: 0.06s; }
.screen > *:nth-child(3) { animation-delay: 0.10s; }
.screen > *:nth-child(4) { animation-delay: 0.14s; }
.screen > *:nth-child(5) { animation-delay: 0.18s; }
.screen > *:nth-child(6) { animation-delay: 0.22s; }
.screen > *:nth-child(7) { animation-delay: 0.26s; }
.screen > *:nth-child(n+8) { animation-delay: 0.30s; }

@media (prefers-reduced-motion: reduce) {
  .screen > *, .portal-main > * { animation: none !important; }
}

/* ---- Islamic geometry ambient background ---- */
.geo-bg { position: relative; }
.geo-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 15% 12%, rgba(201,154,69,0.10), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(14,90,72,0.30), transparent 40%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%23C99A45' stroke-opacity='0.05' stroke-width='1'%3E%3Cpath d='M30 0l30 30-30 30L0 30z'/%3E%3Ccircle cx='30' cy='30' r='14'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---- Premium card treatment ---- */
.card {
  transition: transform var(--ease-standard), box-shadow var(--ease-standard), border-color var(--ease-standard);
  position: relative;
}
a.card:hover, button.card:hover, .card--interactive:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.32);
}
.card--gold-edge {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, rgba(201,154,69,0.5), rgba(201,154,69,0.05) 45%, rgba(201,154,69,0.3)) border-box;
  border: 1px solid transparent;
}

/* Subtle sheen sweep on hero cards */
.card--sheen { overflow: hidden; }
.card--sheen::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.06), transparent);
  transform: skewX(-18deg);
  animation: sheen 6s ease-in-out infinite;
}
@keyframes sheen { 0%, 62% { left: -60%; } 80%, 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .card--sheen::after { display: none; } }

/* ---- Animated Barakah ring ---- */
.barakah-ring { position: relative; width: 128px; height: 128px; flex-shrink: 0; }
.barakah-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.barakah-ring__track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 9; }
[data-theme="ivory_fajr"] .barakah-ring__track { stroke: rgba(0,0,0,0.08); }
.barakah-ring__fill {
  fill: none;
  stroke: url(#barakahGrad);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 6px rgba(201,154,69,0.35));
}
.barakah-ring__label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.barakah-ring__value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; line-height: 1; }
.barakah-ring__unit { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* ---- Mini activity rings (habits) ---- */
.mini-ring { width: 54px; height: 54px; position: relative; }
.mini-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.mini-ring__track { fill: none; stroke: rgba(255,255,255,0.10); stroke-width: 6; }
.mini-ring__fill { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.mini-ring__icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--gold); }

/* ---- Live count-up number ---- */
.count-up { font-variant-numeric: tabular-nums; }

/* ---- Streak flame pulse ---- */
.flame-pulse { animation: flamePulse 2.4s ease-in-out infinite; transform-origin: center bottom; }
@keyframes flamePulse { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.12); opacity: 1; } }

/* ---- Section headers with accent ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.section-head h3 { margin: 0; }
.section-head__link { font-size: 0.82rem; font-weight: 700; color: var(--gold); display: inline-flex; align-items: center; gap: 3px; }

/* ---- Pill tabs (segmented control) ---- */
.pill-tabs { display: inline-flex; background: rgba(255,255,255,0.05); border-radius: 999px; padding: 4px; gap: 2px; }
[data-theme="ivory_fajr"] .pill-tabs { background: rgba(0,0,0,0.05); }
.pill-tab { padding: 8px 16px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; color: var(--muted); cursor: pointer; border: none; background: transparent; transition: all var(--ease-fast); white-space: nowrap; }
.pill-tab.active { background: var(--gold); color: #1A1204; }

/* ---- Hero header with logo ---- */
.brand-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-3);
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 82%, transparent);
}
.brand-header__logo { height: 30px; width: auto; }

/* ---- Chips carousel ---- */
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }

/* ---- Course card ---- */
.course-card { overflow: hidden; padding: 0; }
.course-card__banner {
  height: 96px; position: relative;
  display: flex; align-items: flex-end; padding: var(--space-3);
  background-size: cover; background-position: center;
}
.course-card__banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent, rgba(6,19,22,0.85)); }
.course-card__banner > * { position: relative; z-index: 1; }
.course-card__body { padding: var(--space-4); }

/* course banner gradients */
.grad-faith { background-image: linear-gradient(135deg, #0E5A48, #061316); }
.grad-wellness { background-image: linear-gradient(135deg, #9B7AC8, #281735); }
.grad-finance { background-image: linear-gradient(135deg, #C99A45, #6b4d1c); }
.grad-mind { background-image: linear-gradient(135deg, #6C93B8, #142036); }
.grad-body { background-image: linear-gradient(135deg, #D67D91, #4a2230); }

/* ---- Lesson list row ---- */
.lesson-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: padding-left var(--ease-fast); }
.lesson-row:hover { padding-left: 6px; }
.lesson-row:last-child { border-bottom: none; }
.lesson-row__num { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; flex-shrink: 0; color: var(--muted); }
.lesson-row__num.done { background: var(--gold); border-color: var(--gold); color: #1A1204; }
.lesson-row__num.current { border-color: var(--gold); color: var(--gold); }

/* ---- Instructor chip ---- */
.instructor-chip { display: inline-flex; align-items: center; gap: 8px; }
.instructor-chip img, .instructor-chip .avatar-sm { flex-shrink: 0; }

/* ---- Safety / care alert styling ---- */
.care-alert {
  border: 1px solid rgba(201,92,92,0.4);
  background: linear-gradient(135deg, rgba(201,92,92,0.12), rgba(201,92,92,0.04));
}
.care-alert--gentle { border-color: rgba(155,122,200,0.4); background: linear-gradient(135deg, rgba(155,122,200,0.12), rgba(155,122,200,0.04)); }
.pulse-dot { position: relative; }
.pulse-dot::before {
  content: ""; position: absolute; top: -2px; right: -2px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 0 0 rgba(201,92,92,0.6);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot { 0% { box-shadow: 0 0 0 0 rgba(201,92,92,0.5); } 70% { box-shadow: 0 0 0 8px rgba(201,92,92,0); } 100% { box-shadow: 0 0 0 0 rgba(201,92,92,0); } }

/* ---- Body-literacy timeline ---- */
.body-phase {
  display: flex; gap: 14px; padding: var(--space-4);
  border-radius: var(--radius-md); background: var(--surface-soft);
  border: 1px solid rgba(255,255,255,0.05);
}
.body-phase__dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }

/* ---- Water tracker droplets ---- */
.water-row { display: flex; gap: 6px; flex-wrap: wrap; }
.water-drop { width: 30px; height: 34px; cursor: pointer; opacity: 0.3; transition: opacity var(--ease-fast), transform var(--ease-fast); color: var(--info); }
.water-drop.filled { opacity: 1; transform: scale(1.05); color: #5BA3D0; }

/* ---- Number ticker for stats ---- */
.stat-big { font-family: var(--font-display); font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 600; line-height: 1; }

/* ---- Install PWA banner ---- */
.install-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 86px; width: calc(100% - 32px); max-width: 448px;
  background: var(--surface); border: 1px solid rgba(201,154,69,0.3);
  border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-soft); z-index: 70;
  animation: riseIn 0.4s both;
}

/* ---- Toast success check animation ---- */
@keyframes checkPop { 0% { transform: scale(0); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.check-pop { animation: checkPop 0.4s both; }

/* ---- Skeleton shimmer already in components; add card skeleton ---- */
.skeleton-card { height: 90px; border-radius: var(--radius-lg); }
.skeleton-line { height: 12px; border-radius: 6px; margin-bottom: 8px; }

/* ---- Bottom nav active pop ---- */
.nav-item.active .icon { animation: navPop 0.35s cubic-bezier(0.22,1,0.36,1); }
@keyframes navPop { 0% { transform: scale(0.8); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ---- Gentle floating for FAB ---- */
.chat-fab { animation: fabFloat 3s ease-in-out infinite; }
@keyframes fabFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .chat-fab { animation: none; } }

/* ---- Greeting time-of-day tint ---- */
.greeting-block h1 { background: linear-gradient(90deg, var(--text), var(--gold) 180%); -webkit-background-clip: text; background-clip: text; }

/* ---- Divider with centered ornament ---- */
.divider-orn { display: flex; align-items: center; gap: 12px; margin: var(--space-5) 0; color: var(--gold); }
.divider-orn::before, .divider-orn::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(201,154,69,0.3), transparent); }

/* ---- Compact 2-up grids that stay 2-up on phones ---- */
.wellness-pillar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

/* ---- Responsive polish ---- */
@media (min-width: 640px) {
  .hero-logo { height: 88px !important; }
}
@media (max-width: 360px) {
  .wellness-pillar-grid { grid-template-columns: 1fr; }
}
