/* ═══════════════════════════════════════════════════════════
   KADEMELER (TIER PROGRESSION) SYSTEM — Gamification Layer
   Reuses .plan-modal-* chrome from components.css for full
   theme + mobile compatibility, adds tier-specific pieces here.
   ═══════════════════════════════════════════════════════════ */

/* Trophy button next to the "?" info button */
.ypt-hero-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ypt-tier-btn {
  font-size: 0;
  position: relative;
}

.ypt-tier-btn svg {
  width: 13px;
  height: 13px;
}

.ypt-tier-btn:hover {
  color: #f59e0b;
}

/* ── Modal dialog sizing ── */
#modal-tiers .plan-modal-dialog {
  max-width: 480px;
}

.tier-modal-body {
  padding: 16px !important;
  gap: 16px !important;
}

/* ── Live Status Hero Card ── */
.tier-status-card {
  position: relative;
  border-radius: 20px;
  padding: 18px 16px;
  background: var(--bg-card, rgba(255,255,255,0.05));
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.4s ease, background 0.4s ease;
}

.tier-status-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 0%, var(--tier-glow, rgba(148,163,184,0.18)), transparent 65%);
  opacity: 0.9;
  pointer-events: none;
  transition: background 0.4s ease;
}

.tier-status-top {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.tier-status-avatar-slot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tier-status-info {
  min-width: 0;
  flex: 1;
}

.tier-status-eyebrow {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-s, #94a3b8);
  margin-bottom: 2px;
}

.tier-status-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-p, #fff);
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.25;
}

.tier-status-title .tier-mini-badge {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
}

.tier-status-title .tier-mini-badge svg {
  width: 100%;
  height: 100%;
}

.tier-status-sub {
  font-size: 12px;
  color: var(--text-s, #94a3b8);
  margin-top: 3px;
  font-weight: 600;
}

.tier-status-today {
  font-family: var(--mono, monospace);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--tier-color, var(--accent));
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}

.tier-status-today small {
  display: block;
  font-family: var(--sans, sans-serif);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--text-m, rgba(235,235,245,0.4));
  text-transform: uppercase;
  margin-top: 2px;
}

/* Progress bar to next tier */
.tier-progress-track-wrap {
  position: relative;
  z-index: 1;
}

.tier-progress-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-s, #94a3b8);
  margin-bottom: 6px;
}

.tier-progress-labels .tier-next-name {
  color: var(--text-p, #fff);
}

.tier-progress-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
}

body.light-theme .tier-progress-track,
body.theme-light .tier-progress-track,
[data-theme="light"] .tier-progress-track,
body.litewhite-theme .tier-progress-track,
body.theme-litewhite .tier-progress-track,
[data-theme="litewhite"] .tier-progress-track {
  background: rgba(15,23,42,0.08);
}

.tier-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tier-color, #64748b), var(--tier-color2, #94a3b8));
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px var(--tier-glow-strong, rgba(148,163,184,0.4));
  position: relative;
}

.tier-progress-fill.is-maxed {
  background: linear-gradient(90deg, #f59e0b, #ec4899, #8b5cf6, #38bdf8, #10b981);
  background-size: 300% 100%;
  animation: tierRainbowShift 3.5s linear infinite;
}

@keyframes tierRainbowShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

.tier-progress-remaining {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-s, #94a3b8);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  position: relative;
  z-index: 1;
}

.tier-progress-remaining strong {
  color: var(--tier-color, var(--text-p));
  font-family: var(--mono, monospace);
  font-weight: 800;
}

/* ── Not-studying prompt state ── */
.tier-idle-hint {
  font-size: 11.5px;
  color: var(--text-s, #94a3b8);
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--border, rgba(255,255,255,0.14));
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 8px;
  position: relative;
  z-index: 1;
  line-height: 1.4;
}

/* ── Section label ── */
.tier-ladder-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-s, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tier-ladder-label span.tier-ladder-count {
  font-weight: 700;
  color: var(--text-m, rgba(235,235,245,0.4));
  text-transform: none;
  letter-spacing: 0;
}

/* ── Ladder list ── */
.tier-ladder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.tier-ladder-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 13px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  background: var(--bg-card, rgba(255,255,255,0.04));
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.tier-ladder-row.is-done {
  opacity: 0.72;
}

.tier-ladder-row.is-current {
  border-color: var(--tier-row-color, var(--accent));
  background: var(--tier-row-bg, rgba(148,163,184,0.1));
  box-shadow: 0 0 0 1px var(--tier-row-color, var(--accent)) inset, 0 4px 18px var(--tier-row-glow, rgba(148,163,184,0.22));
  animation: tierCurrentPulse 2.6s ease-in-out infinite;
}

@keyframes tierCurrentPulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--tier-row-color, var(--accent)) inset, 0 4px 18px var(--tier-row-glow, rgba(148,163,184,0.22)); }
  50% { box-shadow: 0 0 0 1.5px var(--tier-row-color, var(--accent)) inset, 0 4px 26px var(--tier-row-glow, rgba(148,163,184,0.4)); }
}

