/* ==========================================================================
   CANVAS LAB NOTEBOOK & CREATIVE STUDIO SKETCHBOOK
   Aged Paper, Hand-set Editorial Typography, Ink Accents & Index Cards
   ========================================================================== */

:root {
    /* Paper & Ink Palette */
    --bg-paper: #efeae0;
    --bg-card: #faf8f5;
    --bg-card-alt: #f5f2eb;
    --bg-modal: #fcfbfa;
    --bg-code: #f3f0e8;

    --border-paper: rgba(45, 42, 38, 0.14);
    --border-dark: rgba(45, 42, 38, 0.3);

    --ink-primary: #1c1917;
    --ink-secondary: #44403c;
    --ink-muted: #78716c;

    /* Category Ink Accents (Used Sparingly) */
    --ink-sim: #1d4ed8;       /* Prussian Blue */
    --ink-physics: #b91c1c;   /* Terracotta Crimson */
    --ink-games: #15803d;     /* Forest Green */
    --ink-learning: #c2410c;  /* Ochre / Sienna */
    --ink-templates: #6b21a8; /* Deep Plum */

    /* Fonts */
    --font-serif: 'Lora', Georgia, serif;
    --font-hand: 'Caveat', cursive;
    --font-mono: 'Fira Code', monospace;
    --font-sans: 'Inter', system-ui, sans-serif;

    /* Shadows (Tactile Paper Lifts) */
    --shadow-card: 2px 5px 14px rgba(40, 35, 25, 0.07), 0 1px 3px rgba(40, 35, 25, 0.05);
    --shadow-lift: 6px 14px 28px rgba(40, 35, 25, 0.12), 0 2px 5px rgba(40, 35, 25, 0.08);
    --shadow-modal: 0 20px 60px rgba(25, 22, 18, 0.25), 0 0 0 1px rgba(45, 42, 38, 0.15);
}

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

body {
    background-color: var(--bg-paper);
    /* Graph-paper subtle grid pattern */
    background-image: 
        linear-gradient(to right, rgba(45, 42, 38, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(45, 42, 38, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--ink-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.65;
    overflow-x: hidden;
}

/* Background Canvas Frame (Kept intact for JS compatibility) */
#bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.4;
    z-index: 0;
}

.app-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1380px;
    margin: 0 auto;
    padding: 2.5rem 2rem 6rem 2rem;
}

/* Header Navbar - Notebook Header */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-paper);
    border-bottom: 2px solid var(--ink-primary);
    border-radius: 4px;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-card);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--ink-primary);
}

.brand-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--ink-primary);
    color: var(--bg-paper);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.brand-logo h1 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink-primary);
}

.brand-logo .badge {
    background: rgba(45, 42, 38, 0.08);
    color: var(--ink-secondary);
    border: 1px solid var(--border-paper);
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-dark);
    color: var(--ink-primary);
    padding: 0.5rem 1rem;
    border-radius: 3px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link-btn:hover {
    background: var(--ink-primary);
    color: var(--bg-paper);
}

/* Hero Section - Pinned Index Card & Notebook Annotations */
.hero-section {
    margin-bottom: 3.5rem;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2.5rem;
    align-items: center;
}

.hero-title-group h2 {
    font-family: var(--font-serif);
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--ink-primary);
}

.hero-title-group p {
    color: var(--ink-secondary);
    font-size: 1.1rem;
    max-width: 620px;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.hero-handwritten-note {
    font-family: var(--font-hand);
    font-size: 1.35rem;
    color: var(--ink-sim);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Pinned Hero Live Canvas Sketch */
.hero-canvas-frame {
    background: var(--bg-card);
    border: 1px solid var(--border-paper);
    padding: 1rem;
    box-shadow: var(--shadow-lift);
    transform: rotate(1.2deg);
    position: relative;
}

.hero-canvas-frame::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 24px;
    background: rgba(230, 220, 200, 0.7);
    border: 1px solid rgba(180, 170, 150, 0.4);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.hero-canvas-box {
    width: 100%;
    height: 180px;
    background: #090d16;
    border-radius: 2px;
    overflow: hidden;
}

.hero-canvas-caption {
    font-family: var(--font-hand);
    font-size: 1.15rem;
    color: var(--ink-secondary);
    text-align: center;
    margin-top: 0.6rem;
}

/* Stats Bar - Scribbled Tally Note Margin */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.4);
    border-left: 3px solid var(--ink-primary);
    margin-top: 1rem;
    font-family: var(--font-mono);
}

