/**
 * Components - Apple-inspired Design
 */

/* ========================================
   Header & Navigation
   ======================================== */

.site-header {
    min-height: var(--header-height);
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-fixed);
    height: var(--header-height);
    background: hsl(220 15% 8% / 0.75);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid hsl(220 10% 20% / 0.4);
}

body.admin-bar .navbar {
    top: var(--header-offset, 32px);
}

.navbar__inner {
    display: flex;
    align-items: center;
    height: 100%;
    gap: var(--space-lg);
}

.navbar__brand {
    flex-shrink: 0;
}

.navbar__brand img {
    max-height: 26px;
    width: auto;
}

.navbar__logo-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    letter-spacing: var(--letter-spacing-tight);
}

.navbar__nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.navbar__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    height: 36px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    background: transparent;
    border-radius: var(--radius-lg);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.navbar__link:hover,
.navbar__link--active {
    background: var(--color-surface);
    color: var(--color-text);
}

.navbar__link svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.navbar__menu {
    flex-shrink: 0;
}

/* ── Navbar Breadcrumb ─────────────────────────── */
.navbar-bc {
    min-width: 0;
}

.navbar-bc__list {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    min-width: 0;
}

.navbar-bc__item {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.navbar-bc__item a {
    display: flex;
    align-items: center;
    gap: 2px;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.navbar-bc__item a:hover,
.navbar-bc__item a:focus-visible {
    color: var(--color-accent);
}

.navbar-bc__icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.navbar-bc__sep {
    font-size: 0.7em;
    opacity: 0.35;
    margin: 0 3px;
    flex-shrink: 0;
}

/* Current item — truncate long names with marquee */
.navbar-bc__item.is-current {
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.navbar-bc__text {
    display: inline-block;
    white-space: nowrap;
    padding-right: 24px;
}

/* Fade mask + scroll animation when text overflows */
.navbar-bc__item.is-current.is-scrolling {
    -webkit-mask-image: linear-gradient(to right, #000 70%, transparent 95%);
    mask-image: linear-gradient(to right, #000 70%, transparent 95%);
}

.navbar-bc__item.is-current.is-scrolling .navbar-bc__text {
    animation: bc-marquee var(--bc-duration, 5s) ease-in-out 1s infinite;
}

@keyframes bc-marquee {
    0%, 20%  { transform: translateX(0); }
    40%, 60% { transform: translateX(var(--bc-scroll-dist, -60px)); }
    80%, 100% { transform: translateX(0); }
}

.navbar__search {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-sm);
    margin-left: auto;
}

@media (min-width: 768px) {
    .navbar__search {
        flex: 1;
    }
}

.navbar__hamburger {
    flex-shrink: 0;
}

/* ========================================
   Mobile Nav Drawer
   ======================================== */

.mobile-nav {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1050);
    visibility: hidden;
    pointer-events: none;
}

.mobile-nav--open {
    visibility: visible;
    pointer-events: auto;
}

.mobile-nav__backdrop {
    position: absolute;
    inset: 0;
    background: hsl(0 0% 0% / 0.6);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.mobile-nav--open .mobile-nav__backdrop {
    opacity: 1;
}

.mobile-nav__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: calc(100vw - 60px);
    max-width: 300px;
    background: hsl(0 0% 6%);
    border-left: 1px solid hsl(220 10% 20% / 0.4);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-nav--open .mobile-nav__panel {
    transform: translateX(0);
}

.mobile-nav__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--space-lg);
    background: hsl(220 15% 8% / 0.75);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid hsl(220 10% 20% / 0.4);
    flex-shrink: 0;
}

.mobile-nav__title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.mobile-nav__title svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}

.mobile-nav__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: -12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mobile-nav__close:hover {
    color: var(--color-text);
}

.mobile-nav__menu {
    list-style: none;
    margin: 0;
    padding: var(--space-md) 0;
}

.mobile-nav__menu li {
    margin: 0;
}

.mobile-nav__menu a {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.mobile-nav__menu a:hover,
.mobile-nav__menu .current-menu-item a {
    background: var(--color-surface);
    color: var(--color-text);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    height: 36px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    background: var(--color-surface);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition:
        background-color var(--transition-fast),
        transform 120ms var(--ease-spring);
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    background: var(--color-surface-hover);
}

.btn:active {
    transform: scale(0.96);
}

.btn--primary {
    background: var(--color-primary);
    color: white;
}

.btn--primary:hover {
    background: var(--color-primary-hover);
}

.btn--outline {
    background: transparent;
    border: 1.5px solid var(--color-border);
}

.btn--outline:hover {
    background: var(--color-surface);
    border-color: var(--color-surface);
}

.btn--icon {
    width: 36px;
    padding: 0;
}

.btn--icon svg {
    width: 18px;
    height: 18px;
}

/* Navbar icon buttons - iOS style (no background, bold icons) */
.navbar .btn--icon {
    width: 44px;
    height: 44px;
    background: transparent;
    border-radius: 0;
}

.navbar .btn--icon:hover {
    background: transparent;
}

.navbar .btn--icon:active {
    transform: scale(0.9);
}

.navbar .btn--icon svg {
    width: 26px;
    height: 26px;
    color: white;
    stroke-width: 2.5;
}

.btn--sm {
    height: 32px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
}

.btn--lg {
    height: 44px;
    padding: 0 var(--space-lg);
    font-size: var(--font-size-base);
}

.btn--add-video {
    background: transparent;
    color: var(--color-text);
    border: 1.5px solid hsl(0 0% 100% / 0.2);
    border-radius: 20px;
    height: 34px;
    padding: 0 14px 0 10px;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    font-weight: var(--font-weight-medium);
}

.btn--add-video .icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.btn--add-video:hover {
    background: hsl(0 0% 100% / 0.1);
    border-color: hsl(0 0% 100% / 0.35);
}

.btn--add-video:hover .icon {
    opacity: 1;
}

/* ========================================
   Search
   ======================================== */

/* Mobile: hide full search form, show only toggle button */
.search-form {
    display: none;
    align-items: center;
    gap: var(--space-sm);
}

.search-form__toggle {
    display: flex;
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
}

/* Desktop: show full search form, hide toggle */
@media (min-width: 768px) {
    .search-form {
        display: flex;
    }

    .search-form__toggle {
        display: none;
    }
}

.search-form__input {
    width: 220px;
    height: 44px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    border: none;
    border-radius: var(--radius-lg);
    transition: width var(--transition-normal), background-color var(--transition-fast);
}

.search-form__input::-webkit-search-cancel-button,
.search-form__input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.search-form__input:-webkit-autofill,
.search-form__input:-webkit-autofill:hover,
.search-form__input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--color-text);
    -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.search-form__input::placeholder {
    color: var(--color-text-muted);
}

.search-form__input:focus {
    width: 300px;
    background: var(--color-surface-hover);
    outline: none;
}

/* Inline Mobile Search (expands inside navbar) */
.navbar__search-inline {
    display: none;
    flex: 1;
    position: relative;
    align-items: center;
    min-width: 0;
}

@keyframes searchExpand {
    from {
        opacity: 0;
        clip-path: inset(0 0 0 100%);
    }
    to {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

.navbar--search-open .navbar__search-inline {
    display: flex;
    animation: searchExpand 0.25s ease forwards;
}

@media (max-width: 767px) {
    .navbar__inner {
        position: relative;
    }

    .navbar--search-open .navbar__search-inline {
        position: absolute;
        left: 50px;
        right: 50px;
        top: 0;
        bottom: 0;
        z-index: 2;
    }

    body:not(.has-sidebar) .navbar--search-open .navbar__search-inline {
        left: 6px;
    }
}

@media (min-width: 768px) {
    .navbar__search-inline {
        display: none !important;
    }
}

.navbar__search-inline-input {
    width: 100%;
    height: 40px;
    padding: 0 40px 0 36px;
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-bg);
    border: none;
    border-radius: var(--radius-lg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 16px 16px;
}

.navbar__search-inline-input::-webkit-search-cancel-button,
.navbar__search-inline-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.navbar__search-inline-input:-webkit-autofill,
.navbar__search-inline-input:-webkit-autofill:hover,
.navbar__search-inline-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--color-text);
    -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.navbar__search-inline-input:focus {
    outline: none;
}

.navbar__search-inline-input::placeholder {
    color: var(--color-text-muted);
}

.navbar__search-inline-close {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.navbar__search-inline-close:hover {
    background: hsl(0 0% 100% / 0.08);
    color: var(--color-text);
}

/* ========================================
   Section Header - Icon + Title + View All
   ======================================== */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: 0 var(--space-xs);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    letter-spacing: var(--letter-spacing-tight);
}

.section-title svg {
    width: 22px;
    height: 22px;
    color: var(--color-primary);
}

.section-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-primary);
    transition: opacity var(--transition-fast);
}

