/* Home page (page-home.hbs). Loaded only on that template. */

/* Intro: standfirst + photo, then one column per H3 */
.home-intro {
    /* the header is absolutely positioned (~88px), so clear it */
    padding-top: calc(88px + max(4vmin, 24px));
}

.home-intro-top {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 6vmin;
    align-items: center;
}

.home-intro-title {
    margin: 0 0 2.4rem;
    font-size: clamp(4rem, 6vw, 6.4rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--color-darkgrey);
}

.home-intro-body > p {
    font-family: var(--font-sans);
    font-size: clamp(1.9rem, 2.2vw, 2.4rem);
    line-height: 1.5;
    color: var(--color-darkgrey);
}

.home-intro-body > * + * {
    margin-top: 1.6rem;
}

.home-intro-photo {
    margin: 0;
}

.home-intro-photo img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
}

.home-intro-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: max(4vmin, 28px);
    margin-top: max(5vmin, 32px);
    padding-top: max(4vmin, 24px);
    border-top: 1px solid var(--color-border);
}

.home-intro-col > h2,
.home-intro-col > h3 {
    margin: 0 0 8px;
    font-family: var(--font-sans);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--color-secondary-text);
}

.home-intro-col > :not(h2, h3) {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1.6;
    color: var(--color-darkgrey);
}

.home-intro-col > :not(h2, h3) + * {
    margin-top: 1rem;
}

/* Lists: text flush with the label, bullets hanging in the margin */
.home-intro-col ul,
.home-intro-col ol {
    padding-left: 0;
    list-style: none;
}

.home-intro-col li {
    position: relative;
    margin: 0;
    padding: 0;
}

.home-intro-col li + li {
    margin-top: 0.4rem;
}

.home-intro-col ul > li::before {
    content: "•";
    position: absolute;
    left: -0.9em;
    color: var(--color-secondary-text);
}

.home-intro-col ol {
    counter-reset: intro;
}

.home-intro-col ol > li::before {
    counter-increment: intro;
    content: counter(intro) ".";
    position: absolute;
    right: calc(100% + 0.4em);
    color: var(--color-secondary-text);
}

.home-intro-col a {
    color: var(--ghost-accent-color);
    text-decoration: underline;
}

@media (max-width: 767px) {
    .home-intro {
        padding-top: 72px; /* mobile header is ~64px */
    }
    /* not enough gutter to hang bullets on phones */
    .home-intro-col ul,
    .home-intro-col ol {
        padding-left: 1em;
    }
    .home-intro-top {
        grid-template-columns: 1fr;
    }
    .home-intro-photo {
        order: -1;
        max-width: 160px;
    }
    .home-intro-photo img {
        border-radius: 50%;
    }
}

html.dark-mode .home-intro-title,
html.dark-mode .home-intro-body > p,
html.dark-mode .home-intro-col > :not(h2, h3) {
    color: rgba(255, 255, 255, 0.9);
}

html.dark-mode .home-intro-cols {
    border-color: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
    html.auto-color .home-intro-title,
    html.auto-color .home-intro-body > p,
    html.auto-color .home-intro-col > :not(h2, h3) {
        color: rgba(255, 255, 255, 0.9);
    }
    html.auto-color .home-intro-cols {
        border-color: rgba(255, 255, 255, 0.1);
    }
}

.home-section {
    padding-top: max(6vmin, 40px);
}

.home-section:last-child {
    padding-bottom: max(8vmin, 64px);
}

