/* ============================================================
   ByteCurate — Homepage Redesign v1
   Inspired by The Verge, TechCrunch, Wirecutter, Smashing Magazine
   Mobile-first, vanilla CSS, no frameworks
   ============================================================ */

/* ============================================================
   REVEAL ANIMATION (scroll-triggered)
   ============================================================ */
.hp-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0s),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0s);
}
.hp-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   SECTION COMMON
   ============================================================ */
.hp-section {
    padding: var(--space-2xl) 0;
}
.hp-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    gap: var(--space-md);
}
.hp-section__title {
    font-size: var(--text-xl);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text);
    letter-spacing: -0.01em;
}
.hp-section__title svg {
    color: var(--primary);
    flex-shrink: 0;
}
.hp-section__link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    transition: gap 0.2s var(--ease);
}
.hp-section__link:hover {
    gap: 8px;
}

/* ============================================================
   SECTION 1: HERO — Featured Article
   ============================================================ */
.hp-hero {
    position: relative;
    overflow: hidden;
    background: var(--text);
}
.hp-hero__link {
    display: block;
    position: relative;
    min-height: 320px;
}
.hp-hero__image {
    position: absolute;
    inset: 0;
}
.hp-hero__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.hp-hero__link:hover .hp-hero__image img {
    transform: scale(1.03);
}
.hp-hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.4) 40%,
        rgba(0, 0, 0, 0.1) 70%,
        transparent 100%
    );
}
.hp-hero__content {
    position: relative;
    z-index: 2;
    padding: var(--space-3xl) var(--space-lg) var(--space-xl);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 320px;
    max-width: var(--max-width);
    margin: 0 auto;
}
.hp-hero__meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}
.hp-hero__category {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.2);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}
.hp-hero__type {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.hp-hero__type--review { color: #c7d2fe; }
.hp-hero__type--comparison { color: #fde68a; }
.hp-hero__type--news { color: #6ee7b7; }
.hp-hero__type--tutorial { color: #7dd3fc; }
.hp-hero__type--listicle { color: #f9a8d4; }

.hp-hero__title {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: #fff;
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    max-width: 700px;
}
.hp-hero__excerpt {
    margin-top: var(--space-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: var(--text-base);
    line-height: 1.5;
    max-width: 560px;
}
.hp-hero__bottom {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.5);
}
.hp-hero__dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
}

/* Desktop hero */
@media (min-width: 768px) {
    .hp-hero__link {
        min-height: 480px;
    }
    .hp-hero__content {
        min-height: 480px;
        padding: var(--space-4xl) var(--space-xl) var(--space-2xl);
    }
    .hp-hero__title {
        font-size: 2.75rem;
    }
    .hp-hero__excerpt {
        font-size: var(--text-lg);
    }
}

@media (min-width: 1024px) {
    .hp-hero__link {
        min-height: 540px;
    }
    .hp-hero__content {
        min-height: 540px;
    }
    .hp-hero__title {
        font-size: 3.25rem;
        max-width: 800px;
    }
}

/* ============================================================
   CARD COMPONENT (shared)
   ============================================================ */
.hp-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.3s var(--ease),
                transform 0.3s var(--ease);
}
.hp-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

/* Card image */
.hp-card__image {
    display: block;
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg-alt);
}
.hp-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.hp-card:hover .hp-card__image img {
    transform: scale(1.05);
}

/* Card logos */
.hp-card__logos {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    gap: 6px;
    z-index: 2;
}
.hp-card__logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 4px;
    object-fit: contain;
    transition: transform 0.3s var(--ease);
}
.hp-card:hover .hp-card__logo {
    transform: translateY(-2px);
}

/* Card badge */
.hp-card__badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.hp-card__badge--review { color: #4f46e5; }
.hp-card__badge--comparison { color: #b45309; }
.hp-card__badge--news { color: #15803d; }
.hp-card__badge--tutorial { color: #0369a1; }
.hp-card__badge--listicle { color: #be185d; }

/* Card rank (trending) */
.hp-card__rank {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* Card body */
.hp-card__body {
    padding: var(--space-lg);
}
.hp-card__cat {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin-bottom: 6px;
}
.hp-card__cat:hover {
    color: var(--primary-dark);
}
.hp-card__title {
    font-size: var(--text-base);
    font-weight: 700;
    line-height: var(--leading-snug);
}
.hp-card__title a {
    color: var(--text);
    transition: color 0.15s;
}
.hp-card__title a:hover {
    color: var(--primary);
}
.hp-card__excerpt {
    margin-top: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}
.hp-card__meta {
    display: flex;
    gap: var(--space-md);
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   SECTION 2: TRENDING GRID
   ============================================================ */
.hp-trending {
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
}
.hp-trending__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

@media (min-width: 640px) {
    .hp-trending__grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hp-trending__grid .hp-card:first-child {
        grid-column: span 2;
    }
}

@media (min-width: 960px) {
    .hp-trending__grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .hp-trending__grid .hp-card:first-child {
        grid-column: span 1;
    }
}

.hp-card--trending .hp-card__title {
    font-size: var(--text-lg);
    font-weight: 700;
}

/* ============================================================
   SECTION 3: CATEGORIES — Horizontal Scroll Cards
   ============================================================ */
.hp-categories {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border-light);
}
.hp-categories__scroll {
    position: relative;
    overflow: hidden;
}
.hp-categories__track {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-sm);
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.hp-categories__track::-webkit-scrollbar {
    display: none;
}

.hp-cat-card {
    flex: 0 0 auto;
    width: 150px;
    padding: var(--space-lg) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    scroll-snap-align: start;
    transition: all 0.25s var(--ease);
}
.hp-cat-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}
.hp-cat-card__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg);
    border-radius: 14px;
    color: var(--primary);
    transition: background 0.25s, color 0.25s;
}
.hp-cat-card:hover .hp-cat-card__icon {
    background: var(--primary);
    color: #fff;
}
.hp-cat-card__name {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.hp-cat-card__count {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 4px;
}

@media (min-width: 960px) {
    .hp-categories__track {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        overflow-x: visible;
    }
    .hp-cat-card {
        width: auto;
    }
}

/* ============================================================
   SECTION 4: LATEST — Asymmetric Grid
   ============================================================ */
.hp-latest {
    background: var(--bg);
}
.hp-latest__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

/* Tablet: 2 columns */
@media (min-width: 640px) {
    .hp-latest__grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hp-card--large {
        grid-column: span 2;
    }
    .hp-card--large .hp-card__image {
        aspect-ratio: 21/9;
    }
    .hp-card--large .hp-card__title {
        font-size: var(--text-xl);
    }
}

/* Desktop: 3 columns, large spans 2 */
@media (min-width: 960px) {
    .hp-latest__grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .hp-card--large {
        grid-column: span 2;
        grid-row: span 2;
    }
    .hp-card--large .hp-card__image {
        aspect-ratio: 4/3;
        /* Fill remaining height */
        flex: 1;
    }
    .hp-card--large {
        display: flex;
        flex-direction: column;
    }
    .hp-card--large .hp-card__title {
        font-size: var(--text-2xl);
    }
    .hp-card--large .hp-card__body {
        padding: var(--space-xl);
    }
}

/* ============================================================
   SECTION 5: QUICK ANSWERS — Compact Horizontal Scroll
   ============================================================ */
.hp-quick {
    background: var(--bg-alt);
    border-top: 1px solid var(--border-light);
}
.hp-quick__scroll {
    overflow: hidden;
}
.hp-quick__track {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-sm);
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.hp-quick__track::-webkit-scrollbar {
    display: none;
}

.hp-quick-card {
    flex: 0 0 auto;
    width: 280px;
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: all 0.25s var(--ease);
    text-decoration: none;
}
.hp-quick-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.hp-quick-card__icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg);
    border-radius: 10px;
    color: var(--primary);
    flex-shrink: 0;
}
.hp-quick-card__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    line-height: var(--leading-snug);
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hp-quick-card:hover .hp-quick-card__title {
    color: var(--primary);
}
.hp-quick-card__meta {
    display: flex;
    gap: var(--space-md);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: auto;
}
.hp-quick-card__type {
    font-weight: 600;
    color: var(--primary);
}

@media (min-width: 960px) {
    .hp-quick__track {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        overflow-x: visible;
    }
    .hp-quick-card {
        width: auto;
    }
}

@media (min-width: 1200px) {
    .hp-quick__track {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ============================================================
   SKELETON LOADING STATES
   ============================================================ */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.hp-skeleton {
    background: linear-gradient(
        90deg,
        var(--border-light) 0%,
        var(--bg-alt) 50%,
        var(--border-light) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.8s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* ============================================================
   MOBILE ADJUSTMENTS
   ============================================================ */
@media (max-width: 480px) {
    .hp-hero__content {
        padding: var(--space-xl) var(--space-md) var(--space-lg);
    }
    .hp-hero__title {
        font-size: var(--text-2xl);
    }
    .hp-hero__excerpt {
        display: none;
    }
    .hp-section {
        padding: var(--space-xl) 0;
    }
    .hp-section__title {
        font-size: var(--text-lg);
    }
    .hp-card__body {
        padding: var(--space-md);
    }
    .hp-quick-card {
        width: 240px;
        padding: var(--space-md);
    }
    .hp-cat-card {
        width: 130px;
        padding: var(--space-md) var(--space-sm);
    }
}

/* ============================================================
   SCROLL SENTINEL (infinite scroll)
   ============================================================ */
#scroll-sentinel {
    height: 1px;
    margin-top: var(--space-xl);
}
