/* 
  CSS3 Mastery - PhD Level Stylesheet 
  Architecture: ITCSS (Inverted Triangle CSS) inspired 
*/

/* 1. Settings & Token Definitions */
:root {
    /* Brand Colors - Neon & Glassmorphism Palette */
    --color-bg-base: #0a0a0c;
    --color-bg-surface: #141419;
    --color-primary: #00f2ff;
    --color-primary-dim: #00f2ffa8;
    --color-secondary: #7000ff;
    --color-accent: #ff0055;

    --color-text-main: #f0f0f0;
    --color-text-muted: #8b9bb4;

    /* Gradients */
    --gradient-glow: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    --gradient-glass: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));

    /* Spacing & Layout */
    --space-unit: 8px;
    --container-width: 1400px;
    --border-radius-lg: 24px;
    --border-radius-sm: 8px;

    /* Effects */
    --shadow-neon: 0 0 20px -5px var(--color-primary-dim);
    --glass-blur: blur(20px);
    --ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* 0. SPA-like Transitions (View Transitions API) */
@view-transition {
    navigation: auto;
    /* Enable cross-document transitions in Chrome 126+ */
}

/* 0.1 Accessibility - Skip to Content Link */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: #000;
    padding: 1rem 2rem;
    font-weight: bold;
    z-index: 10000;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}

.skip-to-content:focus {
    top: 0;
}

/* 0.2 Keyboard Focus Indicators */
a:focus-visible,
button:focus-visible,
.btn-neon:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

/* 0.3 Scroll Progress Bar (Pure CSS) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-glow);
    z-index: 9999;
    transform-origin: 0 50%;
    animation: scroll-progress auto linear;
    animation-timeline: scroll();
}

@keyframes scroll-progress {
    from {
        transform: scaleX(0);
    }

    to {
        transform: scaleX(1);
    }
}

/* 2. Modern Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 100%;
}

body {
    background-color: var(--color-bg-base);
    color: var(--color-text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* 3. Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(3rem, 8vw, 6rem);
    background: var(--gradient-glow);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
}

/* 4. Utility Components */
.glass-panel {
    background: var(--gradient-glass);
    backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.btn-neon {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2.5rem;
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--ease-elastic);
}

.btn-neon::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    z-index: -1;
    transition: left 0.4s ease;
}

.btn-neon:hover {
    color: #000;
    box-shadow: var(--shadow-neon);
}

.btn-neon:hover::before {
    left: 0;
}

/* 5. Layout Utils (Modern Layouts) */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 6. Live Editor Styles */
.live-editor {
    width: 100%;
    min-height: 150px;
    background: #0f0f13;
    color: var(--color-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    resize: vertical;
    outline: none;
    transition: border-color 0.3s ease;
}

.live-editor:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.1);
}

.playground-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

/* 7. Copy-to-Clipboard Button */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--color-primary);
    color: #000;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.copy-btn:hover {
    background: var(--color-secondary);
    transform: scale(1.05);
}

/* Copy Toast Notification */
.copy-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--color-primary);
    color: #000;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: bold;
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .playground-area {
        grid-template-columns: 1fr;
    }

    /* Mobile Navigation */
    nav.glass-panel {
        flex-wrap: wrap;
        padding: 1rem !important;
    }

    nav.glass-panel ul {
        flex-direction: column;
        gap: 0.5rem !important;
        width: 100%;
        margin-top: 1rem;
    }

    /* Touch-friendly buttons */
    .btn-neon {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
    }

    /* Better mobile grid */
    .grid-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    /* Adjust text sizes */
    h1 {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    /* Hide nav links on very small screens, show hamburger */
    @media (max-width: 480px) {
        nav.glass-panel ul li {
            font-size: 0.9rem;
        }
    }
}

/* Performance: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Stylesheet */
@media print {

    /* Hide navigation and interactive elements */
    nav,
    .copy-btn,
    .skip-to-content,
    footer {
        display: none !important;
    }

    /* Optimize colors for print */
    body {
        background: white;
        color: black;
    }

    .glass-panel {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    /* Better text rendering */
    h1,
    h2,
    h3 {
        color: black;
        background: none;
        -webkit-text-fill-color: black;
    }

    /* Ensure code blocks are readable */
    code,
    pre {
        background: #f5f5f5;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    /* Page breaks */
    section {
        page-break-inside: avoid;
    }

    /* Show URLs for links */
    a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}