/*
=================================================================
| RETRO WAVE THEME - Adapted for the Revamped Generic HTML      |
=================================================================
*/

/* --- 1. Root Variables & Base Styles --- */
:root {
    --background: #1a0f2b;
    --surface: #2c1a47;
    --text-primary: #e0d7ff;
    --text-secondary: #a093c4;
    --glow-magenta: #ff00c1;
    --glow-cyan: #00f2ff;
    --accent-yellow: #faff00;
    --border-radius: 8px;
    --font-primary: 'Orbitron', sans-serif; /* Recommended: Add font link to HTML */
    --font-mono: 'Roboto Mono', monospace;
    --transition: all 0.3s ease-in-out;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-mono);
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
}

/* Animated Grid Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-image:
        linear-gradient(to right, rgba(0, 242, 255, 0.2) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 242, 255, 0.2) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: grid-scroll 10s linear infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes grid-scroll {
    from { background-position: 0 0; }
    to { background-position: 40px 80px; }
}

/* --- 2. Layout & Core Structure --- */
.wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem;
    position: relative;
    z-index: 1;
}

.page {
    background: rgba(26, 15, 43, 0.85);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glow-cyan);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}

/* Decorative elements that don't fit the theme are hidden */
.corner {
    display: none;
}

/* Progress bar styling */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--glow-magenta), var(--glow-cyan));
    z-index: 1000;
    transition: width 0.1s ease;
    box-shadow: 0 0 5px var(--glow-cyan);
}

/* Separators styled to match the theme */
.separator {
    height: 2px;
    border: none;
    background-image: linear-gradient(to right, transparent, var(--glow-cyan), transparent);
    margin: 3rem 0;
}

/* --- 3. Controls & Navigation --- */
.controls {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.button, .dropdown-trigger {
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--glow-cyan);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 8px rgba(0, 242, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.button:hover, .dropdown-trigger:hover {
    color: var(--accent-yellow);
    background: #3c2a5f;
    border-color: var(--accent-yellow);
    box-shadow: 0 0 15px rgba(250, 255, 0, 0.7);
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--glow-cyan);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    z-index: 1002;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    margin-top: 0.1rem;
    overflow: auto;
    max-height: 400px;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background-color: rgba(0, 242, 255, 0.2);
    color: var(--glow-cyan);
}

/* --- 4. Window Decoration --- */
.window {
    border: 2px solid var(--glow-magenta);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    border-bottom: none;
}
.window-titlebar {
    background: var(--surface);
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-primary);
    text-transform: uppercase;
}

.window-title {
    color: var(--glow-magenta);
    text-shadow: 0 0 5px var(--glow-magenta);
}

.window-button {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid var(--text-secondary);
    border-radius: 2px;
    margin-left: 5px;
    line-height: 10px;
    text-align: center;
    font-size: 10px;
    color: var(--text-secondary);
}

/* --- 5. Main Page: Header & Cards --- */
.header {
    text-align: center;
    padding: 2rem;
}

.title-main {
    font-family: var(--font-primary);
    font-size: 3.5rem;
    color: #fff;
    margin-bottom: 1rem;
    text-transform: uppercase;
    animation: flicker 3s infinite alternate;
}

@keyframes flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% {
        text-shadow:
            0 0 4px #fff,
            0 0 11px var(--glow-magenta),
            0 0 19px var(--glow-magenta),
            0 0 40px var(--glow-magenta);
    }
    20%, 24%, 55% { text-shadow: none; }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.category {
    padding: 0 1.5rem;
}

.title-category {
    font-size: 2.25rem;
    color: var(--glow-cyan);
    text-shadow: 0 0 5px var(--glow-cyan), 0 0 10px var(--glow-cyan);
    padding-bottom: 0.5rem;
    margin: 2rem 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.link {
    text-decoration: none;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--glow-magenta);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: var(--transition);
    box-shadow: 0 0 15px rgba(255, 0, 193, 0.3);
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 25px rgba(0, 242, 255, 0.5);
    border-color: var(--glow-cyan);
}

