/* ==========================================================================
   Arden's Arcade — Quiz Game  ·  v2 "Quiet"
   Flat, typographic, monochrome. One ink color; green/red only for answers.
   ========================================================================== */

/* Fuentes del sistema (sin red) */

:root {
    --bg: #fafafb;
    --surface: #ffffff;
    --ink: #10233f;
    --ink-soft: #1d3a66;
    --muted: #6a6f7b;
    --line: #e6e7eb;
    --line-strong: #d3d5db;
    --hover: #f3f4f6;

    --good: #15803d;
    --good-bg: #e9f7ee;
    --bad: #d92d20;
    --bad-bg: #fdeeec;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --r: 12px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(20px, 7vh, 72px) clamp(16px, 5vw, 32px) 40px;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h2,
p {
    margin: 0;
}

h2 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

br {
    display: none;
}

/* ---------- Page shell (no card) ---------- */
.container {
    width: 100%;
    max-width: 560px;
    min-width: 0;
}

/* Wordmark */
.container::before {
    content: "MexcoParts · Trivia Vocho";
    display: block;
    margin-bottom: clamp(28px, 6vh, 48px);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 22px;
}

/* ---------- Screens ---------- */
.screen {
    display: none;
    min-width: 0;
}

.screen.active {
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Primary button ---------- */
.btn {
    width: 100%;
    min-height: 56px;
    padding: 14px 24px;
    font: inherit;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #fff;
    background: var(--ink);
    border: 0;
    border-radius: var(--r);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.12s var(--ease);
}

.btn:hover:not(:disabled) {
    background: var(--ink-soft);
}

.btn:active:not(:disabled) {
    transform: scale(0.985);
}

.btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ==========================================================================
   START SCREEN — a settings list: label on the left, control on the right
   ========================================================================== */
#start-screen.active {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr);
    grid-template-areas:
        "title  title"
        "sub    sub"
        "countL count"
        "btn    btn"
        "foot   foot";
    align-content: start;
    column-gap: 20px;
}

#start-screen > h2 {
    grid-area: title;
    font-size: clamp(1.625rem, 5vw, 2rem);
}

#start-screen > p:not(#loading-message) {
    grid-area: sub;
    margin: 8px 0 28px;
    color: var(--muted);
}

#start-screen label {
    align-self: stretch;
    display: flex;
    align-items: center;
    font-size: 0.9375rem;
    font-weight: 500;
}

label[for="category"],
.dd[data-for="category"],
#category              { grid-area: cat; }
label[for="category"]  { grid-area: catL; }

label[for="difficulty"],
.dd[data-for="difficulty"],
#difficulty            { grid-area: diff; }
label[for="difficulty"] { grid-area: diffL; }

label[for="question-count"],
.dd[data-for="question-count"],
#question-count        { grid-area: count; }
label[for="question-count"] { grid-area: countL; }

/* Row lines */
#start-screen label,
.dd {
    min-height: 68px;
    border-top: 1px solid var(--line);
}

label[for="question-count"],
.dd[data-for="question-count"] {
    border-bottom: 1px solid var(--line);
}

.dd {
    display: flex;
    align-items: center;
    min-width: 0;
}

#start-btn {
    grid-area: btn;
    margin-top: 28px;
}

#loading-message {
    grid-area: status;
    margin-top: 12px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--muted);
}

#loading-message.error {
    font-size: 1rem;
    color: var(--bad);
}

#loading-message:empty {
    display: none;
}

#start-screen::after {
    content: "Gratis, sin registrarse.";
    grid-area: foot;
    margin-top: 28px;
    font-size: 0.8125rem;
    color: var(--muted);
}

/* ---------- Custom dropdown (built by dropdown.js) ---------- */
.dd-box {
    position: relative;
    width: 100%;
    min-width: 0;
}

/* The real <select> stays in the DOM (your script still reads it) but is hidden */
.dd-native {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.dd-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: left;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.18s, background-color 0.18s;
}

