/* ============================================================
   Core CSS — shared across all domains
   Theme colors come from CSS custom properties set per-domain.
   Domain-specific brand overrides go in separate theme files
   or are injected inline from site settings.
   ============================================================ */

/* --- Reset & Base --- */

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* --- Container --- */

.container {
    width: 100%;
    max-width: 1280px;
    margin-inline: auto;
    padding-inline: 1rem;
}
@media (min-width: 640px)  { .container { padding-inline: 1.5rem; } }
@media (min-width: 1024px) { .container { padding-inline: 2rem; } }

/* --- Typography --- */

h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-heading);
    margin: 0;
}

.section-heading {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    padding-bottom: 0.6rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--color-primary);
    display: inline-block;
}

.blurb {
    max-width: 72ch;
    margin-inline: auto;
    text-align: center;
    padding: 2rem 1rem;
}

.blurb h2 {
    font-size: clamp(1.3rem, 3vw, 1.75rem);
    margin-bottom: 0.75rem;
}

.blurb p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    margin: 0;
}

/* --- Navigation --- */

.site-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border);
}

.site-nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.5rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--color-heading);
    white-space: nowrap;
}

.nav-brand img { height: 2rem; width: auto; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    display: block;
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    border-radius: 0.375rem;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    color: var(--color-heading);
    background: var(--color-surface);
}

.nav-auth {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-auth a {
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-auth .btn-login {
    color: var(--color-text-muted);
}
.nav-auth .btn-login:hover { color: var(--color-heading); }

.nav-auth .btn-register {
    background: var(--color-primary);
    color: #fff;
}
.nav-auth .btn-register:hover { filter: brightness(1.15); }

.nav-auth .nav-user {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

@media (max-width: 767px) {
    .nav-links, .nav-auth { display: none; }
    .nav-toggle { display: block; }

    .site-nav.open .nav-links,
    .site-nav.open .nav-auth {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: absolute;
        top: 3.5rem;
        left: 0;
        right: 0;
        background: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        padding: 0.75rem 1rem;
        gap: 0.25rem;
    }

    .site-nav.open .nav-auth {
        top: auto;
        position: relative;
        border-bottom: none;
        border-top: 1px solid var(--color-border);
        padding-top: 0.75rem;
        margin-top: 0.25rem;
    }
}

/* --- Hero Row (always 4 cards) --- */

.hero-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .hero-row { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
}

.hero-card {
    position: relative;
    display: block;
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--color-surface);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.hero-card__image {
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: var(--color-surface-alt);
}

.hero-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.hero-card:hover .hero-card__image img {
    transform: scale(1.06);
}

.hero-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-alt);
}

.hero-card__label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem 0.75rem 0.75rem;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
}

.hero-card__title {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* --- Card Grid --- */

.card-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
}

@media (min-width: 1024px) {
    .card-grid { grid-template-columns: repeat(4, 1fr); }
}

.card-grid--hero {
    gap: 1rem;
}

@media (min-width: 640px) {
    .card-grid--hero { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .card-grid--hero { grid-template-columns: repeat(4, 1fr); }
}

/* --- Card --- */

.card {
    position: relative;
    background: var(--color-surface);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.card__image {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--color-surface-alt);
}

.card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.card:hover .card__image img {
    transform: scale(1.06);
}

.card__body {
    padding: 0.6rem 0.75rem;
}

.card__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

.card__meta {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.card__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 1rem;
}

.card:hover .card__overlay { opacity: 1; }

.card__overlay-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

/* Card stats strip (views + likes) */

.card__stats {
    display: flex;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.card__stat {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1;
}

.card__stat svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Hero card variant */
.card--hero .card__image { aspect-ratio: 3 / 4; }
.card--hero .card__body { padding: 0.75rem 1rem; }
.card--hero .card__title { font-size: 0.95rem; }

/* --- Tag Cloud --- */

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    line-height: 1;
}

.tag-cloud__item {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s, transform 0.15s;
    white-space: nowrap;
}

.tag-cloud__item:hover {
    background: var(--color-primary);
    color: #fff;
    transform: scale(1.05);
}

/* --- Ad Zones --- */

.ad-zone {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.ad-slot {
    width: 300px;
    height: 250px;
    overflow: hidden;
    border-radius: 0.375rem;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* --- BOTD thumb button (card acting as button) --- */

.botd-thumb-btn {
    cursor: pointer;
    border: none;
    padding: 0;
    text-align: left;
    width: 100%;
    background: none;
}

/* --- BOTD Image Modal --- */

.botd-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.botd-modal[hidden] { display: none; }

.botd-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.botd-modal__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: calc(100vw - 8rem);
    max-height: calc(100vh - 8rem);
}

.botd-modal__img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 10rem);
    object-fit: contain;
    border-radius: 0.375rem;
}

.botd-modal__counter {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
}

.botd-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.botd-modal__close:hover { background: rgba(255,255,255,0.2); }

.botd-modal__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.botd-modal__nav:hover { background: rgba(255,255,255,0.25); }
.botd-modal__nav--prev { left: 1rem; }
.botd-modal__nav--next { right: 1rem; }

