/*
 * style.css — Coder Breaker game-specific styles
 * Shared tokens (colors, fonts, buttons, modals) come from ../shared.css
 */

/* ─── START SCREEN ───────────────────────────────────────────────── */
#start-logo {
    font-size: 4.5rem;
    margin-bottom: 8px;
    animation: logoEntrance 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    filter: drop-shadow(0 0 24px rgba(56, 189, 248, 0.55));
}
@keyframes logoEntrance {
    0%   { transform: scale(4); opacity: 0; }
    35%  { opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.lc-detail { margin-top: 4px; }

/* ─── GAME AREA LAYOUT ───────────────────────────────────────────── */
#game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 12px 8px;
    overflow: hidden;
    gap: 8px;
    position: relative;
}

/* ─── CIPHER REFERENCE PANEL ─────────────────────────────────────── */
#ref-panel {
    width: 100%;
    max-width: 480px;
    background: rgba(255,255,255,0.03);
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 8px 10px;
    flex-shrink: 0;
}
#ref-panel-title {
    font-size: 0.65rem;
    letter-spacing: 3px;
    color: #64748b;
    text-align: center;
    margin-bottom: 7px;
    text-transform: uppercase;
}
#ref-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}
.ref-cell {
    /* 8 per row: 7 gaps × 4px = 28px; each cell = (100% - 28px) / 8 */
    flex: 0 0 calc(12.5% - 3.5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 5px 2px;
    cursor: pointer;
    border: 1.5px solid #1e293b;
    background: rgba(255,255,255,0.04);
    transition: border-color 0.12s, background 0.12s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
    gap: 3px;
}
.ref-cell:hover {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.07);
}
.ref-cell:active { transform: scale(0.9); }
.ref-cell.selected {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.18);
    animation: refPulse 1s ease-in-out infinite;
}
.ref-cell.used {
    opacity: 0.28;
    pointer-events: none;
}
@keyframes refPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.08); }
}
.ref-symbol { font-size: 1.4rem; line-height: 1; }
.ref-letter {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    font-family: system-ui, -apple-system, sans-serif;
    letter-spacing: 0.5px;
}

/* ─── WORD TIMER BAR ─────────────────────────────────────────────── */
#word-timer-wrap {
    width: 100%;
    height: 5px;
    background: #0d1117;
    flex-shrink: 0;
    /* sits flush below the header — no border-radius, no max-width */
}
#word-timer-bar {
    height: 100%;
    width: 100%;
    background: var(--accent);
    border-radius: 0;
    transform-origin: left;
    transition: background 0.4s;
}
#word-timer-bar.warn  { background: #f97316; }
#word-timer-bar.crit  { background: var(--error-color); }

/* ─── LETTER SLOTS ───────────────────────────────────────────────── */
#slots-section {
    width: 100%;
    max-width: 480px;
    flex-shrink: 0;
    margin: 10px 0;
}
#slots-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    width: 100%;
}
.slot {
    /* 12-slot equivalent width: 11 gaps × 4px = 44px; each = (100% - 44px) / 12 */
    flex: 0 0 calc(8.333% - 3.667px);
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    border: 1.5px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.6rem, 3vw, 1rem);
    font-weight: bold;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}
