/* ============================================================
   FRONT PAGE — Benqu-styled magazine layout. Only enqueued on
   is_front_page().

   Three blocks, matching front-page.php:
     .featured  — .hero + .hero-sub cards | .featured__side rail
     .latest    — .section-title + .story-grid
     .categories — .section-title + .category-grid

   Surfaces are neutral throughout; color enters only through the
   per-category --card-color / badge hex set inline per instance
   from insidebulgaria_get_category_color().
   ============================================================ */

/* ------------------------------------------------------------
   Shared primitives
   ------------------------------------------------------------
   .cat-badge and .entry-meta now live in base.css — the single
   templates use them too.
   ------------------------------------------------------------ */

/* .section-title is in base.css — search.php and 404.php use it too. */

/* ------------------------------------------------------------
   Block 1 — featured: hero + secondary cards | side rail
   ------------------------------------------------------------ */
.featured__inner {
    max-width: 1480px;
    margin: 0 auto;
    padding: clamp(24px, 4vw, 48px) clamp(20px, 4vw, 56px);
    display: grid;
    gap: 24px;
}

@media (min-width: 1024px) {
    .featured__inner {
        grid-template-columns: minmax(0, 1fr) 340px;
        align-items: start;
    }
}

.featured__main {
    display: grid;
    gap: 24px;
    align-content: start;
}

/* Hero — image fills the tile, text sits on top of a scrim. */
.hero {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--c-surface-tint);
    aspect-ratio: 16 / 10;
}

.hero__media {
    position: absolute;
    inset: 0;
    display: block;
}

.hero__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Scaled up so assets/js/hero-parallax.js has room to translate
       the image on scroll without exposing empty edges. Reset to
       none under reduced motion below — the script no-ops there too,
       so the two stay in sync. */
    transform: scale(1.15);
    will-change: transform;
}

.hero__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--grad-media-scrim);
}

.hero__body {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: clamp(20px, 3vw, 36px);
}

.hero__title {
    margin: 0;
    max-width: 24ch;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3.4vw, 2.6rem);
    font-weight: 700;
    line-height: 1.15;
    color: #fff;
}

.hero__title a {
    color: inherit;
    text-decoration: none;
}

.hero__title a:hover {
    opacity: 0.85;
}

/* The scrim already guarantees contrast, so the meta strip only needs
   to be lightened off its default ink-faint. */
.hero__body .entry-meta {
    color: rgba(255, 255, 255, 0.85);
}

/* Two secondary cards under the hero. */
.hero-sub {
    display: grid;
    gap: 24px;
}

@media (min-width: 560px) {
    .hero-sub {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ------------------------------------------------------------
   Post card — used by .hero-sub and .story-grid
   ------------------------------------------------------------ */
.post-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px -22px var(--c-shadow);
}

/* JS-driven scroll reveal — see assets/js/scroll-reveal.js. The default
   state (no .is-hidden) is fully visible, so content never depends on JS
   running; the class is only ever added BY the script. */
.post-card.is-hidden {
    opacity: 0;
    transform: translateY(24px);
}

.post-card__media {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--c-surface-tint);
}

.post-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.post-card:hover .post-card__media img,
.post-card:focus-within .post-card__media img {
    transform: scale(1.05);
}

/* Badge floats over the image. It lives outside .post-card__media in
   the markup so the chip stays a real, focusable link rather than
   sitting inside the aria-hidden image link. */
.post-card__badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 1;
}

/*
 * A flex column that fills whatever height the card has, so the meta
 * line can be pushed to the floor of it.
 *
 * It was `display: grid` with `align-content: start`, which stacked the
 * title, excerpt and meta tightly from the top — and cards in a row are
 * stretched to the tallest, so a two-line title left the date sitting
 * higher than the date beside it. The eye reads that row of dates as a
 * line; one card out of step breaks it.
 */
.post-card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px 18px;
}

/* The floor. Every card in a row lands its meta on the same line, no
   matter how many lines the title and the excerpt took. */
.post-card__body .entry-meta {
    margin-top: auto;
}

.post-card__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
    /* Clamped so cards in the same row keep matching body heights. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card__title a {
    color: var(--c-ink);
    text-decoration: none;
}

.post-card__title a:hover {
    color: var(--c-accent);
}

.post-card__excerpt {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--c-ink-soft);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ------------------------------------------------------------
   Side rail — thumbnail left, badge/title/date right
   ------------------------------------------------------------ */
.featured__side {
    display: grid;
    align-content: start;
    gap: 20px;
    padding: 20px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
}

.post-mini {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.post-mini + .post-mini {
    padding-top: 20px;
    border-top: 1px solid var(--c-border);
}

.post-mini__media {
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--c-surface-tint);
}

.post-mini__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.post-mini:hover .post-mini__media img {
    transform: scale(1.06);
}

.post-mini__body {
    display: grid;
    justify-items: start;
    gap: 8px;
}

.post-mini__body .cat-badge {
    padding: 3px 12px;
    font-size: 0.68rem;
}

.post-mini__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    /* Three lines, not two: the rail column is narrow enough that a
       2-line clamp truncates most Bulgarian headlines mid-word. */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-mini__title a {
    color: var(--c-ink);
    text-decoration: none;
}

.post-mini__title a:hover {
    color: var(--c-accent);
}

/* ------------------------------------------------------------
   Block 2 — latest stories row
   ------------------------------------------------------------ */
.latest,
.categories {
    padding-bottom: clamp(32px, 5vw, 64px);
}

.story-grid,
.category-grid {
    max-width: 1480px;
    margin: 0 auto;
    padding: clamp(20px, 3vw, 32px) clamp(20px, 4vw, 56px) 0;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 480px) {
    .story-grid,
    .category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .story-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/*
 * Three across at every desktop width. It used to go to five at 1200px,
 * which made each card about 270px wide and the images too small to be
 * worth having; three in a 1480px container is roughly 460px a card,
 * and front-page.php carries nine posts instead of five so the section
 * still fills whole rows.
 *
 * The title had been shrunk to 1.05rem to fit that five-across row. At
 * 460px it goes back to the .post-card default and a little past it on
 * the widest screens; the two-line clamp is left alone, so the cards
 * still vary by at most one line of title.
 */
.story-grid .post-card__title {
    font-size: clamp(1.2rem, 1.05rem + 0.35vw, 1.4rem);
}

@media (min-width: 1200px) {
    .story-grid {
        gap: 32px;
    }
}

/* ------------------------------------------------------------
   Block 3 — category tiles
   ------------------------------------------------------------ */
.category-grid {
    gap: 16px;
}

@media (min-width: 768px) {
    .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .category-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* The tile itself is in base.css — archive.php's sidebar reuses it. */

/* ------------------------------------------------------------
   Motion preferences
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .post-card,
    .post-card__media img,
    .post-mini__media img {
        transition: none;
    }

    /* hero-parallax.js also no-ops under reduced motion — this keeps
       the static image from being stuck at its zoomed-in scale. */
    .hero__media img {
        transform: none;
    }
}
