/* =========================================================
   DIGITAL SKETCHPAD STYLES 
   Based on OptiScanner UI (Terminal/Microfilm Aesthetic)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap');

/* ------------------------------ */
/* 1) TOKENS & THEMES             */
/* ------------------------------ */
:root {
    /* OptiScanner Base Tokens */
    --os-font-ui: 'Roboto Mono', 'Courier New', monospace;
    --os-font-body: system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    
    /* Neutral "microfilm" palette */
    --os-bg: #e9e9e9;        
    --os-surface: #d1d1d1;   
    --os-backdrop: #ffffff;  
    --os-text: #2c2c2c;
    --os-border: #555555;
    --os-interactive: #4a4a4a; 

    /* Spacing (4px base) */
    --os-s-2: 8px;  
    --os-s-3: 12px; 
    --os-s-4: 16px;
    --os-s-5: 20px; 

    /* Square corners */
    --os-radius: 0;
}

/* 🌙 Neon Dark Mode Overrides */
body.neon-mode {
    --os-bg: #0a0a0a;        /* Pitch black background */
    --os-surface: #1a1a1a;   /* Dark panels */
    --os-backdrop: #000000;  /* Pure black canvas */
    --os-text: #00ffcc;      /* Glowing cyan/neon text */
    --os-border: #333333;
    --os-interactive: #00ffcc;
}

/* ------------------------------ */
/* 2) BASE LAYOUT (The iPad Setup)*/
/* ------------------------------ */
html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden; /* Stops page scrolling */
    background: var(--os-bg);
    color: var(--os-text);
    font-family: var(--os-font-body);
    /* CRITICAL: Prevents Apple Pencil from triggering browser gestures */
    touch-action: none; 
}

/* ------------------------------ */
/* 3) THE WORKSPACE & CANVAS      */
/* ------------------------------ */
#workspace {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent native scrollbars from clipping our zoomed canvas! */
}

#canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    /* NEW: Smoothly animate the camera moves, and scale from the center */
    transform-origin: center center;
    transition: transform 0.05s linear; 
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#layer-background {
    background-color: var(--os-backdrop);
    transition: background-color 0.3s ease;
}

/* ------------------------------ */
/* 4) MINIMALIST UI TOGGLE        */
/* ------------------------------ */
.floating-btn {
    position: absolute;
    top: var(--os-s-4);
    left: var(--os-s-4);
    z-index: 100;
    
    font-family: var(--os-font-ui);
    text-transform: uppercase;
    font-size: 1rem;
    background: var(--os-surface);
    color: var(--os-text);
    border: 1px solid var(--os-border);
    padding: 10px 14px;
    border-radius: var(--os-radius);
    cursor: pointer;
    
    display: flex;
    align-items: center;
    gap: var(--os-s-3);
    transition: background 0.2s, color 0.2s;
}

.floating-btn:hover {
    background: var(--os-interactive);
    color: var(--os-bg);
}

#active-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--os-text);
    border-radius: 50%; /* The only non-square element! */
}

/* Make it glow in Neon Mode */
body.neon-mode #active-indicator {
    box-shadow: 0 0 8px var(--os-text);
}

/* ------------------------------ */
/* 5) SLIDING DRAWER              */
/* ------------------------------ */
.drawer {
    position: absolute;
    top: 0;
    left: 0;
    width: 330px; /* NEW: Widened to comfortably fit all 7 layer buttons! */
    height: 100%;
    z-index: 200;
    
    background: var(--os-surface);
    border-right: 1px solid var(--os-border);
    display: flex;
    flex-direction: column;
    padding: var(--os-s-5);
    padding-bottom: 120px; /* NEW: Extra padding so the Export button clears the bottom */
    gap: var(--os-s-5);
    overflow-y: auto;
    
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer.hidden {
    transform: translateX(-100%);
}

/* ------------------------------ */
/* 6) DRAWER TYPOGRAPHY           */
/* ------------------------------ */
.drawer header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--os-border);
    padding-bottom: var(--os-s-3);
}

.drawer h2 {
    font-family: var(--os-font-ui);
    text-transform: uppercase;
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
}

.drawer h3 {
    font-family: var(--os-font-ui);
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--os-text);
    opacity: 0.7;
    margin: 0 0 var(--os-s-2) 0;
}

/* ------------------------------ */
/* 7) TOOLS & CONTROLS            */
/* ------------------------------ */
.tool-group {
    display: flex;
    flex-direction: column;
    gap: var(--os-s-2);
}

.tool-group button, #theme-toggle {
    font-family: var(--os-font-ui);
    text-transform: uppercase;
    font-size: 0.9rem;
    border: 1px solid var(--os-border);
    background: var(--os-bg);
    color: var(--os-text);
    padding: 10px 18px;
    cursor: pointer;
    border-radius: var(--os-radius);
    text-align: left;
    transition: background 0.2s, color 0.2s;
}

.tool-group button:hover, #theme-toggle:hover {
    background: var(--os-interactive);
    color: var(--os-bg);
}

/* The selected tool gets an outline just like the OptiScanner segments */
.tool-group button.active {
    background: var(--os-text);
    color: var(--os-bg);
    outline: 2px solid var(--os-text);
    outline-offset: 2px;
}

/* Range Sliders (Brush Size) */
input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--os-text);
}

/* Native Color Picker (Make it massive and square for easy tapping) */
input[type="color"] {
    width: 100%;
    height: 48px;
    padding: 2px;
    background: var(--os-backdrop);
    border: 1px solid var(--os-border);
    border-radius: var(--os-radius);
    cursor: pointer;
}

/* Neon mode color picker override to look more cyberpunk */
body.neon-mode input[type="color"] {
    border-color: var(--os-text);
    box-shadow: 0 0 5px var(--os-text);
}

/* Real-time additive blending for the Draft Layer preview! */
body.neon-mode #layer-draft {
    mix-blend-mode: plus-lighter;
}

/* --- DRAWER FOOTER --- */
.drawer-footer {
    margin-top: auto;
    padding-top: var(--os-s-4);
    padding-bottom: 100px;
    border-top: 1px dashed var(--os-border);
    display: flex;
    justify-content: center; /* NEW: Groups everything in the middle */
    gap: 12px;               /* NEW: Sets the exact spacing between items */
    font-family: var(--os-font-ui);
    font-size: 0.8rem;
}

.drawer-footer a {
    color: var(--os-text);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.drawer-footer a:hover {
    opacity: 1;
    text-decoration: underline dashed;
}