.tier-ladder-row.is-locked {
  opacity: 0.5;
  filter: grayscale(0.55);
}

.tier-ladder-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tier-ladder-icon svg {
  width: 100%;
  height: 100%;
}

.tier-ladder-mid {
  flex: 1;
  min-width: 0;
}

.tier-ladder-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-p, #fff);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tier-ladder-range {
  font-size: 10.5px;
  color: var(--text-s, #94a3b8);
  font-family: var(--mono, monospace);
  font-weight: 700;
  margin-top: 1px;
}

.tier-ladder-status {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.tier-ladder-status.st-done {
  background: rgba(16,185,129,0.14);
  color: #10b981;
}

.tier-ladder-status.st-current {
  background: var(--tier-row-color, var(--accent));
  color: #08080a;
}

.tier-ladder-status.st-locked {
  background: rgba(148,163,184,0.12);
  color: var(--text-m, rgba(235,235,245,0.4));
  display: flex;
  align-items: center;
  gap: 3px;
}

.tier-ladder-status.st-locked svg {
  width: 10px;
  height: 10px;
}

/* Footnote */
.tier-modal-footnote {
  font-size: 10.5px;
  color: var(--text-m, rgba(235,235,245,0.35));
  text-align: center;
  line-height: 1.5;
  padding: 0 4px;
}

/* ═══════════════════════════════════════════
   LEVEL-UP CELEBRATION TOAST
   ═══════════════════════════════════════════ */
#tier-levelup-toast-host {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200000;
  pointer-events: none;
  padding: 0 14px;
}

.tier-levelup-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 380px;
  width: 100%;
  background: var(--bg-mid, #12141a);
  border: 1.5px solid var(--tier-color, var(--accent));
  border-radius: 16px;
  padding: 11px 14px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.4), 0 0 24px var(--tier-glow-strong, rgba(148,163,184,0.35));
  cursor: pointer;
  animation: tierToastIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

body.light-theme .tier-levelup-toast,
body.theme-light .tier-levelup-toast,
[data-theme="light"] .tier-levelup-toast,
body.litewhite-theme .tier-levelup-toast,
body.theme-litewhite .tier-levelup-toast,
[data-theme="litewhite"] .tier-levelup-toast {
  background: #ffffff;
}

.tier-levelup-toast.is-leaving {
  animation: tierToastOut 0.35s ease-in forwards;
}

@keyframes tierToastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tierToastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-10px) scale(0.96); }
}

.tier-levelup-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tierIconPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

.tier-levelup-icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 6px var(--tier-glow-strong, rgba(148,163,184,0.5)));
}

@keyframes tierIconPop {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

.tier-levelup-text {
  min-width: 0;
  flex: 1;
}

.tier-levelup-eyebrow {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tier-color, var(--accent));
}

.tier-levelup-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-p, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tier-levelup-particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--tier-color, var(--accent));
  opacity: 0;
  animation: tierParticleFloat 1.1s ease-out forwards;
}

@keyframes tierParticleFloat {
  0% { opacity: 0.9; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--px, 20px), var(--py, -40px)) scale(0.3); }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  #modal-tiers .plan-modal-dialog {
    max-width: 100%;
  }

  .tier-status-title {
    font-size: 15.5px;
  }

  .tier-status-today {
    font-size: 12px;
  }

  .tier-ladder-list {
    max-height: 46vh;
  }

  .tier-levelup-toast {
    max-width: 100%;
  }
}
