/* ============================================================
   games.css — styles for the SterileGenius learning games
   Builds on the teal theme variables defined in style.css
   ============================================================ */

/* ---------- Games landing page ---------- */
.games-hero { padding-bottom: 1rem; }
.games-kicker {
    display: inline-block;
    background: var(--mint);
    color: var(--teal-dark);
    font-weight: 800;
    font-size: .85rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    margin-bottom: .75rem;
}
.games-login-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    margin-top: 1rem;
}
.games-login-note .btn { margin-left: .25rem; }

.games-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.4rem;
}
.game-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.6rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}
.game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.game-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    background: var(--teal);
}
.game-card--amber::before { background: var(--amber); }
.game-card--coral::before { background: var(--coral); }
.game-card--teal::before  { background: var(--teal-light); }
.game-card-icon {
    font-size: 2.6rem;
    line-height: 1;
    margin-bottom: .5rem;
}
.game-tag {
    align-self: flex-start;
    background: var(--mint);
    color: var(--teal-dark);
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .25rem .6rem;
    border-radius: 999px;
    margin-bottom: .5rem;
}
.game-card h2 { margin: .1rem 0 .35rem; font-size: 1.35rem; }
.game-how { color: var(--slate); font-size: .92rem; margin: .35rem 0 1rem; }
.game-card-best {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--mint);
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-size: .9rem;
    margin-bottom: 1rem;
    color: var(--teal-dark);
}
.game-card .btn { margin-top: auto; }

/* ---------- Individual game page ---------- */
.game-back {
    display: inline-block;
    color: var(--teal-dark);
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 1rem;
}
.game-back:hover { text-decoration: underline; }
.game-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.game-head-icon { font-size: 2.6rem; line-height: 1; }
.game-title { margin: 0; font-size: 1.9rem; }

/* Sticky status bar */
.game-bar {
    position: sticky;
    top: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .8rem 1.1rem;
    margin-bottom: 1.4rem;
}
.gb-stat { display: flex; flex-direction: column; min-width: 64px; }
.gb-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); font-weight: 700; }
.gb-value { font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 1.4rem; color: var(--teal-dark); }
.gb-progress { flex: 1 1 160px; min-width: 140px; }
.gb-track { height: 10px; background: var(--mint); border-radius: 999px; overflow: hidden; margin-top: .35rem; }
.gb-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal-light), var(--teal)); border-radius: 999px; transition: width .35s ease; }
.gb-actions { display: flex; gap: .5rem; margin-left: auto; }

/* Generic stage */
.game-stage { margin-bottom: 2rem; }

/* ----- Two-column boards (matcher / temperature) ----- */
.board-cols {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 1.4rem;
    align-items: start;
}
.board-col-title { font-family:'Poppins',sans-serif; font-size: 1rem; margin: 0 0 .75rem; color: var(--ink); }

