/* ── Quiz Common Styles ──
   Shared across all drag-and-drop bucket sorting tools.
*/

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --correct: #10b981;
    --correct-light: #d1fae5;
    --incorrect: #ef4444;
    --too-early: #ef4444;
    --too-late: #8b5cf6;
    --selected: #f59e0b;
    --selected-light: #fef3c7;
    --tab-focus: #06b6d4;
    --tab-focus-light: #cffafe;
    --border-radius: 12px;
    --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.5);
    --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header { text-align: center; margin-bottom: 1rem; max-width: 750px; }
h1 { margin: 0 0 0.5rem; color: var(--primary); font-size: 1.75rem; }

.instructions {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.instructions kbd, .kb-banner kbd {
    font-family: var(--mono);
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.8em;
    font-weight: 700;
    color: var(--text-main);
}

.kb-banner kbd { background: white; border-color: #d97706; }

/* ── Toolbar ── */
.toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.toolbar-pill {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    background: var(--card-bg);
    padding: 0.4rem 1rem;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.toolbar-pill .val { color: var(--correct); }
.toolbar-pill .timer-val { color: var(--primary); font-family: var(--mono); font-size: 0.9em; }

button.reset-btn {
    background: var(--card-bg);
    border: 2px solid #e2e8f0;
    color: var(--text-main);
    padding: 0.4rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
button.reset-btn:hover { border-color: var(--primary); background-color: #f1f5f9; }
button.reset-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Banners ── */
.kb-banner {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--selected-light);
    border: 2px solid var(--selected);
    border-radius: 8px;
    padding: 0.4rem 1rem;
    font-size: 0.88rem;
    color: #92400e;
    text-align: center;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 0.75rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}
.kb-banner.visible { opacity: 1; visibility: visible; }

.complete-banner {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--correct-light);
    border: 2px solid var(--correct);
    border-radius: var(--border-radius);
    padding: 0.5rem 1.5rem;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #065f46;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}
.complete-banner.visible { opacity: 1; visibility: visible; }

/* ── Layout ── */
.layout {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
}

/* ── Bank ── */
.bank-container {
    flex: 0 0 360px;
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    border: 2px solid #e2e8f0;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    position: sticky;
    top: 1.5rem;
}
.bank-container.drag-over { background-color: #f1f5f9; border-color: var(--primary); }
.bank-container.kb-target { border-color: var(--selected); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3); }
.bank-container h2 { margin: 0 0 0.75rem; font-size: 1.1rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; }
.bank-count { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }

/* ── Items (Milestones) ── */
.milestone {
    background-color: var(--primary);
    color: white;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
    cursor: grab;
    touch-action: manipulation;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgb(79 70 229 / 0.2);
    transition: transform 0.1s, box-shadow 0.15s, background-color 0.2s, opacity 0.15s;
    user-select: none;
    outline: none;
    border: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.milestone-key {
    font-family: var(--mono);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 0.55em;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.3);
    line-height: 1;
}
.milestone.correct .milestone-key { background: rgba(255,255,255,0.3); }
.milestone:hover:not(.correct) { background-color: var(--primary-light); transform: translateY(-1px); box-shadow: 0 4px 8px rgb(79 70 229 / 0.25); }
.milestone:focus-visible { outline: 2px solid white; outline-offset: 1px; }
.milestone:active:not(.correct) { cursor: grabbing; transform: scale(0.98); }
.milestone.kb-selected { outline: 3px solid var(--selected); outline-offset: 1px; box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.25); background-color: #4338ca; animation: pulse 1.5s infinite; }
.milestone.correct { background-color: var(--correct); box-shadow: 0 2px 4px rgb(16 185 129 / 0.2); cursor: default; }
.milestone.incorrect  { background-color: var(--incorrect); }
.milestone.too-early  { background-color: var(--too-early); }
.milestone.too-late   { background-color: var(--too-late); }
.milestone-hint { display: none; font-size: 0.7em; margin-top: 0.15em; flex-basis: 100%; padding-left: calc(1.5em + 0.55em); }
.milestone.incorrect .milestone-hint, .milestone.too-early .milestone-hint, .milestone.too-late .milestone-hint { display: block; color: rgba(255,255,255,0.9); font-weight: 500; }

/* ── Zones ── */
.grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.age-zone { background: var(--card-bg); border: 2px dashed #cbd5e1; border-radius: var(--border-radius); padding: 1rem; min-height: 150px; transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; outline: none; }
.age-zone:focus-visible { box-shadow: var(--focus-ring); }
.age-zone.drag-over { background-color: #e0e7ff; border-color: var(--primary); border-style: solid; }
.age-zone.kb-target { border-color: var(--selected); border-style: solid; background-color: var(--selected-light); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3); }
.age-zone h3 { margin: 0 0 0.75rem; color: var(--text-main); text-align: center; font-size: 1.05rem; pointer-events: none; }
.zone-key { font-family: var(--mono); display: inline-flex; align-items: center; justify-content: center; width: 1.5em; height: 1.5em; background: #e2e8f0; color: var(--text-muted); border-radius: 4px; font-size: 0.8rem; font-weight: 700; margin-right: 0.35em; vertical-align: middle; border: 1px solid #cbd5e1; transition: background-color 0.15s, color 0.15s; }
.kb-target .zone-key { background: var(--selected); color: white; border-color: var(--selected); }
.zone-hint { color: var(--text-muted); font-size: 0.8rem; text-align: center; font-style: italic; pointer-events: none; }

/* ── Modal Overlays ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; padding: 2rem; }
.modal-overlay.visible { display: flex; }
.modal-card { background: var(--card-bg); border-radius: var(--border-radius); padding: 2rem; width: 100%; box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25); max-height: 85vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 1rem; color: var(--primary); font-size: 1.3rem; }
.modal-close { position: absolute; top: 0.85rem; right: 0.85rem; background: none; border: none; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; color: var(--text-muted); font-size: 1.2rem; line-height: 1; padding: 0; }
.modal-close:hover { background: #f1f5f9; color: var(--text-main); }
.modal-card .close-hint { text-align: center; margin-top: 1.25rem; color: var(--text-muted); font-size: 0.85rem; }
.modal-card .close-hint kbd { font-family: var(--mono); background: #e2e8f0; border: 1px solid #cbd5e1; border-radius: 4px; padding: 0.05rem 0.3rem; font-size: 0.85em; font-weight: 700; }

/* ── Cheatsheet table specific ── */
.cheatsheet-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; line-height: 1.4; }
.cheatsheet-table th { background: var(--primary); color: white; padding: 0.5rem 0.6rem; text-align: center; font-size: 0.8rem; font-weight: 700; border: 1px solid #4338ca; white-space: nowrap; }
.cheatsheet-table td { padding: 0.45rem 0.6rem; border: 1px solid #e2e8f0; vertical-align: top; }
.cheatsheet-table li { margin-bottom: 0.15em; transition: background-color 0.2s; }
.cheatsheet-table li.correct, .prog-item.correct { background: rgba(16, 185, 129, 0.18); border-radius: 3px; padding: 0 3px; }
.cheatsheet-table li.too-early, .prog-item.too-early { background: rgba(239, 68, 68, 0.18); border-radius: 3px; padding: 0 3px; }
.cheatsheet-table li.too-late, .prog-item.too-late { background: rgba(139, 92, 246, 0.18); border-radius: 3px; padding: 0 3px; }

/* ── Animations ── */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 0%, 100% { outline-color: var(--selected); } 50% { outline-color: transparent; } }

/* ── Utilities ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
