/* ============================================
   ~/nerdhaven — retro terminal blog theme
   ============================================ */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0a0a0a;
    --bg-surface: #0d0d0d;
    --bg-hover: #111111;
    --text: #ff6600;
    --text-muted: #cc5200;
    --accent: #ff6600;
    --accent-glow: rgba(255, 102, 0, 0.15);
    --accent-bright: #ff8533;
    --border: rgba(255, 102, 0, 0.2);
    --border-solid: #ff6600;
    --max-width: 950px;
    --terminal-glow: #ff6600;
    --glow: 0 0 1px var(--terminal-glow), 0 0 2px var(--terminal-glow);
    --green: #00ff00;
}

html { font-size: 16px; }

body {
    font-family: "Fira Code", "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 3rem;
}

::selection {
    background: var(--accent);
    color: var(--bg);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}
a:hover {
    color: var(--accent-bright);
    text-shadow: var(--glow);
}

/* ============================================
   CRT Scanline Overlay
   ============================================ */
body::before {
    content: '';
    position: fixed;
    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;
    z-index: 9999;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 102, 0, 0.06);
    pointer-events: none;
    z-index: 9998;
    animation: scanline-scroll 8s linear infinite;
}

@keyframes scanline-scroll {
    0% { top: -4px; }
    100% { top: 100vh; }
}

/* ============================================
   Text Glow Utility
   ============================================ */
.text-glow {
    text-shadow: var(--glow);
}

/* ============================================
   Blinking Cursor
   ============================================ */
.blinking-cursor::after {
    content: '\2588';
    animation: blink-cursor 1s step-end infinite;
    margin-left: 2px;
}

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* ============================================
   Glitch Effect on Hover
   ============================================ */
.glitch {
    position: relative;
    transition: all 0.2s ease;
    display: inline-block;
}

.glitch:hover {
    animation: glitch-animation 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes glitch-animation {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

/* ============================================
   Header
   ============================================ */
.site-header {
    padding: 3rem 1.5rem 0;
}
.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-solid);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.site-title {
    font-size: 2.25rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.02em;
    text-shadow: var(--glow);
    display: inline;
}
.site-title:hover { color: var(--accent-bright); text-decoration: none; }
.site-title .prompt {
    color: var(--accent);
    font-weight: 400;
}

.site-subtitle {
    font-size: 0.875rem;
    color: var(--text);
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.site-nav {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}
.site-nav a {
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 400;
    position: relative;
    display: inline-block;
}
.site-nav a::before { content: "["; }
.site-nav a::after {
    content: "]";
    position: static;
    background: none;
    width: auto;
    height: auto;
    bottom: auto;
    left: auto;
}
.site-nav a:hover {
    text-decoration: none;
    color: var(--accent-bright);
    text-shadow: var(--glow);
}
.site-nav a.active {
    text-shadow: var(--glow);
}

/* Mobile Header */
@media (max-width: 600px) {
    .site-header { padding: 2rem 1.25rem 0; }
    .site-title { font-size: 1.75rem; }
    .site-nav { gap: 1rem; flex-wrap: wrap; }
    .site-nav a { font-size: 0.8rem; }
}

@media (min-width: 992px) {
    .site-header { padding: 3rem 1.5rem 0; }
    .site-title { font-size: 2.5rem; }
}

/* ============================================
   Content
   ============================================ */
.content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

.content > h1,
.section-heading {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.02em;
    text-shadow: var(--glow);
}

/* ============================================
   Post Cards (Home)
   ============================================ */
.post-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-solid);
    background: var(--bg-surface);
    transition: background 0.2s ease;
}
.post-card:hover {
    background: var(--bg-hover);
}

.post-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.post-card time {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.6;
    letter-spacing: 0.03em;
}

.post-card-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.post-card-tags .tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border-solid);
    color: var(--text);
    opacity: 0.6;
}

.post-card h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    text-shadow: var(--glow);
}
.post-card a { text-decoration: none; }
.post-card a h2 { color: var(--accent); transition: color 0.2s ease; }
.post-card a:hover h2 { color: var(--accent-bright); }

.post-card .excerpt {
    margin-bottom: 1rem;
    color: var(--text);
    opacity: 0.8;
    font-size: 0.875rem;
    line-height: 1.6;
}

.post-card .read-more {
    font-size: 0.875rem;
    color: var(--accent);
    display: inline-block;
}
.post-card .read-more:hover {
    text-shadow: var(--glow);
}

/* ============================================
   Post List (Compact)
   ============================================ */
.post-list-compact .post-list-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.125rem;
    gap: 1.5rem;
    transition: background 0.2s ease;
}
.post-list-compact .post-list-item:hover {
    background: var(--bg-surface);
}
.post-list-compact .post-list-item a {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.post-list-compact .post-list-item time {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.6;
    white-space: nowrap;
    letter-spacing: 0.03em;
}

/* ============================================
   Post Detail
   ============================================ */
.post-header { margin-bottom: 2.5rem; }
.post-header h1 {
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--accent);
    text-shadow: var(--glow);
}
.post-meta {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text);
    opacity: 0.6;
    display: flex;
    gap: 0.75rem;
    letter-spacing: 0.02em;
}

