/* Karir Kompas Quiz — Stylesheet v2.1.0 */
/* Prefix semua class: .kk- untuk menghindari konflik */

/* ── Global box-sizing reset (scoped, tidak merusak halaman lain) ───────── */
.kk-quiz-wrap *,
.kk-quiz-wrap *::before,
.kk-quiz-wrap *::after {
    box-sizing: border-box;
}

:root {
    --kk-primary-color: #1e5fbf;
    --kk-primary-dark:  #164fa0;
    --kk-primary-light: #e8effe;
    --kk-success:       #00a32a;
    --kk-warning:       #f0a500;
    --kk-danger:        #d63638;
    --kk-text:          #1d2327;
    --kk-text-muted:    #646970;
    --kk-border:        #dcdcde;
    --kk-bg:            #ffffff;
    --kk-card-shadow:   0 2px 16px rgba(0,0,0,0.10);
    --kk-radius:        8px;
    --kk-font:          'Montserrat', sans-serif;
    --kk-timer-warn:    #e67e22;
    --kk-timer-danger:  #d63638;
}

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.kk-quiz-wrap {
    font-family: var(--kk-font);
    color: var(--kk-text);
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
    position: relative;
    /* Defensive: cegah elemen anak manapun overflow ke kanan */
    overflow-x: hidden;
}

/* ── Steps ───────────────────────────────────────────────────────────────── */
.kk-step { display: none; }
.kk-step.kk-active { display: block; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.kk-card {
    background: var(--kk-bg);
    border-radius: var(--kk-radius);
    box-shadow: var(--kk-card-shadow);
    padding: 32px 36px;
    border: 1px solid var(--kk-border);
    /* Pastikan card tidak melampaui wrapper */
    width: 100%;
    max-width: 100%;
}

@media (max-width: 480px) {
    .kk-card { padding: 20px 18px; }
}

/* ── Intro ───────────────────────────────────────────────────────────────── */
.kk-quiz-title {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--kk-primary-color);
    margin: 0 0 16px;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
}

.kk-intro-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.kk-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--kk-text-muted);
}

.kk-meta-item svg { flex-shrink: 0; stroke: var(--kk-primary-color); }

.kk-intro-rules {
    background: var(--kk-primary-light);
    border-radius: var(--kk-radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.kk-intro-rules h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--kk-primary-color);
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Teks aturan dari Settings API — bisa berisi HTML dasar */
.kk-intro-rules .kk-rules-text {
    font-size: 0.875rem;
    color: var(--kk-text);
    line-height: 1.6;
    margin: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.kk-intro-rules .kk-rules-text p { margin: 0 0 8px; }
.kk-intro-rules .kk-rules-text p:last-child { margin-bottom: 0; }

/* Backward-compat: ul list style masih bisa dipakai jika admin isi dengan <ul> */
.kk-intro-rules ul {
    margin: 0;
    padding: 0 0 0 18px;
    list-style: disc;
}

.kk-intro-rules li {
    font-size: 0.875rem;
    color: var(--kk-text);
    margin-bottom: 6px;
    line-height: 1.5;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.kk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border: none;
    border-radius: var(--kk-radius);
    font-family: var(--kk-font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    text-decoration: none;
}

.kk-btn:active { transform: scale(0.98); }

.kk-btn-primary {
    background: var(--kk-primary-color);
    color: #fff;
}

.kk-btn-primary:hover,
.kk-btn-primary:focus {
    background: var(--kk-primary-dark);
    color: #fff;
    outline: none;
}

.kk-btn-primary:disabled {
    background: #9fb8e0;
    cursor: not-allowed;
}

.kk-start-btn { width: 100%; font-size: 1.05rem; padding: 14px; }

/* ── Step 1: Form ────────────────────────────────────────────────────────── */
.kk-step-1 h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--kk-primary-color);
}

.kk-step-desc {
    color: var(--kk-text-muted);
    font-size: 0.875rem;
    margin: 0 0 20px;
}

.kk-form-group { margin-bottom: 16px; }

.kk-form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--kk-text);
}

.kk-req { color: var(--kk-danger); }

.kk-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--kk-border);
    border-radius: 6px;
    font-family: var(--kk-font);
    font-size: 0.95rem;
    color: var(--kk-text);
    background: #fff;
    transition: border-color 0.15s;
}

