/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

:root {
    /* Dark Theme (Default) */
    --bg-primary: #000000;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --bg-card: #1e1e1e;
    --bg-hover: #2a2a2a;
    
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    
    --accent-primary: #4a9eff;
    --accent-secondary: #ff4a4a;
    --accent-success: #4aff4a;
    
    --border-color: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.5);
    
    /* Layout */
    --sidebar-width: 50px;
    --header-height: 60px;
    --content-padding: 2rem;
    
    /* Typography */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-display: 'Arial', sans-serif;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: transparent;
    width: var(--sidebar-width);
    border-right: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    z-index: 1000;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    width: calc(var(--sidebar-width) + 22px);
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.7) 0%, transparent 100%);
    pointer-events: none;
    z-index: -1;
}

.logo {
    width: 40px;
    height: 40px;
    margin-bottom: 2rem;
}

.logo-icon {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: var(--text-primary);
    stroke-width: 2;
}

.logo-icon text {
    fill: none;
    stroke: var(--text-primary);
    stroke-width: 1.5;
    font-size: 24px;
    font-weight: bold;
}

.nav-icons {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 0 0 auto;
}

.nav-item a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.nav-item a:hover,
.nav-item.active a {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* Back Button (shown on non-index pages) */
.back-btn {
    margin-top: auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.back-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.back-btn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* Main Content */
.main-content {
    margin-left: 0;
    min-height: 100vh;
}

/* Hero Section */
.hero {
    position: relative;
    aspect-ratio: 32 / 9;
    overflow: hidden;
}

.hero-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
}

/* Hero Slideshow Overlay - fade to black at bottom starting at 60% */
#wotd-slideshow .image-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%; /* Cover bottom 40% of image (fade starts at 60%) */
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.95) 100%);
    pointer-events: none;
    z-index: 1;
}

.hero-content {
    position: absolute;
    bottom: 40px;
    left: 80px;
    z-index: 10;
}

.hero-title {
    font-size: clamp(1.5rem, 3.5vw, 4rem);
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-bottom: 0;
    text-shadow: 2px 2px 4px var(--shadow-color);
    white-space: nowrap;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.hero-download-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
}

.location {
    position: relative;
}

.location::after {
    content: '|';
    position: absolute;
    right: -1rem;
    color: var(--text-tertiary);
}

.download-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.download-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.download-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}


/* Trending Section */
.trending {
    padding: var(--content-padding);
    padding-left: calc(var(--sidebar-width) + var(--content-padding));
    /* Right: no sidebar to mirror — content should reach the banner edge */
    padding-right: var(--content-padding);
    background-color: var(--bg-primary);
}

.section-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 300;
}

.user-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: absolute;
    right: 0;
}

.user-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.user-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.trending-carousel {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    /* The two columns are width-capped; spread them so the thumbnail
       column actually reaches the section's right edge */
    justify-content: space-between;
}

.carousel-main {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Proportional caps (G13): same 73/24 split as the old 1024/320px pair
       had at 1555, but they now scale up to fill a 1920 body */
    max-width: 73%;
}

.wallpaper-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.wallpaper-card:hover {
    transform: scale(1.02);
}

.wallpaper-card.large {
    /* 32:9 aspect ratio for extreme ultrawide */
    aspect-ratio: 32/9;
    width: 100%;
}

.wallpaper-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
}

.card-overlay h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.card-overlay p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.card-actions {
    display: flex;
    gap: 1rem;
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.carousel-sidebar {
    flex: 1;
    position: relative;
    max-width: 24%;
}

.bookmark-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
}

.bookmark-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    overflow: visible; /* Allow hover transforms to be visible */
    padding: 0.5rem; /* Add padding so scaled elements don't get clipped */
}

.wallpaper-thumbnail {
    /* 32:9 aspect ratio for all wallpapers */
    aspect-ratio: 32/9;
    background-color: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease;
}

.wallpaper-thumbnail:hover {
    outline: 2px solid var(--accent-primary);
    transform: scale(1.05);
}

.download-small {
    position: absolute;
    bottom: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 4px;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-primary);
}

