/**
 * ============================================================================
 * THE GREAT STREAMING QUEST - Main Stylesheet (Heavy Armor)
 * ============================================================================
 *
 * This CSS file is part of the "Heavy Armor" that the Hero (Browser) downloads
 * WHILE the Quest Giver (Server) is fetching data from the Dungeon (Database).
 *
 * Because the <head> is streamed instantly, the browser starts downloading
 * this file immediately - even before the <body> content arrives!
 */

:root {
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --hero-color: #3fb950;
    --server-color: #58a6ff;
    --system-color: #f0883e;
    --treasure-gold: #ffd700;
    --time-pink: #ff7b72;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Home Button */
.home-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text);
    font-size: 1.25rem;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    z-index: 1000;
}

.home-btn:hover {
    background: var(--border);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.home-btn:active {
    transform: translateY(0);
}

body {
    font-family: 'Fira Code', monospace;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    font-family: 'MedievalSharp', cursive;
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--treasure-gold), #ff9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #8b949e;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Legend Component */
.legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.legend-icon {
    font-size: 1.2rem;
}

/* Quest Log Component */
.quest-log {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.8;
    min-height: 300px;
}

.quest-log h2 {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Log Entry Animation */
.log-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.4rem 0;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.timestamp {
    color: var(--time-pink);
    font-weight: bold;
    min-width: 70px;
    font-size: 0.85rem;
}

.actor {
    font-weight: bold;
    min-width: 120px;
}

.actor.hero { color: var(--hero-color); }
.actor.server { color: var(--server-color); }
.actor.system { color: var(--system-color); }

.message {
    flex: 1;
}

/* Loading Indicator */
.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(88, 166, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--server-color);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--server-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Treasure Box Component */
.treasure-box {
    margin-top: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #2d1f00, #3d2900);
    border: 3px solid var(--treasure-gold);
    border-radius: 12px;
    text-align: center;
    animation: treasureReveal 0.6s ease-out;
}

@keyframes treasureReveal {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.treasure-box h3 {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.8rem;
    color: var(--treasure-gold);
    margin-bottom: 0.5rem;
}

.treasure-box p {
    color: #d4a574;
}

/* Stats Grid */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--hero-color);
}

.stat-label {
    font-size: 0.75rem;
    color: #8b949e;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design - Tablet */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }
    
    .container {
        max-width: 100%;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
        margin-bottom: 1.5rem;
    }
    
    .legend {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .legend-item {
        font-size: 0.75rem;
        gap: 0.4rem;
    }
    
    .legend-icon {
        font-size: 1rem;
    }
    
    .quest-log {
        padding: 1rem;
        font-size: 0.85rem;
        line-height: 1.6;
    }
    
    .quest-log h2 {
        font-size: 1.1rem;
    }
    
    .log-entry {
        gap: 0.5rem;
        padding: 0.3rem 0;
    }
    
    .timestamp {
        font-size: 0.75rem;
        min-width: 60px;
    }
    
    .actor {
        min-width: 100px;
        font-size: 0.8rem;
    }
    
    .loading {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    .treasure-box {
        padding: 1.25rem;
    }
    
    .treasure-box h3 {
        font-size: 1.4rem;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .stat {
        padding: 0.75rem 0.5rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 480px) {
    .home-btn {
        width: 38px;
        height: 38px;
        top: 0.5rem;
        left: 0.5rem;
        font-size: 1rem;
    }
    
    body {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.4rem;
    }
    
    .subtitle {
        font-size: 0.7rem;
    }
    
    .legend {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .quest-log {
        padding: 0.75rem;
        font-size: 0.8rem;
        min-height: 200px;
    }
    
    .quest-log h2 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .log-entry {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.4rem 0;
        border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    }
    
    .log-entry:last-child {
        border-bottom: none;
    }
    
    .timestamp,
    .actor {
        min-width: auto;
    }
    
    .timestamp {
        font-size: 0.7rem;
    }
    
    .actor {
        font-size: 0.75rem;
    }
    
    .message {
        font-size: 0.75rem;
        padding-left: 0.5rem;
    }
    
    .loading {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .treasure-box {
        padding: 1rem;
        margin-top: 1rem;
    }
    
    .treasure-box h3 {
        font-size: 1.2rem;
    }
    
    .treasure-box p {
        font-size: 0.8rem;
    }
    
    .stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .stat {
        padding: 0.6rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
        text-align: right;
    }
}

/* Footer */
.footer {
    margin-top: 2rem;
    padding: 1rem;
    text-align: center;
    font-size: 0.75rem;
    color: #484f58;
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--server-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .footer {
        font-size: 0.65rem;
        padding: 0.75rem;
        margin-top: 1.5rem;
    }
}
