/* =========================================
   MMIDDL.com — Gilded Terminal Design System
   ========================================= */

/* --- CSS Custom Properties --- */
:root {
    --color-bg-deep: #0f0806;
    --color-bg-card: #1a0f08;
    --color-bg-header: #2a1810;
    --color-accent-gold: #e8a44c;
    --color-accent-copper: #c4956a;
    --color-accent-ember: #d4654a;
    --color-text-primary: #f0dcc0;
    --color-text-muted: #a08660;
    --color-mesh-warm: #e87040;
    --color-mesh-cool: #6b2040;
    --cursor-x: 50%;
    --cursor-y: 50%;
    --scroll-progress: 0;
}

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

html {
    scroll-behavior: smooth;
    background-color: var(--color-bg-deep);
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.8;
    letter-spacing: 0.02em;
    color: var(--color-text-primary);
    background-color: var(--color-bg-deep);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Custom Selection --- */
::selection {
    background: #e87040;
    color: #0f0806;
}

/* --- Scroll Progress Bar --- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: calc(var(--scroll-progress) * 100%);
    height: 2px;
    background: var(--color-accent-gold);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* --- Cursor Glow --- */
.cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background: radial-gradient(
        600px circle at var(--cursor-x) var(--cursor-y),
        rgba(232, 164, 76, 0.06),
        transparent 60%
    );
    transition: background 0.15s ease;
}

/* --- Gradient Mesh Background --- */
.gradient-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0;
    transition: opacity 2s ease;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(232, 112, 64, 0.12), transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(107, 32, 64, 0.10), transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(232, 164, 76, 0.06), transparent 70%);
    pointer-events: none;
}

.gradient-mesh.visible {
    opacity: 1;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    background-color: var(--color-bg-deep);
}

.hero-terminal {
    max-width: 900px;
    width: 90%;
    padding: 2rem;
}

.boot-output {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--color-accent-gold);
    white-space: pre-wrap;
    line-height: 2;
}

.boot-output .boot-line {
    display: block;
    opacity: 0;
    animation: fadeInLine 0.3s ease forwards;
}

@keyframes fadeInLine {
    to { opacity: 1; }
}

.boot-output .site-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.3em;
    color: var(--color-accent-gold);
    display: block;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.terminal-cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.2em;
    background: var(--color-accent-gold);
    vertical-align: text-bottom;
    animation: cursorBlink 1.2s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Card Grid Section --- */
.card-grid-section {
    position: relative;
    z-index: 2;
    padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 4vw, 3rem);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.card-grid-section.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Morse Code Divider --- */
.morse-divider {
    text-align: center;
    padding: 2rem 0 3rem;
}

.morse-code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    color: var(--color-accent-gold);
    opacity: 0.4;
}

/* --- Card Grid Layout --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: clamp(1.5rem, 3vw, 2.5rem);
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Dispatch Card --- */
.dispatch-card {
    background: var(--color-bg-card);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
    opacity: 0;
    transform: translateY(20px);
    border: 1px solid rgba(196, 149, 106, 0.15);
}

.dispatch-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.dispatch-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-color: rgba(196, 149, 106, 0.4);
}

/* Scanline overlay */
.dispatch-card .card-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(15, 8, 6, 0.15) 2px,
        rgba(15, 8, 6, 0.15) 4px
    );
}

/* Corner ornaments */
.dispatch-card::before,
.dispatch-card::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--color-accent-copper);
    opacity: 0.4;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.dispatch-card::before {
    top: 4px;
    left: 4px;
    border-top: 1px solid;
    border-left: 1px solid;
}

.dispatch-card::after {
    bottom: 4px;
    right: 4px;
    border-bottom: 1px solid;
    border-right: 1px solid;
}

.dispatch-card:hover::before,
.dispatch-card:hover::after {
    opacity: 0.8;
}

/* --- Card Header --- */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--color-bg-header), var(--color-bg-card));
    border-bottom: 1px solid rgba(196, 149, 106, 0.1);
    border-radius: 6px 6px 0 0;
}