.download-small svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dot.active,
.dot:hover {
    background-color: var(--text-primary);
    transform: scale(1.2);
}

.thumbnail-strip {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.strip-thumbnail {
    flex-shrink: 0;
    width: 200px;
    /* 32:9 aspect ratio for all wallpapers */
    aspect-ratio: 32/9;
    background-color: var(--bg-card);
    border-radius: 4px;
    cursor: pointer;
}

/* Themes Section */
.themes {
    padding: var(--content-padding);
    padding-left: calc(var(--sidebar-width) + var(--content-padding));
    /* Right: no sidebar to mirror — content should reach the banner edge */
    padding-right: var(--content-padding);
    background-color: var(--bg-primary);
}

.section-icon {
    width: 24px;
    height: 24px;
    fill: var(--text-secondary);
    margin-right: 0.5rem;
}

.themes-grid {
    display: flex;
    gap: 2rem;
    /* Same as .trending-carousel: both columns are width-capped, so spread
       them — the right column tracks the banner edge like trending's does */
    justify-content: space-between;
}

.themes-left {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 73%; /* proportional, see .carousel-main (G13) */
}

.theme-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.theme-categories .theme-card {
    aspect-ratio: 32/9;
    position: relative;
}

.theme-categories .theme-card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.5);
}

.theme-categories .theme-card h3 {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.75rem;
    font-size: clamp(0.8rem, 1.2vw + 0.3rem, 1.2rem);
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
}

