/**
 * ☣️ Toxic Words - Game Styling
 * Foundation 6 + Nerd Hub aesthetic
 */

:root {
    --toxic-primary: #0023FF;
    --toxic-safe: #22c55e;
    --toxic-warn: #ff8c00;
    --toxic-danger: #ef4444;
    --toxic-neutral: #71717a;
    --toxic-dark: #18181b;
    --toxic-light: #f4f4f5;
}

/* Full-page game: prevent the browser from scrolling behind the container */
body.toxic-page {
    overflow: hidden;
}

/* Game Container - flex column, fills from header to bottom of viewport */
#toxic-game-container {
    height: 100vh;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    max-width: 480px;
    margin: 0 auto;
    background: #f9f9f9;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    padding: 0;
}

/* Header */
.toxic-header {
    flex: 0 0 auto;
    padding: 10px;
}

.toxic-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--toxic-primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.toxic-subtitle {
    font-size: 1rem;
    color: var(--toxic-neutral);
    font-weight: 500;
}

/* HP Bar - Fixed at top, doesn't scroll */
.toxic-hp-container {
    flex: 0 0 auto;
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    background: #f9f9f9;
    border-bottom: 1px solid #e5e7eb;
}

.toxic-hp-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.toxic-hp-bar {
    width: 100%;
    height: 30px;
    background: #e5e7eb;
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid var(--toxic-dark);
    position: relative;
}

.toxic-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--toxic-primary), #0066ff);
    transition: width 0.3s ease, background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.toxic-hp-fill.low {
    background: linear-gradient(90deg, var(--toxic-danger), #ff6b6b);
}

.toxic-hp-fill.medium {
    background: linear-gradient(90deg, var(--toxic-warn), #fbbf24);
}

/* Guess Grid Container */
.toxic-guess-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
    align-items: center;
    width: 100%;
}

/* Scrollable viewport - grows to fill space between HP and keyboard */
#toxic-viewport {
    flex: 1 1 auto !important;
    width: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 1rem 1.5rem;
    scroll-behavior: smooth;
    background: #f9f9f9;
}

/* (duplicate .toxic-modal block removed — see full definition below) */

/* Midnight countdown */
#toxic-midnight-countdown { font-weight:700; margin-top:1rem; }

/* Fixed: Guess Row as tight horizontal flexbox with max-width corral */
.toxic-guess-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 350px !important; /* Corral to prevent ghost gutters */
    margin: 0 auto !important;
    padding: 0 !important;
    gap: 6px;
}

.toxic-letter-box {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    margin: 0;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    border: 2px solid var(--toxic-neutral);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 0 !important;
    background: white;
    color: var(--toxic-dark);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    position: relative;
    text-transform: uppercase;
}

.toxic-letter-box.active {
    border-color: var(--toxic-primary);
    border-width: 3px;
}

.toxic-letter-box.filled {
    background: white;
    color: var(--toxic-dark);
    border-color: var(--toxic-neutral);
}

.toxic-letter-box.green {
    background-color: #22c55e !important;
    color: #fff !important;
    border-color: #22c55e !important;
    animation: flip 0.4s ease;
}

.toxic-letter-box.orange {
    background-color: #f97316 !important;
    color: #fff !important;
    border-color: #f97316 !important;
    animation: flip 0.4s ease;
}

.toxic-letter-box.red {
    background-color: #ef4444 !important;
    color: #fff !important;
    border-color: #ef4444 !important;
    animation: flip 0.4s ease;
}

.toxic-letter-damage {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--toxic-danger);
}

@keyframes flip {
    0% {
        transform: rotateX(0deg);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

/* Input Area */
.toxic-input-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.toxic-input-container {
    background: #f9f9f9;
    border-bottom: 1px solid #e5e7eb;
}

.toxic-input {
    flex: 1;
    padding: 0.75rem;
    font-size: 1.2rem;
    text-transform: uppercase;
    border: 2px solid var(--toxic-neutral);
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.3em;
    text-align: center;
    background: white;
    color: var(--toxic-dark);
}

.toxic-input::placeholder {
    color: #a1a1aa;
}

.toxic-input:focus {
    outline: none;
    border-color: var(--toxic-primary);
}

.toxic-submit-btn {
    padding: 0.75rem 2rem;
    background: var(--toxic-primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toxic-submit-btn:hover {
    background: #0019cc;
    transform: translateY(-2px);
}

.toxic-submit-btn:disabled {
    background: var(--toxic-neutral);
    cursor: not-allowed;
    transform: none;
}

/* How to Play bar */
.toxic-how-to-play-bar {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    padding: 0.4rem 1rem;
    background: #f9f9f9;
    border-top: 1px solid #e5e7eb;
}

.toxic-how-to-play-btn {
    background: transparent;
    border: 1px solid #a1a1aa !important;
    color: #555;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.03em;
}

.toxic-how-to-play-btn:hover {
    background: #e5e7eb;
    color: var(--toxic-dark);
    border-color: #555 !important;
}

/* Keyboard - Fixed at bottom, doesn't scroll */
.toxic-keyboard {
    flex: 0 0 auto !important;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem 0.5rem 1rem 0.5rem;
    background: #121213;
    border-top: 1px solid #3a3a3c;
}

.toxic-keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

#toxic-game-container .toxic-key {
    aspect-ratio: auto !important;
    flex: 1 1 auto;
    max-width: 44px;
    min-height: 58px;
    padding: 0;
    background: #818384;
    color: #fff;
    border: none !important;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    box-shadow: none !important;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toxic-game-container .toxic-key:hover {
    background: #9a9a9c;
}

#toxic-game-container .toxic-key.wide {
    aspect-ratio: auto !important;
    max-width: 90px;
    font-size: 0.8rem;
}

#toxic-game-container .toxic-key.green {
    background-color: #22c55e !important;
    color: #fff !important;
}

#toxic-game-container .toxic-key.orange {
    background-color: #f97316 !important;
    color: #fff !important;
}

#toxic-game-container .toxic-key.red {
    background-color: #ef4444 !important;
    color: #fff !important;
}

