/* ==============================================
   GAMES DATABASE STYLES
   Extends the main terminal theme with game-specific components
   Features dynamic content sizing, and typing animations
   ============================================== */

/* ---------------------------------------------
   1. SELF-HOSTED FONT DEFINITIONS
   --------------------------------------------- */
@font-face {
    font-family: 'Share Tech Mono';
    src: url('https://lucidnightmare.neocities.org/media/fonts/Share_Tech_Mono/ShareTechMono-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Share Tech';
    src: url('https://lucidnightmare.neocities.org/media/fonts/Share_Tech/ShareTech-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ---------------------------------------------
   2. GAMES DATABASE VARIABLES & FONT STACKS
   --------------------------------------------- */
:root {
    /* CRT Glow Animation Colors */
    --crt-glow-start: rgba(78, 255, 56, 0.3);
    --crt-glow-peak: rgba(78, 255, 56, 0.9);
    --crt-glow-end: rgba(78, 255, 56, 0.1);

    /* Enhanced terminal font stacks */
    --terminal-font-stack: 'Share Tech Mono', 'Courier New', 'Lucida Console', 'Monaco', monospace;
    --terminal-header-font: 'Share Tech', 'Share Tech Mono', 'Arial', sans-serif;
}

/* Enhanced font rendering for crisp display */
* {
    font-family: var(--terminal-font-stack);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Apply monospace font to main content */
body {
    font-family: var(--terminal-font-stack);
    font-size: clamp(14px, 2.5vw, 16px);
}

/* Use Share Tech for headers (gives nice variety) */
.terminal-header h1,
.terminal-header h2 {
    font-family: var(--terminal-header-font);
}

/* Ensure all game content uses monospace */
.terminal-content,
.game-entry,
.game-details,
.database-controls,
.terminal-footer {
    font-family: var(--terminal-font-stack);
}

/* ---------------------------------------------
   3. CRT GLOW ANIMATION KEYFRAMES
   --------------------------------------------- */
@keyframes crt-glow-cycle {
    0% { 
        text-shadow: 0 0 5px var(--crt-glow-start);
        opacity: 0.7;
    }
    25% { 
        text-shadow: 0 0 15px var(--crt-glow-peak);
        opacity: 1;
    }
    50% { 
        text-shadow: 0 0 20px var(--crt-glow-peak);
        opacity: 1;
    }
    75% { 
        text-shadow: 0 0 10px var(--crt-glow-start);
        opacity: 0.8;
    }
    100% { 
        text-shadow: 0 0 3px var(--crt-glow-end);
        opacity: 0.6;
    }
}

/* Dynamic expand animation */
@keyframes expand-details {
    0% {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        max-height: 2000px; /* Large enough for any content */
        opacity: 1;
        padding-top: 20px;
        padding-bottom: 20px;
    }
}

@keyframes collapse-details {
    0% {
        max-height: 2000px;
        opacity: 1;
        padding-top: 20px;
        padding-bottom: 20px;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
}

/* Thoughts typing animation */
@keyframes thoughts-typing {
    0% { width: 0; opacity: 1; }
    20% { opacity: 1; }
    40% { opacity: 1; }
    45% { opacity: 0.9; }
    50% { opacity: 0.7; }
    55% { opacity: 0.5; }
    60% { opacity: 0.3; }
    65% { opacity: 0.1; }
    70% { opacity: 0; }
    100% { opacity: 0; }
}

/* Character reveal animation for typing effect */
@keyframes char-reveal {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Isolated typing cursor animation - prevents character inheritance */
@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ---------------------------------------------
   4. GAMES DATABASE CONTAINER
   --------------------------------------------- */
.games-database {
    background-color: rgba(15, 31, 14, 0.7);
    border: 1px solid var(--terminal-border);
    padding: 20px;
    position: relative;
    margin-bottom: 20px;
}

.games-database::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

.database-stats {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid var(--terminal-border);
    background-color: var(--terminal-dark);
}

.database-stats p {
    margin: 5px 0;
    color: var(--terminal-highlight);
}

/* ---------------------------------------------
   5. GAME ENTRY COMPONENTS
   --------------------------------------------- */
.games-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.game-entry {
    border: 1px solid var(--terminal-border);
    background-color: rgba(15, 31, 14, 0.8);
    position: relative;
    overflow: hidden;
}

.game-header {
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.game-header:hover {
    background-color: rgba(78, 255, 56, 0.1);
    border-bottom-color: var(--terminal-border);
    box-shadow: inset 0 0 10px var(--terminal-glow);
}

.game-header.expanded {
    border-bottom-color: var(--terminal-border);
    background-color: rgba(78, 255, 56, 0.05);
}

.game-title {
    font-size: clamp(16px, 4vw, 18px);
    font-weight: bold;
    color: var(--terminal-highlight);
    margin: 0;
    letter-spacing: 1px;
}

.game-title::before {
    content: ">";
    margin-right: 10px;
    color: var(--terminal-text);
}

.expand-indicator {
    font-size: 16px;
    color: var(--terminal-text);
    transition: transform 0.3s ease;
}

.expand-indicator.expanded {
    transform: rotate(90deg);
}

/* ---------------------------------------------
   6. DYNAMIC GAME DETAILS WITH CRT GLOW
   --------------------------------------------- */
.game-details {
    max-height: 0;
    overflow: hidden;
    padding: 0 20px;
    background-color: rgba(10, 10, 10, 0.9);
    border-top: 1px solid var(--terminal-border);
    transition: all 0.6s ease;
    opacity: 0;
}

.game-details.expanded {
    animation: expand-details 0.6s ease forwards;
    overflow: visible; /* Allow content to be fully visible */
}

.game-details.collapsing {
    animation: collapse-details 0.6s ease forwards;
}

.game-details-content {
    animation: crt-glow-cycle 3s infinite;
    padding: 10px 0;
    min-height: auto; /* Dynamic height based on content */
}

.detail-row {
    display: flex;
    margin: 15px 0;
    align-items: flex-start;
    gap: 15px;
}

.detail-label {
    color: var(--terminal-highlight);
    font-weight: bold;
    min-width: 120px;
    text-transform: uppercase;
}

.detail-label::after {
    content: ":";
    margin-left: 5px;
}

.detail-value {
    color: var(--terminal-text);
    flex: 1;
    line-height: 1.4;
}

/* Star Rating System */
.star-rating {
    display: flex;
    gap: 2px;
}

.star {
    color: var(--terminal-border);
    font-size: 16px;
}

.star.filled {
    color: var(--terminal-highlight);
    text-shadow: 0 0 5px var(--terminal-glow);
}

/* Enhanced Game Thoughts with Typing Animation */
.game-thoughts {
    font-style: italic;
    border-left: 3px solid var(--terminal-border);
    padding-left: 15px;
    margin: 20px 0;
    background-color: rgba(78, 255, 56, 0.05);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 60px; /* Minimum space for typing animation */
}

.game-thoughts strong {
    color: var(--terminal-highlight);
    display: block;
    margin-bottom: 10px;
}

/* Typing animation container for thoughts */
.thoughts-content {
    position: relative;
    overflow: hidden;
}

.thoughts-content.typing {
    position: relative;
}

/* Stable character styling - completely isolated from cursor */
.typed-char-stable {
    opacity: 1 !important;
    animation: none !important;
    display: inline !important;
}

.thoughts-content .char {
    opacity: 0;
}

.thoughts-content .char.revealed {
    opacity: 1;
    animation: none;
}

.typing-cursor-isolated {
    display: inline-block;
    background-color: var(--terminal-text);
    animation: cursor-blink 1s infinite;
    margin-left: 2px;
    vertical-align: baseline;
    width: auto;
    height: auto;
}

/* Hours and Date Styling */
.completion-info {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dotted var(--terminal-border);
}

.hours-played {
    color: var(--terminal-highlight);
}

.completion-date {
    color: var(--terminal-text);
    font-size: 14px;
}

/* ---------------------------------------------
   7. GAME IMAGE STYLING
   --------------------------------------------- */
.game-image-container {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    border: 1px solid var(--terminal-border);
    background-color: rgba(10, 10, 10, 0.8);
    position: relative;
}

.game-image-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

.game-image {
    max-width: 100%;
    max-height: 250px; /* Slightly larger for better visibility */
    width: auto;
    height: auto;
    border: 1px solid var(--terminal-border);
    box-shadow: 0 0 10px var(--terminal-glow);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.game-image:hover {
    box-shadow: 0 0 20px var(--terminal-glow);
    transform: scale(1.02);
}

.game-image-label {
    display: block;
    margin-top: 10px;
    font-size: 12px;
    color: var(--terminal-highlight);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-image-label::before {
    content: ">";
    margin-right: 5px;
}

/* Image loading states */
.game-image.loading {
    opacity: 0.5;
    filter: blur(2px);
}

.game-image.error {
    opacity: 0.3;
    border-color: #ff4444;
}

.image-error-message {
    color: #ff4444;
    font-size: 12px;
    margin-top: 5px;
    text-align: center;
}

.image-error-message::before {
    content: "[ERROR] ";
}

/* CRT glow effect for images */
.game-image-container.crt-glow {
    animation: crt-glow-cycle 3s infinite;
}

/* ---------------------------------------------
   8. DATABASE CONTROLS
   --------------------------------------------- */
.database-controls {
    margin-top: 20px;
}

.database-control-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.database-control-buttons .terminal-button {
    min-width: 120px;
    text-align: center;
}

/* ---------------------------------------------
   9. RESPONSIVE DESIGN
   --------------------------------------------- */
@media (max-width: 768px) {
    .terminal-content {
        font-size: clamp(13px, 3vw, 15px);
        line-height: 1.4;
    }

    .game-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .game-title {
        font-size: clamp(16px, 4vw, 18px);
    }

    .game-details {
        font-size: clamp(12px, 2.8vw, 14px);
        padding: 0 15px;
    }

    .detail-row {
        flex-direction: column;
        gap: 5px;
    }

    .detail-label {
        min-width: auto;
    }

    .completion-info {
        flex-direction: column;
        gap: 10px;
    }

    .database-stats {
        padding: 8px;
    }

    .game-image {
        max-height: 180px;
    }

    .game-image-container {
        padding: 10px;
        margin-bottom: 20px;
    }

    .game-thoughts {
        padding-left: 10px;
        margin: 15px 0;
        min-height: 50px;
    }

    .database-control-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .database-control-buttons .terminal-button {
        min-width: 200px;
    }
}

/* High DPI display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    * {
        -webkit-font-smoothing: subpixel-antialiased;
    }
}

/* Zoom-friendly sizing using relative units */
.terminal-header h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
}

.terminal-header h2 {
    font-size: clamp(1rem, 3vw, 1.5rem);
}

/* ---------------------------------------------
   10. ACCESSIBILITY ENHANCEMENTS
   --------------------------------------------- */
.game-header:focus {
    outline: 2px solid var(--terminal-highlight);
    outline-offset: 2px;
}

.game-entry[aria-expanded="true"] .game-header {
    background-color: rgba(78, 255, 56, 0.1);
}

/* Screen reader only content */
.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;
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    .game-details.expanded {
        animation: none;
        max-height: none;
        opacity: 1;
        padding: 20px;
    }

    .thoughts-content .char {
        animation: none;
        opacity: 1;
    }

    .typing-cursor-isolated {
        animation: none;
        opacity: 1;
    }
}

/* ROBCO Host Interface Styles */
#robco-host-interface {
    margin: 20px 0;
    border: 2px solid var(--terminal-border);
    background-color: rgba(15, 31, 14, 0.9);
    position: relative;
}

.host-panel {
    padding: 15px;
    transition: opacity 0.3s ease;
}

.host-panel.host-disabled {
    opacity: 0.5;
}

.host-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--terminal-border);
}

.host-name {
    color: var(--terminal-highlight);
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 1px;
}

.host-status {
    color: #00ff00;
    font-size: 12px;
    animation: crt-glow-cycle 2s infinite;
}

.host-commentary {
    min-height: 60px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--terminal-border);
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

.commentary-text {
    color: var(--terminal-text);
    line-height: 1.5;
    font-family: var(--terminal-font-stack);
}

.commentary-text.greeting {
    color: var(--terminal-highlight);
}

.commentary-text.game-reaction {
    color: #ffff00;
}

.commentary-text.button-reaction {
    color: #00ffff;
}

.commentary-text.idle {
    color: #ff8800;
    font-style: italic;
}

.host-avatar {
    font-size: 16px;
    margin-right: 8px;
}

.host-cursor {
    animation: cursor-blink 1s infinite;
    color: var(--terminal-highlight);
}

.host-offline {
    color: #666;
    font-style: italic;
}

.host-controls {
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .host-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .host-commentary {
        min-height: 50px;
        padding: 10px;
    }
}
