/* Modern CSS Cheatsheet Site Styles */

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

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --border-color: #e2e8f0;
    --code-bg: #fdf6e3;
    /* Solarized Base3 */
    --code-text: #657b83;
    /* Solarized Base00 */
    --spacing-unit: 1rem;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* ... existing styles ... */

/* Solarized Syntax Colors (Visual improvement for plain text) */
.code-block code {
    color: var(--code-text);
}

/* Visual Previews - Layout & Sizing */

/* Flexbox Preview */
.flex-preview {
    display: flex;
    gap: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px dashed #ccc;
    margin-bottom: 1rem;
}

.flex-item {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: bold;
}

/* Grid Preview */
.grid-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #f0f0f0;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.grid-item {
    background: white;
    border: 2px solid var(--secondary-color);
    padding: 1rem;
    text-align: center;
    border-radius: 4px;
    font-weight: bold;
    color: var(--secondary-color);
}

/* Alignment Preview */
.align-preview-box {
    display: grid;
    place-items: center;
    height: 150px;
    background: #e2e8f0;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.center-target {
    width: 50px;
    height: 50px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.3);
}

/* Aspect Ratio Preview */
.ratio-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

.ratio-box {
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
    width: 100px;
    /* Base width */
}

.ratio-1-1 {
    aspect-ratio: 1 / 1;
}

.ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.ratio-4-3 {
    aspect-ratio: 4 / 3;
}

/* Responsive Design Preview */
.responsive-bar {
    display: flex;
    gap: 5px;
    height: 20px;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.rw-mobile {
    background: #fee2e2;
    flex: 1;
}

/* Red-ish */
.rw-tablet {
    background: #fef3c7;
    flex: 2;
}

/* Yellow-ish */
.rw-desktop {
    background: #d1fae5;
    flex: 3;
}

/* Green-ish */

/* Pseudo-elements Preview */
.pseudo-demo-btn {
    position: relative;
    padding: 10px 20px;
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    z-index: 1;
    transition: color 0.3s;
}

.pseudo-demo-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    z-index: -1;
    transition: transform 0.3s ease;
    transform: scaleX(0);
    transform-origin: left;
}

.pseudo-demo-btn:hover {
    color: white;
}