.section-link:hover {
    opacity: 0.8;
    color: var(--color-primary);
}

.section-link svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Sort Dropdown
   ======================================== */

.sort-dropdown {
    position: relative;
    flex-shrink: 0;
}

.sort-dropdown__toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    height: 36px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sort-dropdown__toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-border);
}

.sort-dropdown__toggle[aria-expanded="true"] {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-primary);
}

.sort-dropdown__toggle .icon {
    color: var(--color-primary);
}

.sort-dropdown__chevron {
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.sort-dropdown__toggle[aria-expanded="true"] .sort-dropdown__chevron {
    transform: rotate(180deg);
}

.sort-dropdown__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    padding: var(--space-xs);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: var(--z-dropdown);
    list-style: none;
}

.sort-dropdown--open .sort-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sort-dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sort-dropdown__item:hover {
    background: hsl(0 0% 100% / 0.05);
    color: var(--color-text);
}

.sort-dropdown__item--active {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.sort-dropdown__item--active:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

/* Checkmark for active item */
.sort-dropdown__item--active::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    border-radius: var(--radius-full);
}

/* ========================================
   Video Card - Clean, modern
   ======================================== */

.video-card {
    display: block;
    color: inherit;
    transition: transform var(--transition-normal);
    border-radius: var(--radius-lg);
    padding-bottom: var(--space-sm);
}

