/* Teletext Theme CSS - CRT Monitor Aesthetic */
/* Created: November 2025 */
/* Refined with input from Clive (ChatGPT) and Claude (Anthropic) */

/* ============================================
   GLOBAL
   ============================================ */

/* Prevent page jiggle when scrollbar appears/disappears */
html {
    overflow-y: scroll;
}

/* ============================================
   FONTS
   ============================================ */

@font-face {
    font-family: 'European Teletext';
    src: url('/lib/fonts/european_teletext/EuropeanTeletext.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'European Teletext Taken';
    src: url('/lib/fonts/european_teletext_taken/EuropeanTeletextTaken.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

/* ============================================
   COLOR PALETTE
   ============================================ */

:root {
    --teletext-bg: #000000;
    --teletext-text: #00FF00;
    --teletext-yellow: #FFFF00;
    --teletext-cyan: #00FFFF;
    --teletext-magenta: #FF00FF;
    --teletext-red: #FF0000;
    --teletext-blue: #0000FF;
    --teletext-white: #FFFFFF;
}

/* ============================================
   BASE STYLES
   ============================================ */

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

body {
    background: var(--teletext-bg);
    color: var(--teletext-cyan);
    font-family: 'Courier New', 'Courier', monospace;
    font-size: 18px;
    line-height: 1.6;
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1 {
    color: var(--teletext-text);
    font-size: 3em;
    font-weight: bold;
    margin: 1em 0 0.3em 0;  /* Reduced bottom margin to group with post-meta */
    letter-spacing: 2px;
}

h2 {
    color: var(--teletext-text);
    font-size: 2em;
    font-weight: bold;
    margin: 1.5em 0 0.5em 0;
    letter-spacing: 1px;
}

/* Welcome banner on homepage */
.welcome-banner {
    border-top: 1px solid var(--teletext-yellow);
    border-bottom: 1px solid var(--teletext-yellow);
    padding: 6px 0;  /* Match post-meta padding */
    margin: 2em 0;  /* Increased vertical spacing for breathing room */
}

.welcome-banner h1 {
    color: var(--teletext-cyan);
    font-size: 1em;  /* Match body text size */
    font-weight: normal;  /* Not bold - less dominant */
    margin: 0;
    letter-spacing: 0.5px;
    line-height: 1.6;  /* Match body text line-height */
}

.welcome-banner a {
    color: var(--teletext-cyan);
    text-decoration: underline;
    border-bottom: none;  /* Override default link border */
}

.welcome-banner a:hover {
    color: var(--teletext-yellow);  /* Hover state for visual feedback */
}

/* Homepage post title - keep h1 visual appearance for h2 */
main h2:first-of-type {
    color: var(--teletext-text);  /* Green */
    font-size: 3em;  /* Keep same size as h1 */
    font-weight: bold;
    margin: 1em 0 0.3em 0;
    letter-spacing: 2px;
}

h3 {
    color: var(--teletext-text);
    font-size: 1.5em;
    font-weight: bold;
    margin: 1.2em 0 0.4em 0;
}

h4 {
    color: var(--teletext-text);
    font-size: 1.2em;
    font-weight: bold;
    margin: 1em 0 0.3em 0;
}

p {
    color: var(--teletext-cyan);
    margin-bottom: 1.5em;
}

/* ============================================
   LINKS
   ============================================ */

a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
}

a:hover {
    color: var(--teletext-yellow);
    border-bottom-color: var(--teletext-yellow);
    background: rgba(255, 255, 0, 0.1);
}

a:visited {
    opacity: 0.7;
}

/* ============================================
   TEXT FORMATTING
   ============================================ */

strong, b {
    font-weight: bold;
}

em, i {
    font-style: italic;
}

code {
    background: rgba(0, 255, 0, 0.1);
    color: var(--teletext-yellow);
    padding: 2px 6px;
    border: 1px solid var(--teletext-text);
    font-family: 'Courier New', monospace;
}

pre {
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid var(--teletext-text);
    padding: 20px;
    overflow-x: auto;
    margin: 1em 0;
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

/* ============================================
   LISTS
   ============================================ */

ul, ol {
    margin: 1em 0 1em 2em;
}

ul li {
    list-style: none;
    position: relative;
    padding-left: 1em;
}

ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--teletext-yellow);
}

ol {
    list-style: decimal;
    list-style-position: outside;
}

ol li {
    color: var(--teletext-text);
    padding-left: 0.5em;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */

blockquote {
    border-left: 4px solid var(--teletext-cyan);
    padding-left: 20px;
    margin: 1.5em 0;
    color: var(--teletext-cyan);
    font-style: italic;
}

/* ============================================
   TABLES
   ============================================ */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    border: 2px solid var(--teletext-cyan);
}

th {
    background: rgba(0, 255, 255, 0.1);
    color: var(--teletext-yellow);
    padding: 12px;
    text-align: left;
    border: 1px solid var(--teletext-cyan);
    font-weight: bold;
}

td {
    padding: 10px 12px;
    border: 1px solid var(--teletext-text);
    color: var(--teletext-text);
}

tr:nth-child(even) {
    background: rgba(0, 255, 0, 0.02);
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */

hr {
    border: none;
    border-top: 2px solid var(--teletext-cyan);
    margin: 2em 0;
    opacity: 0.5;
}

/* ============================================
   IMAGES & FIGURES
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Paragraphs containing only images */
p:has(img:only-child) {
    margin-bottom: 0.3em;
}

/* Figure captions - paragraphs starting with <strong>Figure */
p:has(strong:first-child):not(.timeline-content p) {
    margin-top: 0;
    margin-bottom: 2.5em;
    font-style: italic;
    color: var(--teletext-yellow);
}

/* ============================================
   BUTTONS / INTERACTIVE ELEMENTS
   ============================================ */

button, .button {
    background: var(--teletext-cyan);
    color: var(--teletext-bg);
    border: 2px solid var(--teletext-cyan);
    padding: 10px 20px;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover, .button:hover {
    background: var(--teletext-yellow);
    border-color: var(--teletext-yellow);
    color: var(--teletext-bg);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.highlight {
    background: var(--teletext-yellow);
    color: var(--teletext-bg);
    padding: 2px 6px;
    font-weight: bold;
}

.error {
    color: var(--teletext-red);
    font-weight: bold;
}

.success {
    color: var(--teletext-text);
    font-weight: bold;
}

.info {
    color: var(--teletext-cyan);
}

.warning {
    color: var(--teletext-yellow);
    font-weight: bold;
}

/* ============================================
   CRT MONITOR EFFECTS
   ============================================ */

/* Scanlines - very subtle horizontal lines with gentle drift */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.08),
        rgba(0, 0, 0, 0.08) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9998;
    animation: scanlineDrift 8s ease-in-out infinite;
}

@keyframes scanlineDrift {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(1px); }
}

/* Screen texture - very subtle RGB pixel grid */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            90deg,
            rgba(255, 0, 0, 0.015),
            rgba(255, 0, 0, 0.015) 1px,
            rgba(0, 255, 0, 0.015) 1px,
            rgba(0, 255, 0, 0.015) 2px,
            rgba(0, 0, 255, 0.015) 2px,
            rgba(0, 0, 255, 0.015) 3px
        );
    pointer-events: none;
    z-index: 9998;
}