.botd-modal__actions {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    gap: 0.75rem;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    border-radius: 9999px;
    padding: 0.5rem 1.25rem;
}

.botd-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    border-radius: 0.375rem;
    transition: color 0.15s;
    text-decoration: none;
}

.botd-action-btn:hover { color: #fff; }

.botd-action-btn--active {
    color: #60a5fa;
}

.botd-action-btn--active svg {
    fill: #60a5fa;
    stroke: #60a5fa;
}

.botd-action-btn--faved svg {
    fill: #f43f5e;
    stroke: #f43f5e;
}

/* --- Babe of the Day (home featured) --- */

.botd-featured {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.botd-featured__image {
    flex: 0 0 auto;
    width: 100%;
    max-width: 360px;
    border-radius: 0.5rem;
    overflow: hidden;
    display: block;
}

.botd-featured__image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.botd-featured__image:hover img {
    transform: scale(1.04);
}

.botd-featured__meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.botd-featured__name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-heading);
    margin: 0;
}

.botd-featured__date {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: 0;
}

.botd-featured__link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
}

.botd-featured__link:hover {
    opacity: 0.8;
}

@media (max-width: 639px) {
    .botd-featured { flex-direction: column; }
    .botd-featured__image { max-width: 100%; }
}

/* Inline ad inside card-grid — spans full row */
.card-grid__ad {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

/* --- Link Grid (partner sites) --- */

.link-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.link-grid__item {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    background: var(--color-surface);
    border-radius: 0.375rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.link-grid__item:hover {
    background: var(--color-primary);
    color: #fff;
}

/* --- Section Spacing --- */

.section { padding: 2rem 0; }
.section + .section { padding-top: 0; }
.section:first-child { padding-top: 1.5rem; }

/* --- Footer --- */

.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 3rem;
}

.site-footer a {
    color: var(--color-text-muted);
    transition: color 0.15s;
}
.site-footer a:hover { color: var(--color-heading); }

/* --- Scrollbar --- */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
    background: var(--color-surface-alt);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* --- Flash messages --- */

.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.flash--success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* --- Empty State --- */

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-text-muted);
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    opacity: 0.3;
}

/* --- Leaderboard filter bar --- */

.lb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.lb-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.filter-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 0.2rem;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-muted);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.filter-tab:hover {
    color: var(--color-heading);
    background: var(--color-surface-alt);
}

.filter-tab--active {
    background: var(--color-primary);
    color: #fff;
}

.filter-tab--active:hover {
    background: var(--color-primary);
    color: #fff;
    filter: brightness(1.1);
}

/* --- Pagination --- */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

.pagination__btn {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

a.pagination__btn:hover {
    color: var(--color-heading);
    border-color: var(--color-primary);
}

.pagination__btn--active {
    color: var(--color-heading);
    border-color: var(--color-primary);
    background: var(--color-primary);
    font-weight: 600;
    cursor: default;
}

.pagination__btn--disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination__dots {
    padding: 0.375rem 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* --- Image viewer / gallery lightbox --- */

/* Reset <button> elements used as card tiles */
button.card {
    width: 100%;
    border: none;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

/* Image in viewer modal — shorter to leave room for thumbs + link */
.viewer-modal__img {
    max-height: calc(100vh - 15rem);
}

/* Thumbnail strip inside the viewer modal */
.viewer-thumbs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.5rem 0 0;
    max-width: min(calc(100vw - 6rem), 680px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.viewer-thumb {
    flex-shrink: 0;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.25rem;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: opacity 0.15s, border-color 0.15s;
    background: none;
    padding: 0;
}

.viewer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.viewer-thumb:hover { opacity: 0.85; }
.viewer-thumb--active { border-color: var(--color-primary); opacity: 1; }

/* "View details" link inside modal */
.viewer-link {
    color: rgba(255,255,255,0.55);
    font-size: 0.75rem;
    text-decoration: none;
    margin-top: 0.35rem;
    display: inline-block;
    transition: color 0.15s;
}
.viewer-link:hover { color: #fff; }

/* Hero image on image page — click to enlarge */
.img-page__hero-btn {
    position: relative;
    display: block;
    width: 100%;
    border: none;
    background: none;
    padding: 0;
    cursor: zoom-in;
    border-radius: 0.375rem;
    overflow: hidden;
}

.img-page__hero-btn img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0.375rem;
}

.img-page__hero-hint {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
    color: rgba(255,255,255,0.9);
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
}

.img-page__hero-btn:hover .img-page__hero-hint { opacity: 1; }

/* Related image buttons on image page */
.related-grid button {
    display: block;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    border-radius: 0.375rem;
    overflow: hidden;
    width: 100%;
    border: 2px solid transparent;
    transition: border-color 0.15s, opacity 0.15s;
}

.related-grid button img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    transition: opacity 0.15s;
}

.related-grid button:hover img { opacity: 0.8; }
.related-grid button.viewer-active { border-color: var(--color-primary); }