.video-card:hover {
    background: rgba(var(--card-color, 128,128,128), 0.2);
    transform: translateY(-6px);
}

/* Fade-in animation for new items loaded via infinite scroll */
.video-card--new {
    opacity: 0;
    animation: videoCardFadeIn 0.4s ease forwards;
}

@keyframes videoCardFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.video-card__thumbnail {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-normal);
    /* Fallback aspect ratio - inline style will override with actual video dimensions */
    aspect-ratio: 16 / 9;
}

.video-card:hover .video-card__thumbnail {
    box-shadow: var(--shadow-card-hover);
}

/* Skeleton loading shimmer effect - shown as background behind image */
.video-card__thumbnail::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        var(--color-surface) 0%,
        var(--color-surface-raised) 50%,
        var(--color-surface) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 0;
}

.video-card__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transition: transform var(--transition-slow), opacity 300ms ease;
}

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

.video-card__preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
}

.video-card:hover .video-card__image.hidden {
    opacity: 0;
}

.video-card:hover .video-card__preview.active {
    opacity: 1;
}


/* Overlay badges - top right */
.video-card__badges {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    display: flex;
    gap: var(--space-xs);
    z-index: 2;
}

.video-card__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: hsl(0 0% 0% / 0.6);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
}

.video-card__badge svg {
    width: 14px;
    height: 14px;
}

.video-card__badge--muted {
    color: var(--color-error);
}

/* Bottom gradient + meta */
.video-card__thumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        hsl(0 0% 0% / 0.8) 0%,
        hsl(0 0% 0% / 0.4) 30%,
        transparent 60%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.video-card:hover .video-card__thumbnail::after {
    opacity: 1;
}

.video-card__overlay {
    position: absolute;
    bottom: var(--space-sm);
    left: var(--space-sm);
    right: var(--space-sm);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 2;
}

.video-card__sound {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: hsl(0 0% 0% / 0.6);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-full);
    color: var(--color-error);
}

.video-card__sound svg {
    width: 12px;
    height: 12px;
}

.video-card__meta {
    display: flex;
    align-items: center;
    background: hsl(0 0% 0% / 0.6);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.video-card__quality {
    padding: 5px 8px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.03em;
}

.video-card__quality--uhd {
    background: var(--color-uhd);
    color: white;
}

.video-card__quality--hd {
    background: var(--color-hd);
    color: white;
}

.video-card__quality--sd {
    color: var(--color-text-muted);
}

.video-card__duration {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.video-card__duration svg {
    width: 10px;
    height: 10px;
    opacity: 0.7;
}

/* Card content below thumbnail */
.video-card__content {
    padding: var(--space-sm) var(--space-xs) 0;
}

.video-card__title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    line-height: var(--line-height-normal);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--transition-fast);
}

.video-card:hover .video-card__title {
    color: var(--color-primary);
}

.video-card__info {
    margin-top: 2px;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
}

.video-card__artist {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--transition-fast);
}

