/* public/css/style.css */

/* Basic Reset & Defaults */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth; /* Smooth scrolling for anchor links */
}

body {
    font-family: var(--font-body); /* Defined in theme.css */
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    color: var(--text-color); /* Defined in theme.css */
    background-color: var(--bg-color); /* Defined in theme.css */
    background-image: var(--bg-image); /* Defined in theme.css */
    background-size: var(--bg-size, cover); /* Defined in theme.css */
    background-position: var(--bg-position, center center); /* Defined in theme.css */
    background-attachment: var(--bg-attachment, fixed); /* Defined in theme.css */
}

/* Containers */
.landing-container, .page-container {
    width: 100%;
    max-width: 1200px; /* Max width of content area */
    margin: 0 auto;
    padding: 20px; /* Standard padding */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Ensures footer stays at bottom */
}

.landing-container {
    /* text-align: center; /* Centering of direct children is handled by flex */
    justify-content: center; /* Center content vertically for landing page focus */
    align-items: center; /* Center content horizontally */
}

/* Header */
.site-header {
    padding: 20px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color); /* Defined in theme.css */
    text-align: center;
    width: 100%; /* Ensure header takes full width within its container */
}

.site-header h1 {
    font-family: var(--font-heading); /* Defined in theme.css */
    font-size: clamp(2rem, 5vw, 2.8rem); /* Responsive font size */
    font-weight: 700;
    color: var(--header-text-color); /* Defined in theme.css */
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.site-header a.logo-link {
    text-decoration: none;
}

.site-header a.logo-link:hover h1,
.site-header a.logo-link:focus h1 { /* Added focus for accessibility */
    color: var(--accent-color); /* Defined in theme.css */
}

.site-header .tagline {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem); /* Responsive font size */
    color: var(--tagline-color); /* Defined in theme.css */
    font-style: italic;
}

/* Main Content Area */
.landing-content, .search-page-content {
    flex-grow: 1;
    width: 100%;
    text-align: center; /* Center inline/inline-block children like the notice and search form */
}

.search-page-content {
    text-align: left; /* Override for search page content if needed, or handle per component */
}


.construction-notice {
    font-size: clamp(1.2rem, 4vw, 1.6rem); /* Responsive font size */
    margin: 40px 0;
    color: var(--notice-text-color); /* Defined in theme.css */
    line-height: 1.4;
}

/* Search Form */
.search-form {
    display: flex;
    flex-wrap: wrap; /* Allows button to wrap on small screens if needed */
    justify-content: center;
    align-items: center;
    margin: 25px auto; /* Auto margins for horizontal centering */
    max-width: 700px; /* Limit width for better readability */
    gap: 10px; /* Space between input and button */
}

.search-form input[type="search"] {
    flex-grow: 1; /* Takes available space */
    min-width: 200px; /* Minimum width before wrapping/shrinking */
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid var(--input-border-color); /* Defined in theme.css */
    border-radius: 5px;
    background-color: var(--input-bg-color); /* Defined in theme.css */
    color: var(--input-text-color); /* Defined in theme.css */
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-form input[type="search"]:focus {
    border-color: var(--accent-color); /* Defined in theme.css */
    box-shadow: 0 0 8px var(--accent-color-shadow); /* Defined in theme.css */
}

.search-form button[type="submit"] {
    padding: 12px 25px;
    font-size: 1rem;
    background-color: var(--button-bg-color); /* Defined in theme.css */
    color: var(--button-text-color); /* Defined in theme.css */
    border: 1px solid var(--button-border-color); /* Defined in theme.css */
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-weight: bold;
}

.search-form button[type="submit"]:hover,
.search-form button[type="submit"]:focus { /* Added focus for accessibility */
    background-color: var(--button-hover-bg-color); /* Defined in theme.css */
    transform: translateY(-2px); /* Subtle lift effect */
}

.search-tip {
    font-size: 0.9rem;
    color: var(--muted-text-color); /* Defined in theme.css */
    margin-top: 10px;
    text-align: center;
}

/* Featured Product Posts Section (for index.html) */
.posts-section {
    width: 100%; /* Makes the section take full width of its parent container */
    padding: 40px 0; /* Vertical spacing */
    margin-top: 30px; /* Space above this section on the landing page */
    text-align: left; /* Reset text-align if parent had it centered */
}

.posts-section .container { /* Styles for the inner container for content alignment */
    max-width: 1200px; /* Match your main page container width */
    margin: 0 auto;    /* Center the container */
    padding: 0 20px;   /* Match your main page container padding */
}

.posts-section h2 {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    color: var(--header-text-color);
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--accent-color);
    padding-bottom: 10px;
    /* Centering technique for inline-block with border */
    display: table; /* Or inline-block and then center its parent if needed */
    margin-left: auto;
    margin-right: auto;
}

