/* ==========================================================================
   KOLOROLANDIA - DESIGN SYSTEM & STYLING (style.css)
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. Theme Variables & Base Configuration
   ------------------------------------------------------------------------- */
:root {
    /* Day Theme Settings (Default) */
    --font-heading: 'Fredoka', sans-serif;
    --font-body: 'Quicksand', sans-serif;
    
    --bg-app: #fdfaf4;             /* Warm cream desk */
    --bg-header: #fffefe;
    --bg-card: #ffffff;
    --bg-card-border: #f0ebe0;
    --bg-desk: #f6efe2;            /* Craft wood table */
    --bg-desk-shadow: rgba(139, 115, 85, 0.15);
    --bg-canvas: #ffffff;
    --bg-tray: #fefcf9;
    --border-tray: #ecdcc9;
    
    --color-text-main: #4a3e3d;
    --color-text-muted: #8d7e7c;
    --color-primary: #ff6b6b;      /* Primary friendly red */
    --color-accent: #fcc419;       /* Sunshine yellow */
    --color-success: #51cf66;      /* Apple green */
    
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 20px rgba(139, 115, 85, 0.1);
    --shadow-lg: 0 20px 40px rgba(139, 115, 85, 0.15);
    
    --border-radius-sm: 12px;
    --border-radius-md: 20px;
    --border-radius-lg: 32px;
    
    --glow-active: 0 0 12px rgba(252, 196, 25, 0.5);
    --transition-speed: 0.3s;
    
    --bubble-color: rgba(255, 107, 107, 0.06);
}

/* Night Theme Settings */
body.night-theme {
    --bg-app: #0e111a;             /* Deep space sky */
    --bg-header: #151926;
    --bg-card: #1c2234;
    --bg-card-border: #2c354f;
    --bg-desk: #121520;            /* Starry night desk */
    --bg-desk-shadow: rgba(0, 0, 0, 0.5);
    --bg-canvas: #1e2436;
    --bg-tray: #161b2a;
    --border-tray: #27304b;
    
    --color-text-main: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-primary: #748ffc;
    --color-accent: #ffe066;
    --color-success: #2b8a3e;
    
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
    
    --glow-active: 0 0 20px rgba(116, 143, 252, 0.6);
    
    --bubble-color: rgba(116, 143, 252, 0.06);
}

/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-app);
    color: var(--color-text-main);
    font-family: var(--font-body);
    font-weight: 500;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* -------------------------------------------------------------------------
   2. Layout & Structure
   ------------------------------------------------------------------------- */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

/* Header styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 10px;
    background-color: transparent;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon-wrapper {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #fcc419, #4dabf7);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-sm);
    animation: rotatePalette 15s linear infinite;
}

.paint-palette-icon {
    font-size: 26px;
    color: white;
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
    color: var(--color-text-main);
}

.logo-text h1 span {
    color: #fcc419;
    text-shadow: 1px 1px 0px #4a3e3d;
}

body.night-theme .logo-text h1 span {
    color: #4dabf7;
    text-shadow: none;
}

.logo-text p {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    border: none;
    outline: none;
    background-color: var(--bg-card);
    border: 2px solid var(--bg-card-border);
    color: var(--color-text-main);
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease-in-out;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.control-btn:active {
    transform: translateY(1px);
}

.sound-toggle-btn i {
    color: #40c057;
}

.theme-toggle-btn i {
    color: #748ffc;
}

/* Workspace main grid */
.workspace {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    flex-grow: 1;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------------------------------------
   3. Sidebar / Choice Selector
   ------------------------------------------------------------------------- */
.sidebar {
    background-color: var(--bg-card);
    border: 3px solid var(--bg-card-border);
    border-radius: var(--border-radius-md);
    padding: 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: fit-content;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text-main);
    border-bottom: 2px dashed var(--bg-card-border);
    padding-bottom: 12px;
}