.video-card__artist-icon {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.video-card:hover .video-card__artist {
    color: var(--color-text);
}

.video-card__views {
    display: block;
}

/* Processing state */
.video-card--processing {
    display: none;
}

.logged-in .video-card--processing {
    display: block;
}

.video-card__processing {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(0 0% 0% / 0.85);
    border-radius: var(--radius-xl);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    z-index: 10;
}

/* ========================================
   Tags
   ======================================== */

/* Prevent WP body.tag class collision with tag badge component */
body.tag { display: block !important; }

.tag {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    background: var(--color-tag-bg);
    border-radius: var(--radius-lg);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.tag:hover {
    background: var(--color-tag-bg-hover);
    color: var(--color-text);
}

.tag svg {
    width: 12px;
    height: 12px;
    margin-right: 4px;
}

.tag--primary {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.tag--primary:hover {
    background: var(--color-primary);
    color: white;
}

a.tag-group {
    display: inline-flex;
    border-radius: var(--radius-md);
    overflow: hidden;
}

a.tag-group .tag {
    border-radius: 0;
    height: 26px;
}

a.tag-group .tag:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

a.tag-group .tag:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Tags list with horizontal scroll */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.tags-scroll {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding: var(--space-sm) 0;
    margin: 0 calc(var(--space-md) * -1);
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tags-scroll::-webkit-scrollbar {
    display: none;
}

.tags-scroll .tag {
    flex-shrink: 0;
}

/* ========================================
   Pagination
   ======================================== */

.pagination {
    display: flex;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-xl) 0;
}

.pagination__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    background: transparent;
    border-radius: var(--radius-lg);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.pagination__item:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

.pagination__item--current {
    background: var(--color-primary);
    color: white;
    pointer-events: none;
}

/* ========================================
   Footer
   ======================================== */

.site-footer {
    margin-top: var(--space-3xl);
    padding: var(--space-2xl) 0 var(--space-lg);
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border-subtle);
}

.footer-widgets {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-2xl);
    margin-bottom: var(--space-xl);
}

@media (max-width: 768px) {
    .footer-widgets {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }
}

.site-info {
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border-subtle);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ========================================
   Forms
   ======================================== */

.form-field {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    height: 44px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.form-input:hover,
.form-select:hover {
    background: var(--color-surface-hover);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--color-primary);
    background: var(--color-surface-hover);
    outline: none;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23808080' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-md) center;
    padding-right: var(--space-xl);
}

/* ========================================
   Modal
   ======================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal--open {
    opacity: 1;
    visibility: visible;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: hsl(0 0% 0% / 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal__container {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal--open .modal__container {
    transform: scale(1) translateY(0);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border-subtle);
}

.modal__title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.modal__title svg {
    color: var(--color-primary);
}

.modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal__close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.modal__body {
    padding: var(--space-lg);
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal__field {
    margin-bottom: var(--space-lg);
}

.modal__field:last-child {
    margin-bottom: 0;
}

.modal__label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
}

.modal__footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--color-border-subtle);
}

.modal__footer .btn {
    flex: 1;
}

/* Chip Group - Selection chips */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-border);
}

.chip--active {
    background: hsl(0 0% 100% / 0.12);
    color: var(--color-text);
    border-color: hsl(0 0% 100% / 0.2);
}

.chip--active:hover {
    background: hsl(0 0% 100% / 0.18);
    border-color: hsl(0 0% 100% / 0.25);
    color: var(--color-text);
}

/* Body scroll lock when modal open */
body.modal-open {
    overflow: hidden;
}

/* ========================================
   Sidebar - Persistent (desktop) / Overlay (mobile)
   ======================================== */

/* --- Mobile default: overlay mode --- */
.sidebar {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    visibility: hidden;
    pointer-events: none;
}

.sidebar--open {
    visibility: visible;
    pointer-events: auto;
}

.sidebar__backdrop {
    position: absolute;
    inset: 0;
    background: hsl(0 0% 0% / 0);
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    transition: background-color 0.35s ease, backdrop-filter 0.35s ease;
    cursor: pointer;
}