.post-content { line-height: 1.75; font-size: 0.95rem; }
.post-content h2 {
    font-size: 1.15rem;
    margin: 2rem 0 0.75rem;
    font-weight: 500;
    color: var(--accent);
    text-shadow: var(--glow);
}
.post-content h3 {
    font-size: 1rem;
    margin: 1.5rem 0 0.5rem;
    font-weight: 500;
    color: var(--accent);
}
.post-content p { margin-bottom: 1rem; }
.post-content ul, .post-content ol { margin: 0.5rem 0 1rem 1.5rem; }
.post-content li { margin-bottom: 0.25rem; }
.post-content blockquote {
    border-left: 2px solid var(--accent);
    padding: 0.5rem 1rem;
    color: var(--text);
    opacity: 0.8;
    margin: 1.25rem 0;
    background: var(--bg-surface);
}
.post-content img.post-image {
    max-width: 100%;
    height: auto;
    margin: 1.25rem 0;
    border: 1px solid var(--border);
}
.post-content a.post-attachment {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border-solid);
    font-size: 0.8rem;
    transition: border-color 0.2s ease;
}
.post-content a.post-attachment:hover {
    border-color: var(--accent-bright);
}

/* Code */
.post-content code {
    background: var(--bg-surface);
    padding: 0.15rem 0.4rem;
    font-size: 0.85em;
    color: var(--accent-bright);
    border: 1px solid var(--border);
}
.post-content pre {
    background: var(--bg-surface);
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.25rem 0;
    border: 1px solid var(--border);
}
.post-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    color: var(--text);
    border: none;
}
.post-content .highlight {
    background: var(--bg-surface);
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.25rem 0;
    border: 1px solid var(--border);
}
.post-content .highlight pre {
    background: none;
    padding: 0;
    margin: 0;
    border: none;
}