.pseudo-demo-btn:hover::before {
    transform: scaleX(1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding-block: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.site-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
}

/* Tab Bar */
.tab-bar {
    background: var(--card-bg);
    display: flex;
    gap: 0;
    padding-inline: var(--spacing-unit);
    border-block-end: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.tab-button {
    background: transparent;
    border: none;
    padding-block: 1rem;
    padding-inline: 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-block-end: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-button:hover {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.tab-button.active {
    color: var(--primary-color);
    border-block-end-color: var(--primary-color);
}

/* Main Container */
.main-container {
    max-inline-size: 1400px;
    margin-inline: auto;
    padding-block: 2rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    padding-inline: var(--spacing-unit);
}

/* Side Navigation */
.side-nav {
    position: sticky;
    top: 80px;
    align-self: start;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding-block: 1.5rem;
    padding-inline: 1rem;
    box-shadow: var(--shadow);
    max-block-size: calc(100vh - 100px);
    overflow-y: auto;
}

.side-nav nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    padding-block: 0.75rem;
    padding-inline: 1rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease;
    border-inline-start: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
}

.nav-link.active {
    background: rgba(102, 126, 234, 0.15);
    color: var(--primary-color);
    border-inline-start-color: var(--primary-color);
}

/* Content Area */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.content-section {
    background: var(--card-bg);
    padding-block: 2rem;
    padding-inline: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    scroll-margin-top: 100px;
}

.content-section h2 {
    color: var(--primary-color);
    margin-block-end: 1rem;
    font-size: 1.75rem;
    border-block-end: 2px solid var(--border-color);
    padding-block-end: 0.5rem;
}

.content-section p {
    color: var(--text-muted);
    margin-block-end: 1.5rem;
    font-size: 1.05rem;
}

/* Callout Box */
.callout-box {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-inline-start: 4px solid var(--primary-color);
    padding-block: 1.5rem;
    padding-inline: 1.5rem;
    border-radius: var(--border-radius);
    margin-block: 1.5rem;
}

.callout-box h3 {
    color: var(--primary-color);
    margin-block-end: 1rem;
    font-size: 1.2rem;
}

.callout-box ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.callout-box li {
    padding-inline-start: 1.5rem;
    position: relative;
}

.callout-box li::before {
    content: '✓';
    position: absolute;
    inset-inline-start: 0;
    color: var(--primary-color);
    font-weight: bold;
}

/* Feature List */
.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-block: 1.5rem;
}

.feature-list li {
    padding-inline-start: 1.5rem;
    position: relative;
    line-height: 1.8;
}

.feature-list li::before {
    content: '→';
    position: absolute;
    inset-inline-start: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.feature-list code {
    background: rgba(102, 126, 234, 0.1);
    padding-block: 0.2rem;
    padding-inline: 0.4rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--primary-color);
}

/* Code Blocks */
.code-block {
    position: relative;
    margin-block: 1.5rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.code-block pre {
    background: var(--code-bg);
    padding-block: 1.5rem;
    padding-inline: 1.5rem;
    overflow-x: auto;
    margin: 0;
}

.code-block code {
    color: var(--code-text);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.copy-btn {
    position: absolute;
    top: 0.75rem;
    inset-inline-end: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding-block: 0.5rem;
    padding-inline: 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.copy-btn.copied {
    background: rgba(46, 204, 113, 0.3);
    border-color: rgba(46, 204, 113, 0.5);
}

.copy-btn.copied::after {
    content: ' ✓';
}

/* Responsive Design */
@media (max-width: 768px) {
    .tab-content.active {
        grid-template-columns: 1fr;
    }

    .side-nav {
        position: static;
        max-block-size: none;
    }

    .side-nav nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 0.5rem;
    }

    .nav-link {
        white-space: nowrap;
        border-inline-start: none;
        border-block-end: 3px solid transparent;
    }

    .nav-link.active {
        border-inline-start-color: transparent;
        border-block-end-color: var(--primary-color);
    }

    .content-section {
        padding-block: 1.5rem;
        padding-inline: 1rem;
    }

    .tab-bar {
        padding-inline: 0.5rem;
    }

    .tab-button {
        padding-inline: 1rem;
        font-size: 0.9rem;
    }
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection */
::selection {
    background: var(--primary-color);
    color: white;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    inline-size: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* --- Visual Preview Styles --- */
.preview-box {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-block: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    background-image:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    position: relative;
    overflow: hidden;
}

/* Modern Backgrounds Previews */
.preview-box .gradient-text {
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 3rem;
    font-weight: 800;
}

.preview-box .layered-bg-preview {
    width: 100%;
    height: 200px;
    border-radius: 8px;
    background:
        linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.8) 100%),
        linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    display: flex;
    align-items: flex-end;
    padding: 1rem;
    color: white;
    font-weight: bold;
}

.preview-box .duotone-preview {
    width: 100%;
    height: 200px;
    border-radius: 8px;
    background:
        linear-gradient(#667eea, #764ba2),
        repeating-linear-gradient(45deg, #ccc 0, #ccc 10px, #fff 10px, #fff 20px);
    background-blend-mode: multiply;
}

/* Border Features Previews */
.preview-box .logical-box {
    width: 150px;
    height: 100px;
    background: var(--primary-color);
    border-start-start-radius: 10px;
    border-start-end-radius: 20px;
    border-end-end-radius: 30px;
    border-end-start-radius: 40px;
}

.preview-box .pill {
    padding: 1rem 2rem;
    background: var(--secondary-color);
    color: white;
    border-radius: 9999px;
    font-weight: bold;
}

.preview-box .organic {
    width: 120px;
    height: 120px;
    background: linear-gradient(45deg, #ff9a9e, #fad0c4);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: morph 4s infinite alternate;
}

@keyframes morph {
    0% {
        border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    }

    100% {
        border-radius: 70% 30% 30% 70% / 70% 30% 30% 70%;
    }
}

.preview-box .gradient-border-box {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    color: var(--text-color);
    font-weight: bold;
    z-index: 1;
}

.preview-box .gradient-border-box::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 12px;
    background: linear-gradient(45deg, #667eea, #764ba2, #ff9a9e);
    z-index: -1;
}

/* Text Decoration Previews */
.preview-box .text-deco-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-color);
}

.preview-box .fancy-link {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-color: var(--secondary-color);
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
    text-decoration-style: wavy;
    cursor: pointer;
}

.preview-box .fancy-link:hover {
    text-decoration-style: solid;
    text-decoration-color: var(--primary-color);
}

/* Subgrid Preview */
.preview-box .subgrid-preview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
}

.subgrid-card {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 0.5rem;
}

/* Property Table Styles */
.property-table {
    width: 100%;
    border-collapse: collapse;
    margin-block: 1.5rem;
    font-size: 0.95rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.property-table th,
.property-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.property-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-color);
    width: 30%;
}

.property-table td {
    color: var(--text-muted);
}

.property-table tr:last-child td {
    border-bottom: none;
}

.property-name {
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: 600;
}

.property-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.value-tag {
    background: #edf2f7;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    color: #4a5568;
}

.value-desc {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.9em;
    color: #718096;
}

/* Semantic Layout Demo */
.semantic-layout-demo {
    display: grid;
    grid-template-areas:
        "header header header"
        "nav main aside"
        "footer footer footer";
    gap: 0.5rem;
    padding: 1rem;
    background: #f1f5f9;
    border-radius: 8px;
    height: 300px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #475569;
}

.semantic-box {
    background: white;
    border: 2px dashed #cbd5e1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
}

.semantic-box:hover {
    border-color: var(--primary-color);
    transform: scale(1.02);
    z-index: 2;
    background: #eff6ff;
    color: var(--primary-color);
    font-weight: bold;
}

.sem-header {
    grid-area: header;
    background: #fee2e2;
    border-color: #fca5a5;
}

.sem-nav {
    grid-area: nav;
    background: #fef3c7;
    border-color: #fcd34d;
}

.sem-aside {
    grid-area: aside;
    background: #e0f2fe;
    border-color: #7dd3fc;
}

.sem-footer {
    grid-area: footer;
    background: #f3e8ff;
    border-color: #d8b4fe;
}

.sem-main {
    grid-area: main;
    background: #dcfce7;
    border-color: #86efac;
    /* Allow nesting */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
    align-items: stretch;
    justify-content: flex-start;
}

.sem-container {
    border: 1px dashed #94a3b8;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.8em;
}

.sem-article {
    border: 1px solid #86efac;
    background: white;
    padding: 0.5rem;
    border-radius: 4px;
    flex: 1;
}

.sem-section {
    border: 1px dotted #86efac;
    background: #f0fdf4;
    padding: 0.25rem;
    margin-top: 0.25rem;
    font-size: 0.85em;
}

/* Responsive adjustment for demo */
@media (max-width: 600px) {
    .semantic-layout-demo {
        grid-template-areas:
            "header"
            "nav"
            "main"
            "aside"
            "footer";
        height: auto;
    }

    .semantic-box {
        padding: 1rem;
    }
}

/* Fallback visualization for subgrid */
.subgrid-card>div:nth-child(1) {
    height: 50px;
    background: #e2e8f0;
    border-radius: 4px;
}

.subgrid-card>div:nth-child(2) {
    font-weight: bold;
}

.subgrid-card>div:nth-child(3) {
    color: #718096;
    font-size: 0.9em;
}