/* Disabled key — permanently knocked out, no recovery */
#toxic-game-container .toxic-key.disabled {
    background-color: #2a2a2c !important;
    color: #555 !important;
    cursor: not-allowed !important;
    text-decoration: line-through;
    opacity: 0.45;
    pointer-events: none;
}

/* Guess counter pill in the HP label row */
.toxic-guess-counter {
    margin-left: auto;
    font-size: 0.85rem;
    font-weight: 700;
    color: #333;
    background: #e5e7eb;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* Clean-streak/healing indicator row below HP bar */
.toxic-streak-row {
    min-height: 1.2em;
    text-align: center;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

#toxic-streak-display {
    /* colour set dynamically by JS */
}

/* Heal flash on HP bar */
@keyframes healPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.8); }
    60%  { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.toxic-hp-bar.healing {
    animation: healPulse 0.6s ease;
}

.toxic-modal-site-links {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: #aaa;
    text-align: center;
}

.toxic-modal-site-links a {
    color: #888;
    text-decoration: none;
}

.toxic-modal-site-links a:hover {
    color: #555;
    text-decoration: underline;
}

/* Strategy Guide */
.toxic-strategy-guide {
    background: white;
    border-left: 4px solid var(--toxic-primary);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 4px;
}

.toxic-strategy-guide h3 {
    color: var(--toxic-primary);
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 700;
}

.toxic-strategy-guide ol {
    margin-left: 1.5rem;
    line-height: 1.8;
}

.toxic-strategy-guide li {
    margin-bottom: 0.8rem;
}

.toxic-strategy-guide strong {
    color: var(--toxic-dark);
}

/* Messages */
.toxic-message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
}

.toxic-message.error {
    background: #fee2e2;
    color: var(--toxic-danger);
    border: 2px solid var(--toxic-danger);
}

.toxic-message.success {
    background: #dcfce7;
    color: var(--toxic-safe);
    border: 2px solid var(--toxic-safe);
}

.toxic-message.info {
    background: #dbeafe;
    color: var(--toxic-primary);
    border: 2px solid var(--toxic-primary);
}

/* Game Over Modal — full-screen overlay */
.toxic-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    box-sizing: border-box;
}

.toxic-modal-dismiss {
    position: absolute;
    top: 0.75rem;
    right: 0.85rem;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    color: #aaa;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    transition: color 0.15s ease;
}

.toxic-modal-dismiss:hover {
    color: #333;
    background: transparent !important;
}

/* Full-screen overlay needs relative positioning for the dismiss button */
.toxic-modal-content {
    position: relative;
    background: white;
    padding: 2rem 1.75rem;
    border-radius: 10px;
    width: 100%;
    max-width: 480px;
    text-align: center;
    max-height: 92vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.toxic-modal-content h2 {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
    color: var(--toxic-primary);
}

.toxic-modal-content .stats {
    margin: 1.25rem 0;
    padding: 0.75rem 1rem;
    background: var(--toxic-light);
    border-radius: 6px;
    text-align: left;
}

.toxic-modal-content .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 1rem;
}

.toxic-modal-content .stat-item:last-child {
    border-bottom: none;
}

/* Countdown line */
#toxic-midnight-countdown {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 1rem 0 0.5rem;
}

/* Action buttons container */
.toxic-modal-actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Full-width buttons inside the modal */
.toxic-modal-btn {
    width: 100% !important;
    padding: 0.85rem 1rem !important;
    font-size: 1.05rem !important;
    box-sizing: border-box !important;
}

.toxic-modal-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed !important;
}

.toxic-modal-note {
    margin: 0;
    font-size: 0.85rem;
    color: #666;
}

/* Phone adjustments */
@media (max-width: 480px) {
    .toxic-modal {
        padding: 0.75rem;
        align-items: flex-end; /* slide up from bottom feels more native */
    }
    .toxic-modal-content {
        padding: 1.5rem 1.25rem 2rem;
        border-radius: 12px 12px 0 0; /* bottom-sheet style */
        max-width: 100%;
        max-height: 85vh;
    }
    .toxic-modal-content h2 {
        font-size: 1.5rem;
    }
    .toxic-modal-content .stat-item {
        font-size: 0.95rem;
    }
    .toxic-modal-btn {
        padding: 1rem !important;
        font-size: 1rem !important;
    }
}

/* Debug Window */
.toxic-debug {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.9);
    color: #00ff00;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    max-width: 400px;
    max-height: 300px;
    overflow: auto;
    z-index: 999;
}

.toxic-debug pre {
    margin: 0;
    white-space: pre-wrap;
}

/* Responsive Design */
@media (max-width: 640px) {
    .toxic-game-container {
        padding: 1rem;
    }
    
    .toxic-title {
        font-size: 2rem;
    }
    
    .toxic-letter-box {
        flex: 0 0 55px;
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }
    
    .toxic-guess-row {
        max-width: 310px !important;
        gap: 5px;
    }
    
    #toxic-game-container .toxic-key {
        min-height: 50px;
        font-size: 0.85rem;
    }
    
    #toxic-game-container .toxic-key.wide {
        font-size: 0.7rem;
    }
}

/* Mobile: hide native input to force on-screen keyboard use */
#toxic-input {
    opacity: 0 !important;
    position: absolute;
    pointer-events: none;
}
