/* CSS styles for the bulletin */
/* @import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400..700&display=swap'); */ /* Commented out - will be replaced by local @font-face rules */
/* @import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap'); */ /* Commented out - will be replaced by local @font-face rules */

/* CSS Variables for modern styling */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #4CAF50;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --background-light: #fafafa;
    --background-lighter: #f5f5f5;
    --border-color: #e0e0e0;
    --border-radius: 3px;
    --box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
    --multi-day-bg: linear-gradient(135deg, #f8fff8 0%, #f0f8f0 100%);
    --announcement-bg: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

/* LOCAL FONT DEFINITIONS */
@font-face {
  font-family: 'Dancing Script';
  font-style: normal;
  font-weight: 400; /* Normal weight */
  src: url('fonts/DancingScript-Regular.ttf') format('truetype'); /* ADJUST FILENAME if needed */
}

@font-face {
  font-family: 'Dancing Script';
  font-style: normal;
  font-weight: 700; /* Bold weight */
  src: url('fonts/DancingScript-Bold.ttf') format('truetype'); /* ADJUST FILENAME if needed */
}

@font-face {
  font-family: 'Merriweather';
  font-style: normal;
  font-weight: 400; /* Normal/Regular weight */
  src: url('fonts/Merriweather_24pt-Regular.ttf') format('truetype'); /* ADJUST FILENAME if needed (e.g., another optical size or if you renamed it) */
}

@font-face {
  font-family: 'Merriweather';
  font-style: normal;
  font-weight: 700; /* Bold weight */
  src: url('fonts/Merriweather_24pt-Bold.ttf') format('truetype'); /* ADJUST FILENAME if needed (e.g., Merriweather-Bold.ttf or another optical size) */
}

/* ADD @font-face for the body font (e.g., Open Sans) */
@font-face {
  font-family: 'Open Sans'; /* Or your chosen open-source sans-serif */
  font-style: normal;
  font-weight: 400;
  src: url('fonts/OpenSans-Regular.woff2') format('woff2'); /* ADJUST FILENAME if using TTF or different name */
}

@font-face {
  font-family: 'Open Sans'; /* Or your chosen open-source sans-serif */
  font-style: normal;
  font-weight: 700; /* For bold */
  src: url('fonts/OpenSans-Bold.woff2') format('woff2'); /* ADJUST FILENAME if using TTF or different name */
}
/* END LOCAL FONT DEFINITIONS */

@page {
    size: letter landscape; /* US Letter landscape (11in x 8.5in) */
    /* Or use A4 landscape: size: A4 landscape; */
    margin: 0.5in; /* Adjust margin as needed */
}

body {
    margin: 0; /* Remove default body margin */
    font-family: 'Open Sans', sans-serif; /* Using Open Sans as the FOSS body font */
    -webkit-print-color-adjust: exact !important; /* Ensure colors print in WebKit browsers */
    print-color-adjust: exact !important;         /* Standard */
    word-break: break-word; /* Help break long words to prevent overflow */
}

.page {
    display: flex;
    flex-direction: row; /* Panels side-by-side */
    width: 100%; /* Fill the content box of the @page */
    height: 100%; /* Fill the content box of the @page */
    box-sizing: border-box;
    page-break-after: always; /* Each .page div creates a new PDF page */
}

body > .page:last-of-type {
    page-break-after: avoid !important; /* Avoid a blank page after the last .page, more specific and important */
}

.panel {
    width: 50%; /* Fallback */
    flex-basis: 50%; /* Explicit flex basis */
    flex-shrink: 1;  /* Allow shrinking */
    flex-grow: 0;    /* Do not allow growing beyond basis */
    min-height: 0;   /* Crucial for allowing shrink with overflow */
    height: 100%;
    box-sizing: border-box;
    padding: 12px; /* Slightly Reduced panel padding */
    overflow: hidden; /* Prevent content from overflowing and breaking layout */
    page-break-inside: avoid; /* Suggest to renderer not to break inside a panel */
    /* border: 1px solid #eee; */ /* Optional: for visualizing panel boundaries */
}

/* Ensure panels that are not the first child in a .page have a left border for separation */
.panel + .panel {
    border-left: 1px dotted #ccc; /* Visual separator between panels on the same page */
}


/* General styling for content within panels */
h1, h2, h3, h4 {
    margin-top: 0;
    color: #333;
}

h1 { font-size: 1.8em; margin-bottom: 0.5em; }
h2 { font-size: 1.5em; margin-bottom: 0.4em; }
h3 { font-size: 1.2em; margin-bottom: 0.3em; }
h4 { font-size: 1em; margin-bottom: 0.2em; }

p {
    font-size: 0.9em;
    line-height: 1.4;
    margin-bottom: 0.8em;
}

a {
    color: #0066cc;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Panel Specific Styles */

/* Panel 1: Front Cover */
.panel-front-cover {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 8px 0.25in; /* Reduced padding for more space */
    height: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Prevent any overflow from this panel */
}
.panel-front-cover h1 {
    font-family: 'Dancing Script', cursive;
    font-size: 2.4em; /* Reduced from 2.8em for more space */
    font-weight: 700; /* Use bold Dancing Script (700) */
    margin: 0 0 3px 0; /* Minimal margins */
    text-align: center; /* Center the h1 text */
    flex-shrink: 0; /* Don't shrink the title */
}
.bulletin-date-front-cover { /* New style for the date */
    font-family: 'Dancing Script', cursive;
    font-size: 1.2em; /* Reduced from 1.4em */
    font-weight: 400; /* Use normal Dancing Script (400) */
    color: #333; /* Same color as headings or adjust */
    margin: 0 0 8px 0; /* Minimal margins */
    text-align: center; /* Ensure it's centered like the h1 */
    flex-shrink: 0; /* Don't shrink the date */
}

/* New rule for the container */
.cover-image-container {
    width: 100%;
    flex: 1; /* Take up remaining space in the flex container */
    min-height: 0; /* Allow flex item to shrink */
    max-height: 100%; /* Don't exceed parent bounds */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin-bottom: 5px; /* Minimal margin */
    box-sizing: border-box;
    position: relative;
}

.panel-front-cover img {
    max-width: 95%; /* Slightly smaller than container to ensure no overflow */
    max-height: 95%; /* Slightly smaller than container to ensure no overflow */
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
/* .panel-front-cover p { 
/*    font-size: 1.1em;
/*    font-weight: bold;
/* } 
*/

/* Panel 2: Inside Left (Theme, Sabbath School, Divine Worship) */
.panel-inside-left h2 { /* Bulletin Theme Title */
    font-family: 'Dancing Script', cursive; /* Changed from Merriweather */
    text-align: center;
    margin-bottom: 8px; /* Reduced from 15px */
    font-size: 1.7em; /* Reduced from 1.9em */
    font-weight: normal; /* Dancing Script often uses normal or a specific weight like 400 or 700 */
}

.section { /* Applies to SS and DW main section divs */
    margin-bottom: 20px; /* Increased from 10px to add more space */
}

.section h3 { /* Sabbath School & Divine Worship titles */
    font-family: 'Merriweather', serif; /* Or your chosen serif font */
    font-weight: 700; /* Changed to bold */
    border-bottom: 1px solid #eee;
    padding-bottom: 2px; /* Reduced from 3px */
    margin-bottom: 6px; /* Reduced from 10px */
    font-size: 1.2em; /* Reduced from 1.3em */
}

.divine-worship-items-column-container { /* NEW: For 2-column layout within DW section */
    column-count: 2;
    column-gap: 6px; /* Further reduced for more space */
    column-fill: balance; /* Changed from auto to balance columns better */
    orphans: 1; /* Allow single lines at bottom of column */
    widows: 1; /* Allow single lines at top of column */
}

.event-item { /* General style for SS and DW items */
    margin-bottom: 5px; /* Increased from 3px to use more space */
    break-inside: avoid-column; /* Suggestion for items in DW columns */
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
}

.event-label { /* Applies to SS and DW labels */
    font-weight: bold;
    font-size: 1.0em; /* Increased from 0.95em - we have room now */
}

span.event-value { /* Specifically target SS details span */
    font-size: 0.9em; /* Reduced from 1.0em to save space */
    display: inline-block; 
    margin-left: 6px; /* Reduced from 8px */
    line-height: 1.3; /* Reduced from 1.45 */
}

/* Target p tags within event-item (mostly affects DW items) */
.event-item p,
.event-item .event-title, 
.event-item .event-details, 
.event-item .event-speaker {
    font-size: 1.0em; /* Increased from 0.9em */
    line-height: 1.4; /* Increased from 1.3 */
    margin-top: 2px; /* Increased from 1px */ 
    margin-bottom: 4px; /* Increased from 3px */
}

.event-title {
    font-style: italic;
    margin-left: 6px; /* Further reduced indent */
}
.event-details, .event-speaker {
    margin-left: 6px; /* Further reduced indent */
}
.event-speaker em {
    font-style: normal; /* Speaker name might not need to be double italicized if .event-speaker is italic */
}

/* New styles for section titles with time and SS item times */
.section-title-with-time {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.section-time { /* For Divine Worship time */
    font-size: 0.8em; 
    font-weight: normal;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    color: #555; 
}

.ss-time { /* For Sabbath School item times */
    font-weight: normal;
    font-size: 0.9em; 
    margin-right: 8px;
    color: #333; 
    display: inline-block; 
}

/* Styles for Sabbath School items with time alignment */
.sabbath-school .event-item { /* Make .event-item within .sabbath-school a flex container */
    display: flex;
    justify-content: space-between; /* Pushes time to one side, info to the other */
    align-items: flex-start;          /* Align to top edge, more robust for varying content heights */
    /* margin-bottom: 6px; */ /* Retain or adjust item bottom margin, inherits from generic .event-item if not overridden */
}

.sabbath-school .ss-time { /* Styles for the time itself */
    font-weight: normal;
    font-size: 0.9em; 
    color: #333; 
    display: inline-block; /* Keep as inline-block or block as needed */
    flex-shrink: 0; /* Prevent time from shrinking */
    /* margin-right: 10px; /* Removed, relying on space-between from parent */
}

.sabbath-school .ss-info { /* Container for label and details */
    text-align: left; /* Default, adjust if you want label/details aligned right */
    flex-grow: 1;
    /* margin-left: 10px; /* Add if .ss-time doesn't have margin-right & space-between isn't enough */
    display: flex; /* Make this a flex container as well */
    align-items: baseline; /* Align children to their baseline */
}

/* Adjustments to existing .event-label and .event-value when inside .sabbath-school */
.sabbath-school .event-label {
    /* font-weight: bold; /* Inherits from generic .event-label */
    /* font-size: 1.05em; /* Inherits generic .event-label if specific styles here are commented out or match */
    /* display: inline; /* Changed from inline */
    min-width: 125px; /* Adjust this value as needed - Increased from 110px */
    display: inline-block; /* Or just block if preferred, but inline-block allows fixed width */
    margin-right: 5px; /* Add some space between label and value */
}

.sabbath-school span.event-value {
    /* font-size: 1.0em; /* Inherits from generic span.event-value */
    /* display: inline; /* No longer strictly needed if parent is flex and label has width */ 
    /* margin-left: 8px; /* Inherits */ 
    /* line-height: 1.45; /* Inherits */
}

/* Panel 3: Inside Right (Announcements) */
.panel-inside-right {
    /* column-count: 2; */ /* Moved to .announcements-column-container */
    /* column-gap: 10px; */ /* Moved */
    /* column-fill: auto;  */ /* Moved */
    /* height: 100%; */ /* Panel already has height: 100% */
}

.panel-inside-right h2 { /* Title "Announcements" */
    text-align: center;
    margin-bottom: 4px; /* Reduced margin for more space */
    font-size: 1.3em; /* Slightly smaller header */
    font-weight: 700; /* Added to make it explicitly bold */
    /* Ensure the body font ('Open Sans' or system fallback) has a bold version available */
}

.announcements-column-container { /* New class for applying column styles */
    column-count: 2; /* Enable 2-column layout */
    column-gap: 8px; /* Reduced space between columns */
    column-fill: balance; /* Balance content between columns */
    height: calc(100% - 40px); /* Account for header height */
    max-height: 100%; /* Strict height limit */
    overflow: hidden; /* If content still overflows columns, clip it here */
    orphans: 1; /* Allow single lines at bottom of column */
    widows: 1; /* Allow single lines at top of column */
    /* Dynamic font scaling based on content amount */
    font-size: 0.75em; /* Default, overridden by inline style */
}

.announcement {
    margin-bottom: 3px; /* Further reduced for ultra-compact layout */
    padding: 3px 4px; /* Very compact padding */
    border-radius: var(--border-radius); /* Using CSS variable */
    background: var(--announcement-bg); /* Using CSS variable */
    border-left: 2px solid var(--border-color); /* Thinner border */
    break-inside: avoid-column; /* Prevent breaking across columns */
    -webkit-column-break-inside: avoid; /* For Safari/Chrome */
    page-break-inside: avoid; /* Fallback */
    transition: var(--transition); /* Using CSS variable */
    width: 100%; /* Ensure proper width in columns */
    box-sizing: border-box; /* Include padding and border in width */
}

.announcement.multi-day {
    border-left-color: var(--accent-color); /* Using CSS variable */
    background: var(--multi-day-bg); /* Using CSS variable */
}

.announcement:hover {
    box-shadow: var(--box-shadow); /* Using CSS variable */
    transform: translateY(-1px); /* Slight lift effect */
}

.announcement strong { /* Event Title */
    font-size: 1.1em; /* Relative to container's dynamic font size */
    display: block;
    margin-bottom: 1px; /* Minimal margin */
    line-height: 1.0; /* Very tight line height */
    color: var(--text-color); /* Using CSS variable */
    font-weight: 600; /* Slightly heavier weight */
}
.announcement p {
    font-size: 1em; /* Relative to container's dynamic font size */
    line-height: 1.1; /* Very tight line height */
    margin-top: 0;
    margin-bottom: 1px; /* Minimal margin */
    color: var(--secondary-color); /* Using CSS variable */
}
.announcement p small { /* For "When" and "Where" */
    font-size: 0.9em; /* Relative to parent p */
    color: var(--text-light); /* Using CSS variable */
    line-height: 1.0; /* Very tight line height */
    font-weight: 500; /* Slightly bolder for better visibility */
    display: inline-block; /* Better control over spacing */
    margin-top: 0; /* No top margin */
}
hr.announcement-divider {
    display: none; /* Remove dividers entirely for max space */
    /* border: 0;
    border-top: 1px dashed #ddd;
    margin: 5px 0 8px 0; 
    column-span: all; */
}
.panel-inside-right > .announcement:last-of-type + hr.announcement-divider {
    display:none; /* This rule becomes redundant if all are display:none but harmless */
}

/* Grouped events styling */
.announcement.grouped {
    border-left-color: #3498db; /* Blue border for grouped events */
    background: linear-gradient(135deg, #f8fcff 0%, #f0f8ff 100%);
}

.group-sessions {
    margin-top: 2px;
    padding-left: 8px;
    border-left: 1px solid #e0e0e0;
}

.group-sessions .session {
    margin-bottom: 2px;
    padding: 2px 0;
    border-bottom: 1px dotted #e0e0e0;
}

.group-sessions .session:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.group-sessions .session strong {
    font-size: 0.9em; /* Relative to container's dynamic font size */
    color: var(--secondary-color);
    font-weight: 500;
}

.group-sessions .session p {
    font-size: 0.85em; /* Relative to container's dynamic font size */
    margin-bottom: 0;
}

.group-sessions .session p small {
    font-size: 1em; /* Relative to parent p */
    color: var(--text-light);
}


/* Panel 4: Back Cover (Sermon Notes, Contact Info) */
.panel-back-cover {
    text-align: center;
    /* padding-top: 0.2in; */    /* Attempt to vertically center content - removed for testing */
    /* padding-bottom: 0.2in; */ /* Attempt to vertically center content - removed for testing */
}

.panel-back-cover h2 { /* Sermon Notes title */
    text-align: center;
    margin-bottom: 10px;
}
.notes-lines {
    width: 90%; /* ADDED */
    margin: 0 auto 15px auto; /* MODIFIED from margin-bottom: 15px; */
}

.writable-line {
    height: 1.7em; /* MODIFIED from 1.6em, was 1.8em */
    border-bottom: 1px solid #b0b0b0; /* The line itself */
    box-sizing: border-box; /* Include border in height if padding were added */
    /* No margin needed usually, as height itself creates the row space */
}

.contact-section {
    width: 90%; /* ADDED */
    margin: 30px auto 0 auto; /* MODIFIED from margin-top: 30px; */
    text-align: center; /* Center contact info block */
}
.contact-section h3 {
    margin-bottom: 10px;
}
.contact-section h4 { /* Sunset Times sub-header */
    margin-top: 15px;
    margin-bottom: 5px;
    font-size: 0.9em;
    font-weight: bold;
    color: #444;
}
.contact-info p {
    font-size: 0.78em; /* MODIFIED from 0.8em */
    line-height: 1.2; /* MODIFIED from 1.3 */
    margin-bottom: 3px; /* MODIFIED from 4px */
}
.contact-section > p { /* For the actual sunset times text */
    font-size: 0.82em; /* MODIFIED from 0.85em */
    font-style: italic;
    line-height: 1.2; /* ADDED */
    margin-bottom: 3px; /* ADDED */
}

/* Ensure images from user content are constrained */
.panel img {
    max-width: 100%;
    height: auto;
}

/* Add any further refinements for typography, spacing, etc. */

/* Add @page rules for print specifics later if needed */
/* e.g. 
@page {
    size: A4 landscape;
    margin: 10mm;
}
*/ 