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

:root {
    --bg-linen: #F5EFE6;
    --card-white: #FAF9F6;
    --border-sand: #E8DCC4;
    --btn-earth: #7A5F44;
    --text-charcoal: #4A4A48;
    --text-warmgrey: #A8A29E;

    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --transition: 0.25s ease;
}

body {
    background: var(--bg-linen);
    color: var(--text-charcoal);
    font-family: "Inter", sans-serif;
    line-height: 1.6;
}

/* --------------------------------------------------
    NAVBAR (Warm Linen Theme)
-------------------------------------------------- */
.main-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 35px 40px;
    background: var(--card-white);
    border-bottom: 1px solid var(--border-sand);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-left {
    display: flex;
    align-items: center;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 1rem;
    color: var(--text-warmgrey);
    pointer-events: none;
}

.navbar-search {
    width: 240px;
    padding: 8px 14px 8px 34px;
    border: 1px solid var(--border-sand);
    border-radius: var(--radius);
    background: var(--card-white);
    color: var(--text-charcoal);
}

.navbar-search:focus {
    outline: none;
    border-color: var(--btn-earth);
    box-shadow: 0 0 0 3px rgba(122,95,68,0.2);
}

.navbar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.navbar-brand {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-charcoal);
}

.navbar-headings {
    display: flex;
    gap: 35px;
}

.navbar-headings a {
    text-decoration: none;
    font-size: 1.15rem;
    color: var(--text-charcoal);
    font-weight: 500;
    padding-bottom: 4px;
    position: relative;
}

.navbar-headings a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0%;
    height: 2px;
    background: var(--btn-earth);
    transition: width var(--transition);
}

.navbar-headings a:hover::after {
    width: 100%;
}

.navbar-right {
    display: flex;
    justify-content: flex-end;
    gap: 30px;
    align-items: center;
}

.navbar-right a {
    text-decoration: none;
    font-size: 1.2rem;
    color: var(--text-charcoal);
    font-weight: 500;
    padding-bottom: 4px;
}

/* Account Dropdown */
.account-dropdown {
    position: relative;
}

.account-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 28px;
    right: 0;
    background: var(--card-white);
    border: 1px solid var(--border-sand);
    padding: 10px 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 160px;
}

.account-dropdown:hover .dropdown-menu {
    display: block;
}

.account-dropdown .dropdown-menu a {
    display: block;
    padding: 10px 20px;
    font-size: 1rem;
    color: var(--text-charcoal);
    transition: background var(--transition);
}

.account-dropdown .dropdown-menu a:hover {
    background: var(--bg-linen);
    color: var(--btn-earth);
}

/* MOBILE NAV */
.mobile-toggle {
    display: none;
    font-size: 2rem;
    cursor: pointer;
    justify-self: end;
}

@media (max-width: 768px) {
    .main-header {
        grid-template-columns: auto auto auto;
    }
    .navbar-left { display: none; }
    .navbar-center { grid-column: span 3; }
    .navbar-headings {
        margin-top: 10px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 20px;
    }
    .navbar-right {
        display: none;
        flex-direction: column;
        gap: 20px;
        margin-top: 20px;
    }
    .mobile-toggle { display: block; }
}

/* --------------------------------------------------
    HERO SECTION
-------------------------------------------------- */
.hero-modern {
    background: var(--bg-linen);
    padding: 100px 40px;
    border-bottom: 1px solid var(--border-sand);
}

.hero-inner {
    max-width: 1200px;
    margin: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero-text h1 {
    font-size: 3rem;
    color: var(--text-charcoal);
    margin-bottom: 20px;
}

.hero-text p {
    font-size: 1.2rem;
    color: var(--text-warmgrey);
    margin-bottom: 30px;
    max-width: 480px;
}

.hero-btn {
    background: var(--btn-earth);
    padding: 14px 28px;
    font-size: 1.1rem;
    border-radius: var(--radius);
    display: inline-block;
    color: white;
}

.hero-btn:hover { background: #6a523a; }

.hero-visual img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border-sand);
    box-shadow: var(--shadow);
    object-fit: cover;
}

