/*
 * MARCore TechLab - Design Tokens (PRD §43-44, §77)
 * File ini jadi fondasi visual untuk seluruh phase berikutnya.
 */

:root {
    /* Core brand colors */
    --network-primary: #2563EB;
    --network-secondary: #06B6D4;
    --network-tertiary: #38BDF8;

    --computer-primary: #7C3AED;
    --computer-secondary: #A855F7;
    --computer-tertiary: #C084FC;

    --programming-primary: #059669;
    --programming-secondary: #10B981;
    --programming-tertiary: #34D399;

    /* Neutrals */
    --ink: #0F172A;
    --ink-soft: #475569;
    --paper: #F8FAFC;
    --surface: #FFFFFF;
    --border: #E2E8F0;

    --success: #16A34A;
    --danger: #DC2626;

    /* Layout tokens */
    --radius-card: 20px;
    --radius-sm: 10px;
    --shadow-card: 0 8px 30px rgba(15, 23, 42, .08);

    --font-heading: 'Poppins', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    margin: 0;
}

a {
    color: var(--network-primary);
}

/* Lesson content blocks (rendered by BlockRenderer, PRD §14/§49) */
.lb { margin-bottom: 18px; line-height: 1.65; }
.lb p { margin: 4px 0 0; }
.lb-label { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--network-primary); margin-bottom: 2px; }
.lb-callout { background: rgba(37,99,235,.06); border: 1px solid rgba(37,99,235,.15); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; gap: 10px; align-items: flex-start; }
.lb-diagram pre { background: var(--ink); color: #E2E8F0; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--font-mono); font-size: .82rem; line-height: 1.5; }
.lb-image img { max-width: 100%; border-radius: var(--radius-card); border: 1px solid var(--border); display: block; }
.lb-image .lb-caption { display: block; font-size: .8rem; color: var(--ink-soft); margin-top: 6px; text-align: center; }
.lb-image-missing { color: var(--danger); font-size: .85rem; }
.lb-soon { background: var(--paper); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-size: .85rem; color: var(--ink-soft); }
.lb-summary { background: rgba(5,150,105,.06); border: 1px solid rgba(5,150,105,.15); border-radius: var(--radius-sm); padding: 14px 16px; }

/* Practice (Phase 6) */
.lb-practice-group { margin-top: 8px; }
.practice-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 14px; }
.practice-question { font-weight: 600; margin: 0 0 10px; }
.practice-option { display: block; font-size: .9rem; padding: 6px 0; cursor: pointer; }
.practice-option input { margin-right: 8px; }
.practice-feedback { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .85rem; }
.practice-feedback.ok { background: rgba(22,163,74,.08); color: var(--success); }
.practice-feedback.fail { background: rgba(220,38,38,.08); color: var(--danger); }

/* Quiz CTA (Phase 6) */
.lb-quiz-ref { display: flex; flex-direction: column; gap: 10px; }
.quiz-cta-card { background: rgba(37,99,235,.05); border: 1px solid rgba(37,99,235,.18); border-radius: var(--radius-sm); padding: 16px; }
.quiz-cta-title { font-weight: 700; margin-bottom: 2px; }
.quiz-cta-count { font-weight: 400; color: var(--ink-soft); font-size: .85rem; }
.quiz-cta-sub { font-size: .82rem; color: var(--ink-soft); margin-bottom: 10px; }

/* ════════════════════════════════════════════════════════════
 * UI Polish + Mobile Friendly
 * ════════════════════════════════════════════════════════════ */
html { -webkit-text-size-adjust: 100%; }
img, video { max-width: 100%; height: auto; }