/* CRT Screen overlay - minimal, clean */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    /* Removed vignette, dust, scratches, and glare for cleaner look */
}

/* Phosphor glow - minimal, readable */
h1, h2, header {
    text-shadow: 
        0 0 2px currentColor,
        0 0 4px rgba(0, 255, 255, 0.15);
}

a:hover, strong {
    text-shadow: 
        0 0 1px currentColor,
        0 0 3px rgba(255, 255, 0, 0.2);
}

/* Rare glitch flash animation - happens occasionally */
@keyframes glitchFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.97; }
}

/* Removed brightness on hover and flicker animation for cleaner experience */

/* Screen bloom effect on colors - toned down */
.teletext-glow {
    filter:
        brightness(1.05)
        contrast(1.05);
}

/* ============================================
   SITE HEADER (Phase 5) - Teletext Band Style
   ============================================ */

.site-header {
    background: var(--teletext-blue);
    margin: -40px 0 6px 0;
    padding: 10px 20px;
    position: relative;
}

.site-header .identity {
    display: flex;
    align-items: baseline;
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.site-header .logo-container {
    height: 4em; /* Scales with font-size */
    display: flex;
    align-items: center;
    gap: 15px;
}

.site-header .logo {
    font-family: 'European Teletext Taken', 'European Teletext', 'Courier New', monospace;
    color: var(--teletext-yellow);
    font-size: 4em;
    font-weight: normal; /* Use font's natural weight to preserve kerning */
    letter-spacing: 0;
    margin: 0;
    line-height: 1;
    text-shadow: none; /* No glow in header band */
    position: relative;
    white-space: nowrap; /* Prevent logo from wrapping */
}

.site-header .ninja-icon {
    height: 100%;
    width: auto;
    display: inline-block;
    image-rendering: pixelated; /* Preserve pixel-art sharpness */
    image-rendering: crisp-edges;
}

.site-header .tagline {
    color: var(--teletext-white);
    font-size: 0.85em;
    margin: 0;
    margin-left: auto; /* Push to right side */
    opacity: 0.9;
    white-space: nowrap;
    align-self: center;
}

/* ============================================
   SITE NAVIGATION (Phase 5)
   ============================================ */

.site-nav {
    display: flex;
    gap: 15px;
    padding: 8px 0;
    margin-top: 0;
    margin-bottom: 1.5em;
    border-top: 1px solid var(--teletext-red);
    border-bottom: 1px solid var(--teletext-red);
}

.site-nav a {
    text-decoration: none;
    padding: 0px 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9em;
    background: transparent;
    transition: all 0.15s ease;
    border: 1px solid;
}

/* Teletext Remote 4-Color Buttons - Gel hover style */
.site-nav .nav-red {
    color: var(--teletext-red);
    border-color: var(--teletext-red);
}

.site-nav .nav-red:hover,
.site-nav .nav-red.active {
    background: rgba(255, 0, 0, 0.3);
    border-color: rgba(255, 0, 0, 0.6);
}

.site-nav .nav-green {
    color: var(--teletext-text);
    border-color: var(--teletext-text);
}

.site-nav .nav-green:hover,
.site-nav .nav-green.active {
    background: rgba(0, 255, 0, 0.3);
    border-color: rgba(0, 255, 0, 0.6);
}

.site-nav .nav-yellow {
    color: var(--teletext-yellow);
    border-color: var(--teletext-yellow);
}

.site-nav .nav-yellow:hover,
.site-nav .nav-yellow.active {
    background: rgba(255, 255, 0, 0.3);
    border-color: rgba(255, 255, 0, 0.6);
}

.site-nav .nav-blue {
    color: var(--teletext-cyan);
    border-color: var(--teletext-cyan);
}

.site-nav .nav-blue:hover,
.site-nav .nav-blue.active {
    background: rgba(0, 255, 255, 0.3);
    border-color: rgba(0, 255, 255, 0.6);
}

.site-nav a:visited {
    /* Preserve original color on visited */
}

.site-nav .nav-red:visited {
    color: var(--teletext-red);
}

.site-nav .nav-green:visited {
    color: var(--teletext-text);
}

.site-nav .nav-yellow:visited {
    color: var(--teletext-yellow);
}

.site-nav .nav-blue:visited {
    color: var(--teletext-cyan);
}

/* ============================================
   SITE FOOTER (Phase 5)
   ============================================ */

.site-footer {
    margin-top: 4em;
    padding: 20px 0;
    border-top: 1px solid var(--teletext-red);
    text-align: center;
}

.site-footer p {
    color: var(--teletext-red);
    font-size: 0.85em;
    opacity: 0.6;
    margin: 0;
}

/* ============================================
   POST METADATA (Phase 5)
   ============================================ */

.post-meta {
    display: flex;
    gap: 20px;
    align-items: center;
    margin: 0 0 2em 0;  /* No top margin (grouped with H1), larger bottom margin for breathing room */
    padding: 6px 0;
    border-top: 1px solid var(--teletext-yellow);
    border-bottom: 1px solid var(--teletext-yellow);
    opacity: 0.8;
    line-height: 1.2;  /* Tighter line-height to match nav visual density */
}

.post-date {
    color: var(--teletext-cyan);
    font-size: 0.9em;
}

.read-more {
    margin-top: 2em;  /* Add breathing room above the read more link */
}

.post-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tag {
    color: var(--teletext-yellow);
    font-size: 0.85em;
    padding: 4px 10px;
    border: 1px solid var(--teletext-yellow);
    background: rgba(255, 255, 0, 0.05);
}

/* ============================================
   ARCHIVE LISTING (Phase 5)
   ============================================ */

.post-listing {
    display: flex;
    flex-direction: column;
    gap: 2em;
}

.post-preview {
    padding-bottom: 2em;
    border-bottom: 1px solid var(--teletext-yellow);
}

.post-preview:last-child {
    border-bottom: none;
}

.post-preview h3 {
    margin: 0 0 0.5em 0;
    font-size: 1.8em;
}

.post-preview h3 a {
    border: none;
}

.post-preview h3 a:hover {
    background: none;
}

.post-preview .post-meta {
    margin: 0.5em 0;
    border: none;
    padding: 0;
}

.post-excerpt {
    color: var(--teletext-cyan);
    margin: 1em 0 0 0;
    opacity: 0.9;
}

/* ============================================
   PAGINATION (Phase 5)
   ============================================ */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3em 0;
    padding: 20px;
    border-top: 2px solid var(--teletext-cyan);
    border-bottom: 2px solid var(--teletext-cyan);
}

