/* ════════════════════════════════════════════════════════════════
   EduExpert — AI Playground Styles
   Loaded AFTER landing.css so any tied styles win.
   Scoped class names avoid conflict with landing CSS.
   ════════════════════════════════════════════════════════════════ */

/* ── Section base ── */
.pg-section {
  position: relative;
  padding: 4rem 1rem 5rem;
}
.pg-section::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(37,99,235,0.06), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(99,102,241,0.06), transparent 40%);
  pointer-events: none;
  z-index: 0;
}
.pg-section > * { position: relative; z-index: 1; }

/* ── Glass card ── */
.pg-glass {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 24px 60px -12px rgba(15,23,42,0.10);
}
:where(.dark) .pg-glass {
  background: rgba(15,23,42,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 24px 60px -12px rgba(0,0,0,0.4);
}

/* ── Primary button (with magnetic + ripple) ── */
.pg-btn-primary {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #6366f1 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.15) inset,
    0 10px 30px -6px rgba(37,99,235,0.5);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pg-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.15) inset,
    0 14px 38px -6px rgba(37,99,235,0.65);
}
.pg-btn-primary:active { transform: translateY(0); }
.pg-magnetic { transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ── Ripple ── */
.pg-ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.35);
  pointer-events: none;
  transform: scale(0);
  animation: pgRippleOut 0.6s ease-out;
}
@keyframes pgRippleOut {
  to { transform: scale(4); opacity: 0; }
}

/* ── Chip (quick topics) ── */
.pg-chip {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(37,99,235,0.08);
  border: 1px solid rgba(37,99,235,0.18);
  color: #1d4ed8;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}
.pg-chip:hover {
  background: rgba(37,99,235,0.14);
  transform: translateY(-1px);
}
:where(.dark) .pg-chip {
  background: rgba(96,165,250,0.10);
  border-color: rgba(96,165,250,0.22);
  color: #93c5fd;
}
:where(.dark) .pg-chip:hover { background: rgba(96,165,250,0.18); }

/* ── Form inputs ── */
.pg-input, .pg-select {
  transition: all 0.18s ease;
  background: rgba(255,255,255,0.7);
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  width: 100%;
  font-size: 0.95rem;
  color: #0f172a;
}
:where(.dark) .pg-input, :where(.dark) .pg-select {
  background: rgba(15,23,42,0.5);
  border-color: #334155;
  color: #f1f5f9;
}
.pg-input:focus, .pg-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
  background: white;
}
:where(.dark) .pg-input:focus, :where(.dark) .pg-select:focus {
  background: rgba(15,23,42,0.7);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.2);
}

