/* =========================
   DASHBOARD
========================= */

.dashboard {
  max-width: 1150px;
  margin: 0 auto;
  padding: 30px 20px 60px;
}

/* =========================
   HERO
========================= */

.dashboard-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: white;
  border-radius: 24px;
  padding: 40px;
  margin-bottom: 30px;
  box-shadow: 0 20px 45px rgba(124, 58, 237, 0.18);
}

/* Parallax shapes — JS (scrollEffects.js) sets translateY on
   these via data-parallax-speed; CSS only handles their static
   look. Same visual language as the landing page hero. */
.dashboard-hero-shape {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(2px);
  will-change: transform;
}

.dashboard-hero-shape-1 {
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.06);
  top: -60px;
  right: -40px;
}

.dashboard-hero-shape-2 {
  width: 100px;
  height: 100px;
  background: rgba(192, 132, 252, 0.16);
  bottom: -30px;
  left: 20%;
}

.hero-text {
  position: relative;
}

/* Title row: welcome heading + notification bell side by side.
   Split out from .hero-text (which still wraps the whole block,
   including the subtitle line below) so the bell sits flush with
   the heading instead of centered against the taller two-line
   hero. */
.hero-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hero-top h1 {
  font-size: 2rem;
  margin-bottom: 0;
}

.hero-text p {
  opacity: 0.9;
  line-height: 1.7;
  max-width: 600px;
  margin-top: 12px;
  transition: opacity 0.3s ease;
}

.hero-text p.message-updating {
  opacity: 0;
}

/* =========================
   NOTIFICATION BELL
========================= */

.notif-bell-wrap {
  flex: 0 0 auto;
}

.notif-bell {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .notif-bell:hover {
    background: rgba(255, 255, 255, 0.2);
  }
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid #7c3aed;
}

/* A little wiggle to draw the eye when there's something unread —
   same "make it feel alive" language as the trend-line draw and
   count-up elsewhere on this page. Only plays while the badge is
   actually showing, via :has() (Baseline-widely-available as of
   2024); browsers without :has() just get a still bell instead of
   a broken one. */
@supports selector(:has(a)) {
  .notif-bell:has(.notif-badge:not([hidden])) {
    animation: notif-bell-wiggle 2.2s ease-in-out infinite;
  }
}

@keyframes notif-bell-wiggle {
  0%,
  75%,
  100% {
    transform: rotate(0deg);
  }
  78% {
    transform: rotate(-12deg);
  }
  81% {
    transform: rotate(10deg);
  }
  84% {
    transform: rotate(-8deg);
  }
  87% {
    transform: rotate(4deg);
  }
  90% {
    transform: rotate(0deg);
  }
}

/* The panel itself is appended straight to document.body by
   dashboard.js (see setupNotifBell / positionNotifPanel), not
   nested under .dashboard-hero — that box has overflow:hidden to
   clip its decorative parallax shapes at the rounded corners,
   which was also silently clipping the dropdown. Being on body
   with position:fixed and JS-computed top/left sidesteps that
   entirely, the same way dangerDialog.js's overlay lives on body
   instead of inside whichever admin tab happened to be open. */
.notif-panel {
  position: fixed;
  width: min(300px, 80vw);
  max-height: 360px;
  overflow-y: auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  z-index: 1000;
  color: #111827;
}

.notif-panel-header {
  position: sticky;
  top: 0;
  background: white;
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid #ececec;
}

.notif-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: #fafafa;
}

@media (hover: hover) and (pointer: fine) {
  .notif-item:hover {
    background: #f3f0fb;
  }
}

.notif-item-main {
  min-width: 0;
  flex: 1 1 auto;
}

.notif-item-delete {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .notif-item-delete:hover {
    background: #fde8e8;
    color: #dc2626;
  }
}

.notif-message {
  font-size: 13px;
  line-height: 1.55;
  color: #111827;
  margin-bottom: 4px;
}

.notif-time {
  font-size: 11px;
  color: #9ca3af;
}

.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

/* =========================
   ACTION CARDS
========================= */

.action-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 30px;
}

.action-card {
  background: white;
  border-radius: 22px;
  padding: 28px;
  cursor: pointer;
  transition:
    transform 0.15s ease-out,
    box-shadow 0.25s ease;
  border: 1px solid #ececec;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

/* Hover-lift only on devices with real hover (mouse/trackpad).
   On touch, :hover often triggers on tap and sticks until the
   user taps elsewhere — same fix already applied on the landing
   page's feature cards. The JS tilt effect (initCardTilt) is
   already separately gated to the same capability check. */
@media (hover: hover) and (pointer: fine) {
  .action-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.09);
  }
}

.action-icon {
  width: 65px;
  height: 65px;
  border-radius: 18px;
  background: #ede9fe;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 30px;
  margin-bottom: 18px;
}

.action-card h3 {
  margin-bottom: 10px;
  color: #111827;
}

.action-card p {
  color: #6b7280;
  line-height: 1.7;
}

.action-link {
  display: inline-block;
  margin-top: 18px;
  color: #7c3aed;
  font-weight: 700;
}

/* =========================
   STATS
========================= */

.stats-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: 20px;
  padding: 25px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
  border: 1px solid #ececec;
}

.stat-icon {
  font-size: 30px;
  display: inline-block;
}