.pagination a {
    color: var(--teletext-cyan);
    text-decoration: none;
    border: 2px solid var(--teletext-cyan);
    padding: 10px 20px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--teletext-cyan);
    color: var(--teletext-bg);
}

.pagination-info {
    color: var(--teletext-yellow);
    font-weight: bold;
}

.pagination a:disabled,
.pagination a.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============================================
   TAG FILTERING
   ============================================ */

.filter-ui {
    margin: 2em 0;
    padding: 1em;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--teletext-cyan);
    border-radius: 4px;
}

.filter-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em;
}

.filter-label {
    color: var(--teletext-cyan);
    font-weight: bold;
    margin-right: 0.5em;
}

.filter-tag {
    background: var(--background-dark);
    color: var(--teletext-cyan);
    padding: 0.3em 0.6em;
    border: 2px solid var(--teletext-cyan);
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    transition: all 0.2s;
    text-transform: uppercase;
}

.filter-tag:hover {
    background: rgba(0, 255, 255, 0.3);
    border-color: rgba(0, 255, 255, 0.6);
}

.filter-tag .remove-tag {
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1;
}

.clear-filters {
    color: var(--teletext-red);
    text-decoration: underline;
    font-size: 0.9em;
    margin-left: 0.5em;
}

.clear-filters:hover {
    color: var(--teletext-white);
}

