/* UiTM brand layer for ICT602 quizzes.
   Palette per UITM-BRAND-SIMPLE-DESIGN.md.
   Yellow (#F2A900) is 2.01:1 on white — fills and dark surfaces only, never text on light. */

:root {
    --uitm-blue: #002F6C;
    --uitm-purple: #9B26B6;
    --uitm-yellow: #F2A900;
    --bg-white: #FFFFFF;
    --bg-light-gray: #F8F9FA;
    --uitm-cool-gray: #63666A;

    /* Derived surfaces (tints of the corporate blue, all AA-safe for body text) */
    --blue-ink: #001E45;
    --blue-050: #EAF1FA;
    --blue-100: #D6E3F5;
    --purple-050: #F6EBFA;
    --success: #1F6F45;
    --success-bg: #E4F4EA;
    --danger: #A3202F;
    --danger-bg: #FCE8EA;

    /* Layered shadows: contact + ambient + brand glow */
    --shadow-1: 0 1px 2px rgba(0, 47, 108, 0.10), 0 2px 6px rgba(0, 47, 108, 0.08);
    --shadow-2: 0 2px 4px rgba(0, 47, 108, 0.08), 0 10px 24px rgba(0, 47, 108, 0.10);
    --shadow-3: 0 4px 8px rgba(0, 47, 108, 0.10), 0 18px 48px rgba(0, 47, 108, 0.16);
    --shadow-pop: 0 10px 30px rgba(155, 38, 182, 0.22);
    --ring: 0 0 0 4px rgba(155, 38, 182, 0.35);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --maxw: 1080px;
    --nav-h: 4rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--uitm-blue);
    background:
        radial-gradient(1200px 520px at 12% -12%, var(--blue-050) 0%, rgba(234, 241, 250, 0) 62%),
        radial-gradient(900px 460px at 92% 0%, var(--purple-050) 0%, rgba(246, 235, 250, 0) 58%),
        var(--bg-light-gray);
    background-attachment: fixed;
    line-height: 1.55;
    padding-bottom: 3rem;
}

/* ---------- glass navigation ---------- */

.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-1);
}

@supports ((-webkit-backdrop-filter: blur(15px)) or (backdrop-filter: blur(15px))) {
    .nav {
        -webkit-backdrop-filter: saturate(160%) blur(15px);
        backdrop-filter: saturate(160%) blur(15px);
    }
}

@supports not ((-webkit-backdrop-filter: blur(15px)) or (backdrop-filter: blur(15px))) {
    .nav { background: var(--bg-light-gray); }
}

.nav-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    min-height: var(--nav-h);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--uitm-blue);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand-mark {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--uitm-purple), var(--uitm-blue));
    box-shadow: var(--shadow-1);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.nav-links {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    position: relative;
    display: inline-block;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--uitm-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 4px;
    height: 2px;
    border-radius: 2px;
    background: var(--uitm-purple);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after { transform: scaleX(1); }

.nav-links a[aria-current="page"] {
    background: var(--blue-050);
    color: var(--uitm-blue);
}

/* ---------- page shell ---------- */

.shell {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 20px;
}

.hero {
    position: relative;
    margin: 28px 0 22px;
    padding: 34px 30px 30px;
    border-radius: var(--radius-lg);
    background: linear-gradient(150deg, var(--uitm-blue) 0%, #093B82 58%, #4A1A6B 100%);
    color: #fff;
    box-shadow: var(--shadow-3);
    overflow: hidden;
    isolation: isolate;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: linear-gradient(90deg, var(--uitm-yellow), var(--uitm-purple));
    z-index: 1;
}

.hero::after {
    content: "";
    position: absolute;
    right: -110px;
    top: -130px;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(242, 169, 0, 0.42), rgba(155, 38, 182, 0.18) 55%, transparent 70%);
    filter: blur(6px);
    z-index: -1;
}

.hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--uitm-yellow);
}

.hero .eyebrow::before {
    content: "";
    width: 22px;
    height: 2px;
    background: var(--uitm-yellow);
    border-radius: 2px;
}

.hero h1 {
    margin: 10px 0 8px;
    font-size: clamp(1.55rem, 4.4vw, 2.35rem);
    font-weight: 700;
    line-height: 1.16;
    letter-spacing: -0.02em;
    max-width: 22ch;
}

.hero p:not(.eyebrow) {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.96rem;
    max-width: 52ch;
}

.pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 17px;
    border-radius: 100vw;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    border: 2px solid transparent;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.pill-primary {
    background: var(--uitm-purple);
    color: #fff;
    box-shadow: var(--shadow-pop);
}

.pill-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 34px rgba(155, 38, 182, 0.32); }

.pill-ghost {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

.pill-ghost:hover { background: rgba(255, 255, 255, 0.2); }

.pill-light {
    background: #fff;
    color: var(--uitm-blue);
    border-color: var(--uitm-blue);
}

.pill-light:hover { background: var(--blue-050); }

/* ---------- layout: 75 / 25 on desktop ---------- */

.layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 28px;
}

@media (max-width: 900px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
}

.panel {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    padding: 24px 22px;
    border: 1px solid rgba(0, 47, 108, 0.06);
}

.sidebar {
    background: var(--bg-light-gray);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    border: 1px solid rgba(0, 47, 108, 0.08);
    padding: 18px 16px;
    position: sticky;
    top: calc(var(--nav-h) + 16px);
}

@media (max-width: 900px) { .sidebar { position: static; } }

.sidebar h2 {
    margin: 0 0 10px;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--uitm-cool-gray);
}

.sidebar ol { margin: 0; padding-left: 1.1rem; }
.sidebar li { margin-bottom: 8px; font-size: 0.88rem; }
.sidebar a { color: var(--uitm-blue); text-decoration: none; font-weight: 600; }
.sidebar a:hover { text-decoration: underline; text-decoration-color: var(--uitm-purple); text-decoration-thickness: 2px; }

/* ---------- typography ---------- */

.panel h2 { margin: 0 0 6px; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.panel h3 { margin: 22px 0 10px; font-size: 1rem; font-weight: 700; }
.panel p { margin: 0 0 12px; }
.lede { color: var(--uitm-cool-gray); font-size: 0.94rem; }
.muted { color: var(--uitm-cool-gray); font-size: 0.84rem; }

/* ---------- forms ---------- */

label { display: block; font-weight: 700; font-size: 0.86rem; margin: 16px 0 6px; }
.hint { font-weight: 400; color: var(--uitm-cool-gray); font-size: 0.78rem; }

input[type="text"] {
    width: 100%;
    font: inherit;
    color: var(--uitm-blue);
    background: #fff;
    padding: 12px 14px;
    border: 2px solid var(--blue-100);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 1px 2px rgba(0, 47, 108, 0.06);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--uitm-purple);
    box-shadow: var(--ring);
}

button { font: inherit; }

:where(a, button, input, [tabindex]):focus-visible {
    outline: 3px solid var(--uitm-purple);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 20px;
    padding: 13px 20px;
    border: 0;
    border-radius: 100vw;
    background: linear-gradient(135deg, var(--uitm-purple), #7A1C93);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-pop);
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); filter: saturate(1.08); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-1); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: none; background: #8A8FA3; }

.link {
    background: none;
    border: 0;
    padding: 4px 0;
    color: var(--uitm-blue);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--uitm-purple);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    cursor: pointer;
}

.form-error {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    border-left: 4px solid var(--danger);
    color: var(--danger);
    font-size: 0.86rem;
    font-weight: 700;
}

/* ---------- quiz ---------- */

.quiz-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.chip {
    display: inline-block;
    margin: 0;
    padding: 4px 12px;
    border-radius: 100vw;
    background: var(--blue-050);
    color: var(--uitm-blue);
    font-size: 0.78rem;
    font-weight: 700;
}

.question {
    border: 0;
    border-top: 1px solid rgba(0, 47, 108, 0.12);
    margin: 0;
    padding: 18px 0 4px;
}

.question:first-of-type { border-top: 0; padding-top: 6px; }

