/* ==========================================================================
   TLDR.it - Common Styles
   ========================================================================== */

/* ==========================================================================
   CSS Variables (Base Theme)
   Each page can override --accent and --accent-glow
   ========================================================================== */
:root {
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-code: #1a1a1a;
    --text: #e8e8e8;
    --text-dim: #888888;
    --accent: #a855f7;
    --accent-glow: rgba(168, 85, 247, 0.15);
    --border: #2a2a2a;
    --success: #4ade80;
    --error: #f87171;
    --info: #60a5fa;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Noise overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ==========================================================================
   Header
   ========================================================================== */
header {
    padding: 80px 0 60px;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 28px;
    color: var(--bg);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 24px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent);
}

h1 {
    font-family: 'Instrument Serif', serif;
    font-size: clamp(48px, 8vw, 72px);
    font-weight: 400;
    letter-spacing: -2px;
    line-height: 1.1;
    margin-bottom: 16px;
}

h1 span {
    color: var(--accent);
}

.tagline {
    font-size: 18px;
    color: var(--text-dim);
    max-width: 600px;
}

.version-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    margin-top: 24px;
}

.version-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

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

/* ==========================================================================
   Navigation (Guide Pages)
   ========================================================================== */
nav {
    position: sticky;
    top: 0;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    z-index: 100;
}

nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
}

nav a {
    display: block;
    padding: 8px 16px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.2s;
}

nav a:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--bg-card);
}

/* ==========================================================================
   Main Content
   ========================================================================== */
main {
    padding: 60px 0;
}

section {
    margin-bottom: 80px;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Typography
   ========================================================================== */
h2 {
    font-family: 'Instrument Serif', serif;
    font-size: 36px;
    font-weight: 400;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

h3 {
    font-size: 20px;
    font-weight: 500;
    margin: 32px 0 16px;
    color: var(--accent);
}

p {
    margin-bottom: 16px;
    color: var(--text-dim);
}

/* ==========================================================================
   Code Blocks
   ========================================================================== */
pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    padding: 20px 24px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.7;
    margin: 16px 0 24px;
    position: relative;
}

pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px 12px;
    background: var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

code {
    font-family: 'JetBrains Mono', monospace;
}

:not(pre) > code {
    background: var(--bg-code);
    padding: 2px 8px;
    border: 1px solid var(--border);
    font-size: 0.9em;
}

/* ==========================================================================
   Syntax Highlighting
   ========================================================================== */
.kw { color: #c792ea; }
.fn { color: #82aaff; }
.str { color: #c3e88d; }
.num { color: #f78c6c; }
.cmt { color: #546e7a; font-style: italic; }
.type { color: #ffcb6b; }
.builtin { color: #89ddff; }
.op { color: #89ddff; }
.lifetime { color: #f07178; }
.macro { color: #82aaff; }
.attr { color: #c792ea; }

/* ==========================================================================
   Cards
   ========================================================================== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 24px;
    transition: all 0.3s;
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--accent-glow);
}

.card h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card p {
    font-size: 14px;
    margin: 0;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrapper {
    overflow-x: auto;
    margin: 24px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border: 1px solid var(--border);
}

th {
    background: var(--bg-card);
    font-weight: 500;
    color: var(--accent);
}

td {
    background: var(--bg-code);
}

td code {
    background: transparent;
    border: none;
    padding: 0;
}

/* ==========================================================================
   Concept List
   ========================================================================== */
.concept-list {
    display: grid;
    gap: 16px;
    margin: 24px 0;
}

.concept {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
}

.concept dt {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--accent);
}

.concept dd {
    color: var(--text-dim);
}

/* ==========================================================================
   Tips & Warnings
   ========================================================================== */
.tip {
    background: linear-gradient(135deg, var(--accent-glow), transparent);
    border: 1px solid var(--accent);
    border-left: 4px solid var(--accent);
    padding: 16px 20px;
    margin: 24px 0;
}

.tip::before {
    content: '💡 ';
}

.warning {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.1), transparent);
    border: 1px solid var(--error);
    border-left: 4px solid var(--error);
    padding: 16px 20px;
    margin: 24px 0;
}

.warning::before {
    content: '⚠️ ';
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
    border-top: 1px solid var(--border);
    padding: 40px 0;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    header {
        padding: 60px 0 40px;
    }

    .concept {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    nav ul {
        gap: 4px;
    }

    nav a {
        padding: 6px 12px;
        font-size: 13px;
    }
}