.sidebar--open .sidebar__backdrop {
    background: hsl(0 0% 0% / 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.sidebar__container {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: calc(100vw - 60px);
    display: flex;
    flex-direction: column;
    background: hsl(220 15% 8% / 0.75);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 4px 0 20px hsl(0 0% 0% / 0.4);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile: floating panel style with rounded corners */
@media (max-width: 480px) {
    .sidebar__container {
        top: var(--space-sm);
        left: var(--space-sm);
        bottom: var(--space-sm);
        width: calc(100vw - 80px);
        max-width: 300px;
        border-radius: var(--radius-xl);
        background: hsl(220 15% 8% / 0.75);
        box-shadow: 0 8px 32px hsl(0 0% 0% / 0.6);
        border: 1px solid hsl(0 0% 100% / 0.06);
    }
}

.sidebar--open .sidebar__container {
    transform: translateX(0);
}

/* Hide collapse button on mobile */
.sidebar__collapse {
    display: none;
}

/* --- Desktop: persistent fixed panel --- */
@media (min-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: var(--sidebar-width);
        height: auto;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: calc(var(--z-fixed) + 1);
        visibility: visible;
        pointer-events: auto;
        overflow: visible;
    }

    body.admin-bar .sidebar {
        top: var(--header-offset, 32px);
    }

    html.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Push navbar right when sidebar is open on listing pages */
    html.sidebar-open body.has-sidebar .navbar {
        left: var(--sidebar-width);
    }

    /* Push page content right when sidebar is open on listing pages */
    html.sidebar-open body.has-sidebar #page {
        margin-left: var(--sidebar-width);
    }

    /* Smooth transitions for navbar and page push */
    body.has-sidebar .navbar {
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.has-sidebar #page {
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* FOUC prevention: no transitions until sidebar-ready */
    html:not(.sidebar-ready) body.has-sidebar .navbar,
    html:not(.sidebar-ready) body.has-sidebar #page,
    html:not(.sidebar-ready) .sidebar,
    html:not(.sidebar-ready) .navbar__menu {
        transition: none !important;
    }

    /* Container handles internal scrolling with thin scrollbar */
    .sidebar__container {
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: hsl(0 0% 30%) transparent;
    }

    .sidebar__container::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar__container::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar__container::-webkit-scrollbar-thumb {
        background: hsl(0 0% 30%);
        border-radius: 2px;
    }

    /* Animate navbar toggle out when sidebar opens on desktop */
    .navbar__menu {
        transition: opacity 0.2s ease, width 0.2s ease, padding 0.2s ease, margin 0.2s ease;
        overflow: hidden;
    }

    html.sidebar-open .navbar__menu {
        opacity: 0;
        width: 0;
        padding: 0;
        margin-right: calc(var(--space-lg) * -1); /* Cancel flex gap */
        pointer-events: none;
    }

    /* No backdrop on desktop */
    .sidebar__backdrop {
        display: none;
    }

    /* Sidebar container fills the fixed sidebar, not absolute */
    .sidebar > .sidebar__container {
        position: static;
        width: var(--sidebar-width);
        max-width: none;
        height: 100%;
        transform: none;
        transition: none;
        box-shadow: none;
        border-right: 1px solid var(--color-border-subtle);
    }

    /* Hide mobile close button on desktop */
    .sidebar__close {
        display: none;
    }

    /* Show collapse button on desktop — centered at navbar height */
    .sidebar__collapse {
        display: flex;
        position: absolute;
        right: -16px;
        top: calc(var(--header-height) / 2);
        transform: translateY(-50%);
        width: 32px;
        height: 32px;
        border-radius: var(--radius-full);
        background: var(--color-surface);
        border: 1px solid var(--color-border-subtle);
        color: var(--color-text-muted);
        cursor: pointer;
        z-index: 2;
        align-items: center;
        justify-content: center;
        transition: all var(--transition-fast);
        opacity: 0;
        pointer-events: none;
    }

    html.sidebar-open .sidebar__collapse {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar__collapse:hover {
        background: var(--color-surface-hover);
        color: var(--color-text);
        border-color: var(--color-border);
    }

    .sidebar__collapse svg {
        width: 16px;
        height: 16px;
        transition: transform var(--transition-fast);
    }
}

/* Header */
.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: var(--header-height);
    padding: 0 var(--space-lg);
    background: hsl(220 15% 8% / 0.75);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid hsl(220 10% 20% / 0.4);
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .sidebar__header {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
}

.sidebar__title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.sidebar__title svg {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}

.sidebar__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: -12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar__close:hover {
    background: hsl(0 0% 100% / 0.08);
    color: var(--color-text);
}

/* Hide close button on desktop (collapse chevron is used instead) */
@media (min-width: 768px) {
    .sidebar__close {
        display: none !important;
    }
}

/* Body */
.sidebar__body {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: hsl(0 0% 30%) transparent;
}

.sidebar__body::-webkit-scrollbar {
    width: 4px;
}

.sidebar__body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar__body::-webkit-scrollbar-thumb {
    background: hsl(0 0% 30%);
    border-radius: 2px;
}

/* Filter Field */
.sidebar__field {
    margin-bottom: var(--space-lg);
}

.sidebar__field:last-child {
    margin-bottom: 0;
}

.sidebar__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.sidebar__label svg {
    width: 12px;
    height: 12px;
    opacity: 0.5;
}

/* Sidebar Tabs - Segmented Control */
.sidebar .chip-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: 3px;
    gap: 2px;
}

.sidebar .chip-group[data-name="quality"] {
    grid-template-columns: 1fr 1fr 1fr;
}

.sidebar .chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 6px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.sidebar .chip:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.sidebar .chip--active {
    color: var(--color-text);
    background: hsl(0 0% 100% / 0.12);
}

.sidebar .chip--active:hover {
    background: hsl(0 0% 100% / 0.18);
}

/* Chip Icons */
.chip__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar .chip--active .chip__icon {
    opacity: 1;
}

/* Tag Input */
.tag-input-wrapper {
    position: relative;
}

.tag-input {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-sm);
    font-size: 16px; /* Prevent iOS Safari zoom on focus */
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.tag-input::placeholder {
    color: var(--color-text-muted);
}

.tag-input:focus {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
}

/* Tag Suggestions Dropdown */
.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: 4px;
    z-index: 100;
    display: none;
}

.tag-suggestions.active {
    display: block;
}

.tag-suggestion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.tag-suggestion:hover {
    background: var(--color-surface-hover);
}

.tag-suggestion__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-suggestion__count {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-left: var(--space-sm);
}

.tag-suggestions__empty {
    padding: 12px;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    text-align: center;
}

/* Selected Tags */
.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.selected-tags:empty {
    display: none;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding: 0 8px 0 10px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: white;
    background: var(--color-primary);
    border-radius: var(--radius-lg);
}

.selected-tag__remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    background: hsl(0 0% 100% / 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.selected-tag__remove:hover {
    background: hsl(0 0% 100% / 0.3);
}

.selected-tag__remove svg {
    width: 10px;
    height: 10px;
    stroke: white;
    stroke-width: 2.5;
}

/* Reset button in sidebar header */
.sidebar__header .btn {
    flex-shrink: 0;
    height: 28px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-xs);
    margin-left: auto;
}

/* Active filter count badge */
.sidebar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: white;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    margin-left: var(--space-xs);
}