.dd-value {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dd-trigger::after {
    content: "";
    flex: none;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%236A6F7B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5.25l4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform 0.2s var(--ease);
}

.dd-trigger:hover:not(:disabled) {
    border-color: var(--ink);
}

.dd-trigger:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.dd-trigger[aria-expanded="true"] {
    border-color: var(--ink);
}

.dd-trigger[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.dd-trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Panel */
.dd-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    max-height: 320px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 16px 40px -12px rgba(17, 19, 24, 0.22), 0 2px 6px rgba(17, 19, 24, 0.05);
    overflow: hidden;
    transform-origin: top;
    animation: panel-in 0.14s var(--ease);
}

.dd-panel[hidden] {
    display: none;
}

.dd-box.dd-up .dd-panel {
    top: auto;
    bottom: calc(100% + 6px);
    transform-origin: bottom;
}

@keyframes panel-in {
    from { opacity: 0; transform: scale(0.98) translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

.dd-search {
    flex: none;
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    outline: none;
}

.dd-search::placeholder {
    color: var(--muted);
}

.dd-search[hidden] {
    display: none;
}

.dd-list {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    outline: none;
}

.dd-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px;
    font-size: 0.9375rem;
    line-height: 1.35;
    color: var(--ink);
    border-radius: 8px;
    cursor: pointer;
}

.dd-option[hidden] {
    display: none;
}

.dd-option.is-active {
    background: var(--hover);
}

.dd-option.is-selected {
    font-weight: 600;
}

.dd-option.is-selected::after {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23111318' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat;
}

.dd-empty {
    padding: 14px 10px;
    font-size: 0.875rem;
    color: var(--muted);
}

/* Fallback if JS fails: a tidy native select */
select:not(.dd-native) {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
}

/* ==========================================================================
   QUIZ SCREEN
   ========================================================================== */
#quiz-screen.active {
    display: flex;
    flex-direction: column;
}

.quiz-header {
    display: contents;
}

/* 1 — progress line */
.progress-bar {
    order: 1;
    height: 3px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.progress {
    width: 0;
    height: 100%;
    background: var(--ink);
    border-radius: inherit;
    transition: width 0.45s var(--ease);
}

/* 2 — counter and score */
.quiz-info {
    order: 2;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    font-size: 0.875rem;
    color: var(--muted);
}

.quiz-info p:last-child {
    font-weight: 600;
    color: var(--ink);
}

.quiz-info span {
    font-variant-numeric: tabular-nums;
}

/* 3 — question */
#question-text {
    order: 3;
    margin: 28px 0 24px;
    font-size: clamp(1.25rem, 4vw, 1.625rem);
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* 4 — answers: one clean column */
.options-container {
    order: 4;
    display: grid;
    gap: 8px;
    counter-reset: option;
}

.option-btn {
    counter-increment: option;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-width: 0;
    min-height: 54px;
    padding: 13px 16px;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    color: var(--ink);
    overflow-wrap: anywhere;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, transform 0.12s var(--ease);
}

.option-btn::before {
    content: counter(option, upper-alpha);
    flex: none;
    width: 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
}

/* Hover only while the question is open */
.options-container:not(.answered) .option-btn:not(:disabled):not(.disabled):not(.correct):not(.wrong):not(.incorrect):hover {
    background: var(--hover);
    border-color: var(--line-strong);
}

.options-container:not(.answered) .option-btn:not(:disabled):not(.disabled):active {
    transform: scale(0.99);
}

.option-btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.options-container .option-btn.selected {
    border-color: var(--ink);
}

/* Correct */
.options-container .option-btn.correct {
    color: var(--ink);
    background: var(--good-bg);
    border-color: var(--good);
}

.options-container .option-btn.correct::before {
    color: var(--good);
}

.options-container .option-btn.correct::after {
    content: "";
    flex: none;
    width: 18px;
    height: 18px;
    margin-left: auto;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18' fill='none' stroke='%2315803D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5l3.5 3.5L14 5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Incorrect (.wrong or .incorrect) */
.options-container .option-btn.wrong,
.options-container .option-btn.incorrect {
    color: var(--ink);
    background: var(--bad-bg);
    border-color: var(--bad);
    animation: nudge 0.28s;
}

.options-container .option-btn.wrong::before,
.options-container .option-btn.incorrect::before {
    color: var(--bad);
}

.options-container .option-btn.wrong::after,
.options-container .option-btn.incorrect::after {
    content: "";
    flex: none;
    width: 18px;
    height: 18px;
    margin-left: auto;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18' fill='none' stroke='%23D92D20' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 5l8 8M13 5l-8 8'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Locked after answering */
.options-container.answered .option-btn,
.option-btn:disabled,
.option-btn.disabled {
    cursor: default;
    pointer-events: none;
}

.option-btn:disabled {
    color: var(--ink);
}

.options-container .option-btn:disabled:not(.correct):not(.wrong):not(.incorrect),
.options-container.answered .option-btn:not(.correct):not(.wrong):not(.incorrect),
.options-container .option-btn.disabled:not(.correct):not(.wrong):not(.incorrect) {
    opacity: 0.5;
}

@keyframes nudge {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ==========================================================================
   RESULT SCREEN
   ========================================================================== */
#result-screen.active {
    display: flex;
    flex-direction: column;
}

#result-screen > h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0;
}

.result-info {
    margin: 12px 0 32px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.result-info p {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.4em;
    font-size: 1.0625rem;
    color: var(--muted);
}

#final-score {
    font-size: clamp(4rem, 17vw, 5.5rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.05em;
    color: var(--ink);
}

#max-score {
    font-weight: 600;
    color: var(--ink);
}

#result-message {
    margin-top: 14px;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

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

/* Mobile: labels stack above controls */
@media (max-width: 599px) {
    #start-screen.active {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "title"
            "sub"
            "countL"
            "count"
            "btn"
            "foot";
    }

    #start-screen label,
    .dd {
        min-height: 0;
        border: 0;
    }

    #start-screen label {
        padding: 18px 0 8px;
    }

    .dd {
        padding: 0;
    }

    .dd-trigger {
        min-height: 50px;
    }

    #start-btn {
        margin-top: 32px;
    }
}

@media (max-width: 360px) {
    .option-btn {
        padding: 12px 12px;
        gap: 10px;
    }
}

@media (min-width: 1400px) {
    html {
        font-size: 106.25%;
    }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}