.kk-input:focus {
    border-color: var(--kk-primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(30,95,191,0.12);
}

.kk-input.kk-error-field { border-color: var(--kk-danger); }

.kk-form-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--kk-danger);
    margin-bottom: 16px;
}

.kk-step1-submit { width: 100%; margin-top: 8px; }

/* ── Step 2: Quiz ────────────────────────────────────────────────────────── */
.kk-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.kk-progress-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--kk-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kk-skip-counter {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--kk-warning);
}

.kk-progress-bar-wrap {
    background: var(--kk-border);
    border-radius: 100px;
    height: 6px;
    margin-bottom: 20px;
    overflow: hidden;
}

.kk-progress-bar {
    height: 100%;
    background: var(--kk-primary-color);
    border-radius: 100px;
    transition: width 0.4s ease;
    width: 0%;
}

/* Timer */
.kk-timer-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}

.kk-timer-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--kk-primary-light);
    border: 3px solid var(--kk-primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s, background 0.3s;
    flex-shrink: 0;
}

.kk-timer-circle.kk-timer-warn {
    background: #fff8e1;
    border-color: var(--kk-timer-warn);
}

.kk-timer-circle.kk-timer-warn .kk-timer-count { color: var(--kk-timer-warn); }

.kk-timer-circle.kk-timer-urgent {
    background: #fff0f0;
    border-color: var(--kk-timer-danger);
    animation: kk-pulse 0.5s ease infinite alternate;
}

.kk-timer-circle.kk-timer-urgent .kk-timer-count { color: var(--kk-timer-danger); }

@keyframes kk-pulse {
    from { transform: scale(1); }
    to   { transform: scale(1.08); }
}

.kk-timer-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--kk-primary-color);
    line-height: 1;
}

.kk-timer-label {
    font-size: 0.8rem;
    color: var(--kk-text-muted);
}

/* Question */
.kk-question-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--kk-text);
    line-height: 1.55;
    margin-bottom: 20px;
    min-height: 2.5em;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GRID PILIHAN JAWABAN — BUG FIX
   Menggunakan minmax(0, 1fr) agar track bisa menyusut di bawah content
   minimum-size, mencegah overflow horizontal keluar card.
   ═══════════════════════════════════════════════════════════════════════════ */
.kk-options-grid {
    display: grid;
    /* minmax(0, 1fr) — kunci: minimum 0 (bukan 'auto') agar grid item
       bisa mengecil dan tidak memaksa parent melebar/overflow */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 12px;
    /* Pastikan grid tidak lebih lebar dari parent */
    width: 100%;
}

/* Di mobile: 1 kolom supaya nyaman dibaca di HP */
@media (max-width: 600px) {
    .kk-options-grid {
        grid-template-columns: 1fr;
    }
}

.kk-option-btn {
    /* width: 100% supaya button mengisi penuh grid track-nya */
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid var(--kk-border);
    border-radius: var(--kk-radius);
    background: #fff;
    text-align: left;
    font-family: var(--kk-font);
    font-size: 0.9rem;
    color: var(--kk-text);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    line-height: 1.45;
    /* Teks panjang WRAP ke bawah — JANGAN overflow horizontal */
    overflow-wrap: break-word;
    word-break: break-word;
    /* Tidak ada white-space: nowrap yang mencegah wrapping */
    white-space: normal;
    /* Minimum height biar kartu tampak seragam */
    min-height: 56px;
}

.kk-option-btn:hover,
.kk-option-btn:focus {
    border-color: var(--kk-primary-color);
    background: var(--kk-primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(30,95,191,0.1);
}

.kk-option-btn.kk-selected {
    border-color: var(--kk-primary-color);
    background: var(--kk-primary-color);
    color: #fff;
}

.kk-option-btn.kk-selected .kk-option-label {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

.kk-option-label {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    min-width: 28px; /* Cegah label huruf menyempit */
    border-radius: 50%;
    background: var(--kk-primary-light);
    color: var(--kk-primary-color);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Label A/B/C/D tidak perlu wrap */
    flex-shrink: 0;
}

.kk-option-text {
    flex: 1;
    min-width: 0; /* Izinkan teks menyusut dan wrap, bukan overflow */
    word-break: break-word;
    overflow-wrap: break-word;
}

.kk-skip-hint {
    text-align: center;
    font-size: 0.78rem;
    color: var(--kk-text-muted);
    margin: 0;
}

/* ── Step 3: Result ──────────────────────────────────────────────────────── */
.kk-result-card { text-align: center; }

.kk-result-header { margin-bottom: 16px; }

.kk-result-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--kk-text-muted);
    margin: 0 0 8px;
}