.card-title {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    color: var(--accent-yellow);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 4px var(--accent-yellow);
}

.card-path {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    word-break: break-all;
}

.card-meta {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-actions {
    margin-top: auto; /* Pushes button to the bottom */
    text-align: right;
}

.button-read {
    background: transparent;
    border: 1px solid var(--glow-magenta);
    color: var(--glow-magenta);
}
.button-read:hover {
    background: rgba(255, 0, 193, 0.2);
    color: #fff;
    box-shadow: 0 0 10px var(--glow-magenta);
}

/* --- 6. Markdown Content Page --- */
#content {
    padding: 1rem 2rem 2rem;
}

#content h1, #content h2, #content h3, #content h4 {
    font-family: var(--font-primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#content h1 {
    font-size: 2.8rem;
    color: var(--glow-cyan);
    text-shadow: 0 0 8px var(--glow-cyan);
    margin: 1.5rem 0 2rem 0;
    text-align: center;
}

#content h2 {
    font-size: 2rem;
    margin: 3rem 0 1.5rem 0;
    color: var(--glow-magenta);
    text-shadow: 0 0 5px var(--glow-magenta);
    border-bottom: 2px solid var(--glow-magenta);
    padding-bottom: 0.5rem;
}

#content p {
    margin: 1.5rem 0;
    font-size: 1.1rem;
}

#content a {
    color: var(--glow-cyan);
    text-decoration: none;
    font-weight: bold;
    transition: var(--transition);
    text-shadow: 0 0 3px var(--glow-cyan);
}

#content a:hover {
    color: var(--accent-yellow);
    text-shadow: 0 0 5px var(--accent-yellow);
}

#content blockquote {
    margin: 2.5rem 0;
    padding: 1.5rem;
    background: transparent;
    border: 2px solid var(--glow-magenta);
    border-radius: var(--border-radius);
    box-shadow: inset 0 0 10px var(--glow-magenta), 0 0 15px rgba(255, 0, 193, 0.3);
    font-style: italic;
    color: var(--text-secondary);
}

#content code {
    background: var(--surface);
    color: var(--accent-yellow);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
}

#content pre {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 2.5rem 0;
    border: 1px solid var(--glow-cyan);
    box-shadow: inset 0 0 8px var(--glow-cyan);
}

#content img {
    max-width: 100%;
    margin: 2.5rem auto;
    display: block;
    border-radius: var(--border-radius);
    border: 2px solid var(--glow-magenta);
    box-shadow: 0 0 20px var(--glow-magenta);
    transition: var(--transition);
    cursor: pointer;
}

#content img:hover {
    transform: scale(1.02);
    box-shadow: 0 0 30px var(--glow-cyan);
    border-color: var(--glow-cyan);
}

#content hr {
    border: none;
    height: 2px;
    background-image: linear-gradient(to right, transparent, var(--glow-cyan), transparent);
    margin: 4rem 0;
}

/* --- 7. Footer --- */
.footer {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

/* --- 8. Modals & Messages --- */
.message {
    padding: 3rem;
    text-align: center;
    font-style: italic;
}

.message-loading {
    color: var(--text-secondary);
}

.message-error {
    color: #ff4d6a;
    background-color: rgba(255, 0, 193, 0.1);
    border: 1px solid #ff4d6a;
    border-radius: var(--border-radius);
}

.modal {
    display: flex;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    align-items: center;
    justify-content: center;
}

.modal.modal-open {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.modal-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 2001;
}

.modal-content .image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--border-radius);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
}

.image-caption {
    color: #fff;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
}

.spinner {
    border: 4px solid #3c2a5f;
    border-top: 4px solid var(--glow-cyan);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: auto;
}

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

/* --- 9. Responsive Design --- */
@media (max-width: 768px) {
    .wrapper {
        padding: 2rem 1rem;
    }
    .title-main, #content h1 {
        font-size: 2.5rem;
    }
    .grid {
        grid-template-columns: 1fr;
    }
}