.slot.inactive {
    display: none;
}
/* Moving-border empty slot using @property conic-gradient */
@property --slot-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
.slot.empty {
    background:
        linear-gradient(#0d1117, #0d1117) padding-box,
        conic-gradient(from var(--slot-angle), #1e293b 70%, #38bdf8 87%, #1e293b 100%) border-box;
    border: 1.5px solid transparent;
    animation: slotBorderSpin 2.5s linear infinite;
}
@keyframes slotBorderSpin {
    to { --slot-angle: 360deg; }
}
.slot.empty:hover {
    background:
        linear-gradient(rgba(56, 189, 248, 0.07), rgba(56, 189, 248, 0.07)) padding-box,
        conic-gradient(from var(--slot-angle), #1e293b 50%, #38bdf8 75%, #1e293b 100%) border-box;
    animation: slotBorderSpin 1.2s linear infinite;
}
.slot.has-symbol {
    border-color: #334155;
    background: rgba(255,255,255,0.05);
}
.slot.has-symbol:hover {
    border-color: rgba(239, 68, 68, 0.5);
}
.slot-symbol { font-size: 1.2em; line-height: 1; }
.slot.correct {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.12);
    color: var(--success);
    pointer-events: none;
}
.slot.correct .slot-letter { font-size: 1em; font-weight: bold; }

/* Flash wrong */
.slot.flash-wrong {
    animation: slotWrong 0.35s ease forwards;
}
@keyframes slotWrong {
    0%, 100% { border-color: #1e293b; background: rgba(255,255,255,0.03); }
    40%       { border-color: var(--error-color); background: rgba(239,68,68,0.18); }
}

/* Flash correct reveal */
.slot.flash-correct {
    animation: slotCorrect 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes slotCorrect {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ─── HINT TEXT ──────────────────────────────────────────────────── */
#hint-text {
    font-size: 0.78rem;
    font-style: italic;
    color: #475569;
    text-align: center;
    max-width: 480px;
    width: 100%;
    padding: 0 4px;
    min-height: 1.4em;
    animation: hintFadeIn 0.5s ease forwards;
    flex-shrink: 0;
}
@keyframes hintFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── MULTIPLE CHOICE ────────────────────────────────────────────── */
#mc-section {
    width: 100%;
    max-width: 480px;
    flex-shrink: 0;
}
#mc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.mc-btn {
    --border-angle: 0deg;
    background:
        linear-gradient(#0f0f0f, #0f0f0f) padding-box,
        conic-gradient(from var(--border-angle), #1e293b 70%, #334155 85%, #1e293b 100%) border-box;
    border: 1.5px solid transparent;
    color: #f1f5f9;
    border-radius: 10px;
    padding: 13px 10px;
    font-size: 1rem;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 1px;
    text-align: center;
    text-transform: uppercase;
    transition: transform 0.1s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    word-break: break-word;
    animation: borderSpin 4s linear infinite;
}
.mc-btn:hover {
    background:
        linear-gradient(#060f1e, #060f1e) padding-box,
        conic-gradient(from var(--border-angle), #1e293b 40%, var(--accent) 70%, #1e293b 100%) border-box;
    animation: borderSpin 1.5s linear infinite;
    color: var(--accent);
}
.mc-btn:active { transform: scale(0.95); }
.mc-btn.locked {
    opacity: 0.35;
    pointer-events: none;
}
.mc-btn.correct-flash {
    border-color: var(--success) !important;
    color: var(--success);
    background: rgba(74,222,128,0.1);
    animation: none;
}
.mc-btn.wrong-flash {
    border-color: var(--error-color) !important;
    color: var(--error-color);
    background: rgba(239,68,68,0.1);
    animation: none;
}

/* ─── SCORE DISPLAY ──────────────────────────────────────────────── */
#score-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: #475569;
    flex-shrink: 0;
}
#score-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(56,189,248,0.4);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
#score-value.bump {
    animation: scoreBump 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes scoreBump {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* ─── HEADER TIMER ───────────────────────────────────────────────── */
#header {
    font-size: 1rem;
    font-family: system-ui, -apple-system, sans-serif;
    letter-spacing: 0.5px;
    gap: 0;
}
#header-level-name {
    color: var(--accent);
    font-weight: 700;
}
#header-word-label {
    color: #cbd5e1;
    font-weight: 600;
}
.hdot {
    color: #475569;
    margin: 0 5px;
}
#header-timer {
    color: #f1f5f9;
    font-weight: 700;
    font-size: 1.05rem;
    text-shadow: 0 0 10px rgba(255,255,255,0.35);
    transition: color 0.3s;
}
#header-timer.warning {
    color: var(--error-color);
    animation: pulse 1s infinite;
}

/* ─── RULES OVERLAY ──────────────────────────────────────────────── */
#rules-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
}
#rules-overlay.hidden { display: none; }

#rules-card {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: rulesCardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes rulesCardIn {
    from { transform: scale(0.85) translateY(24px); opacity: 0; }
    to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

#rules-icon {
    font-size: 3rem;
    filter: drop-shadow(0 0 22px rgba(56, 189, 248, 0.65));
}
#rules-level-name {
    font-size: 0.8rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
    font-family: system-ui, -apple-system, sans-serif;
}
#rules-card h2 {
    font-size: 1rem;
    color: #f1f5f9;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
}
#rules-list {
    list-style: none;
    padding: 14px 18px;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 9px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #1e293b;
    border-radius: 14px;
    box-sizing: border-box;
}
#rules-list li {
    font-size: 0.88rem;
    font-family: system-ui, -apple-system, sans-serif;
    color: #94a3b8;
    line-height: 1.5;
    padding-left: 1.5em;
    position: relative;
}
#rules-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
}
#rules-start-btn {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 64px;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 4px;
    cursor: pointer;
    text-transform: uppercase;
    font-family: system-ui, -apple-system, sans-serif;
    box-shadow: 0 0 32px rgba(56, 189, 248, 0.55), 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: startBtnPulse 1.5s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
    margin-top: 4px;
}
@keyframes startBtnPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 32px rgba(56, 189, 248, 0.55), 0 4px 20px rgba(0, 0, 0, 0.5);
    }
    50% {
        transform: scale(1.07);
        box-shadow: 0 0 56px rgba(56, 189, 248, 0.85), 0 6px 28px rgba(0, 0, 0, 0.55);
    }
}
#rules-start-btn:active { transform: scale(0.95) !important; animation: none; }

#rules-back-btn {
    font-size: 0.78rem;
    color: #475569;
    background: none;
    border: none;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 6px 16px;
    font-family: system-ui, -apple-system, sans-serif;
    transition: color 0.15s;
}
#rules-back-btn:hover { color: #94a3b8; }

/* ─── COUNTDOWN OVERLAY ──────────────────────────────────────────── */
#countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
#countdown-overlay.hidden { display: none; }

#countdown-number {
    font-size: clamp(90px, 20vw, 240px);
    font-weight: 700;
    color: var(--accent);
    text-shadow:
        0 0 40px rgba(56, 189, 248, 0.9),
        0 0 90px rgba(56, 189, 248, 0.35);
    letter-spacing: -4px;
    line-height: 1;
}
.count-pop {
    animation: countPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes countPop {
    0%   { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}
#countdown-number.go-text {
    color: #4ade80;
    font-size: clamp(55px, 13vw, 160px);
    letter-spacing: 0;
    text-shadow:
        0 0 40px rgba(74, 222, 128, 0.85),
        0 0 80px rgba(74, 222, 128, 0.3);
}