.posts-grid {
    display: grid;
    gap: 25px;
    /* Default: Good for smaller screens to be responsive, overridden by media queries below */
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.post-item {
    background-color: var(--product-bg-color);
    border: 1px solid var(--product-border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-item:hover,
.post-item:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--product-shadow-color);
}

.post-item-image-link img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--product-border-color);
}

.post-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.post-content h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.post-content h3 a {
    color: var(--product-text-color);
    text-decoration: none;
}

.post-content h3 a:hover,
.post-content h3 a:focus {
    color: var(--accent-color);
    text-decoration: underline;
}

.post-excerpt {
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.5;
    margin-bottom: 15px;
    flex-grow: 1;
}

.post-item-button.zazzle-button {
    display: block;
    width: calc(100% - 30px); /* Full width minus padding of .post-content (15px each side) */
    margin: 0 auto 15px auto; /* Center button, 15px bottom margin */
    padding: 10px 15px;
    background-color: var(--accent-color);
    color: var(--button-text-color);
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.post-item-button.zazzle-button:hover,
.post-item-button.zazzle-button:focus {
    background-color: var(--button-hover-bg-color);
    transform: translateY(-2px);
}


/* Search Results Container & Messages from search.js / main.js */
.search-results-container {
    margin-top: 30px;
}

.result-summary {
    text-align: center;
    margin: 20px 0;
    padding: 12px;
    background-color: var(--results-summary-bg);
    border-radius: 4px;
    font-size: 1.1rem;
}
.result-summary strong {
    color: var(--accent-color);
}

/* Styles for Amazon/Zazzle links to make them look like buttons and be centered */
.external-search-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px auto; /* Centers the block if it's narrower than its container */
    flex-wrap: wrap;
    padding: 10px 0;
}

.external-search-links a {
    padding: 10px 18px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95rem;
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
    display: inline-block;
    border: 1px solid transparent;
    text-align: center;
}

.external-search-links a:hover,
.external-search-links a:focus {
    transform: translateY(-2px);
}

.external-search-links a.amazon-link {
    background-color: #FF9900;
    color: #111;
    border-color: #E68A00;
}
.external-search-links a.amazon-link:hover,
.external-search-links a.amazon-link:focus {
    background-color: #E68A00;
}

.external-search-links a.zazzle-more-link {
    background-color: var(--accent-color);
    color: var(--button-text-color);
    border-color: var(--button-border-color);
}
.external-search-links a.zazzle-more-link:hover,
.external-search-links a.zazzle-more-link:focus {
    background-color: var(--button-hover-bg-color);
}

.external-search-links.bottom-links {
    margin-top: 30px;
}


/* Zazzle Results Grid (for search.html) */
.zazzle-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.zazzle-product {
    background-color: var(--product-bg-color);
    border: 1px solid var(--product-border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.zazzle-product:hover,
.zazzle-product:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px var(--product-shadow-color);
}

.zazzle-product a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.zazzle-product img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--product-border-color);
}

.zazzle-product p.product-title {
    padding: 12px 15px;
    font-size: 0.95rem;
    text-align: center;
    min-height: 60px;
    color: var(--product-text-color);
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Styles for Share Buttons under products */
.share-icons {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--product-border-color);
    background-color: var(--product-share-bg);
    width: 100%;
    box-sizing: border-box;
}

