@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&family=Open+Sans:wght@400;600&display=swap');

:root {
    --primary-color: #6082B6; /* Softer Blue */
    --secondary-color: #A7C7E7; /* Lighter Blue for accents */
    --accent-color: #F5E8C7; /* Soft Gold/Beige */
    --text-color: #333333; /* Dark Gray */
    --light-text-color: #FFFFFF;
    --background-color: #F4F6F8; /* Light Grayish Blue */
    --content-background: #FFFFFF;
    --border-color: #DEE2E6;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --hover-primary-color: #5072A0; /* Darker shade of primary for hover */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Utility: visually hidden but screen-reader accessible */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap; /* added line */
    border: 0;
}

body {
    font-family: 'Open Sans', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--background-color);
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1100px; /* Slightly reduced for a more contained feel */
    margin: 20px auto; /* Added top/bottom margin */
    background-color: var(--content-background);
    padding: 30px 40px; /* Increased padding */
    border-radius: 12px; /* Softer radius */
    box-shadow: 0 8px 25px var(--shadow-color); /* Softer shadow */
    transition: box-shadow 0.3s ease;
    position: relative; /* Anchor absolute children like AY badge and theme toggle */
}

header {
    text-align: center;
    margin-bottom: 40px; /* Increased margin */
    border-bottom: 1px solid var(--border-color); /* Subtle separator */
    padding-bottom: 20px;
}

header h1 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-color);
    font-weight: 700; /* Bolder heading */
    font-size: 2.5em; /* Larger heading */
    margin-bottom: 8px; /* Adjusted spacing */
}

header p {
    font-size: 1.1em;
    color: #555; /* Slightly lighter than main text */
}

/* AY author tag */
.ay-owner {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.ay-owner-fixed {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 6px 10px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    border: 1px solid var(--border-color);
}

.ay-owner-fixed:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    transform: translateY(-1px);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ay-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--content-background);
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid var(--primary-color);
}

.ay-text {
    font-size: 0.9em;
    color: #555;
    font-weight: 600;
}

/* Tooltip behavior: only show text on hover/focus */
.ay-owner-fixed {
    position: absolute;
}
.ay-owner-fixed .ay-text {
    position: absolute;
    left: 44px; /* to the right of the badge */
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 1002;
}
.ay-owner-fixed:hover .ay-text,
.ay-owner-fixed:focus-within .ay-text,
.ay-owner-fixed .ay-badge:focus + .ay-text {
    opacity: 1;
    pointer-events: auto;
}

/* Tooltip for dark mode: lighter bubble */
body.dark-mode .ay-owner-fixed .ay-text {
    background: rgba(255,255,255,0.92);
    color: #111;
    box-shadow: 0 6px 16px rgba(255,255,255,0.12);
}

.controls {
    display: flex;
    gap: 15px; /* Increased gap */
    margin-bottom: 40px; /* Increased margin */
    flex-wrap: wrap;
    align-items: center; /* Vertically align items */
}

select, button {
    padding: 12px 18px; /* Increased padding */
    border-radius: 8px; /* Softer radius */
    border: 1px solid var(--border-color);
    font-size: 1em; /* Relative font size */
    font-family: 'Open Sans', sans-serif;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

select:focus, button:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 130, 182, 0.25); /* Focus ring */
}

button {
    background-color: var(--primary-color);
    color: var(--light-text-color);
    border: none;
    cursor: pointer;
    font-weight: 600; /* Bolder button text */
    transition: background-color 0.3s ease, transform 0.2s ease;
}

button:hover {
    background-color: var(--hover-primary-color);
    transform: translateY(-2px); /* Subtle lift on hover */
}

.loading {
    text-align: center;
    margin: 40px 0; /* Increased margin */
    color: var(--primary-color); /* Match primary color */
}

.spinner {
    border: 6px solid var(--secondary-color); /* Lighter border for spinner */
    border-top: 6px solid var(--primary-color); /* Primary color for moving part */
    border-radius: 50%;
    width: 60px; /* Larger spinner */
    height: 60px;
    animation: spin 1.2s linear infinite; /* Slightly slower spin */
    margin: 0 auto 20px;
}

.spinner--small {
    width: 18px;
    height: 18px;
    border-width: 3px;
    margin: 0 6px 0 0;
    display: inline-block;
    vertical-align: middle;
}

.inline-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
}