/* Draggable item cards */
.bank {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.drag-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 5px solid var(--teal);
    border-radius: var(--radius-sm);
    padding: .7rem .85rem;
    cursor: grab;
    box-shadow: var(--shadow);
    touch-action: none;
    transition: transform .1s ease, box-shadow .1s ease, opacity .1s ease;
}
.drag-card:active { cursor: grabbing; }
.drag-card.dragging { opacity: .5; transform: scale(.98); }
.drag-card.ghost { box-shadow: var(--shadow-lg); transform: scale(1.03); }
.drag-card h4 { margin: 0 0 .15rem; font-size: .98rem; }
.drag-card p { margin: 0; font-size: .8rem; color: var(--slate); }
.drag-card.correct { border-left-color: var(--green); background: #f0fdf4; }
.drag-card.incorrect { border-left-color: var(--coral); background: #fef2f2; }

/* Drop zones */
.zones { display: grid; gap: .9rem; }
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: .75rem;
    background: var(--bg);
    min-height: 84px;
    transition: border-color .15s ease, background .15s ease;
}
.drop-zone.over { border-color: var(--teal); background: var(--mint); }
.drop-zone-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.drop-zone-head .dz-icon { font-size: 1.4rem; }
.drop-zone-head h4 { margin: 0; font-size: 1rem; }
.drop-zone-head .dz-hint { font-size: .75rem; color: var(--slate); display:block; }
.drop-zone .drop-items { display: flex; flex-direction: column; gap: .5rem; }
.drop-zone .drag-card { border-left-width: 5px; }

/* Bank wrapper used as a drop target too (to send items back) */
.bank-wrap.drop-zone { min-height: 120px; }

/* ----- Sequence board ----- */
.seq-board { display: grid; grid-template-columns: 1fr; gap: .6rem; max-width: 720px; margin: 0 auto; }
.seq-slot {
    display: flex;
    align-items: stretch;
    gap: .75rem;
}
.seq-num {
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    background: var(--teal);
    color: #fff;
    border-radius: var(--radius-sm);
}
.seq-drop {
    flex: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    min-height: 58px;
    padding: .3rem;
    transition: border-color .15s ease, background .15s ease;
}
.seq-drop.over { border-color: var(--teal); background: var(--mint); }
.seq-drop .drag-card { border-left-color: var(--amber); }

/* ----- Temperature challenge (tap to link) ----- */
.match-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .7rem .85rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: border-color .12s ease, background .12s ease, transform .1s ease;
    position: relative;
}
.match-card:hover { border-color: var(--teal-light); }
.match-card.selected { border-color: var(--teal); background: var(--mint); transform: scale(1.02); }
.match-card.linked { border-style: solid; }
.match-card.linked::after {
    content: attr(data-badge);
    position: absolute;
    top: -10px; right: -10px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: var(--teal); color: #fff;
    border-radius: 50%;
    font-size: .8rem; font-weight: 800;
    box-shadow: var(--shadow);
}
.match-card.correct { border-color: var(--green); background: #f0fdf4; }
.match-card.incorrect { border-color: var(--coral); background: #fef2f2; }
.match-card h4 { margin: 0 0 .15rem; font-size: .98rem; }
.match-card p { margin: 0; font-size: .8rem; color: var(--slate); }
.match-card .temp { font-weight: 800; color: var(--teal-dark); font-size: 1rem; }

/* ----- Contamination spotter ----- */
.spotter-wrap { max-width: 880px; margin: 0 auto; }
.spotter-scene {
    position: relative;
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: crosshair;
    user-select: none;
}
.spotter-scene svg { display: block; width: 100%; height: auto; }
.hotspot {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}
.hotspot.found {
    border-color: var(--green);
    background: rgba(22,163,74,.18);
    animation: pop .3s ease;
}
.hotspot.found::after {
    content: "✓";
    position: absolute;
    top: -12px; left: -12px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: var(--green); color: #fff;
    border-radius: 50%;
    font-weight: 800; font-size: .85rem;
    box-shadow: var(--shadow);
}
.hotspot.reveal { border-color: var(--amber); background: rgba(245,165,36,.18); }
.spot-miss {
    position: absolute;
    width: 30px; height: 30px;
    margin: -15px 0 0 -15px;
    border-radius: 50%;
    border: 2px solid var(--coral);
    color: var(--coral);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    pointer-events: none;
    animation: pop .3s ease;
}
.spotter-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .5rem;
    margin-top: 1rem;
}
.check-item {
    display: flex; align-items: center; gap: .5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem .65rem;
    font-size: .85rem;
    color: var(--slate);
}
.check-item .ci-dot {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border);
    flex: 0 0 auto;
}
.check-item.done { color: var(--ink); }
.check-item.done .ci-dot { background: var(--green); border-color: var(--green); }
.check-item.done .ci-dot::after { content: "✓"; color:#fff; font-size:.7rem; display:flex; align-items:center; justify-content:center; height:100%; }

@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ----- Toasts ----- */
.toast-host {
    position: fixed;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex; flex-direction: column; gap: .5rem;
    align-items: center;
    pointer-events: none;
}
.toast {
    background: var(--ink);
    color: #fff;
    padding: .65rem 1.1rem;
    border-radius: 999px;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    animation: toastIn .25s ease;
}
.toast.good { background: var(--green); }
.toast.bad  { background: var(--coral); }
.toast.info { background: var(--teal); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ----- Leaderboard ----- */
.game-side { margin-top: 1.5rem; }
.lb-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.4rem;
    max-width: 560px;
}
.lb-title { margin: 0 0 .5rem; font-size: 1.25rem; }
.lb-me { color: var(--teal-dark); font-weight: 700; margin: 0 0 .75rem; }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row {
    display: grid;
    grid-template-columns: 42px 1fr auto auto;
    align-items: center;
    gap: .6rem;
    padding: .5rem .25rem;
    border-bottom: 1px solid var(--border);
}
.lb-row:last-child { border-bottom: none; }
.lb-row--me { background: var(--mint); border-radius: var(--radius-sm); }
.lb-rank { font-weight: 800; font-size: 1.05rem; text-align: center; }
.lb-name { font-weight: 700; color: var(--ink); }
.lb-score { font-weight: 800; color: var(--teal-dark); }
.lb-time { color: var(--slate); font-size: .85rem; }

/* ----- Result modal ----- */
.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,85,99,.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 1rem;
    animation: toastIn .2s ease;
}
.result-overlay[hidden] { display: none; }
.result-modal {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.75rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    animation: pop .35s ease;
}
.result-emoji { font-size: 3.4rem; line-height: 1; }
.result-modal h2 { margin: .5rem 0 .35rem; font-size: 1.6rem; }
.result-msg { color: var(--slate); margin: 0 0 1.1rem; }
.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: 1rem;
}
.result-stats > div {
    background: var(--mint);
    border-radius: var(--radius-sm);
    padding: .6rem .25rem;
}
.rs-num { display: block; font-family:'Poppins',sans-serif; font-weight: 800; font-size: 1.4rem; color: var(--teal-dark); }
.rs-lbl { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--slate); font-weight: 700; }
.result-best {
    background: var(--amber);
    color: #5a3d00;
    font-weight: 800;
    border-radius: 999px;
    padding: .4rem .9rem;
    display: inline-block;
    margin: 0 0 1rem;
}
.result-actions { display: flex; gap: .6rem; justify-content: center; }

/* ----- Dashboard game stats ----- */
.game-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.gs-best-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}
.gs-best-card .gs-icon { font-size: 1.8rem; }
.gs-best-card h4 { margin: .3rem 0 .25rem; font-size: 1rem; }
.gs-best-card .gs-score { font-family:'Poppins',sans-serif; font-weight:800; color: var(--teal-dark); font-size: 1.3rem; }
.gs-best-card .gs-meta { font-size: .8rem; color: var(--slate); }
.gs-best-card .btn { margin-top: .6rem; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .games-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .board-cols { grid-template-columns: 1fr; }
    .game-bar { gap: .85rem; padding: .7rem .85rem; }
    .gb-value { font-size: 1.2rem; }
    .gb-actions { width: 100%; margin-left: 0; }
    .gb-actions .btn { flex: 1; }
    .game-title { font-size: 1.5rem; }
}
@media (max-width: 520px) {
    .result-stats { grid-template-columns: 1fr; }
    .lb-row { grid-template-columns: 34px 1fr auto; }
    .lb-time { display: none; }
}
