/* ================================================================
   Wiki Rote Ndao — Premium Engagement CSS
   Fitur: 3D Parallax • Ambient Glow • Progress Bar • Trivia • Sasando
   ================================================================ */

/* ============================================================
   FITUR 1 — 3D Parallax Hover Cards
   ============================================================ */

.stat-card {
    transform-style: preserve-3d;
    transform: perspective(800px) rotateX(0deg) rotateY(0deg) scale(1);
    will-change: transform;
    position: relative;
    overflow: hidden;
    cursor: default;
}

.stat-card.tilt-active {
    transition: none;
}

.stat-card:not(.tilt-active) {
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.4s ease;
}

/* Glare overlay layer */
.stat-card .card-glare {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.22) 0%,
        rgba(255, 255, 255, 0.06) 50%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
    mix-blend-mode: screen;
}

.stat-card:hover .card-glare {
    opacity: 1;
}

/* Shimmer shine at card edge */
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        105deg,
        transparent 40%,
        rgba(255, 255, 255, 0.08) 45%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.08) 55%,
        transparent 60%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 1;
}

.stat-card:hover::before {
    opacity: 1;
}

/* Category cards also get parallax */
.cat-card {
    transform-style: preserve-3d;
    will-change: transform;
    position: relative;
    overflow: hidden;
}

.cat-card.tilt-active {
    transition: none;
}

.cat-card:not(.tilt-active) {
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.4s ease, border-color 0.3s ease;
}

.cat-card .card-glare {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.25) 0%,
        transparent 65%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    mix-blend-mode: screen;
}

.cat-card:hover .card-glare {
    opacity: 1;
}


/* ============================================================
   FITUR 2A — Reading Progress Bar (Neon Gold)
   ============================================================ */

#reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg,
        var(--gold-dark) 0%,
        var(--gold) 40%,
        #F5C518 70%,
        #fff8c4 85%,
        var(--gold) 100%
    );
    background-size: 200% 100%;
    animation: progress-shimmer 2s linear infinite;
    z-index: 9999;
    transition: width 0.12s ease-out;
    box-shadow:
        0 0 8px 2px rgba(245, 166, 35, 0.5),
        0 0 20px 4px rgba(245, 197, 24, 0.3),
        0 0 40px 6px rgba(245, 166, 35, 0.1);
    border-radius: 0 3px 3px 0;
    pointer-events: none;
}

@keyframes progress-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#reading-progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: var(--gold);
    border-radius: 50%;
    box-shadow: 0 0 8px 4px rgba(245, 166, 35, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#reading-progress-bar.active::after {
    opacity: 1;
}


/* ============================================================
   FITUR 2B — Ambient Dynamic Glow per Kategori
   ============================================================ */

/* Default body glow already defined in style.css, we just override via body classes */