.kk-result-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--kk-primary-color);
    margin: 0;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: break-word;
}

.kk-result-image {
    margin: 0 auto 20px;
    max-width: 360px;
    width: 100%;
}

.kk-result-img {
    width: 100%;
    height: auto;
    border-radius: var(--kk-radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.kk-result-desc {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--kk-text);
    text-align: left;
    margin-bottom: 24px;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* CTA Buttons */
.kk-cta-wrap {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.kk-cta-btn {
    flex: 1;
    min-width: 160px;
    max-width: 300px;
    padding: 13px 24px;
    background: var(--kk-primary-color);
    color: #fff;
    border: none;
    border-radius: var(--kk-radius);
    font-family: var(--kk-font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    word-break: break-word;
    overflow-wrap: break-word;
}

.kk-cta-btn:hover,
.kk-cta-btn:focus {
    background: var(--kk-primary-dark);
    color: #fff;
    text-decoration: none;
    outline: none;
}

.kk-cta-wrap.kk-cta-single .kk-cta-btn { flex: 0 0 100%; max-width: 100%; }

@media (max-width: 480px) {
    .kk-cta-wrap { flex-direction: column; }
    .kk-cta-btn  { max-width: 100%; }
}

/* Share buttons */
.kk-share-section { margin-top: 8px; }

.kk-share-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--kk-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px;
}

.kk-share-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.kk-share-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--kk-primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
    text-decoration: none;
}

.kk-share-btn:hover,
.kk-share-btn:focus {
    background: var(--kk-primary-dark);
    transform: scale(1.1);
    outline: none;
}

.kk-share-btn svg { display: block; }

.kk-copy-feedback {
    font-size: 0.8rem;
    color: var(--kk-success);
    font-weight: 600;
    margin-top: 8px;
    text-align: center;
}

/* Score details */
.kk-score-details {
    margin-top: 20px;
    text-align: left;
}

.kk-score-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--kk-text-muted);
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
}

.kk-score-details summary::before {
    content: '▶';
    font-size: 0.65em;
    transition: transform 0.2s;
}

.kk-score-details[open] summary::before { transform: rotate(90deg); }

.kk-score-breakdown {
    padding: 12px;
    background: var(--kk-primary-light);
    border-radius: 6px;
    font-size: 0.875rem;
}

.kk-score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(30,95,191,0.12);
}

.kk-score-row:last-child { border-bottom: none; }

.kk-score-row.kk-winner {
    font-weight: 700;
    color: var(--kk-primary-color);
}

/* Error box */
.kk-error {
    background: #fff0f0;
    border: 1px solid #f5a5a5;
    border-radius: var(--kk-radius);
    padding: 16px 20px;
    color: var(--kk-danger);
    font-family: var(--kk-font);
    font-size: 0.9rem;
    max-width: 680px;
    margin: 0 auto;
}

/* Loading overlay */
.kk-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.9);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--kk-radius);
    gap: 14px;
}

.kk-loading p {
    font-size: 0.9rem;
    color: var(--kk-text-muted);
    font-weight: 600;
}

.kk-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--kk-primary-light);
    border-top-color: var(--kk-primary-color);
    border-radius: 50%;
    animation: kk-spin 0.8s linear infinite;
}

@keyframes kk-spin {
    to { transform: rotate(360deg); }
}

/* Modal */
.kk-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.kk-modal-inner {
    background: #fff;
    border-radius: var(--kk-radius);
    padding: 28px 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    animation: kk-modal-in 0.2s ease;
}

@keyframes kk-modal-in {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.kk-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--kk-text);
    margin: 0 0 10px;
}

.kk-modal-msg {
    font-size: 0.9rem;
    color: var(--kk-text-muted);
    margin: 0 0 20px;
    line-height: 1.55;
}

.kk-modal-close { width: 100%; }

/* Step transitions */
.kk-step {
    animation: kk-fade-in 0.25s ease;
}

@keyframes kk-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