.share-icons a {
    margin: 0 8px;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.share-icons a:hover,
.share-icons a:focus {
    opacity: 1;
    transform: scale(1.1);
}

.share-icons img {
    width: 18px;
    height: 18px;
    border: none;
    display: block;
}


/* Loading Indicator & Messages */
.loading-indicator {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: var(--notice-text-color);
}
.spinner {
    margin: 20px auto;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-message {
    text-align: center;
    padding: 25px 15px;
    margin: 20px auto;
    font-size: 1.1rem;
    border-radius: 5px;
    max-width: 600px;
}
.search-message.info-message {
    background-color: var(--info-bg-color);
    color: var(--info-text-color);
    border: 1px solid var(--info-border-color);
}
.search-message.error-message {
    background-color: var(--error-bg-color);
    color: var(--error-text-color);
    border: 1px solid var(--error-border-color);
}


/* Footer */
.site-footer {
    text-align: center;
    padding: 25px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--muted-text-color);
    width: 100%; /* Ensure footer takes full width within its container */
}
.affiliate-disclosure {
    font-size: 0.8rem;
    margin-top: 8px;
    font-style: italic;
}

/* --- Mobile Responsiveness --- */

/* Default state for posts-grid (mobile-first approach for column count) */
.posts-grid {
    grid-template-columns: 1fr; /* Single column on the smallest screens */
}

/* Two columns for small tablets and up */
@media (min-width: 600px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Four columns for larger tablets/desktops and up */
@media (min-width: 992px) {
    .posts-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* General responsive adjustments */
@media (max-width: 768px) { /* This breakpoint often targets tablets in portrait and large phones */
    .site-header h1 { font-size: clamp(1.8rem, 4.5vw, 2.2rem); }
    .construction-notice { font-size: clamp(1rem, 3.5vw, 1.3rem); }

    .search-form {
        flex-direction: column;
    }
    .search-form input[type="search"],
    .search-form button[type="submit"] {
        width: 100%;
        max-width: 400px;
    }

    /* .posts-grid is handled by the min-width queries above */

    .zazzle-results { /* For search results page */
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
}


@media (max-width: 599px) { /* Targeting smaller mobile phones specifically */
    .posts-section h2 { /* Adjust heading for featured posts on small screens */
        font-size: clamp(1.3rem, 5vw, 1.8rem);
    }
    /* .posts-grid is already 1fr from the default style or specific max-width query if needed */
}


@media (max-width: 480px) { /* Very small mobile phones */
    .external-search-links {
        gap: 10px;
    }
    .external-search-links a {
        font-size: 0.9rem;
        padding: 8px 12px;
        width: 100%;
        max-width: 280px;
        margin-bottom: 5px;
    }
    .external-search-links a:last-child {
        margin-bottom: 0;
    }

    .zazzle-results { /* For search results page */
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    .zazzle-product p.product-title {
        font-size: 0.9rem;
        min-height: 50px;
        padding: 10px;
    }

    .post-item-button.zazzle-button { /* Button in featured posts */
        font-size: 0.9rem;
    }

    .page-container, .landing-container {
        padding: 15px;
    }
}

/* Load More Button (for search results) */
.load-more-button {
    display: block; /* Makes it a block element, taking full width available to its container */
    margin: 25px auto; /* Centers the button horizontally, with vertical spacing */
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    background-color: var(--button-bg-color); /* Using existing theme variable */
    color: var(--button-text-color); /* Using existing theme variable */
    border: 1px solid var(--button-border-color); /* Using existing theme variable */
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-align: center;
    max-width: 300px; /* Optional: constrain max width */
}

.load-more-button:hover,
.load-more-button:focus {
    background-color: var(--button-hover-bg-color); /* Using existing theme variable */
    transform: translateY(-2px); /* Subtle lift effect */
}

/* Style for the initially hidden additional results container (if needed, mostly handled by inline style) */
/* #zazzle-additional-results { */
    /* display: none; /* Initial state set by inline style, JS will change to 'grid' */
/* } */

/* In style.css (add this if you haven't already) */

.result-summary .load-more-hint {
    font-size: 0.9em;
    color: var(--muted-text-color); /* Adjust as per your theme */
    font-style: italic;
    margin-left: 5px;
}

/* Ensure other styles for .load-more-button, .result-summary etc. are present */