.stat-card h2 {
  font-size: 2rem;
  margin: 15px 0 8px;
  color: #7c3aed;
}

.stat-card p {
  color: #6b7280;
}

/* Day Streak card (replaces the old static Best Score card): gets
   its own visual treatment once a streak exists, plus a status
   subtitle (JS: updateStreakCard() in dashboard.js) so the card
   actually communicates something actionable instead of just a
   number — a warm background + pulsing flame while alive, an amber
   "act today" tint while at risk (streak alive but not done today),
   and a calmer green tint once today is already locked in. */
.stat-card.streak-active {
  background: linear-gradient(160deg, #fff7ed, #ffffff 65%);
  border-color: #fed7aa;
}

.stat-card.streak-active .stat-icon {
  animation: streak-flame-pulse 1.6s ease-in-out infinite;
}

.streak-subtitle {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  color: #9ca3af;
  min-height: 15px;
}

.stat-card.streak-at-risk {
  background: linear-gradient(160deg, #fffbeb, #ffffff 65%);
  border-color: #fde68a;
}

.stat-card.streak-at-risk .streak-subtitle {
  color: #b45309;
}

.stat-card.streak-done-today {
  background: linear-gradient(160deg, #ecfdf5, #ffffff 65%);
  border-color: #a7f3d0;
}

.stat-card.streak-done-today .streak-subtitle {
  color: #059669;
}

@keyframes streak-flame-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

/* =========================
   SCORE TREND CHART
========================= */

.score-trend-container {
  width: 100%;
}

.score-trend-chart {
  width: 100%;
  height: 180px;
  display: block;
}

.trend-baseline {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.trend-line {
  stroke: #7c3aed;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-dot {
  fill: #7c3aed;
  stroke: white;
  stroke-width: 2;
}

/* =========================
   RECENT ATTEMPTS LIST
========================= */

.attempts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.attempt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fafafa;
  border: 1px solid #ececec;
}

.attempt-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attempt-title {
  font-weight: 700;
  color: #111827;
  font-size: 14px;
}

.attempt-mode-badge {
  background: #ede9fe;
  color: #6d28d9;
}

.attempt-item-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: #6b7280;
}

.attempt-score {
  font-weight: 700;
  color: #7c3aed;
}

/* =========================
   RECENT ACTIVITY
========================= */

.dashboard-section {
  background: white;
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
  border: 1px solid #ececec;
  margin-bottom: 30px;
}

.section-header h2 {
  margin-bottom: 20px;
}

.empty-state {
  text-align: center;
  padding: 45px 20px;
  color: #9ca3af;
  line-height: 1.8;
}

/* =========================
   LOGOUT
========================= */

.logout-btn {
  width: 100%;
  border: none;
  padding: 16px;
  border-radius: 16px;
  background: #ef4444;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.25s;
}

.logout-btn:hover {
  background: #dc2626;
}

/* =========================================================
   ENTRANCE ANIMATIONS (Duolingo-style)

   Two triggers:
   - .load-in: plays automatically on mount. Used for the
     action cards and stat cards, since they're above the fold
     and visible immediately — no need to wait for a scroll
     event that may never come.
   - .reveal / .reveal-visible: scroll-triggered (via
     scrollEffects.js's initScrollReveal), for the Score Trend
     and Recent Activity sections that often sit below the fold,
     especially on mobile.

   Both use the same squash-and-stretch bounce curve as the
   loading-overlay blob, so it reads as one consistent animation
   language across the app rather than several different styles.
========================================================= */

@keyframes dashboard-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(14px);
  }
  60% {
    opacity: 1;
    transform: scale(1.03) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.load-in {
  animation: dashboard-pop-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Stagger the cards so they pop in one after another rather
   than all at once. */
.action-grid .action-card:nth-child(1) {
  animation-delay: 0s;
}
.action-grid .action-card:nth-child(2) {
  animation-delay: 0.08s;
}
.action-grid .action-card:nth-child(3) {
  animation-delay: 0.16s;
}

.stats-grid .stat-card:nth-child(1) {
  animation-delay: 0.1s;
}
.stats-grid .stat-card:nth-child(2) {
  animation-delay: 0.18s;
}

.reveal {
  opacity: 0;
  transform: scale(0.92) translateY(20px);
  transition:
    opacity 0.5s ease,
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reveal-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Self-drawing score trend line: the path "draws itself" once
   the chart is injected into the DOM. 1000 is a fixed value
   comfortably longer than any realistic chart path — a common,
   simple alternative to measuring the path's real length in JS. */
.trend-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: trend-draw 1.1s ease-out 0.15s forwards;
}

@keyframes trend-draw {
  to {
    stroke-dashoffset: 0;
  }
}

.trend-dot {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: trend-dot-pop 0.4s ease-out 1.1s forwards;
}

@keyframes trend-dot-pop {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .load-in,
  .trend-line,
  .trend-dot,
  .notif-bell,
  .stat-card.streak-active .stat-icon {
    animation: none;
  }

  /* Without the animation running, the base "hidden" state
     (stroke-dashoffset: 1000 / opacity: 0) would otherwise leave
     the chart looking invisible instead of just unanimated. */
  .trend-line {
    stroke-dashoffset: 0;
  }

  .trend-dot {
    opacity: 1;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* =========================
   DESKTOP
========================= */

@media (min-width: 768px) {
  .action-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