.home-section-title {
    margin: 0 0 2.4rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

/* Latest posts: reuse Casper's post-feed, always 3 across on desktop */
.home-feed {
    padding-top: 0;
}

/* Undo Casper's "Classic" home layout (first post large, next two wide)
   so all three cards match the /blog/ archive */
.home-feed .post-card,
.home-feed .post-card.post-card-large,
.home-feed .post-card.dynamic {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.home-feed .post-card-large .post-card-image-link {
    margin-bottom: 32px;
}

.home-feed .post-card-large .post-card-content {
    order: 0;
}

.home-feed .post-card-large .post-card-tags {
    margin-bottom: 0;
}

.home-feed .post-card-large .post-card-title,
.home-feed .post-card.dynamic .post-card-title {
    margin-top: 0;
    font-size: 2.6rem;
    line-height: 1.2;
}

.home-feed .post-card .post-card-excerpt {
    display: -webkit-box;
    overflow-y: hidden;
    margin-top: 8px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@media (max-width: 991px) {
    .home-feed {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .home-feed {
        grid-template-columns: 1fr;
    }
    .home-feed .post-card {
        grid-column: auto;
    }
}

.home-more {
    display: inline-block;
    margin-top: 3.2rem;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--ghost-accent-color);
}

.home-more:hover {
    text-decoration: underline;
}

/* Static cards: 3 to a row, single column on mobile */
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4.8vmin 4vmin;
}

@media (max-width: 767px) {
    .home-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

/* Each card spans 5 shared rows (image, label, title, excerpt, cta) via subgrid,
   so titles, excerpts and CTAs line up across a row even when one title wraps */
.home-card {
    display: grid;
    grid-row: span 5;
    grid-template-rows: subgrid;
    row-gap: 0;
}

.home-card-content {
    grid-row: span 4;
    display: grid;
    grid-template-rows: subgrid;
    row-gap: 0;
}

.home-card-cta {
    align-self: end;
}

/* Fallback for browsers without subgrid: CTA pinned to the bottom */
@supports not (grid-template-rows: subgrid) {
    .home-card,
    .home-card-content {
        display: flex;
        flex-direction: column;
    }
    .home-card-content {
        flex: 1;
    }
    .home-card-cta {
        margin-top: auto;
        padding-top: 12px;
    }
}

.home-card-image-link {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 100 / 55; /* same shape as Casper's post-card images */
    border-radius: 3px;
    background: var(--color-lightgrey);
}

.home-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Covers/artwork: a soft, blurred, enlarged copy of the image fills the box */
.home-card-bg {
    position: absolute;
    inset: -20%;
    background-size: cover;
    background-position: center;
    filter: blur(24px) saturate(1.5);
    opacity: 0.85;
}

.home-card-image-link.is-contain .home-card-image {
    position: relative;
    object-fit: contain;
    padding: 4%;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
}

.home-card:hover .home-card-image {
    transform: scale(1.03);
}

.home-card-content {
    padding-top: 32px;
    color: var(--color-darkgrey);
}

.home-card-label {
    display: block;
    margin-bottom: 4px;
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    color: var(--color-secondary-text);
}

.home-card-title {
    margin: 0;
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.home-card:hover .home-card-title {
    opacity: 0.9;
}

.home-card-excerpt {
    margin: 8px 0 0;
    font-size: 1.6rem;
    line-height: 1.5;
    color: var(--color-secondary-text);
}

.home-card-cta {
    display: inline-block;
    margin-top: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ghost-accent-color);
}

/* Elsewhere */
.home-social {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2.4rem;
}

@media (max-width: 767px) {
    .home-social {
        grid-template-columns: 1fr;
    }
}

.home-social-link {
    display: flex;
    gap: 1.6rem;
    align-items: center;
    padding: 2.4rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-darkgrey);
    transition: border-color 0.2s ease;
}

.home-social-link:hover {
    border-color: var(--ghost-accent-color);
}

/* Avatar with the platform logo as a small badge */
.home-social-avatar {
    position: relative;
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
}

.home-social-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.home-social-avatar svg {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 28px;
    height: 28px;
    padding: 5px;
    border-radius: 50%;
    background: var(--color-white, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    color: var(--ghost-accent-color);
}

.home-social-link strong {
    display: block;
    font-size: 1.9rem;
}

.home-social-link small {
    display: block;
    margin-top: 2px;
    font-size: 1.5rem;
    line-height: 1.4;
    color: var(--color-secondary-text);
}

/* Dark mode */
html.dark-mode .home-card-content,
html.dark-mode .home-social-link {
    color: rgba(255, 255, 255, 0.85);
}

html.dark-mode .home-card-image-link,
html.dark-mode .home-social-link {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
    html.auto-color .home-card-content,
    html.auto-color .home-social-link {
        color: rgba(255, 255, 255, 0.85);
    }
    html.auto-color .home-card-image-link,
    html.auto-color .home-social-link {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }
}