.inline-note {
    font-style: italic;
    color: var(--primary-color);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important; /* Ensure it overrides other display properties */
}

#results {
    border-top: 1px solid var(--border-color);
    padding-top: 30px;
}

.summary-section {
    margin-bottom: 40px;
}

.summary-section h2 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-color);
    font-size: 1.8em; /* Adjusted size */
    margin-bottom: 20px; /* Increased margin */
    border-bottom: 2px solid var(--secondary-color); /* Underline effect */
    padding-bottom: 10px;
}

.summary-section p {
    margin-bottom: 1.2em; /* Relative margin */
    text-align: left; /* Standard text alignment */
    line-height: 1.8; /* Increased line height for readability */
    font-size: 1.05em;
}

.images-section h3 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-color);
    font-size: 1.6em; /* Adjusted size */
    margin-bottom: 25px; /* Increased margin */
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Slightly smaller min size */
    gap: 25px; /* Increased gap */
}

.image-grid img {
    width: 100%;
    border-radius: 10px; /* Softer radius */
    box-shadow: 0 6px 12px var(--shadow-color); /* Softer shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color); /* Subtle border */
}

.image-grid img:hover {
    transform: scale(1.05); /* Slightly more pronounced hover */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12); /* Enhanced shadow on hover */
}

/* Daily Summary Section Styles */
.daily-summary-section {
    background-color: var(--secondary-color); /* Light blue background */
    color: var(--text-color);
    padding: 25px;
    margin-bottom: 40px;
    border-radius: 10px;
    box-shadow: 0 6px 15px var(--shadow-color);
}

.daily-summary-section h2 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-color); /* Use primary color for heading */
    font-size: 1.8em;
    margin-bottom: 15px;
    text-align: center;
}

.daily-summary-section #daily-summary-content p {
    font-size: 1em;
    line-height: 1.7;
    color: var(--text-color); /* Ensure good contrast */
}

/* Search Controls Styles */
.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    align-items: center;
}

.search-controls input[type="text"] {
    flex-grow: 1;
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1em;
    font-family: 'Open Sans', sans-serif;
}

.search-controls input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 130, 182, 0.25);
}

.search-controls button {
    /* Styles are inherited from global button styles, which is good */
    /* Add specific overrides if needed */
    padding: 12px 18px; /* Ensure consistent padding */
}

/* Highlight Style */
.highlight {
    background-color: var(--accent-color); /* Using accent color for highlight */
    color: #333; /* Ensure good contrast on highlight */
    padding: 0.1em 0; /* Small padding for visual separation */
    border-radius: 3px;
    font-weight: bold;
}

/* Theme toggle button style */
.theme-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    z-index: 1000; /* Ensure it's above other elements */
}

.theme-toggle-btn:hover {
    background-color: var(--primary-color);
    color: var(--light-text-color);
    transform: scale(1.1);
}

/* Dark Mode Styles */
body.dark-mode {
    --primary-color: #79A0D6; /* Lighter blue for dark mode */
    --secondary-color: #526E94; /* Darker accent for dark mode */
    --accent-color: #E0C9A0; /* Slightly desaturated gold */
    --text-color: #EAEAEA; /* Light gray for text */
    /* --light-text-color: #121212; /* For text on light buttons if any - careful with this */
    --background-color: #121212; /* Very dark gray/black */
    --content-background: #1E1E1E; /* Dark gray for content boxes */
    --border-color: #3A3A3A;
    --shadow-color: rgba(255, 255, 255, 0.05);
    --hover-primary-color: #8BB0E0;

    color: var(--text-color); /* Use the new text-color for dark mode */
    background-color: var(--background-color); /* Use the new background-color for dark mode */
}

body.dark-mode .container {
    background-color: var(--content-background);
    box-shadow: 0 8px 25px var(--shadow-color);
}

body.dark-mode header {
    border-bottom-color: var(--border-color);
}

body.dark-mode header h1 {
    color: var(--primary-color);
}

body.dark-mode header p {
    color: #AAAAAA; /* Lighter gray for subtext in dark mode */
}

body.dark-mode .ay-text {
    color: var(--text-color);
}

body.dark-mode .ay-owner-fixed {
    background: rgba(30, 30, 30, 0.6);
    border-color: var(--border-color);
    box-shadow: 0 4px 14px rgba(255,255,255,0.06);
}