/* Body scroll lock when sidebar overlay open (mobile only) */
@media (max-width: 767px) {
    body.sidebar-overlay-open {
        overflow: hidden;
        padding-right: var(--scrollbar-width, 0px);
    }

    body.sidebar-overlay-open .navbar {
        padding-right: var(--scrollbar-width, 0px);
    }
}

/* Navbar menu button enhancement */
.navbar__menu {
    position: relative;
}

.navbar__menu::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.navbar__menu.has-filters::after {
    opacity: 1;
    transform: scale(1);
}

/* ========================================
   Filter Form
   ======================================== */

.filter-form {
    padding: var(--space-lg);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-lg);
}

.filter-form__grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr) auto;
    gap: var(--space-md);
    align-items: end;
}

@media (max-width: 992px) {
    .filter-form__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 576px) {
    .filter-form__grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Comments
   ======================================== */

/* Comment Area */
.comments-area {
    padding-top: var(--space-lg);
}

/* Comment Count Header */
.comments-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin-bottom: var(--space-md);
}

/* ---- Comment Form (on top, no card bg) ---- */
.comment-respond {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border-subtle);
}

/* Hide reply title when empty (top-level form) */
.comment-reply-title:empty {
    display: none;
}

/* Reply title (shows "Reply to X" when inline) */
.comment-reply-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.comment-reply-title small a {
    color: var(--color-text-muted);
    font-weight: var(--font-weight-normal);
    transition: color var(--transition-fast);
}

.comment-reply-title small a:hover {
    color: var(--color-primary);
}

/* Logged-in user bar */
.comment-auth {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.comment-auth__user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.comment-auth__avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.comment-auth__user a {
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
}

.comment-auth__user a:hover {
    color: var(--color-primary);
}

.comment-auth__actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

.comment-auth__actions a {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    transition: color var(--transition-fast);
}

.comment-auth__actions a:hover {
    color: var(--color-primary);
}

/* Required fields note (non-logged-in) */
.comment-notes {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: var(--radius-md);
}

.comment-notes svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* Legacy fallback */
.logged-in-as {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.logged-in-as a {
    color: var(--color-primary);
}

/* Form layout — grid: textarea first, then name|email|submit in a row */
.comment-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: var(--space-sm);
}

.comment-form p {
    margin: 0;
}

.comment-form-comment {
    grid-column: 1 / -1;
    grid-row: 2;
}

/* Place author + email + submit on row 3, cookies on row 4 */
.comment-form-author {
    grid-row: 3;
    grid-column: 1;
}

.comment-form-email {
    grid-row: 3;
    grid-column: 2;
}

.comment-form__actions {
    grid-row: 3;
    grid-column: 3;
}

.comment-form-cookies-consent {
    grid-column: 1 / -1;
    grid-row: 4;
}

/* Textarea */
.comment-form textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    min-height: 80px;
    resize: vertical;
    line-height: var(--line-height-relaxed);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.comment-form textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
    outline: none;
}