body.ambient-kecamatan {
    background-image:
        radial-gradient(ellipse at 15% 10%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 50%, rgba(109, 40, 217, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(167, 139, 250, 0.03) 0%, transparent 50%);
}

body.ambient-geografi {
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(34, 197, 94, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(16, 185, 129, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 85%, rgba(52, 211, 153, 0.03) 0%, transparent 50%);
}

body.ambient-pemerintahan {
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(59, 130, 246, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(37, 99, 235, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 85%, rgba(96, 165, 250, 0.03) 0%, transparent 50%);
}

body.ambient-demografi {
    background-image:
        radial-gradient(ellipse at 15% 5%, rgba(6, 182, 212, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(14, 165, 233, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(56, 189, 248, 0.03) 0%, transparent 50%);
}

body.ambient-ekonomi {
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(245, 166, 35, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(245, 197, 24, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(245, 166, 35, 0.03) 0%, transparent 50%);
}

body.ambient-sosial {
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(239, 68, 68, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(220, 38, 38, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(252, 165, 165, 0.03) 0%, transparent 50%);
}

body.ambient-pariwisata {
    background-image:
        radial-gradient(ellipse at 15% 5%, rgba(20, 184, 166, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 35%, rgba(13, 148, 136, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(94, 234, 212, 0.04) 0%, transparent 50%);
}

body.ambient-budaya {
    background-image:
        radial-gradient(ellipse at 20% 5%, rgba(217, 70, 239, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(168, 85, 247, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 35% 80%, rgba(192, 132, 252, 0.04) 0%, transparent 50%);
}

body.ambient-infrastruktur {
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(37, 99, 235, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(29, 78, 216, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(96, 165, 250, 0.03) 0%, transparent 50%);
}

body.ambient-pertanian {
    background-image:
        radial-gradient(ellipse at 20% 5%, rgba(132, 204, 22, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 40%, rgba(101, 163, 13, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(163, 230, 53, 0.03) 0%, transparent 50%);
}

/* Smooth transition for ambient switch */
body {
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

/* Ambient transition layer */
#ambient-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 1.4s cubic-bezier(0.23, 1, 0.32, 1);
    opacity: 0;
}


/* ============================================================
   FITUR 3 — Trivia Kuis "Petualangan Rote" + Virtual Badges
   ============================================================ */

/* Trivia toggle button */
#trivia-toggle {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7C3AED 0%, #5B21B6 100%);
    border: 1.5px solid rgba(167, 139, 250, 0.3);
    box-shadow:
        0 4px 20px rgba(124, 58, 237, 0.35),
        0 0 0 0 rgba(124, 58, 237, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    z-index: 200;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    animation: trivia-pulse 3s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
}

@keyframes trivia-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35), 0 0 0 0 rgba(124, 58, 237, 0.2); }
    50%       { box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45), 0 0 0 10px rgba(124, 58, 237, 0); }
}

#trivia-toggle:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#trivia-toggle:active {
    transform: scale(0.93);
}

/* Badge counter on trivia button */
#trivia-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--gold-gradient);
    border-radius: 50%;
    font-size: 10px;
    font-family: var(--font-sans);
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 1.5px solid #fff;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#trivia-badge-count.visible {
    opacity: 1;
    transform: scale(1);
}

/* Trivia panel */
#trivia-panel {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 320px;
    background: rgba(15, 10, 30, 0.92);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 20px;
    padding: 22px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    z-index: 199;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
    transform-origin: bottom right;
}

#trivia-panel.trivia-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.trivia-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.trivia-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trivia-icon {
    font-size: 20px;
}

.trivia-title {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 700;
    color: #e2d9f3;
    letter-spacing: 0.3px;
}

.trivia-subtitle {
    font-family: var(--font-sans);
    font-size: 10px;
    color: rgba(139, 92, 246, 0.8);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.trivia-close-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.trivia-close-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.trivia-question {
    font-family: var(--font-sans);
    font-size: 14px;
    color: #f0ebff;
    line-height: 1.55;
    margin-bottom: 14px;
    font-weight: 500;
}

.trivia-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.trivia-option {
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 13px;
    color: #d4c8f8;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    text-align: left;
    font-weight: 500;
}

.trivia-option:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.45);
    color: #fff;
    transform: translateX(3px);
}

.trivia-option.correct {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.5);
    color: #86efac;
    animation: trivia-correct-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.trivia-option.wrong {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    animation: trivia-shake 0.4s ease;
}

@keyframes trivia-correct-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes trivia-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    40%       { transform: translateX(5px); }
    60%       { transform: translateX(-3px); }
    80%       { transform: translateX(3px); }
}

.trivia-feedback {
    font-family: var(--font-sans);
    font-size: 12.5px;
    line-height: 1.5;
    color: rgba(212, 200, 248, 0.8);
    padding: 10px 12px;
    background: rgba(139, 92, 246, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(139, 92, 246, 0.15);
    display: none;
    margin-bottom: 12px;
}

.trivia-feedback.show { display: block; }
.trivia-feedback.correct-fb { 
    color: #86efac;
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.2);
}
.trivia-feedback.wrong-fb {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.trivia-next-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #7C3AED, #5B21B6);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: none;
    letter-spacing: 0.2px;
}

.trivia-next-btn.show { display: block; }

.trivia-next-btn:hover {
    background: linear-gradient(135deg, #8B5CF6, #6D28D9);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.trivia-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-sans);
    font-size: 11px;
    color: rgba(139, 92, 246, 0.6);
    border-top: 1px solid rgba(139, 92, 246, 0.12);
    padding-top: 12px;
    margin-top: 4px;
}

.trivia-score-val {
    color: var(--gold);
    font-weight: 700;
}

/* Badge notification toast */
#badge-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: linear-gradient(135deg, rgba(20, 10, 40, 0.96), rgba(40, 15, 70, 0.96));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    padding: 14px 22px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
    z-index: 1000;
    opacity: 0;
    transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    text-align: center;
    min-width: 250px;
}

#badge-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.badge-toast-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 4px;
    animation: badge-spin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-spin {
    from { transform: rotate(-20deg) scale(0.5); opacity: 0; }
    to   { transform: rotate(0deg) scale(1); opacity: 1; }
}

.badge-toast-title {
    font-family: var(--font-sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold);
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

.badge-toast-name {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 700;
    color: #f0ebff;
    display: block;
    margin-bottom: 2px;
}

.badge-toast-desc {
    font-family: var(--font-sans);
    font-size: 11.5px;
    color: rgba(212, 200, 248, 0.7);
    display: block;
}

/* Badges display in trivia panel */
.trivia-badges-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
    border-top: 1px solid rgba(139, 92, 246, 0.12);
    padding-top: 10px;
}

.trivia-badge-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: rgba(245, 166, 35, 0.12);
    border: 1px solid rgba(245, 166, 35, 0.2);
    border-radius: 20px;
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--gold);
    font-weight: 600;
    animation: badge-pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-pop-in {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}


/* ============================================================
   FITUR 4 — Sasando Mini Interactive Widget
   ============================================================ */

.sasando-widget {
    margin-top: 16px;
    background: linear-gradient(145deg, rgba(30, 15, 50, 0.92), rgba(15, 8, 30, 0.95));
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(245, 166, 35, 0.18);
    border-radius: 16px;
    padding: 18px 14px 14px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 0 20px rgba(245, 166, 35, 0.06);
    position: relative;
    overflow: hidden;
}

.sasando-widget::before {
    content: '';
    position: absolute;
    top: -40%;
    left: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(245, 166, 35, 0.06), transparent 70%);
    pointer-events: none;
}

.sasando-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.sasando-header-icon {
    font-size: 18px;
}

.sasando-header-text {
    flex: 1;
}

.sasando-title {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    display: block;
}

.sasando-subtitle {
    font-family: var(--font-sans);
    font-size: 9px;
    color: rgba(245, 166, 35, 0.5);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    display: block;
}

/* The SVG Sasando instrument */
.sasando-instrument {
    width: 100%;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.sasando-string {
    cursor: pointer;
    transition: all 0.15s ease;
}

.sasando-string:hover .sasando-string-line {
    filter: drop-shadow(0 0 4px rgba(245, 166, 35, 0.9));
    stroke-width: 2;
}

.sasando-string-line {
    transition: stroke 0.2s ease;
}

.sasando-string.plucked .sasando-string-line {
    animation: string-vibrate 0.5s ease-out;
}

@keyframes string-vibrate {
    0%   { transform-origin: 50% 0; transform: scaleX(1); opacity: 1; }
    15%  { transform: scaleX(1.008); }
    30%  { transform: scaleX(0.993); }
    45%  { transform: scaleX(1.005); }
    60%  { transform: scaleX(0.997); }
    80%  { transform: scaleX(1.002); }
    100% { transform: scaleX(1); opacity: 0.7; }
}

.sasando-hint {
    font-family: var(--font-sans);
    font-size: 9.5px;
    color: rgba(245, 166, 35, 0.4);
    text-align: center;
    margin-top: 10px;
    letter-spacing: 0.5px;
}

.sasando-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(245, 166, 35, 0.25);
    pointer-events: none;
    animation: sasando-ripple-anim 0.6s ease-out forwards;
}

@keyframes sasando-ripple-anim {
    from { width: 0; height: 0; opacity: 1; transform: translate(-50%, -50%); }
    to   { width: 60px; height: 60px; opacity: 0; transform: translate(-50%, -50%); }
}

/* Volume/mute toggle */
.sasando-mute-btn {
    background: rgba(245, 166, 35, 0.1);
    border: 1px solid rgba(245, 166, 35, 0.15);
    border-radius: 6px;
    padding: 3px 7px;
    color: rgba(245, 166, 35, 0.6);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.sasando-mute-btn:hover {
    background: rgba(245, 166, 35, 0.18);
    color: var(--gold);
}


/* ============================================================
   DARK MODE overrides
   ============================================================ */

body.dark-mode .trivia-question { color: #f0ebff; }
body.dark-mode #trivia-panel {
    background: rgba(5, 2, 15, 0.95);
    border-color: rgba(139, 92, 246, 0.3);
}

body.dark-mode .sasando-widget {
    background: linear-gradient(145deg, rgba(20, 8, 40, 0.98), rgba(8, 3, 20, 0.98));
    border-color: rgba(245, 166, 35, 0.22);
}


/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    #trivia-toggle {
        bottom: calc(88px + env(safe-area-inset-bottom, 16px));
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    #trivia-panel {
        bottom: calc(148px + env(safe-area-inset-bottom, 16px));
        right: 12px;
        left: 12px;
        width: auto;
    }

    #badge-toast {
        bottom: calc(88px + env(safe-area-inset-bottom, 16px));
        width: calc(100% - 40px);
    }

    .sasando-widget {
        display: none; /* Shown only on desktop sidebar */
    }
}
