/**
 * Homepage
 *
 * Dark base that steps out to one light section for the product families,
 * following the client's Vention reference. Tokens live in brand.css.
 *
 * Section rhythm: hero (ground + measuring grid), tools (panel), families
 * (light), clients (ground), latest posts (panel), footer (deep).
 */

body.home {
    background: var(--h2w-ground);
    color: var(--h2w-text);
}

/* The template controls all spacing; drop the block gap between root blocks */
body.home .wp-site-blocks > * {
    margin-block-start: 0;
}

.h2w-home {
    margin: 0;
    font-family: var(--h2w-font-body);
}

.h2w-home > * {
    margin-block: 0;
}

.h2w-home h1,
.h2w-home h2,
.h2w-home h3 {
    color: inherit;
    font-family: var(--h2w-font-display);
}

.h2w-home p {
    margin: 0;
}

/* Zero-specificity defaults so block styles (family grid, cards) win */
:where(.h2w-home) a {
    color: var(--h2w-blue-lit);
}

/* Shared section scaffolding */

.h2w-home-section {
    padding-block: clamp(3.5rem, 7vw, 6rem);
}

.h2w-home-section__head {
    max-width: 62ch;
    margin-bottom: clamp(2rem, 4vw, 3rem);
}

.h2w-home-section__head--split {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem 2rem;
    max-width: none;
}

.h2w-home-section__title {
    margin: 0;
    font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.h2w-home-section__intro {
    margin-top: 0.875rem !important;
    color: var(--h2w-text-muted);
    font-size: 1.0625rem;
    line-height: 1.6;
}

.h2w-home-section__link a {
    font-family: var(--h2w-font-display);
    font-weight: 600;
    text-decoration: none;
}

.h2w-home-section__link a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Hero */

.h2w-home-hero {
    position: relative;
    padding-block: clamp(3.5rem, 8vw, 7rem);
    background-color: var(--h2w-ground);
    /* Measuring grid: 8px minor, 40px major, like a stage datum plate */
    background-image:
        linear-gradient(to right, rgba(138, 168, 240, 0.09) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(138, 168, 240, 0.09) 1px, transparent 1px),
        linear-gradient(to right, rgba(138, 168, 240, 0.035) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(138, 168, 240, 0.035) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
    background-position: -1px -1px;
    overflow: hidden;
}

/* Fade the grid out toward the copy so text sits on a quiet ground */
.h2w-home-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, var(--h2w-ground) 18%, rgba(18, 24, 38, 0.72) 52%, rgba(18, 24, 38, 0) 80%);
    pointer-events: none;
}

.h2w-home-hero__inner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    align-items: center;
    gap: clamp(2.5rem, 5vw, 5rem);
}

.h2w-home-hero__title {
    max-width: 32ch;
    margin: 0;
    font-size: clamp(1.625rem, 0.9rem + 2vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.16;
}

.h2w-home-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: clamp(1.75rem, 3vw, 2.5rem);
}

.h2w-home-hero__actions .wp-block-button {
    margin: 0;
}

/* Product stage: the photo sits on a white plate with datum corner marks */
.h2w-home-hero__stage {
    position: relative;
    padding: 12px;
    background: var(--h2w-panel);
    border: 1px solid var(--h2w-line-dark);
    border-radius: 6px;
}

.h2w-home-hero__image {
    position: relative;
    margin: 0;
}

.h2w-home-hero__image img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 3px;
}

.h2w-home-hero__image::before,
.h2w-home-hero__image::after {
    content: "";
    position: absolute;
    z-index: 1;
    width: 22px;
    height: 22px;
    border: 2px solid var(--h2w-gold-lit);
    pointer-events: none;
}

.h2w-home-hero__image::before {
    top: -6px;
    left: -6px;
    border-right: 0;
    border-bottom: 0;
}

.h2w-home-hero__image::after {
    top: -6px;
    right: -6px;
    border-bottom: 0;
    border-left: 0;
}

.h2w-home-hero__image figcaption {
    margin: 0;
    padding: 0.75rem 0.25rem 0;
    color: var(--h2w-text-muted);
    font-size: 0.8125rem;
    text-align: left;
}

.h2w-home-hero__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0.75rem 0 0;
    border-top: 1px solid var(--h2w-line-dark);
}

.h2w-home-hero__stats .h2w-catalog-stats__item {
    display: flex;
    flex-direction: column-reverse;
    /* Values line up at the top even when a label wraps */
    justify-content: flex-end;
    gap: 0.125rem;
    padding: 0.875rem 0.25rem 0.25rem;
}

.h2w-home-hero__stats .h2w-catalog-stats__item + .h2w-catalog-stats__item {
    padding-left: 1rem;
    border-left: 1px solid var(--h2w-line-dark);
}

.h2w-home-hero__stats dt {
    color: var(--h2w-text-muted);
    font-size: 0.8125rem;
    line-height: 1.3;
}

.h2w-home-hero__stats dd {
    margin: 0;
    color: #fff;
    font-family: var(--h2w-font-mono);
    font-size: clamp(1.375rem, 1rem + 1vw, 1.75rem);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    line-height: 1.1;
}

/* Engineering tools */

.h2w-home-tools {
    background: var(--h2w-panel);
    border-block: 1px solid var(--h2w-line-dark);
}

.h2w-tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: h2w-step;
}

.h2w-tool {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 1.75rem 1.5rem 1.5rem;
    background: var(--h2w-ground);
    border: 1px solid var(--h2w-line-dark);
    border-radius: 6px;
    counter-increment: h2w-step;
}