.theme-wallpapers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.theme-wallpapers .wallpaper-thumbnail {
    /* 32:9 aspect ratio for theme wallpapers */
    aspect-ratio: 32/9;
    background-color: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.theme-wallpapers .wallpaper-thumbnail:hover {
    transform: scale(1.05);
    outline: 2px solid var(--accent-primary);
}

.themes-right {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 24%; /* proportional, see .carousel-sidebar (G13) */
    align-content: start;
}

.theme-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background-color: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.theme-thumbs {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
}

.theme-thumbs img {
    width: 40px;
    /* 32:9 aspect ratio for thumbnail wallpapers */
    aspect-ratio: 32/9;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-card h3 {
    padding: 0.75rem;
    font-size: clamp(0.7rem, 1vw + 0.3rem, 1.1rem);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-card.small {
    aspect-ratio: 21/9;
    position: relative;
    display: flex;
    align-items: flex-end;
}

.theme-card.small img:not(.theme-card-icon) {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.theme-card.small h3 {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.3rem 0.4rem;
    font-size: clamp(0.65rem, 0.8vw + 0.3rem, 1rem);
    line-height: 1.2;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-card-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    width: 40px;
    height: 40px;
    object-fit: contain;
    opacity: 0.35;
    filter: brightness(2);
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.theme-card.small:hover .theme-card-icon {
    opacity: 0.55;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 2rem 32px;
    padding-left: calc(var(--sidebar-width) + 2rem);
    padding-right: calc(var(--sidebar-width) + 2rem);
    border-top: 1px solid #1e1e1e;
    color: #666;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.footer p {
    margin-bottom: 6px;
}

.footer p:last-child {
    margin-bottom: 0;
}

.footer a {
    color: #777;
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: #4a9eff;
}

/* JW6: copyright line reads white */
.footer .footer-copyright {
    color: #fff;
}

/* JW1: alt text (the AI-description "word salad") must not paint visibly
   while wallpaper images load — transparent text keeps it for screen
   readers and image SEO. Covers every resizecache-served tile site-wide. */
img[src*="resizecache"],
img[data-src*="resizecache"] {
    color: transparent;
}

/* Responsive Design */
/* G13 (Dash V2): fill 16:9 screens border-to-border — cap raised 1555 -> 1920.
   Ultrawides stay centered beyond 1920 (Peter: no full-fill on ultrawides). */
@media (min-width: 1920px) {
    body {
        display: flex;
        justify-content: center;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        left: 50%;
        transform: translateX(calc(-960px));
    }

    .main-content {
        max-width: 1920px;
        width: 100%;
    }
}

@media (max-width: 1200px) {
    .themes-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .theme-card h3 {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .theme-categories .theme-card h3 {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .themes-right {
        align-content: start;
    }

    .theme-card.small h3 {
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
    }
}

@media (max-width: 768px) {
    /* The sidebar is hidden on mobile, but every section's horizontal
       padding is computed from these vars — without this override the
       content sits in a narrow strip with big empty margins. */
    :root {
        --sidebar-width: 0px;
        --content-padding: 12px;
    }

    .sidebar {
        /* translateX(-100%) no longer hides it now --sidebar-width is 0 */
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    
    .trending-carousel {
        flex-direction: column;
    }

    .carousel-main {
        max-width: none; /* the 73% cap is desktop-only */
    }

    .carousel-sidebar {
        max-width: none;
        width: 100%;
    }

    .themes-left {
        max-width: none;
    }
    
    .sidebar-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 1024px;
        margin: 0 auto;
    }
    
    .sidebar-grid .wallpaper-thumbnail:nth-child(n+9) {
        display: none;
    }
    
    .themes-grid {
        flex-direction: column;
    }
    
    .themes-right {
        max-width: none;
    }
    
}
/* ============================================================
   Tile control placement — single source of truth (Dash V2 G9).
   Relocating any control on every page = editing one variable here.
   inset order: top right bottom left ("auto" = unpinned side).
   Final grouping waits on Fabien's prototype answer.
   ============================================================ */
:root {
    --tile-dot-inset: 6px auto auto 6px;           /* unseen dot, thumbnails: top-left */
    --tile-fav-inset: 6px 6px auto auto;           /* star, thumbnails: top-right */
    --tile-fav-lg-inset: 10px 10px auto auto;      /* star, homepage featured cards: top-right */
    --tile-fav-featured-inset: 15px 15px auto auto;/* star, theme-page featured cards: top-right */
    --tile-dl-inset: 10px 52px auto auto;          /* crop/download, featured cards: top-right beside the star (JW5, was bottom-left) */
}
.new-dot { inset: var(--tile-dot-inset); }
.tile-fav-btn { inset: var(--tile-fav-inset); }
.wallpaper-card .tile-fav-btn { inset: var(--tile-fav-lg-inset); }
.featured-card .favorite-btn { inset: var(--tile-fav-featured-inset); }
.card-download-btn { position: absolute; inset: var(--tile-dl-inset); z-index: 2; }

/* ===== Vault / Club rarity tiles (WB4, charter §8) ===== */
.vault-tile {
    border: 1px solid rgba(212, 175, 55, 0.6);
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.25);
    animation: vaultBorder 6s ease-in-out infinite alternate;
}
@keyframes vaultBorder {
    from { border-color: rgba(212, 175, 55, 0.5); box-shadow: 0 0 14px rgba(212, 175, 55, 0.18); }
    to   { border-color: rgba(240, 214, 110, 0.95); box-shadow: 0 0 26px rgba(220, 185, 70, 0.45); }
}
.vault-tile img {
    animation: vaultBreath 9s ease-in-out infinite alternate;
}
@keyframes vaultBreath {
    from { transform: scale(1); }
    to   { transform: scale(1.08); }
}
.vault-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(12, 9, 2, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ecd064;
    pointer-events: none;
}
.vault-badge svg { width: 13px; height: 13px; }
@media (prefers-reduced-motion: reduce) {
    .vault-tile, .vault-tile img { animation: none; }
}

/* Homepage "This Week's Club Drops" row (WB5) */
.club-drops { padding: 40px var(--content-padding) 0 calc(var(--sidebar-width) + var(--content-padding)); max-width: 1920px; margin: 0 auto; }
.club-drops-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.club-drops-head h2 { color: #fff; font-size: 1.25rem; margin: 0; }
.club-drops-head a { color: #ecd064; font-size: 0.85rem; text-decoration: none; }
.club-drops-head a:hover { text-decoration: underline; }
.club-drops-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.club-drops-grid .gallery-item { position: relative; aspect-ratio: 32/9; border-radius: 8px; overflow: hidden; cursor: pointer; background: #1a1a1a; }
.club-drops-grid .gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
