/* --- BASE STYLES & TYPOGRAPHY --- */

/* Use Courier New for the logo and a readable sans-serif fallback for body text */
body {
    background-color: #f0f0f0; /* Light gray background outside the notebook area */
    font-family: sans-serif;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Notebook Container (The body of the page) */
.notebook-body {
    width: 100%;
    max-width: 900px; /* Max width to keep the notebook centered and readable */
    margin: 0 auto;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    padding-bottom: 80px; /* Space for the fixed action buttons */
    min-height: calc(100vh - 80px); /* Ensure notebook fills screen height */
}

/* Responsive Centering (As requested, no hardcoded pixel width for the main container) */
@media (max-width: 900px) {
    .notebook-body {
        max-width: 100%;
        margin: 0;
        box-shadow: none;
    }
}

/* --- NOTEBOOK PAPER STYLING --- */

/* Horizontal "Line" effect (using a striped background) */
.notebook-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none; /* Allows drawing/interaction underneath */
    /* Light blue lines, 30px apart (adjust height based on desired line spacing) */
    background-image: repeating-linear-gradient(
        #fff, #fff 29px, #ebf3f8 30px, #ebf3f8 30px
    );
    z-index: 1; 
}

/* Red Margin Line (on the right side) */
.notebook-body::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50px; /* Adjust based on desired margin width */
    bottom: 0;
    width: 2px;
    background-color: #ff5252; /* Bright Red */
    z-index: 2;
}

/* --- HEADER & LOGO --- */

.sticky-header {
    position: sticky;
    top: 0;
    width: 100%;
    max-width: 900px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    z-index: 100; /* Ensure it stays above everything */
}

.logo-container h1 {
    font-family: "Courier New", Courier, monospace; /* Use Courier New font */
    font-size: 2em;
    font-weight: bold;
    color: #333;
    user-select: none;
}

/* --- SEO TAGLINE STYLING --- */
.logo-container .tagline {
    font-family: sans-serif;
    font-size: 0.75em; 
    font-weight: 400;
    color: #777; 
    margin-top: -5px; 
    display: block;
}

/* --- COLOR PICKER (Bic pen colors) --- */

.color-picker {
    display: flex;
    gap: 10px;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #ccc;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
}

.color-dot:hover {
    opacity: 1;
    transform: scale(1.1);
}

.color-dot[data-color="blue"] { background-color: #1976d2; }
.color-dot[data-color="red"] { background-color: #d32f2f; }
.color-dot[data-color="black"] { background-color: #212121; }

.color-dot.active {
    border-color: #000;
    border-width: 3px;
    opacity: 1;
}

/* --- LIVE CANVAS AREA --- */

.canvas-area {
    position: relative;
    width: 100%;
    padding: 20px;
    /* Desktop/Large Screen Height (580px canvas + buffer) */
    min-height: 600px; 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

#scribble-canvas {
    position: absolute;
    top: 0;
    left: 0;
    /* Canvas will be sized by JavaScript, but we want it to fill the section */
    width: 100%; 
    height: 100%;
    z-index: 10;
    cursor: crosshair;
}

#canvas-overlay {
    position: relative;
    padding: 20px;
    font-size: 1.5em;
    color: #ccc;
    z-index: 9;
    user-select: none;
    pointer-events: none; /* Ensure text doesn't block touch/mouse events */
}

/* --- MOBILE HEIGHT FIX (Media Query) --- */
@media (max-width: 768px) {
    .canvas-area {
        /* FIX: Reduced canvas height to 70% of the viewport height.
           This guarantees that the Scribble Stories archive header is immediately visible. */
        min-height: 70vh; 
        /* Padding must be reduced/removed to maximize canvas space on small screens */
        padding: 0;
    }
}


/* --- ARCHIVE FEED --- */

.archive-feed {
    padding: 20px 60px 80px 20px; /* Keeps the images clear of the margin line */
    position: relative;
    z-index: 5;
}

.archive-feed h2 {
    font-family: "Courier New", Courier, monospace;
    font-size: 1.5em;
    color: #666;
    margin-bottom: 20px;
    border-bottom: 1px dashed #ddd;
    padding-bottom: 5px;
}

/* Style for the saved PNGs (which will be inserted here) */
.saved-scribble-image {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 30px;
}

/* --- MOBILE ACTION BUTTONS --- */

.action-buttons-container {
    position: fixed;
    bottom: 20px;
    width: 100%;
    max-width: 900px; /* Match the notebook body width */
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none; /* Allow clicks to pass through to the page */
    z-index: 100;
}

.action-button {
    /* Style for round transparent buttons for easy mobile use */
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    font-weight: bold;
    border: 2px solid #333;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    pointer-events: all; /* Make the buttons clickable */
    transition: background-color 0.2s, transform 0.2s;
}

/* Adjust size for smaller screens */
@media (max-width: 450px) {
    .action-button {
        width: 60px;
        height: 60px;
        font-size: 0.8em;
    }
}

.action-button:hover {
    background-color: rgba(240, 240, 240, 0.9);
    transform: translateY(-2px);
}

/* --- FOOTER --- */

footer {
    width: 100%;
    max-width: 900px;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.8em;
    color: #999;
    border-top: 1px solid #eee;
    margin-top: auto; /* Pushes the footer to the bottom of the visible area */
}