@media (max-width: 768px) {
    .hero-inner {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .hero-text p { margin: 0 auto 30px auto; }
    .hero-visual img { margin-top: 20px; }
}

/* --------------------------------------------------
    FEATURED PATTERNS & MAIN GRIDS
-------------------------------------------------- */
.featured { padding: 60px 40px; }
.featured h2 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2rem;
    color: var(--text-charcoal);
}

/* Universal Grids */
#trendingGrid,
#categoriesGrid,
#newReleasesGrid,
#seasonalGrid,
#productsGrid,
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

#productsGrid {
    max-width: 1200px;
    margin: 30px auto 0 auto;
}

/* --------------------------------------------------
    PRODUCT CARDS (Unified & Fixed)
-------------------------------------------------- */
.product-card {
    background: var(--card-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    text-align: center;
    padding-bottom: 20px;
    border: 1px solid var(--border-sand);
    transition: all 0.2s ease-in-out;
}

.product-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    transform: translateY(-5px); /* Swapped scale for a cleaner lift effect */
}

/* FIX: Forces thumbnails to stay square and fit the card */
.product-card .card-image {
    width: 100%;
    aspect-ratio: 1 / 1; 
    object-fit: cover;
    border-bottom: 1px solid var(--border-sand);
}

.product-card h3 {
    margin-top: 15px;
    font-size: 1.2rem;
    color: var(--text-charcoal);
    padding: 0 15px;
}

/* --------------------------------------------------
    MODAL LAYOUT
-------------------------------------------------- */
.product-modal {
    border: none;
    border-radius: 12px;
    padding: 0; 
    
    /* 1. Make the modal massive in both directions */
    width: 85vw; 
    height: 85vh; 
    max-width: 1400px; /* Caps it gracefully on giant 4K desktop monitors */
    
    background: #fff;
    margin: auto; 
}

.product-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    display: flex;
    flex-direction: column; 
    /* 2. Tell the content wrapper to stretch to the full height of the giant modal */
    height: 100%; 
    position: relative;
}

/* FIX: Scoped to the modal so it doesn't break your subscription popup */
.product-modal .close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #333;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.product-modal .close-btn:hover {
    background: #f0f0f0;
}

/* FIX: Keeps the high-res modal image from overflowing the screen */
.large-image {
    width: 100%;
    
    /* 3. Flex-grow tells the image to expand and fill all the space above the download bar */
    flex-grow: 1; 
    height: 0; /* A neat Flexbox trick that keeps the image from overflowing */
    
    /* 4. 'contain' ensures the whole pattern is visible without chopping off the edges! */
    object-fit: contain; 
    
    border-radius: 12px 12px 0 0;
    display: block;
    background: #fafafa;
}

/* Sleek Download Bar */
.minimal-download-bar {
    display: flex;
    justify-content: flex-end; 
    align-items: center;
    padding: 15px 20px;
    gap: 15px;
    background: #fafafa;
    border-top: 1px solid #eee;
    border-radius: 0 0 12px 12px;
}

.minimal-select {
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    color: var(--text-charcoal);
}

.icon-btn {
    background: #333;
    color: white;
    border: none;
    border-radius: 50%; 
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:hover { background: #555; }

/* --------------------------------------------------
    CATEGORY CARDS
-------------------------------------------------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    padding: 40px;
}

.category-card {
    background: var(--card-white);
    border-radius: var(--radius);
    overflow: hidden;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid var(--border-sand);
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.category-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.category-card h3 {
    padding: 15px;
    font-size: 1.2rem;
    color: var(--text-charcoal);
}

/* --------------------------------------------------
    PAGINATION
-------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 30px 0;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border-sand);
    background: var(--card-white);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--text-charcoal);
}

.pagination button.active {
    background: var(--btn-earth);
    color: white;
    border-color: var(--btn-earth);
}

.pagination button:hover {
    background: var(--bg-linen);
}

/* --------------------------------------------------
    DASHBOARD
-------------------------------------------------- */
.dashboard-container {
    max-width: 1000px;
    margin: 60px auto;
    padding: 0 20px;
}

.dashboard-container h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
    color: var(--text-charcoal);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-warmgrey);
    margin-bottom: 30px;
}

