/* Base reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    padding: 20px;
    /* Prevent layout shifts */
    overflow-y: scroll;

    /* Fixed App Background */
    background-color: #f4f4f4;
    color: #333;
}

.app-container {
    width: 100%;
    margin: 0 auto;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.25rem;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Year Grid Layout */
.year-grid {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
}

/* Screen Grid Columns */
body:not(.landscape) .year-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

body.landscape .year-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
}

/* Holiday styles */
.holiday {
    background-color: #f9f9f9;
    /* Light background for holidays */
    color: #e74c3c;
    /* Red text for holidays */
    font-weight: bold;
}

.holiday-label {
    font-size: 0.65em;
    position: absolute;
    bottom: 2px;
    left: 2px;
    right: 2px;
    /* proper width constraint */
    color: #e74c3c;
    line-height: 1;

    /* Truncation for Screen (Thumbnails) */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media print {
    .holiday-label {
        /* Full text for Print */
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 0.8rem;
        /* readable size on paper */
        bottom: 2px;
        left: 4px;
        /* slight adjustment for print margins */
    }
}

/* Month Card Structure - The "Rigid Rectangle" */
.month-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

    /* Strict Aspect Ratio per Card */
    aspect-ratio: 8.5 / 11;
    /* Default Portrait */
}

body.landscape .month-card {
    aspect-ratio: 11 / 8.5;
}

.month-title {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: min-content;
    grid-auto-rows: 1fr;
    text-align: center;
    flex-grow: 1;
    height: 100%;
}

.weekday-header,
.day {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    /* Anchor for holiday labels */
}

@media print {
    @page {
        margin: 0mm;
        /* Force 0mm margin to hide headers/footers */
        /* size attribute removed to allow js/print-modal.js to control orientation */
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        background: white !important;
    }

    /* Hide Potential Watermarks / Version Numbers */
    body::before,
    body::after,
    html::before,
    html::after {
        content: none !important;
        display: none !important;
    }


    /* Hide Header, Footer, Admin Panel, Modals, Version Badge */
    .app-header,
    .app-footer,
    #admin-panel,
    .modal-overlay,
    #toast-container,
    .controls,
    #version-badge {
        display: none !important;
    }

    .app-container {
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    .year-grid {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .month-card {
        width: 100% !important;
        height: 100vh !important;
        /* Force full viewport height per page */
        break-after: page;
        page-break-after: always;
        break-inside: avoid;
        page-break-inside: avoid;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0.5in !important;
        aspect-ratio: auto !important;
        float: none !important;
        position: relative !important;
    }

    /* Prevent blank page at end */
    .month-card:last-of-type {
        break-after: auto !important;
        page-break-after: auto !important;
        height: 99vh !important;
        /* Slightly less than 100 to avoid spillover */
        margin-bottom: 0 !important;
    }

    .month-title {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .day {
        font-size: 1.2rem;
        border: 1px solid #000;
    }

    .weekday-header {
        border: 1px solid #000;
        font-weight: bold;
        background: #eee;
    }

    /* Test Print Mode: Hide all months except January (or first child) */
    body.test-print-mode .month-card:not(:first-child) {
        display: none !important;
    }

    /* Test Print Mode: Prevent break after the visible card */
    body.test-print-mode .month-card {
        break-after: auto !important;
        page-break-after: auto !important;
        height: 100vh !important;
        /* Force full viewport/page height */
        max-height: 100vh !important;
        overflow: hidden !important;
        /* Prevent content spillover */
        margin-bottom: 0 !important;
    }
    
    /* Hide theme debug footer on Full Year prints */
    body:not(.test-print-mode) .theme-debug-label {
        display: none !important;
    }

    /* Ensure Holiday Label is readable */
    .holiday-label {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 0.8rem;
        bottom: 2px;
        left: 4px;
    }

    /* Hide Debug / Version Label */
    /* Hide Debug / Version Label */
    /* .theme-debug-label {
        display: none !important;
    } */

    /* Ensure Theme Name always shows on print (regardless of App setting) */
    .theme-debug-label {
        display: block !important;
        opacity: 1 !important;
    }
}

/* --- FOOTER & SITE CONTENT MODALS (v77.1) --- */
.app-footer {
    text-align: center;
    padding: 40px 0;
    margin-top: 40px;
    border-top: 1px solid #ddd;
    font-size: 0.9rem;
    color: #666;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}

.footer-link {
    color: #666;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #000;
    text-decoration: underline;
}

/* Reusing .modal-content but adding a modifier for text-heavy modals */
.site-content-modal {
    width: 600px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-body.site-content-body {
    padding: 20px 30px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #444;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.modal-body.site-content-body h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #222;
}

.site-content-body ul {
    margin-bottom: 15px;
    padding-left: 20px;
}

/* --- Animations --- */
/* calendar-jump moved to logo.css */

/* --- Modular Animations (v82) --- */
/* See /css/animations.css */