.tag-link {
    color: var(--teletext-cyan);
    text-transform: uppercase;
}

.no-results {
    color: var(--teletext-yellow);
    font-style: italic;
    margin: 2em 0;
}

/* ============================================
   ABOUT PAGE - TIMELINE
   ============================================ */

/* Intro Section with Portrait */
.about-intro {
    margin-bottom: 3em;
}

.intro-content {
    display: flex;
    gap: 2em;
    align-items: flex-start;
    margin-top: 1.5em;
}

.portrait-image {
    width: 360px;
    height: auto;
    flex-shrink: 0;
}

.intro-text {
    flex: 1;
}

/* Timeline Section */
.about-timeline {
    margin-bottom: 3em;
}

.timeline {
    position: relative;
    padding-left: 0;
    margin-top: 2em;
}

/* Vertical red line connecting all items */
.timeline::before {
    content: '';
    position: absolute;
    left: 22px; /* Center of marker box (44px/2) */
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--teletext-red);
}

/* Individual timeline item */
.timeline-item {
    display: flex;
    gap: 1.5em;
    margin-bottom: 2.5em;
    position: relative;
    align-items: flex-start;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

/* Red square marker box */
.timeline-marker {
    width: 44px;
    height: 44px;
    border: 1px solid var(--teletext-red);
    background: var(--teletext-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1; /* Ensure box appears above connecting line */
    position: relative;
}

.emoji-icon {
    font-size: 1.8em;
    line-height: 1;
}

/* Timeline content */
.timeline-content {
    flex: 1;
    padding-top: 0;
}

.timeline-content p {
    margin: 0 0 1em 0;
    color: var(--teletext-cyan);
}

.timeline-content p:last-child {
    margin-bottom: 0;
}

/* CTA Section */
.about-cta {
    margin-top: 3em;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .site-header {
        margin: -40px -20px 6px -20px; /* Reduce bottom margin from 2em to 6px */
    }

    .site-header .identity {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .site-header .logo-container {
        height: 2.5em; /* Scales with mobile font-size */
    }

    .site-header .logo {
        font-size: 2.5em;
        white-space: nowrap; /* Prevent "Taken" from wrapping */
        flex-shrink: 0; /* Don't let flex container shrink the logo */
    }

    .site-header .ninja-icon {
        display: inline-block; /* Show ninja on mobile */
    }

    .site-header .tagline {
        font-size: 0.75em;
        white-space: normal; /* Allow tagline to wrap */
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        padding-left: 0;
        opacity: 0.85;
        text-align: left; /* Explicitly left-align */
    }

    .site-nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin-top: 6px;
        margin-bottom: 1em;
        padding: 4px 0; /* Reduce from 6px 0 */
    }

    .site-nav a {
        text-align: center;
        padding: 2px 8px; /* Minimal padding for mobile */
        font-size: 0.85em;
        line-height: 1.2; /* Reduce line height */
    }

    .post-meta {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .pagination {
        flex-direction: column;
        gap: 15px;
    }

    /* About page mobile adjustments */
    .intro-content {
        flex-direction: column;
        gap: 1.5em;
    }

    .portrait-image {
        width: 150px;
        align-self: center;
        order: -1; /* Move portrait before text on mobile */
    }

    .timeline {
        padding-left: 0;
    }

    .timeline::before {
        left: 16px; /* Adjust for smaller marker */
    }

    .timeline-marker {
        width: 32px;
        height: 32px;
    }

    .emoji-icon {
        font-size: 1.4em;
    }

    .timeline-item {
        gap: 1em;
    }
}