.stat-card {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.stat-card .stat-val {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ink-primary);
}

.stat-card .stat-lbl {
    font-size: 0.75rem;
    color: var(--ink-muted);
    text-transform: uppercase;
}

/* Filter & Search Bar - Card Catalog Dividers */
.filter-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px dashed var(--border-paper);
    flex-wrap: wrap;
}

.category-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill-btn {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-paper);
    border-bottom: none;
    color: var(--ink-secondary);
    padding: 0.55rem 1.1rem;
    border-radius: 4px 4px 0 0;
    font-size: 0.88rem;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pill-btn:hover {
    background: var(--bg-card);
    color: var(--ink-primary);
}

.pill-btn.active {
    background: var(--ink-primary);
    color: var(--bg-paper);
    border-color: var(--ink-primary);
}

.search-box {
    position: relative;
    min-width: 300px;
}

.search-box i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.search-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    color: var(--ink-primary);
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    border-radius: 3px;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    outline: none;
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: var(--ink-primary);
    box-shadow: 0 0 0 2px rgba(28, 25, 23, 0.1);
}

/* Projects Grid - Loose Intentional Masonry */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2rem;
}

/* Content-Based Varied Grid Spans */
.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-paper);
    border-radius: 3px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    position: relative;
    box-shadow: var(--shadow-card);
}

/* Alternate slight paper rotation */
.projects-grid > .project-card:nth-child(odd) {
    transform: rotate(-0.4deg);
}

.projects-grid > .project-card:nth-child(even) {
    transform: rotate(0.5deg);
}

/* Featured / Wider Spreads */
.project-card.featured-card {
    grid-column: span 2;
    background: var(--bg-card-alt);
}

@media (max-width: 820px) {
    .project-card.featured-card {
        grid-column: span 1;
    }
}

/* Tape Strip at top of card */
.project-card::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 24px;
    width: 60px;
    height: 18px;
    background: rgba(225, 215, 195, 0.65);
    border: 1px solid rgba(180, 170, 150, 0.3);
}

.project-card:hover {
    transform: translateY(-5deg) scale(1.01) !important;
    background: #ffffff;
    border-color: var(--border-dark);
    box-shadow: var(--shadow-lift);
}

.card-top {
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.card-title {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ink-primary);
    line-height: 1.3;
}

/* Rubber Stamp Status Markers */
.status-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 1.5px dashed;
    transform: rotate(-2deg);
    white-space: nowrap;
}

.status-badge.deployed {
    border-color: var(--ink-games);
    color: var(--ink-games);
    background: rgba(21, 128, 61, 0.06);
}

.status-badge.docker {
    border-color: var(--ink-sim);
    color: var(--ink-sim);
    background: rgba(29, 78, 216, 0.06);
}

.status-badge.repo {
    border-color: var(--ink-templates);
    color: var(--ink-templates);
    background: rgba(107, 33, 168, 0.06);
}

.status-badge.local {
    border-color: var(--ink-learning);
    color: var(--ink-learning);
    background: rgba(194, 65, 12, 0.06);
}

.card-desc {
    color: var(--ink-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.tags-list {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tag-item {
    font-size: 0.75rem;
    background: rgba(45, 42, 38, 0.06);
    color: var(--ink-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    font-family: var(--font-mono);
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-paper);
}

.explore-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--ink-primary);
    transition: gap 0.2s ease;
}

.project-card:hover .explore-btn {
    gap: 0.7rem;
    color: var(--ink-sim);
}

.card-links {
    display: flex;
    gap: 0.75rem;
}

.icon-link {
    color: var(--ink-muted);
    font-size: 1.1rem;
    transition: color 0.2s ease;
}

.icon-link:hover {
    color: var(--ink-primary);
}

/* ==========================================================================
   CENTER FLOATING LAB NOTEBOOK MODAL OVERLAY
   ========================================================================== */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(28, 25, 23, 0.6);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.drawer-panel {
    background: var(--bg-modal);
    border: 2px solid var(--ink-primary);
    border-radius: 4px;
    width: 100%;
    max-width: 880px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-modal);
    
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.drawer-backdrop.active .drawer-panel {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.drawer-header {
    padding: 1.25rem 2rem;
    border-bottom: 2px solid var(--ink-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card-alt);
}

.drawer-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.drawer-title-group h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink-primary);
}