/* ── Pulse dot (live indicator) ── */
.pg-pulse-dot {
  position: relative; display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
}
.pg-pulse-dot::before {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%; background: #10b981;
  animation: pgDotRipple 1.6s ease-out infinite;
}
@keyframes pgDotRipple {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ── Reveal animation (for result sections) ── */
.pg-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pg-reveal.pg-in {
  opacity: 1;
  transform: translateY(0);
}

/* ── Loading: think steps ── */
.pg-think-step {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  color: #64748b;
  font-size: 14px;
}
:where(.dark) .pg-think-step { color: #94a3b8; }
.pg-think-step .pg-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #cbd5e1;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
:where(.dark) .pg-think-step .pg-dot { border-color: #475569; }
.pg-think-step.pg-active { color: #1d4ed8; }
.pg-think-step.pg-active .pg-dot {
  border-color: #3b82f6;
  background: #3b82f6;
  animation: pgDotPulse 1.2s ease-in-out infinite;
}
.pg-think-step.pg-done { color: #047857; }
.pg-think-step.pg-done .pg-dot {
  background: #10b981;
  border-color: #10b981;
}
.pg-think-step.pg-done .pg-dot::after {
  content: '';
  width: 8px; height: 4px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
}
:where(.dark) .pg-think-step.pg-done { color: #34d399; }
@keyframes pgDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
}

/* ── Spinner ── */
.pg-spin {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(37,99,235,0.18);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: pgSpin 0.8s linear infinite;
}
@keyframes pgSpin { to { transform: rotate(360deg); } }

/* ── Progress bar ── */
.pg-progress-track {
  height: 4px;
  background: rgba(15,23,42,0.06);
  border-radius: 2px; overflow: hidden;
}
:where(.dark) .pg-progress-track { background: rgba(255,255,255,0.06); }
.pg-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Section card in result ── */
.pg-mod-section {
  border-left: 3px solid;
  padding: 4px 0 4px 18px;
  margin-bottom: 22px;
}
.pg-mod-section.pg-cp      { border-color: #6366f1; }
.pg-mod-section.pg-tp      { border-color: #10b981; }
.pg-mod-section.pg-mp      { border-color: #f59e0b; }
.pg-mod-section.pg-kp      { border-color: #06b6d4; }
.pg-mod-section.pg-assess  { border-color: #ec4899; }
.pg-mod-section.pg-ref     { border-color: #8b5cf6; }

/* ── Subject color theming (auto-applied to result) ── */
.pg-subject-accent {
  transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}
.pg-theme-ipa     { --pg-accent: #10b981; --pg-accent-bg: rgba(16,185,129,0.10); --pg-accent-fg: #047857; }
.pg-theme-mat     { --pg-accent: #6366f1; --pg-accent-bg: rgba(99,102,241,0.10); --pg-accent-fg: #4338ca; }
.pg-theme-bin     { --pg-accent: #f59e0b; --pg-accent-bg: rgba(245,158,11,0.10); --pg-accent-fg: #b45309; }
.pg-theme-bing    { --pg-accent: #ef4444; --pg-accent-bg: rgba(239,68,68,0.10); --pg-accent-fg: #b91c1c; }
.pg-theme-ipas    { --pg-accent: #14b8a6; --pg-accent-bg: rgba(20,184,166,0.10); --pg-accent-fg: #0f766e; }
.pg-theme-seni    { --pg-accent: #ec4899; --pg-accent-bg: rgba(236,72,153,0.10); --pg-accent-fg: #be185d; }

.pg-subject-accent .pg-mod-section { border-left-color: var(--pg-accent); }
.pg-subject-accent .pg-num-pill { background: var(--pg-accent-bg); color: var(--pg-accent-fg); }
.pg-subject-accent .pg-r-title { color: var(--pg-accent-fg); }
.pg-subject-accent .pg-accent-bar { background: var(--pg-accent); }
.pg-subject-accent .pg-result-deco { background: var(--pg-accent); }
:where(.dark) .pg-subject-accent .pg-num-pill { background: color-mix(in srgb, var(--pg-accent) 15%, transparent); color: var(--pg-accent); }

/* ── Accent bar + result deco ── */
.pg-accent-bar { height: 3px; border-radius: 2px; }
.pg-result-deco {
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  opacity: 0.06;
  filter: blur(60px);
  pointer-events: none;
  transition: background 0.4s ease;
}
.pg-result-deco.pg-tr { top: -60px; right: -60px; }
.pg-result-deco.pg-bl { bottom: -60px; left: -60px; }

/* ── Number pill ── */
.pg-num-pill {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  font-size: 13px; font-weight: 800;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  color: #4338ca;
  margin-right: 10px;
}
:where(.dark) .pg-num-pill { background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(99,102,241,0.1)); color: #a5b4fc; }

/* ── Mock tag (demo indicator) ── */
.pg-mock-tag {
  position: absolute; top: 12px; right: 12px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  color: #f59e0b; text-transform: uppercase;
  background: rgba(245,158,11,0.1);
  padding: 3px 8px; border-radius: 6px;
  border: 1px solid rgba(245,158,11,0.25);
  z-index: 2;
}

/* ── Result panel entrance ── */
.pg-result-panel {
  animation: pgPanelRise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pgPanelRise {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Result typography ── */
.pg-r-content p { line-height: 1.7; }
.pg-r-content ol { padding-left: 1.25rem; }
.pg-r-content ol li { line-height: 1.65; padding-left: 4px; }
.pg-r-content ol li::marker { color: var(--pg-accent, #6366f1); font-weight: 700; }

/* ── Scroll area (result content) ── */
.pg-scroll-area { max-height: 70vh; overflow-y: auto; padding-right: 12px; }
.pg-scroll-area::-webkit-scrollbar { width: 6px; }
.pg-scroll-area::-webkit-scrollbar-track { background: transparent; }
.pg-scroll-area::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.3); border-radius: 3px; }
.pg-scroll-area::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.5); }

/* ── Meta tag (code-like) ── */
.pg-meta-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(15,23,42,0.06);
  color: #475569;
}
:where(.dark) .pg-meta-tag { background: rgba(255,255,255,0.06); color: #cbd5e1; }

/* ── Icon halo (empty state) ── */
.pg-icon-halo { position: relative; }
.pg-icon-halo::before {
  content: ''; position: absolute; inset: -8px;
  border-radius: 22px;
  background: radial-gradient(circle, rgba(99,102,241,0.18), transparent 70%);
  animation: pgHaloPulse 3s ease-in-out infinite;
}
@keyframes pgHaloPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 0.3; }
}
.pg-icon-halo-inner { animation: pgIconFloat 4s ease-in-out infinite; }
@keyframes pgIconFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

/* ── Lift hover (for result action buttons) ── */
.pg-lift { transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease; }
.pg-lift:hover { transform: translateY(-2px); }

/* ── Copy success flash ── */
.pg-copy-flash {
  animation: pgFlash 0.6s ease-out;
}
@keyframes pgFlash {
  0% { background: rgba(16,185,129,0.18); }
  100% { background: transparent; }
}

/* ── First-chip attention pulse (5 detik pertama setelah load) ── */
.pg-chip.pg-pulse {
  position: relative;
  animation: pgChipPulse 1.5s ease-in-out 3;
}
.pg-chip.pg-pulse::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 2px solid #3b82f6;
  animation: pgChipRing 1.5s ease-out 3;
  pointer-events: none;
}
.pg-chip.pg-pulse::after {
  content: '';
  position: absolute;
  top: -8px; right: -8px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 2px 6px rgba(245,158,11,0.4);
  animation: pgChipBadge 1.5s ease-in-out 3;
}
@keyframes pgChipPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes pgChipRing {
  0%   { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes pgChipBadge {
  0%, 100% { transform: scale(1) rotate(0); }
  50%      { transform: scale(1.15) rotate(15deg); }
}
@media (prefers-reduced-motion: reduce) {
  .pg-chip.pg-pulse, .pg-chip.pg-pulse::before, .pg-chip.pg-pulse::after { animation: none; }
  .pg-chip.pg-pulse::after { display: none; }
}

/* ── Select value-change flash (when auto-shuffled by demo) ── */
.pg-select.pg-select-flash {
  animation: pgSelectFlash 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pgSelectFlash {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0); transform: scale(1); }
  30%  { box-shadow: 0 0 0 8px rgba(59,130,246,0.30); transform: scale(1.04); }
  70%  { box-shadow: 0 0 0 4px rgba(59,130,246,0.15); transform: scale(1); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .pg-select.pg-select-flash { animation: none; }
}

/* ── Generate button: state classes (idle, loading, done) ── */
.pg-hide { display: none !important; }

.pg-icon-loading { animation: pgBtnSpin 0.8s linear infinite; }
@keyframes pgBtnSpin { to { transform: rotate(360deg); } }

/* Loading state: gradient lebih dalam + pulse scale */
.pg-btn-primary.pg-loading {
  background: linear-gradient(135deg, #4338ca 0%, #6366f1 50%, #818cf8 100%) !important;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.18) inset,
    0 14px 40px -6px rgba(67,56,202,0.7) !important;
  animation: pgBtnPulse 1.4s ease-in-out infinite !important;
  transform: none !important; /* override magnetic */
}
.pg-btn-primary.pg-loading:hover { transform: none !important; }
@keyframes pgBtnPulse {
  0%, 100% { box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 14px 40px -6px rgba(67,56,202,0.7); }
  50%      { box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 18px 48px -6px rgba(67,56,202,0.95); }
}

/* Done state: green success */
.pg-btn-primary.pg-done {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 10px 30px -6px rgba(16,185,129,0.55) !important;
  animation: pgBtnSuccess 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
.pg-btn-primary.pg-done:hover { transform: none !important; }
@keyframes pgBtnSuccess {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Burst ring on click — radial pulse dari center button */
.pg-burst {
  position: absolute;
  left: 50%; top: 50%;
  width: 0; height: 0;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.6);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: pgBurst 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pgBurst {
  0%   { width: 0; height: 0; opacity: 0.9; border-width: 3px; }
  100% { width: 340px; height: 340px; opacity: 0; border-width: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-btn-primary.pg-loading,
  .pg-btn-primary.pg-done,
  .pg-icon-loading,
  .pg-burst { animation: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   CONFETTI BURST (on done state — celebrates generation success)
   ══════════════════════════════════════════════════════════════ */
.pg-confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 999;
  margin-left: -5px;
  margin-top: -5px;
  animation: pgConfettiFall 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes pgConfettiFall {
  0%   { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translate(var(--cx, 0), var(--cy, 200px)) rotate(var(--cr, 360deg)) scale(0.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pg-confetti { animation: none; opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   PANEL TRANSITIONS (loading ↔ result, etc.)
   ══════════════════════════════════════════════════════════════ */
.pg-panel-leaving {
  animation: pgPanelLeave 0.3s ease-out forwards;
}
@keyframes pgPanelLeave {
  to { opacity: 0; transform: translateY(-15px) scale(0.98); }
}
.pg-panel-entering {
  animation: pgPanelEnter 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pgPanelEnter {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .pg-panel-leaving, .pg-panel-entering { animation: none; }
}

/* Number badge pop-in (each section header) */
.pg-mod-section .pg-num-pill {
  animation: pgNumPop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: 0.15s;
}
@keyframes pgNumPop {
  0%   { transform: scale(0) rotate(-90deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pg-mod-section .pg-num-pill { animation: none; }
}