/* Tombol: area sentuh besar (min 44px), feedback saat ditekan */
body .btn { min-height: 44px; justify-content: center; transition: transform .08s, filter .15s, box-shadow .15s, border-color .15s; -webkit-tap-highlight-color: transparent; }
body .btn:active { transform: scale(.97); }
body .btn:focus-visible, body .quiz-option:focus-within { outline: 3px solid rgba(37,99,235,.35); outline-offset: 2px; }
body .btn-primary { box-shadow: 0 4px 12px rgba(37,99,235,.28); }
body .btn-outline:hover { border-color: var(--network-primary); color: var(--network-primary); }
body .btn-sm { min-height: 34px; }
body .btn-success { background: var(--success); color: #fff; }

/* Practice: opsi jadi kartu yang mudah disentuh */
.practice-option { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.practice-option:hover { border-color: var(--network-primary); }
.practice-option input { margin: 0; width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--network-primary); }
.practice-option:has(input:checked) { border-color: var(--network-primary); background: rgba(37,99,235,.06); }
.practice-card input[type="text"] { width: 100%; padding: 12px 14px; font-size: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; font-family: var(--font-body); }
.practice-card .btn { margin-top: 6px; }

/* Kuis: opsi kartu besar + status terpilih */
.quiz-option { display: flex !important; align-items: center; gap: 12px; padding: 14px 16px !important; font-size: .95rem !important; line-height: 1.4; transition: border-color .15s, background .15s; }
.quiz-option input { margin: 0 !important; width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--network-primary); }
.quiz-option.selected, .quiz-option:has(input:checked) { border-color: var(--network-primary); background: rgba(37,99,235,.07); font-weight: 600; }
.quiz-question-card.answered { border-color: rgba(37,99,235,.35); }
.quiz-progress { position: sticky; top: 57px; z-index: 9; background: var(--paper); padding: 10px 0 12px; margin-bottom: 8px; }
.quiz-progress .bar-track { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.quiz-progress .bar-fill { height: 100%; width: 0; background: var(--network-primary); border-radius: 999px; transition: width .25s; }
.quiz-progress .txt { font-size: .78rem; color: var(--ink-soft); margin-top: 6px; font-weight: 600; }
.quiz-submit-bar { position: sticky; bottom: 0; z-index: 9; background: linear-gradient(to top, var(--paper) 70%, transparent); padding: 14px 0 max(14px, env(safe-area-inset-bottom)); }
.quiz-submit-bar .btn { width: 100%; font-size: 1rem; }

/* Kartu yang bisa diklik: efek hover halus */
.core-card, .continue-card { transition: transform .15s, box-shadow .15s; }
.core-card:hover, .continue-card:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(15,23,42,.12); }
.lesson-row { min-height: 56px; }

/* Tabel admin bisa digeser horizontal */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
    /* Area siswa */
    body .learn-topbar { padding: 12px 16px; }
    body .learn-topbar .who span { display: none; }
    body .learn-shell { padding: 18px 14px 60px; }
    body .lesson-body { padding: 16px; }
    body .lesson-head h1 { font-size: 1.2rem; }
    body .lesson-footer { flex-direction: column; align-items: stretch; }
    body .lesson-footer .btn, body .lesson-footer form .btn { width: 100%; }
    body .lesson-footer .completed-badge { justify-content: center; text-align: center; }
    body .continue-card { flex-direction: column; align-items: stretch; }
    body .continue-card .btn { width: 100%; }
    body .core-cards { grid-template-columns: 1fr; }
    body .result-actions .btn { flex: 1 1 100%; }
    body .result-score { font-size: 2rem; }
    .lb-diagram pre { font-size: .74rem; }

    /* Admin: sidebar jadi menu horizontal di atas */
    body { flex-direction: column; }
    body .sidebar { width: 100%; height: auto; position: static; padding: 10px 0 0; overflow: visible; }
    body .sidebar .brand { padding: 0 16px 10px; margin-bottom: 0; border-bottom: none; }
    body .sidebar nav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 8px 8px; }
    body .sidebar nav a { white-space: nowrap; padding: 9px 14px; border-left: none; border-bottom: 3px solid transparent; }
    body .sidebar nav a.active { border-bottom-color: var(--network-secondary); }
    body .sidebar nav .group-label { display: none; }
    body .topbar { padding: 12px 16px; }
    body .content { padding: 16px 14px 40px; max-width: 100%; }
    body .form-card { max-width: 100%; padding: 18px 16px; }
    body table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    body .page-head .btn { width: 100%; }
    input[type="text"], input[type="number"], input[type="password"], textarea, select { font-size: 16px; } /* cegah auto-zoom iOS */
}
@media (max-width: 380px) { body .stat-grid { grid-template-columns: 1fr 1fr; } }

