/* css/style.css - v16 Resizable Side Panel */
@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');

body {
    background-color: #1a110a;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden; /* Prevent body scrollbars */
    color: #333;
}

/* Add classes to body to prevent selection/scrolling during interactions */
body.resizing, body.resizing * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    touch-action: none; /* Prevent scrolling on touch devices during resize */
}
body.side-panel-open {
    /* Optionally prevent body scroll if needed, but overflow:hidden should do it */
}


#main-header {
    height: 150px; /* Keep header space */
    background-color: #333;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

#main-header h1 {
    color: #ff4444;
    text-align: center;
    font-size: 2.5em;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px #ff0000;
    animation: flicker 0.5s infinite alternate;
    margin: 0;
    font-family: 'Permanent Marker', cursive;
}

/* Canvas container */
#canvas {
    position: absolute;
    top: 150px;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: default;
    overflow: hidden;
    touch-action: none; /* Prevent default touch actions like scroll/zoom */
    /* --- ADDED --- */
    user-select: none;         /* Standard syntax */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE/Edge */
    /* ------------- */
}

/* Background Layer */
#background-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('../images/bgcork.png');
    background-repeat: repeat;
    background-size: 1500px 1500px;
    background-position: 0px 0px;
    will-change: background-position, background-size;
    z-index: 1;
}

/* Content Layer */
#canvas-content {
    position: absolute;
    top: 0; left: 0; width: 2600px; height: 1400px;
    transform-origin: 0 0;
    will-change: transform;
    z-index: 2;
    image-rendering: pixelated;
}

/* --- .note styles --- */
.note {
    position: absolute;
    background: #ffff99;
    border: 2px solid #000;
    width: 200px; height: 200px;
    padding: 10px;
    text-align: left;
    cursor: default; /* Default cursor, changes to grabbing during pan */
    transform: rotate(var(--note-rotation, 0deg));
    transition: box-shadow 0.2s, background-color 0.2s, transform 0.2s ease-out;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    font-family: 'Permanent Marker', cursive;
    font-size: 16px;
    color: #000;
    line-height: 1.3;
    z-index: 10;
    box-sizing: border-box;
    user-select: none; -webkit-user-select: none; -moz-user-select: none;
    pointer-events: auto;
    overflow: visible; /* Keep pin visible */
    touch-action: none; /* Prevent default touch actions on notes too */
}

/* --- .note-pin styles --- */
.note-pin {
    position: absolute;
    top: -25px; left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: #CC0000;
    cursor: pointer; /* Explicitly pointer */
    z-index: 11;
    pointer-events: auto;
    padding: 5px; margin: -5px; /* Hit area */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    user-select: none; -webkit-user-select: none; -moz-user-select: none;
    transition: transform 0.15s ease-out, color 0.15s ease-out;
    touch-action: auto; /* Allow default touch actions on pin (e.g., for click) */
}
.note-pin:hover {
    transform: translateX(-50%) scale(1.25);
    color: #FF0000;
}

/* Style for pin when side panel is open for this note */
.note.selected-pin .note-pin {
    transform: translateX(-50%) scale(1.1);
    color: #FF3333;
}


/* --- Image note styles --- */
.note.note-image {
    width: auto; height: auto;
    background: transparent; border: none; padding: 0;
    font-size: 0; color: transparent;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
}
.note.note-image .note-image-content {
    position: relative; pointer-events: none;
}
.note.note-image .note-image-content img {
    display: block; width: auto; height: auto; max-width: none;
    border: 3px solid #333; box-sizing: border-box; pointer-events: none;
}


/* Style for note when its title is shown in the BOTTOM info bar */
.note.selected-bottom:not(.note-image) {
    box-shadow: 0 0 0 2px rgba(255, 255, 100, 0.7), 3px 3px 10px rgba(0, 0, 0, 0.5); /* Subtle yellow outline */
}
.note.note-image.selected-bottom {
    box-shadow: 0 0 0 3px rgba(255, 255, 100, 0.7), 3px 3px 10px rgba(0, 0, 0, 0.5); /* Subtle yellow outline for image */
}


/* --- #n1 styles (Pepe Silvia reveal) --- */
#n1 {
    transform: scale(0) rotate(calc(var(--note-rotation, 0deg) - 15deg));
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.4s ease-out;
}
#n1.visible {
    transform: scale(1) rotate(var(--note-rotation, 0deg));
    opacity: 1;
}


/* --- #info Panel Style (Bottom Center for Title) --- */
#info {
    position: fixed;
    bottom: 15px; /* Slightly lower */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 15px; /* Make it smaller */
    border-radius: 5px;
    max-width: 60%;
    font-size: 13px; /* Smaller font */
    display: none;
    z-index: 1100; /* Above notes */
    text-align: center;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    font-family: sans-serif;
    pointer-events: none; /* Click through this simple panel */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- NEW Side/Bottom Info Panel Style --- */