.brass-rivets {
    display: flex;
    gap: 6px;
}

.rivet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: box-shadow 0.3s ease;
}

.rivet-gold {
    background: radial-gradient(circle at 35% 35%, #f5c96e, #e8a44c 50%, #a07030);
}

.rivet-amber {
    background: radial-gradient(circle at 35% 35%, #e8b870, #c4956a 50%, #8a6540);
}

.rivet-copper {
    background: radial-gradient(circle at 35% 35%, #d4856a, #d4654a 50%, #8a3a2a);
}

.dispatch-card:hover .rivet-gold {
    box-shadow: 0 0 6px rgba(232, 164, 76, 0.6);
}

.dispatch-card:hover .rivet-amber {
    box-shadow: 0 0 6px rgba(196, 149, 106, 0.5);
}

.dispatch-card:hover .rivet-copper {
    box-shadow: 0 0 6px rgba(212, 101, 74, 0.5);
}

.card-label {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-accent-copper);
}

/* --- Card Content --- */
.card-content {
    padding: 1.5rem 1.25rem;
    position: relative;
}

.card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    letter-spacing: 0.04em;
    color: var(--color-accent-gold);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.card-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.9rem;
    line-height: 1.8;
    letter-spacing: 0.02em;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

.card-status {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--color-accent-ember);
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border: 1px solid rgba(212, 101, 74, 0.3);
    border-radius: 2px;
}

/* --- Card Footer --- */
.card-footer {
    padding: 0 1.25rem 1rem;
}

.flourish {
    width: 100%;
    height: 12px;
    color: var(--color-accent-gold);
    opacity: 0.3;
}

/* --- Terminal Prompt Section --- */
.terminal-prompt-section {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 5vw, 4rem);
}

.terminal-window {
    max-width: 700px;
    width: 100%;
    background: var(--color-bg-card);
    border-radius: 6px;
    border: 1px solid rgba(196, 149, 106, 0.2);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--color-bg-header), var(--color-bg-card));
    border-bottom: 1px solid rgba(196, 149, 106, 0.1);
}

.terminal-body {
    padding: 1.5rem;
}

.terminal-line {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--color-text-primary);
    line-height: 2.2;
    opacity: 0.7;
}

.prompt-symbol {
    color: var(--color-accent-gold);
    font-weight: 500;
    margin-right: 0.5rem;
}

.active-prompt {
    opacity: 1;
    margin-top: 1rem;
}

.active-prompt .prompt-text {
    color: var(--color-accent-gold);
    font-weight: 400;
}

.prompt-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1.1em;
    background: var(--color-accent-gold);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: cursorBlink 1.2s step-end infinite;
}

/* --- Colophon Footer --- */
.colophon {
    position: relative;
    z-index: 2;
    padding: 1rem 0;
    background: var(--color-bg-card);
    border-top: 1px solid rgba(196, 149, 106, 0.15);
    overflow: hidden;
}

.ticker-tape {
    width: 100%;
    overflow: hidden;
    position: relative;
}

.ticker-content {
    display: flex;
    align-items: center;
    gap: 0;
    white-space: nowrap;
    animation: tickerScroll 40s linear infinite;
}

.ticker-cell {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: 0.3rem 0.6rem;
    border: 1px solid rgba(160, 134, 96, 0.15);
    margin: 0 2px;
    white-space: nowrap;
}

.ticker-separator {
    color: rgba(160, 134, 96, 0.25);
    padding: 0 0.3rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
}

@keyframes tickerScroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* --- Link Hover Animation --- */
a {
    color: var(--color-accent-gold);
    text-decoration: none;
    background-image: linear-gradient(var(--color-accent-gold), var(--color-accent-gold));
    background-size: 0% 2px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition: background-size 0.3s ease;
}

a:hover {
    background-size: 100% 2px;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .hero-terminal {
        padding: 1.5rem;
    }

    .boot-output .site-name {
        letter-spacing: 0.15em;
    }

    .terminal-body {
        padding: 1rem;
    }

    .morse-code {
        font-size: 1rem;
        letter-spacing: 0.15em;
    }
}