.sheet-selector-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (max-width: 1024px) {
    .sheet-selector-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .sheet-selector-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.sheet-select-card {
    border: 3px solid var(--bg-card-border);
    background-color: var(--bg-app);
    border-radius: var(--border-radius-sm);
    padding: 15px;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sheet-select-card:hover {
    transform: scale(1.03) translateY(-2px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.sheet-select-card.active {
    background-color: var(--bg-card);
    border-color: var(--color-accent);
    box-shadow: var(--glow-active);
    transform: scale(1.05);
}

.sheet-preview {
    width: 64px;
    height: 64px;
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-card);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--bg-card-border);
    font-size: 28px;
    transition: background-color var(--transition-speed);
}

.sheet-select-card.active .sheet-preview {
    background: linear-gradient(135deg, rgba(252, 196, 25, 0.15), rgba(255, 107, 107, 0.15));
    border-color: var(--color-accent);
}

.dino-preview-icon { color: #51cf66; }
.rocket-preview-icon { color: #4dabf7; }
.cat-preview-icon { color: #ff922b; }
.castle-preview-icon { color: #cc5de8; }

.sheet-select-card h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-main);
}

/* -------------------------------------------------------------------------
   4. Center Canvas / Drawing Desk
   ------------------------------------------------------------------------- */
.canvas-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.drawing-desk {
    background-color: var(--bg-desk);
    border: 12px solid #ecdcc9; /* Wood frame border */
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg), inset 0 0 40px var(--bg-desk-shadow);
    padding: 30px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transition: border-color var(--transition-speed);
}

body.night-theme .drawing-desk {
    border-color: #27304b;
}

.desk-screws {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #cbd5e1;
    border: 2px solid #94a3b8;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2);
}

body.night-theme .desk-screws {
    background-color: #475569;
    border-color: #334155;
}

.desk-screws::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 2px;
    background-color: #94a3b8;
    top: 4px;
    left: 0;
}

body.night-theme .desk-screws::after {
    background-color: #334155;
}

.screw-tl { top: 12px; left: 12px; transform: rotate(25deg); }
.screw-tr { top: 12px; right: 12px; transform: rotate(-45deg); }
.screw-bl { bottom: 12px; left: 12px; transform: rotate(115deg); }
.screw-br { bottom: 12px; right: 12px; transform: rotate(70deg); }

/* Canvas Area Container */
.canvas-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    max-width: 800px;
    background-color: var(--bg-canvas);
    border-radius: var(--border-radius-sm);
    border: 4px solid var(--border-tray);
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.06);
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Drawing SVGs */
.drawing-svg {
    display: none;
    width: 100%;
    height: 100%;
    user-select: none;
}

.drawing-svg.active {
    display: block;
}

/* Coloring Elements Interaction */
.colorable {
    cursor: pointer;
    transition: fill 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.colorable:hover {
    stroke-width: 5.5px !important;
    filter: brightness(0.98);
}

body.night-theme .colorable:hover {
    filter: brightness(1.15);
}

/* HUD Overlay on Desk */
.hud-panel {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    background-color: var(--bg-card);
    border: 2px solid var(--bg-card-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 20px;
    box-shadow: var(--shadow-sm);
    gap: 15px;
    font-size: 14px;
    transition: all var(--transition-speed);
}

.hud-item-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.hud-label {
    color: var(--color-text-muted);
}

.hud-value {
    color: var(--color-text-main);
}

.progress-wrapper {
    flex-grow: 1;
    max-width: 320px;
    justify-content: flex-end;
}

.hud-progress-bar-bg {
    width: 120px;
    height: 10px;
    background-color: var(--bg-app);
    border: 1px solid var(--bg-card-border);
    border-radius: 5px;
    overflow: hidden;
}

.hud-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #40c057, #51cf66);
    width: 0%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* Toolbar Buttons beneath desk */
.desk-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.action-btn {
    border: none;
    outline: none;
    background-color: var(--bg-card);
    border: 2px solid var(--bg-card-border);
    color: var(--color-text-main);
    padding: 12px 22px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease-in-out;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.action-btn.highlight {
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.action-btn.highlight:hover {
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.45);
    border: none;
}

/* -------------------------------------------------------------------------
   5. Footer Tray & Crayons
   ------------------------------------------------------------------------- */
.coloring-tray-container {
    background-color: var(--bg-tray);
    border: 3px solid var(--border-tray);
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
    padding: 20px 24px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.03);
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: all var(--transition-speed);
}

.tray-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 16px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tray-title i {
    color: #ff922b;
}

.crayon-box {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 5px;
    scrollbar-width: thin;
}

/* Crayon slide container */
.crayon-wrapper {
    flex: 1;
    min-width: 48px;
    max-width: 90px;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.crayon-wrapper:hover {
    transform: translateY(-15px) scale(1.05);
}

.crayon-wrapper.active {
    transform: translateY(-25px);
}

/* The actual crayon body drawing */
.crayon {
    position: relative;
    width: 100%;
    height: 130px;
    background-color: var(--crayon-color);
    border-radius: 4px 4px 8px 8px;
    border: 2px solid #4a3e3d;
    box-shadow: 3px 5px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 20px;
    box-shadow: inset -5px 0 10px rgba(0, 0, 0, 0.15), 3px 5px 8px rgba(0,0,0,0.1);
}

body.night-theme .crayon {
    border-color: #1e2436;
}

.crayon-wrapper.active .crayon {
    box-shadow: inset -5px 0 10px rgba(0,0,0,0.15), 0 0 15px var(--crayon-color);
}

/* Pointy crayon tip */
.crayon-tip {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 24px solid var(--crayon-color);
    filter: brightness(0.9);
}

.crayon-tip::after {
    content: '';
    position: absolute;
    top: 14px;
    left: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--crayon-color);
}

/* Eraser style wrapper */
.crayon-wrapper.utility {
    max-width: 90px;
}

.eraser-crayon {
    background-color: #f8f9fa;
    border-style: dashed;
}

.eraser-crayon .crayon-tip {
    border-bottom-color: #f1f3f5;
    border-style: none;
    width: 100%;
    height: 24px;
    top: -24px;
    border-radius: 12px 12px 0 0;
    background-color: #ffa8a8; /* Pink eraser head */
    border: 2px solid #4a3e3d;
    border-bottom: none;
    left: 0;
    transform: none;
}

body.night-theme .eraser-crayon .crayon-tip {
    border-color: #1e2436;
}

/* Rainbow Crayon gradient styling */
.rainbow-crayon {
    background: linear-gradient(to top, #ff6b6b, #ff922b, #ffe066, #40c057, #4dabf7, #748ffc, #d0bfff);
    border: 2px solid #4a3e3d;
}

.rainbow-crayon .crayon-tip {
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 24px solid #ff6b6b;
    background: transparent;
}

/* Label on crayon */
.crayon-label {
    writing-mode: vertical-rl;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    color: rgba(0,0,0,0.5);
    user-select: none;
    transform: rotate(180deg);
}

.eraser-crayon .crayon-label,
.rainbow-crayon .crayon-label {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 10px;
    text-align: center;
    width: 100%;
    padding: 0 2px;
}

/* -------------------------------------------------------------------------
   6. Modals & Success Overlays
   ------------------------------------------------------------------------- */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(74, 62, 61, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.success-overlay.active {
    display: flex;
    opacity: 1;
}

.success-modal {
    background-color: var(--bg-card);
    border: 6px solid var(--color-accent);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-overlay.active .success-modal {
    transform: scale(1);
}

.modal-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(252, 196, 25, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
    border: 3px solid var(--color-accent);
    animation: pulseTrophy 2s infinite;
}

.modal-trophy-icon {
    font-size: 40px;
    color: var(--color-accent);
}

.success-modal h2 {
    font-family: var(--font-heading);
    font-size: 32px;
    color: var(--color-text-main);
    margin-bottom: 12px;
}

.success-modal p {
    font-size: 16px;
    color: var(--color-text-muted);
    margin-bottom: 30px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    border: none;
    outline: none;
    padding: 14px 28px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.45);
}

.modal-btn.outline {
    background-color: transparent;
    border: 2px solid var(--bg-card-border);
    color: var(--color-text-muted);
}

.modal-btn.outline:hover {
    background-color: var(--bg-app);
    color: var(--color-text-main);
}

/* Confetti piece styling */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--confetti-color);
    top: -10px;
    border-radius: 30%;
    animation: confettiFall 3s linear infinite;
}

/* -------------------------------------------------------------------------
   7. Background Floating Elements
   ------------------------------------------------------------------------- */
.bubble-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.bg-bubble {
    position: absolute;
    background-color: var(--bubble-color);
    border-radius: 50%;
    bottom: -100px;
    animation: floatUp 15s infinite ease-in;
}

/* -------------------------------------------------------------------------
   8. Keyframes & Animations
   ------------------------------------------------------------------------- */
@keyframes rotatePalette {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseTrophy {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); box-shadow: 0 0 20px rgba(252, 196, 25, 0.3); }
    100% { transform: scale(1); }
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-110vh) scale(1.5) rotate(360deg);
        opacity: 0;
    }
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(450px) rotate(360deg);
    }
}

/* -------------------------------------------------------------------------
   9. Print Media Adjustments (Coloring Book Mode)
   ------------------------------------------------------------------------- */
@media print {
    body, body.night-theme {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    
    .app-container {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .app-header, 
    .sidebar, 
    .hud-panel, 
    .desk-toolbar, 
    .coloring-tray-container,
    .success-overlay,
    .bubble-bg,
    .desk-screws {
        display: none !important;
    }
    
    .workspace {
        grid-template-columns: 1fr !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .drawing-desk {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: transparent !important;
    }
    
    .canvas-container {
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        aspect-ratio: 4/3 !important;
    }
    
    .drawing-svg {
        display: none !important;
    }
    
    .drawing-svg.active {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Force white fills and black outlines on printed sheets */
    .colorable {
        fill: #ffffff !important;
        stroke: #000000 !important;
        stroke-width: 3.5px !important;
    }
    
    .bg-rect {
        fill: #ffffff !important;
        stroke: #000000 !important;
    }
}