/* ════════════════════════════════════════════════════════════
 * Artikel (editor blog) — dipakai di halaman siswa DAN di editor,
 * jadi tampilan saat menulis sama dengan hasil akhirnya.
 * ════════════════════════════════════════════════════════════ */
.lb-article { font-size: 1rem; line-height: 1.75; color: var(--ink); overflow-wrap: anywhere; }
.lb-article::after { content: ""; display: block; clear: both; }
.lb-article > :first-child { margin-top: 0; }
.lb-article p { margin: 0 0 14px; }
.lb-article h2 { font-family: var(--font-heading); font-size: 1.35rem; line-height: 1.3; margin: 28px 0 10px; }
.lb-article h3 { font-family: var(--font-heading); font-size: 1.12rem; line-height: 1.35; margin: 22px 0 8px; }
.lb-article h4 { font-size: 1rem; margin: 18px 0 6px; }
.lb-article ul, .lb-article ol { margin: 0 0 14px; padding-left: 1.5em; }
.lb-article li { margin-bottom: 4px; }
.lb-article a { color: var(--network-primary); text-decoration: underline; }
.lb-article blockquote { margin: 0 0 14px; padding: 8px 16px; border-left: 4px solid var(--network-primary); background: var(--paper); color: var(--ink-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.lb-article code { background: var(--paper); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: .88em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.lb-article pre { background: var(--ink); color: #E2E8F0; padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 0 0 14px; font-size: .86rem; line-height: 1.55; }
.lb-article pre code { background: none; border: none; padding: 0; color: inherit; }
.lb-article hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.lb-article mark { background: #FEF08A; padding: 0 2px; border-radius: 3px; }
.lb-article .callout { background: rgba(37,99,235,.07); border: 1px solid rgba(37,99,235,.2); border-left: 4px solid var(--network-primary); border-radius: var(--radius-sm); padding: 12px 16px; margin: 0 0 14px; }
.lb-article .callout > :last-child { margin-bottom: 0; }
.lb-article table { border-collapse: collapse; width: 100%; margin: 0 0 14px; display: block; overflow-x: auto; }
.lb-article th, .lb-article td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.lb-article th { background: var(--paper); }
.lb-article img { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin: 6px auto 14px; }
.lb-article img.img-s { width: 33%; }
.lb-article img.img-m { width: 60%; }
.lb-article img.img-l { width: 100%; }
.lb-article img.img-left { float: left; margin: 4px 16px 10px 0; }
.lb-article img.img-right { float: right; margin: 4px 0 10px 16px; }
.lb-article img.img-center { margin-left: auto; margin-right: auto; }
@media (max-width: 600px) {
    .lb-article img.img-s { width: 55%; }
    .lb-article img.img-m { width: 85%; }
    .lb-article img.img-left, .lb-article img.img-right { float: none; margin: 6px auto 14px; }
}

/* Tabel di artikel: jangan memotong kata di tengah, biarkan tabel bisa digeser */
.lb-article th, .lb-article td { overflow-wrap: normal; word-break: normal; hyphens: none; vertical-align: top; }
.lb-article th { white-space: nowrap; }
.lb-article pre, .lb-article pre code { overflow-wrap: normal; word-break: normal; white-space: pre; }

/* Perataan teks dari editor artikel */
.lb-article .ta-left { text-align: left; }
.lb-article .ta-center { text-align: center; }
.lb-article .ta-right { text-align: right; }
.lb-article .ta-justify { text-align: justify; }