.dashboard-container .card {
    background: var(--card-white);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-sand);
}

.dashboard-container .card h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: var(--text-charcoal);
}

.dashboard-container .card p {
    color: var(--text-warmgrey);
    margin-bottom: 15px;
}

.dashboard-container .card a {
    display: inline-block;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--btn-earth);
    margin-bottom: 15px;
}

.dashboard-container .card a.active {
    color: #6a523a;
    border-bottom: 2px solid #6a523a;
}

.dashboard-container button,
.dashboard-container .btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--btn-earth);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.dashboard-container button:hover,
.dashboard-container .btn:hover {
    background: #6a523a;
}

#recentDownloads {
    list-style: none;
    margin-top: 10px;
    padding-left: 0;
}

#recentDownloads li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-sand);
    color: var(--text-charcoal);
}

/* --------------------------------------------------
    SUBSCRIPTION POPUP 
-------------------------------------------------- */
.subscribe-dialog {
    border: none;
    background: transparent;
    padding: 0;
    
    /* 1. Bulletproof Centering: This forces it to the exact middle, ignoring all other rules */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0; 
}

.subscribe-dialog::backdrop {
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.4);
}

.subscribe-modal {
    /* 2. Changed from 'vw' to '%' so it respects the scrollbar width perfectly */
    width: 100%; 
    min-width: 300px; /* Ensures it doesn't get too crushed on tiny mobile screens */
    max-width: 600px;
    background: var(--card-white);
    padding: 40px 30px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    box-sizing: border-box;
}

.subscribe-modal h2 {
    margin-bottom: 12px;
    font-size: 1.8rem;
    color: var(--text-charcoal);
}

.subscribe-modal p {
    color: var(--text-warmgrey);
    margin-bottom: 25px;
    font-size: 1.05rem;
}

.subscribe-modal button {
    padding: 12px 24px;
    margin: 5px 10px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background var(--transition);
}

#goSubscribeBtn {
    background: var(--btn-earth);
    color: white;
}

#goSubscribeBtn:hover {
    background: #6a523a;
}

/* This is safe to stay global for the subscription popup */
.close-btn {
    background: var(--bg-linen);
    color: var(--text-charcoal);
}

.close-btn:hover {
    background: var(--border-sand);
}

/* --------------------------------------------------
    RESET PASSWORD / AUTH PAGES
-------------------------------------------------- */
.centered-reset {
    max-width: 450px;
    margin: 100px auto;
    text-align: center;
}

.reset-title { margin-bottom: 10px; }
.reset-subtitle { margin-bottom: 25px; }

.reset-form {
    text-align: left;
    margin-top: 10px;
}

.reset-form input { margin-bottom: 20px; }

.reset-btn {
    width: 100%;
    padding: 12px 0;
    font-size: 1.1rem;
    border-radius: var(--radius);
    background: var(--btn-earth);
    color: white;
    border: none;
    transition: background var(--transition);
}

.reset-btn:hover { background: #6a523a; }

.reset-footer { margin-top: 25px; }

.reset-login-link {
    color: var(--btn-earth);
    font-weight: 600;
}

.reset-card {
    max-width: 480px;
    margin: 80px auto;
    text-align: left;
}

.reset-card label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-charcoal);
}

.reset-card input { margin-bottom: 20px; }
.reset-card h1 { margin-bottom: 15px; }
.reset-card p.secondary { margin-bottom: 25px; }

/* --------------------------------------------------
    FOOTER
-------------------------------------------------- */
footer {
    text-align: center;
    padding: 20px;
    background: var(--card-white);
    border-top: 1px solid var(--border-sand);
    margin-top: 60px;
}