.comment-form textarea::placeholder {
    color: var(--color-text-muted);
}

/* Text inputs (Name, Email) */
.comment-form input[type="text"],
.comment-form input[type="email"] {
    width: 100%;
    padding: var(--space-sm) var(--space-sm);
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.comment-form input[type="text"]:focus,
.comment-form input[type="email"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
    outline: none;
}

.comment-form input[type="text"]::placeholder,
.comment-form input[type="email"]::placeholder {
    color: var(--color-text-muted);
}

/* Comment submit button */
.btn--comment-submit {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    height: 100%;
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    background: hsl(0 0% 22%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--transition-fast);
}

.btn--comment-submit:hover {
    background: hsl(0 0% 28%);
}

.btn--comment-submit svg {
    flex-shrink: 0;
    opacity: 0.8;
}

/* Cookie consent */
.comment-form-cookies-consent {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.comment-form-cookies-consent input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.comment-form-cookies-consent label {
    display: inline;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: 0;
    cursor: pointer;
}

/* ---- Comment List (YouTube-style) ---- */
.comment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Comment item */
.comment-item {
    padding: var(--space-md) 0;
}

.comment-item__inner {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
}

/* Avatar — left column (initials circle) */
.comment-item__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    letter-spacing: 0.5px;
    user-select: none;
}

/* Gravatar image avatar */
.comment-item__avatar--img {
    object-fit: cover;
}

/* Content — right column */
.comment-item__content {
    flex: 1;
    min-width: 0;
}

/* Header: name + time */
.comment-item__header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.comment-item__author {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.comment-item__time {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Comment body */
.comment-item__body {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
}

.comment-item__body p {
    margin: 0;
}

.comment-awaiting-moderation {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

/* Actions: like / dislike / reply */
.comment-item__actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.comment-item__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.comment-item__action:hover {
    background: hsl(0 0% 100% / 0.08);
    color: var(--color-text);
}

.comment-item__actions .comment-reply-link {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-full);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.comment-item__actions .comment-reply-link:hover {
    background: hsl(0 0% 100% / 0.08);
    color: var(--color-text);
}

/* Vote count — centered between up/down buttons */
.comment-item__vote-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    min-width: 1.5ch;
    text-align: center;
}

.comment-item__action.voted {
    color: var(--color-primary);
}

/* 3-dot menu (in header row) */
.comment-item__more {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

.comment-item__dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 140px;
    padding: var(--space-xs) 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px hsl(0 0% 0% / 0.4);
    z-index: 10;
}

.comment-item__more.open .comment-item__dropdown {
    display: block;
}

.comment-item__dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.comment-item__dropdown-item:hover {
    background: hsl(0 0% 100% / 0.06);
    color: var(--color-text);
}

.comment-item__dropdown-item.reported {
    color: var(--color-text-muted);
    pointer-events: none;
}

/* Thread replies — indented under avatar */
.comment-list .children {
    list-style: none;
    margin: 0;
    padding-left: calc(40px + var(--space-md));
}

.comment-list .children .comment-item {
    padding: var(--space-sm) 0;
}

/* Inline reply form (when clicking Reply) */
.comment-list .comment-respond {
    margin-top: var(--space-sm);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: none;
}

/* Cancel reply */
#cancel-comment-reply-link {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-left: var(--space-sm);
}

/* ── Report Modal ── */
.report-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast) ease;
}

.report-modal--closing {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.report-modal__backdrop {
    position: absolute;
    inset: 0;
    background: hsl(0 0% 0% / 0.6);
    backdrop-filter: blur(4px);
}

.report-modal__dialog {
    position: relative;
    width: 90%;
    max-width: 440px;
    background: var(--color-bg-elevated, hsl(0 0% 12%));
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 24px 48px hsl(0 0% 0% / 0.4);
}

.report-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid hsl(0 0% 100% / 0.06);
}

.report-modal__title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin: 0;
}

.report-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.report-modal__close:hover {
    background: hsl(0 0% 100% / 0.08);
    color: var(--color-text);
}

.report-modal__body {
    padding: var(--space-lg);
}

.report-modal__subtitle {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    margin: 0 0 var(--space-xs);
}

.report-modal__hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-md);
    line-height: 1.5;
}

.report-modal__options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.report-modal__option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.report-modal__option:hover {
    background: hsl(0 0% 100% / 0.04);
    color: var(--color-text);
}

.report-modal__option input[type="radio"] {
    display: none;
}