/* The tools are a sequence (find, size, quote), so number them */
.h2w-tool::before {
    content: counter(h2w-step);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.25rem;
    border: 1px solid var(--h2w-blue-edge);
    border-radius: 50%;
    color: var(--h2w-blue-lit);
    font-family: var(--h2w-font-mono);
    font-size: 0.875rem;
}

.h2w-tool__title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.2;
}

.h2w-tool p {
    color: var(--h2w-text-muted);
    font-size: 1rem;
    line-height: 1.6;
}

.h2w-tool .h2w-tool__link {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.h2w-tool__link a {
    font-family: var(--h2w-font-display);
    font-weight: 600;
    text-decoration: none;
}

.h2w-tool__link a:hover {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Light section: product families */

.h2w-light {
    background: var(--h2w-paper);
    color: var(--h2w-ink);
}

.h2w-light .h2w-home-section__intro {
    color: var(--h2w-ink-muted);
}

:where(.h2w-light) a {
    color: var(--h2w-blue);
}

.h2w-home-families .h2w-family-grid {
    --h2w-family-accent: var(--h2w-blue);
}

.h2w-home-families .h2w-family-card__title {
    font-family: var(--h2w-font-display);
    font-weight: 600;
}

/* Featured clients */

.h2w-home-clients {
    background: var(--h2w-ground);
}

.h2w-home-clients__title {
    margin-bottom: clamp(1.75rem, 3vw, 2.5rem) !important;
    font-size: clamp(1.375rem, 1rem + 1vw, 1.75rem);
}

.h2w-clients {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border-top: 1px solid var(--h2w-line-dark);
    border-left: 1px solid var(--h2w-line-dark);
}

.h2w-clients > * {
    margin: 0;
}

.h2w-client {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 112px;
    padding: 1.25rem;
    border-right: 1px solid var(--h2w-line-dark);
    border-bottom: 1px solid var(--h2w-line-dark);
    color: var(--h2w-text-muted);
    font-size: 0.875rem;
}

.h2w-client img {
    max-width: 140px;
    max-height: 48px;
    width: auto;
    height: auto;
    opacity: 0.8;
}

.h2w-client.is-placeholder {
    background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(184, 194, 211, 0.05) 10px 11px);
}

/* Latest posts */

.h2w-home-posts {
    background: var(--h2w-panel);
    border-top: 1px solid var(--h2w-line-dark);
}

.h2w-posts {
    margin: 0;
}

.h2w-posts__list,
.h2w-posts .wp-block-post-template {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.h2w-posts .wp-block-post {
    margin: 0;
}

.h2w-post-card {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    height: 100%;
    margin: 0;
    padding: 0 0 1.25rem;
    background: var(--h2w-ground);
    border: 1px solid var(--h2w-line-dark);
    border-radius: 6px;
    overflow: hidden;
}

.h2w-post-card > * {
    margin: 0 !important;
    padding-inline: 1.25rem;
}

/* Posts without a featured image start with the date; keep the card inset */
.h2w-post-card > :first-child:not(.h2w-post-card__media) {
    margin-top: 1.25rem !important;
}

.h2w-post-card .h2w-post-card__media {
    aspect-ratio: 16 / 9;
    margin-bottom: 0.5rem !important;
    padding: 0;
    background: var(--h2w-raised);
}

.h2w-post-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.h2w-post-card.is-placeholder .h2w-post-card__media {
    background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(184, 194, 211, 0.06) 10px 11px);
}

.h2w-post-card__date {
    color: var(--h2w-text-muted);
    font-family: var(--h2w-font-mono);
    font-size: 0.8125rem;
}

.h2w-post-card .h2w-post-card__title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.25;
}

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

.h2w-post-card__title a:hover {
    color: var(--h2w-blue-lit);
}

.h2w-post-card p,
.h2w-post-card__excerpt {
    color: var(--h2w-text-muted);
    font-size: 1rem;
    line-height: 1.6;
}

.h2w-post-card__excerpt .wp-block-post-excerpt__more-text {
    margin-top: 0.5rem;
}

/* Tablet */

@media (max-width: 1023px) {
    .h2w-home-hero::before {
        background: linear-gradient(180deg, var(--h2w-ground) 30%, rgba(18, 24, 38, 0.6) 100%);
    }

    .h2w-home-hero__inner {
        grid-template-columns: minmax(0, 1fr);
    }

    .h2w-home-hero__title {
        max-width: 34ch;
    }

    .h2w-home-hero__stage {
        max-width: 560px;
    }

    .h2w-tools,
    .h2w-posts__list,
    .h2w-posts .wp-block-post-template {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .h2w-tool:last-child:nth-child(odd),
    .h2w-posts .wp-block-post:last-child:nth-child(odd),
    .h2w-posts__list > .h2w-post-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .h2w-clients {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Mobile */

@media (max-width: 600px) {
    .h2w-home-hero__actions .wp-block-button,
    .h2w-home-hero__actions .wp-block-button__link {
        width: 100%;
    }

    .h2w-home-hero__stats .h2w-catalog-stats__item + .h2w-catalog-stats__item {
        padding-left: 0.75rem;
    }

    .h2w-tools,
    .h2w-posts__list,
    .h2w-posts .wp-block-post-template {
        grid-template-columns: minmax(0, 1fr);
    }

    .h2w-clients {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .h2w-client {
        min-height: 88px;
    }
}