body.dark-mode select, 
body.dark-mode .search-controls input[type="text"] {
    background-color: #2c2c2c; /* Slightly lighter than content background for inputs */
    color: var(--text-color);
    border-color: var(--border-color);
}

body.dark-mode button {
    background-color: var(--primary-color);
    color: #1E1E1E; /* Dark text on primary buttons for contrast */
    border: 1px solid var(--primary-color); /* Ensure border is visible or not needed */
}

body.dark-mode button:hover {
    background-color: var(--hover-primary-color);
    color: #121212; /* Slightly darker text on hover */
}

/* Special handling for theme toggle button in dark mode */
body.dark-mode .theme-toggle-btn {
    background-color: var(--secondary-color); /* Darker blue */
    color: var(--primary-color); /* Lighter blue icon */
    border: 1px solid var(--primary-color);
}

body.dark-mode .theme-toggle-btn:hover {
    background-color: var(--primary-color);
    color: var(--content-background); /* Dark background for icon on hover */
}


body.dark-mode .loading {
    color: var(--primary-color);
}

body.dark-mode .spinner {
    border-color: var(--secondary-color); /* Base ring */
    border-top-color: var(--primary-color); /* Moving part */
}

body.dark-mode #results {
    border-top-color: var(--border-color);
}

body.dark-mode .summary-section h2,
body.dark-mode .images-section h3,
body.dark-mode .daily-summary-section h2 {
    color: var(--primary-color);
    border-bottom-color: var(--secondary-color);
}

body.dark-mode .summary-section p,
body.dark-mode .daily-summary-section #daily-summary-text,
body.dark-mode .daily-summary-section #daily-summary-text p {
     color: var(--text-color);
}

body.dark-mode .image-grid img {
    box-shadow: 0 6px 12px var(--shadow-color);
    border-color: var(--border-color); /* Darker border for images */
}

body.dark-mode .image-grid img:hover {
    box-shadow: 0 10px 20px rgba(200, 200, 200, 0.08); /* Lighter shadow on hover for dark mode */
}

body.dark-mode .daily-summary-section {
    background-color: #2a2a2a; /* Slightly different shade for daily summary */
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 15px var(--shadow-color);
}

body.dark-mode #daily-summary-error {
    color: #ff8a8a; /* Lighter, less saturated red for errors in dark mode */
}

body.dark-mode select:focus, 
body.dark-mode button:focus,
body.dark-mode .search-controls input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color); /* Highlight with primary color */
    box-shadow: 0 0 0 3px rgba(121, 160, 214, 0.35); /* Light blue focus ring, good for dark backgrounds */
}

body.dark-mode .highlight {
    background-color: var(--accent-color); /* Use dark mode accent */
    color: #1E1E1E; /* Dark text on accent highlight */
    font-weight: bold;
}


@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }

    header h1 {
        font-size: 2em;
    }
    header p {
        font-size: 1em;
    }

    .controls {
        flex-direction: column;
    }
    
    select, button {
        width: 100%;
    }
    
    .image-grid {
        grid-template-columns: 1fr; /* Single column for smaller screens */
    }

    .summary-section h2, .images-section h3, .daily-summary-section h2 {
        font-size: 1.5em;
    }
    .theme-toggle-btn { /* Adjust toggle button for smaller screens */
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {

    body {
        padding: 10px;
    }
    .container {
        padding: 15px;
    }
    header h1 {
        font-size: 1.8em;
    }
     header {
        padding-bottom: 15px; /* Reduce padding for smaller header */
        margin-bottom: 25px;
    }
    .theme-toggle-btn { /* Further adjust for very small screens */
        top: 5px;
        right: 5px;
    }
    /* Move AY badge into document flow to avoid covering the title */
    .ay-owner-fixed {
        position: static;
        display: inline-flex;
        margin-bottom: 10px;
        padding: 5px 8px;
    }

    /* Larger touch target for mobile */
    .ay-badge {
        width: 34px;
        height: 34px;
        font-size: 0.95em;
    }

    /* Reposition tooltip below the badge and allow wrapping */
    .ay-owner-fixed .ay-text {
        left: 0;
        top: calc(100% + 6px);
        transform: none;
        white-space: normal;
        text-align: left;
        max-width: calc(100vw - 48px); /* viewport minus margins */
        padding: 8px 10px;
        line-height: 1.3;
    }
}