.question legend {
    padding: 0;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 0.97rem;
    line-height: 1.45;
    color: var(--uitm-blue);
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-top: 8px;
    padding: 12px 14px;
    border: 2px solid rgba(0, 47, 108, 0.14);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.option:hover { border-color: var(--uitm-purple); transform: translateY(-1px); box-shadow: var(--shadow-2); }

.option input { margin: 3px 0 0; accent-color: var(--uitm-purple); flex: 0 0 auto; }

.option-key {
    flex: 0 0 1.5rem;
    font-weight: 700;
    color: var(--uitm-purple);
    font-variant-numeric: tabular-nums;
}

.option-text { flex: 1; font-size: 0.92rem; }

.question.answered .option:has(input:checked) {
    border-color: var(--uitm-purple);
    background: var(--purple-050);
    box-shadow: 0 0 0 2px rgba(155, 38, 182, 0.14), var(--shadow-2);
}

/* JS fallback for browsers without :has() */
.option.is-chosen {
    border-color: var(--uitm-purple);
    background: var(--purple-050);
    box-shadow: 0 0 0 2px rgba(155, 38, 182, 0.14), var(--shadow-2);
}

/* ---------- result ---------- */

.score-card {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 6px 0 4px;
}

.score {
    margin: 0;
    font-size: clamp(2.2rem, 7vw, 3rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--uitm-blue), var(--uitm-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.rank { margin: 0 0 4px; font-weight: 700; color: var(--uitm-cool-gray); }

.review { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }

.review-row {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 47, 108, 0.08);
    border-left: 5px solid var(--uitm-cool-gray);
    background: var(--bg-light-gray);
    box-shadow: var(--shadow-1);
}

.review-row.is-correct { border-left-color: var(--success); background: var(--success-bg); }
.review-row.is-wrong { border-left-color: var(--danger); background: var(--danger-bg); }
.review-head { margin: 0 0 5px; font-weight: 700; font-size: 0.88rem; }
.review-body { margin: 0; font-size: 0.86rem; color: #33415C; }

/* ---------- stats ---------- */

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }

.tile {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #fff, var(--blue-050));
    border: 1px solid rgba(0, 47, 108, 0.08);
    box-shadow: var(--shadow-1);
}

.tile-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--uitm-cool-gray);
}

.tile strong {
    display: block;
    margin-top: 4px;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--uitm-blue);
    font-variant-numeric: tabular-nums;
}

.stat-list { display: grid; gap: 10px; margin-top: 4px; }
.stat-row { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.stat-label { font-weight: 700; font-size: 0.84rem; font-variant-numeric: tabular-nums; }

.stat-track {
    height: 12px;
    border-radius: 100vw;
    background: var(--blue-100);
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 47, 108, 0.14);
}

.stat-bar {
    display: block;
    height: 100%;
    border-radius: 100vw;
    background: linear-gradient(90deg, var(--uitm-blue), var(--uitm-purple));
    transition: width 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.stat-value { font-size: 0.78rem; font-weight: 700; color: var(--uitm-cool-gray); font-variant-numeric: tabular-nums; }

/* ---------- leaderboard ---------- */

.board { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }

/* Header is static: a sticky thead inside the overflow-x wrapper pins to the
   wrapper, not the viewport, and ends up covering the first data row. */
.board thead th {
    padding: 8px 8px;
    text-align: left;
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--uitm-cool-gray);
    background: var(--bg-light-gray);
    border-bottom: 2px solid var(--blue-100);
}

.board tbody td { padding: 10px 8px; border-bottom: 1px solid rgba(0, 47, 108, 0.08); }

.board tbody tr:last-child td { border-bottom: 0; }
.board td:nth-child(3), .board th:nth-child(3) { text-align: center; font-variant-numeric: tabular-nums; }
.board td:nth-child(4), .board th:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; }
.board td:first-child { color: var(--uitm-cool-gray); font-weight: 700; width: 3rem; }

.board tbody tr.is-me { background: var(--blue-050); }
.board tbody tr.is-me td:first-child { color: var(--uitm-purple); }

.board tbody tr:nth-child(1) td:first-child { color: var(--uitm-blue); }
.board tbody tr:nth-child(1) { font-weight: 700; }

/* ---------- footer ---------- */

.foot {
    max-width: var(--maxw);
    margin: 8px auto 0;
    padding: 0 20px;
    font-size: 0.78rem;
    color: var(--uitm-cool-gray);
}

.foot a { color: var(--uitm-blue); text-decoration-color: var(--uitm-purple); }

/* ---------- motion / print ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
    html { scroll-behavior: auto; }
    .stat-bar { transition: none; }
}

@media (max-width: 560px) {
    .nav-inner {
        flex-wrap: wrap;
        padding: 8px 14px;
        gap: 4px 10px;
    }
    .brand { font-size: 0.95rem; }
    .nav-links {
        margin-left: 0;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links a { font-size: 0.84rem; padding: 7px 10px; white-space: nowrap; }
    .nav-links a::after { display: none; }
}

@media (max-width: 420px) {
    .stat-row { grid-template-columns: 1.8rem minmax(0, 1fr); }
    .stat-value { grid-column: 2; text-align: left; }
    .hero { padding: 28px 20px 24px; }
    .panel { padding: 20px 16px; }
}