/* Markdown tables */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.85rem;
}
.post-content th, .post-content td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}
.post-content th {
    background: var(--bg-surface);
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

/* ============================================
   CSV Table Loader styles
   ============================================ */
.csv-table-container {
    overflow-x: auto;
    margin: 1.5rem 0;
    background: var(--bg);
}

.csv-table {
    width: auto;
    border-collapse: collapse;
    border: 1px solid var(--border-solid);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.1px;
    background: var(--bg);
    color: var(--accent);
    overflow: hidden;
}

.csv-table thead {
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.csv-table th {
    padding: 7px 7px 2px 7px;
    text-align: left;
    font-weight: 800;
    font-size: 0.95rem;
    text-transform: uppercase;
    color: var(--accent-bright);
    border-bottom: 2px solid var(--border-solid);
    user-select: none;
    position: relative;
    box-sizing: border-box;
    text-shadow: var(--glow);
}

.csv-table th:hover { background: var(--bg-surface); }

.csv-table th .sort-indicator {
    margin-left: 0;
    opacity: 0.3;
    transition: opacity 0.5s ease;
}

.csv-table th:hover .sort-indicator { opacity: 0.6; }

.csv-table td {
    padding: 7px 7px;
    border-bottom: 1px solid rgba(255, 102, 0, 0.1);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.csv-table tbody tr { transition: background-color 0.2s ease; }
.csv-table tbody tr:hover { background: #1a0d00; }
.csv-table tbody tr:last-child td { border-color: var(--border); }

.csv-table .team-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
    display: inline-block;
}

.csv-table td[style*="background-color"] {
    font-weight: 400;
    text-align: center;
    position: relative;
    transition: none;
}

.csv-table td:nth-child(2) { color: var(--accent-bright); }

.csv-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--bg);
}

.csv-table tbody tr:hover td:first-child { background: #1a0d00; }

.table-title {
    font-size: 125%;
    font-weight: bold;
    margin: 0 0 4px;
    text-align: left;
    max-width: 100%;
    color: var(--accent-bright);
    font-family: inherit;
    white-space: pre-wrap;
    text-shadow: var(--glow);
}

.table-subtitle {
    font-size: 85%;
    font-style: italic;
    margin: 0 0 2px;
    line-height: 1.5;
    color: var(--accent);
    font-family: inherit;
    white-space: pre-wrap;
}

.table-source {
    font-size: 12px;
    font-weight: bold;
    font-style: italic;
    text-align: center;
    color: var(--accent);
    font-family: inherit;
    white-space: pre-wrap;
}

.csv-table th:focus,
.csv-table td:focus {
    outline: 2px solid var(--accent-bright);
    outline-offset: -2px;
}

.error {
    color: #af0f00;
    padding: 20px;
    text-align: center;
    background: var(--bg);
    border-left: 4px solid #af0f00;
}

/* ============================================
   Load More / HTMX
   ============================================ */
.load-more {
    text-align: center;
    padding: 2rem;
    color: var(--text);
    opacity: 0.6;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

/* ============================================
   Contact
   ============================================ */
.contact-page {
    font-size: 0.9rem;
}

.contact-box {
    border: 1px solid var(--border-solid);
    background: var(--bg-surface);
    margin-bottom: 1.5rem;
}

.contact-box-header {
    padding: 0.6rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
    text-shadow: var(--glow);
    border-bottom: 1px solid rgba(255, 102, 0, 0.15);
}

.contact-box-body {
    padding: 1.25rem;
}

.contact-box-body p {
    margin-bottom: 0.75rem;
    color: var(--text);
    opacity: 0.8;
    line-height: 1.7;
}

.contact-box-body p:last-child {
    margin-bottom: 0;
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.contact-link-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.contact-link-label {
    color: var(--accent);
    font-weight: 500;
    min-width: 7rem;
    flex-shrink: 0;
}

.contact-link-sep {
    color: var(--text);
    opacity: 0.3;
    flex-shrink: 0;
}

.contact-link-item a,
.contact-link-item span:last-child {
    color: var(--text);
    opacity: 0.8;
}

.contact-link-item a:hover {
    opacity: 1;
    color: var(--accent-bright);
}

.contact-pgp-note {
    text-align: center;
    margin-top: 2rem;
}

.contact-pgp-note p {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.4;
}

@media (max-width: 600px) {
    .contact-link-label {
        min-width: 5rem;
    }
    .contact-link-item {
        flex-wrap: wrap;
    }
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
    padding-top: 10px;
    margin-top: auto;
    text-align: center;
}
.site-footer p {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.6;
    letter-spacing: 0.03em;
}

.badge-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.badge-88x31 {
    width: 88px;
    height: 31px;
    background: #000;
    border: 2px solid var(--badge-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--badge-color);
    text-shadow: 0 0 5px var(--badge-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.badge-88x31:hover {
    background: rgba(255, 255, 255, 0.05);
}

.badge-88x31 .badge-text {
    font-size: 8px;
    font-weight: bold;
    line-height: 1;
    letter-spacing: 0.05em;
}

.badge-88x31 .badge-subtext {
    font-size: 7px;
    line-height: 1;
    margin-top: 2px;
    letter-spacing: 0.03em;
}

/* ============================================
   Music Page
   ============================================ */
.music-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.music-stat-box {
    border: 1px solid var(--border-solid);
    background: var(--bg-surface);
    padding: 1rem;
    text-align: center;
}

.music-stat-value {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--accent);
    text-shadow: var(--glow);
    margin-bottom: 0.25rem;
}

.music-stat-label {
    font-size: 0.7rem;
    color: var(--text);
    opacity: 0.6;
    letter-spacing: 0.1em;
}

.music-list-box {
    border: 1px solid var(--border-solid);
    background: var(--bg-surface);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.music-list-item {
    padding: 0.5rem 0;
}

.music-list-item + .music-list-item {
    border-top: 1px solid rgba(255, 102, 0, 0.08);
}

.music-list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.2rem;
}

.music-list-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.music-list-num {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.4;
    flex-shrink: 0;
}

.music-list-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--accent);
}

.music-list-plays {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.6;
    white-space: nowrap;
    flex-shrink: 0;
}

.music-list-sub {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 2rem;
}

.music-list-artist {
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.6;
    flex-shrink: 0;
}

.music-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 102, 0, 0.1);
    overflow: hidden;
    max-width: 200px;
}

.music-progress-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    opacity: 0.7;
}

.music-footer-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.4;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-solid);
}

@media (max-width: 600px) {
    .music-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .music-list-sub {
        margin-left: 1.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    .music-progress-bar {
        max-width: 150px;
    }
}

/* ============================================
   Status Bar (fixed bottom)
   ============================================ */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-hover);
    border-top: 1px solid var(--border-solid);
    padding: 0.4rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    z-index: 50;
    color: var(--accent);
    text-shadow: var(--glow);
}

.status-bar-left,
.status-bar-right {
    display: flex;
    gap: 1.5rem;
}


/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
    .content { padding: 0.25rem 1.5rem; }
    .post-list-compact .post-list-item { flex-direction: column; gap: 0.1rem; }
    .site-footer { padding-top: 15x; }
    .status-bar { font-size: 9px; position: static; border-top: 1px solid var(--border-solid);}
    .status-bar .status-bar-left { display:none; }
    .status-bar .status-bar-right {gap: 0.5rem; }
    .post-card-header { flex-direction: column; gap: 0.5rem; }
    body {
        padding-bottom: 0;
    }
}

@media (max-width: 900px) {
    .status-bar { font-size: 10px; }
}