#side-info-panel {
    position: fixed;
    background-color: rgba(30, 30, 30, 0.95); /* Dark background */
    color: #eee;
    z-index: 1200; /* Above bottom info and reset button */
    box-shadow: -3px 0 10px rgba(0,0,0,0.5); /* Shadow on the left */
    display: flex; /* Use flex for content */
    flex-direction: column; /* Stack handle/content vertically */
    transition: transform 0.3s ease-out;
    overflow: hidden; /* Hide content overflow initially */
    font-family: sans-serif;
    pointer-events: auto; /* Panel should capture events */
    touch-action: none; /* Prevent default touch actions while interacting with the panel itself */

    /* --- Desktop Defaults (Side Panel) --- */
    top: 150px; /* Below header */
    right: 0;
    bottom: 0; /* Fill height */
    width: 300px; /* Default width */
    height: auto; /* Height is determined by top/bottom */
    transform: translateX(100%); /* Start hidden off-screen right */
    border-left: 1px solid #555;
}
#side-info-panel.visible {
    transform: translateX(0); /* Slide in */
}

/* --- Side Panel Content Area --- */
.side-info-content {
    padding: 15px;
    overflow-y: auto; /* Allow content scrolling */
    flex-grow: 1; /* Take remaining space */
    touch-action: pan-y; /* Allow vertical scrolling on touch devices */
}
.side-info-content img#side-info-image {
    max-width: 100%;
    height: auto;
    border: 1px solid #444;
    margin-bottom: 15px;
    display: block; /* Ensure it behaves as a block */
}
.side-info-content h2#side-info-title {
    margin-top: 0;
    margin-bottom: 10px;
    color: #ffcc66; /* Title color */
    font-size: 1.3em;
}
.side-info-content p {
    font-size: 0.9em;
    line-height: 1.4;
    color: #ccc;
}

/* --- Side Panel Close Button --- */
#side-info-panel .close-btn {
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    padding: 5px;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 1201; /* Above content */
    touch-action: auto; /* Allow default touch action (click) */
}
#side-info-panel .close-btn:hover {
    color: #fff;
}

/* --- Side Panel Resize Handle --- */
#side-info-panel .resize-handle {
    position: absolute;
    background-color: rgba(85, 85, 85, 0.5); /* Semi-transparent handle */
    transition: background-color 0.2s;
    z-index: 1201; /* Above content */
    touch-action: none; /* Crucial: Prevent scrolling when dragging the handle */

    /* --- Desktop Handle (Left Edge) --- */
    top: 0;
    bottom: 0;
    left: 0;
    width: 10px; /* Width of handle */
    cursor: ew-resize; /* East-West resize cursor */
}
#side-info-panel .resize-handle:hover {
    background-color: rgba(120, 120, 120, 0.7);
}

/* --- Mobile Styles (Media Query) --- */
@media (max-width: 768px) {
    #side-info-panel {
        /* --- Mobile Defaults (Bottom Panel) --- */
        top: auto; /* Unset top */
        right: 0;
        left: 0; /* Full width */
        bottom: 0; /* Anchored to bottom */
        width: 100%; /* Full width */
        height: 40%; /* Default height */
        max-height: 80%; /* Limit max height */
        transform: translateY(100%); /* Start hidden off-screen bottom */
        box-shadow: 0 -3px 10px rgba(0,0,0,0.5); /* Shadow on top */
        border-top: 1px solid #555;
        border-left: none; /* Remove side border */
    }
    #side-info-panel.visible {
        transform: translateY(0); /* Slide up */
    }

    #side-info-panel .resize-handle {
         /* --- Mobile Handle (Top Edge) --- */
        top: 0;
        left: 0;
        right: 0;
        bottom: auto; /* Unset bottom */
        width: 100%; /* Full width */
        height: 10px; /* Height of handle */
        cursor: ns-resize; /* North-South resize cursor */
    }

    .side-info-content {
        padding: 10px; /* Adjust padding */
        /* touch-action: pan-y; Already set above */
    }
     .side-info-content h2#side-info-title {
        font-size: 1.1em;
    }
}


/* --- #reset-view-btn Style --- */
#reset-view-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px; height: 44px;
    background-color: rgba(51, 51, 51, 0.8);
    color: #fff;
    border: 1px solid #fff;
    border-radius: 50%;
    font-size: 26px;
    line-height: 42px;
    text-align: center;
    cursor: pointer;
    z-index: 1150; /* Below side panel but above info */
    transition: background-color 0.2s, transform 0.2s;
    user-select: none; -webkit-user-select: none;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    pointer-events: auto;
    touch-action: auto; /* Allow default click */
}
#reset-view-btn:hover {
    background-color: rgba(255, 68, 68, 0.9);
    transform: scale(1.1);
}
#reset-view-btn:active {
    transform: scale(1.0);
}

/* --- Animations --- */
@keyframes flicker {
    0%, 100% { opacity: 1; text-shadow: 2px 2px 4px #ff0000; }
    50% { opacity: 0.7; text-shadow: 2px 2px 8px #ff4444; }
}