.close-drawer-btn {
    background: transparent;
    border: 1px solid var(--border-dark);
    color: var(--ink-primary);
    width: 38px;
    height: 38px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.close-drawer-btn:hover {
    background: var(--ink-primary);
    color: var(--bg-paper);
}

/* Dual-Mode Tabs inside Notebook Modal */
.drawer-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-paper);
    background: var(--bg-card);
}

.tab-btn {
    flex: 1;
    padding: 0.9rem 1.25rem;
    background: none;
    border: none;
    color: var(--ink-muted);
    font-size: 0.9rem;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--ink-primary);
}

.tab-btn.active {
    color: var(--ink-primary);
    border-bottom-color: var(--ink-primary);
    background: var(--bg-modal);
    font-weight: 700;
}

/* Drawer Body Scroll Container */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Canvas Container Frame */
.canvas-runner-box {
    background: #090d16;
    border: 2px solid var(--ink-primary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 420px;
    margin-bottom: 1.5rem;
}

.canvas-runner-box canvas, .canvas-runner-box iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.canvas-top-bar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.canvas-ctrl-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--ink-primary);
    color: var(--ink-primary);
    padding: 0.4rem 0.8rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.canvas-ctrl-btn:hover {
    background: var(--ink-primary);
    color: var(--bg-paper);
}

/* Real-Time Parameter Tweaker Panel */
.tweaker-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-paper);
    border-radius: 3px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.tweaker-panel h4 {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-primary);
}

.tweak-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.tweak-control {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tweak-control label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--ink-secondary);
    font-family: var(--font-mono);
}

.tweak-control label span {
    color: var(--ink-sim);
    font-weight: 700;
}

.tweak-control input[type="range"] {
    accent-color: var(--ink-primary);
    cursor: pointer;
}

/* Command Box for Docker / Git */
.cmd-box {
    background: var(--bg-code);
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.cmd-text {
    color: var(--ink-games);
    word-break: break-all;
}

.copy-cmd-btn {
    background: var(--ink-primary);
    border: none;
    color: var(--bg-paper);
    padding: 0.45rem 0.9rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    font-weight: 600;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.copy-cmd-btn:hover {
    opacity: 0.85;
}

/* Lab Notes Breakdown Section */
.doc-section {
    margin-bottom: 1.75rem;
}

.doc-section h4 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--ink-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.narrative-quote {
    background: rgba(255, 255, 255, 0.7);
    border-left: 4px solid var(--ink-primary);
    padding: 1.25rem 1.5rem;
    border-radius: 0 4px 4px 0;
    color: var(--ink-primary);
    font-size: 0.98rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
}

.build-log {
    margin: 1.25rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.build-stage {
    background: var(--bg-card);
    border: 1px solid var(--border-paper);
    border-left: 3px solid var(--ink-sim);
    border-radius: 3px;
    padding: 1rem 1.25rem;
}

.build-stage h5 {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ink-primary);
    margin-bottom: 0.4rem;
}

.build-stage p {
    font-size: 0.92rem;
    color: var(--ink-secondary);
    margin-bottom: 0.75rem;
}

.build-stage pre {
    background: var(--bg-code);
    border: 1px solid var(--border-dark);
    padding: 0.85rem 1rem;
    border-radius: 3px;
    overflow-x: auto;
}

.build-stage pre code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink-primary);
}

.learnings-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.learnings-list li {
    position: relative;
    padding-left: 1.5rem;
    color: var(--ink-secondary);
    font-size: 0.92rem;
}

.learnings-list li::before {
    content: "▫";
    position: absolute;
    left: 0;
    color: var(--ink-primary);
    font-weight: bold;
}

.math-callout {
    background: rgba(107, 33, 168, 0.05);
    border: 1px solid rgba(107, 33, 168, 0.2);
    border-radius: 3px;
    padding: 1rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--ink-templates);
    margin-bottom: 1.25rem;
}

pre.code-block {
    background: var(--bg-code);
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    padding: 1.25rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.84rem;
    color: var(--ink-primary);
    line-height: 1.6;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--ink-primary);
    color: var(--bg-paper);
    padding: 0.75rem 1.25rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 2000;
    box-shadow: var(--shadow-lift);
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive Rules */
@media (max-width: 880px) {
    .hero-section {
        grid-template-columns: 1fr;
    }
    .hero-canvas-frame {
        transform: rotate(0deg);
    }
    .filter-container {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box {
        min-width: 100%;
    }
}