.report-modal__radio {
    width: 18px;
    height: 18px;
    border: 2px solid hsl(0 0% 100% / 0.25);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: border-color var(--transition-fast);
}

.report-modal__option input:checked ~ .report-modal__radio {
    border-color: hsl(210 80% 60%);
}

.report-modal__option input:checked ~ .report-modal__radio::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: hsl(210 80% 60%);
    border-radius: 50%;
}

.report-modal__textarea {
    width: 100%;
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: hsl(0 0% 100% / 0.04);
    border: 1px solid hsl(0 0% 100% / 0.1);
    border-radius: var(--radius-md);
    resize: vertical;
    font-family: inherit;
}

.report-modal__textarea:focus {
    outline: none;
    border-color: hsl(210 80% 60% / 0.5);
}

.report-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid hsl(0 0% 100% / 0.06);
}

.report-modal__cancel {
    background: transparent !important;
    color: var(--color-text-secondary) !important;
}

.report-modal__cancel:hover {
    color: var(--color-text) !important;
    background: hsl(0 0% 100% / 0.06) !important;
}

.report-modal__success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    color: hsl(150 60% 55%);
}

.report-modal__success p {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    margin: var(--space-sm) 0 0;
}

.report-modal__success span {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

body.modal-open {
    overflow: hidden;
}

/* AJAX comment notices */
.comment-form__notice {
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    color: hsl(0 80% 70%);
    background: hsl(0 50% 20% / 0.3);
    border-radius: var(--radius-md);
    animation: fadeIn var(--transition-normal) ease;
}

.comment-form__notice--info {
    color: hsl(200 80% 70%);
    background: hsl(200 50% 20% / 0.3);
}

/* New comment highlight */
.comment-item--new {
    animation: commentHighlight 2s ease;
}

@keyframes commentHighlight {
    0%   { background: hsl(200 50% 20% / 0.3); }
    100% { background: transparent; }
}

/* Inline spinner for submit button */
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid hsl(0 0% 100% / 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: var(--space-xs);
    vertical-align: middle;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

#cancel-comment-reply-link:hover {
    color: var(--color-primary);
}

/* No comments message */
.no-comments {
    text-align: center;
    padding: var(--space-lg);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* Mobile: stack form fields */
@media (max-width: 639px) {
    .comment-form {
        grid-template-columns: 1fr;
    }

    .comment-form-comment,
    .comment-form-author,
    .comment-form-email,
    .comment-form-cookies-consent,
    .comment-form__actions {
        grid-column: 1;
        grid-row: auto;
    }

    .btn--comment-submit {
        width: 100%;
        justify-content: center;
    }
}


/* ========================================
   Entry Content
   ======================================== */

.entry-content {
    color: var(--color-text-secondary);
    line-height: var(--line-height-relaxed);
    font-size: var(--font-size-base);
}

.entry-content p {
    margin-bottom: var(--space-md);
}

.entry-content a {
    color: var(--color-primary);
}

.entry-content blockquote {
    margin: var(--space-lg) 0;
    padding: var(--space-lg);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border-left: 4px solid var(--color-primary);
}

/* ========================================
   Widget
   ======================================== */

.widget {
    margin-bottom: var(--space-xl);
}

.widget-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-md);
    color: var(--color-text);
}

.widget li {
    padding: var(--space-xs) 0;
}

.widget a {
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.widget a:hover {
    color: var(--color-text);
}

/* ========================================
   Admin Tools
   ======================================== */

.admin-tools {
    padding: var(--space-lg);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    margin: var(--space-lg) 0;
}

.admin-tools__title {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.admin-tools__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* ========================================
   Notifications
   ======================================== */

.notification {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}

.notification--error {
    background: hsl(0 50% 15%);
    color: var(--color-text);
}

.notification--success {
    background: hsl(142 50% 15%);
}

/* ========================================
   Loading
   ======================================== */

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-surface) 0%,
        var(--color-surface-hover) 50%,
        var(--color-surface) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-lg);
}

/* Load More */
.load-more {
    display: flex;
    justify-content: center;
    padding: var(--space-xl) 0;
}

.load-more__btn {
    min-width: 200px;
}

.load-more__btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: var(--space-xs);
    vertical-align: middle;
}

/* ========================================
   Utilities
   ======================================== */

.icon {
    flex-shrink: 0;
    fill: currentColor;
}

.text-gradient {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   Post Navigation (Prev/Next)
   ======================================== */

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.post-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast), background var(--transition-fast);
    max-width: 45%;
}

.post-nav__link:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.post-nav__link--next {
    margin-left: auto;
    text-align: right;
}

.post-nav__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-sm);
}
