/* Homepage: hero, services, section heads. Later tasks add the bento grid, chips and live strip. */

.section {
    padding: 56px 0;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 20px;
}

.section-head .eyebrow {
    margin-bottom: 6px;
}

.section-title {
    font-size: clamp(1.6rem, 4vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* Hero */
.hero {
    position: relative;
    isolation: isolate;
    padding: 88px 0 96px;
}

/* The glows sit on a layer that runs past the hero and fades out, so there is no hard edge. */
.hero::before {
    content: "";
    position: absolute;
    top: calc(-1 * var(--nav-height));
    right: 0;
    bottom: -140px;
    left: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 85% 15%, rgba(124, 92, 255, 0.42), transparent 42%),
        radial-gradient(circle at 8% 80%, rgba(0, 200, 255, 0.22), transparent 40%);
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
    mask-image: linear-gradient(to bottom, #000 55%, transparent);
}

.hero-badge {
    display: inline-block;
    margin-bottom: 22px;
    padding: 5px 14px;
    border: 1px solid var(--purple-border);
    border-radius: 999px;
    background: rgba(124, 92, 255, 0.12);
    color: var(--purple-ink);
    font-size: 13px;
    font-weight: 600;
}

.hero-title {
    margin-bottom: 20px;
    font-size: clamp(2.4rem, 7vw, 4rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.035em;
}

.hero-line {
    display: block;
}

.hero-title .gradient-text {
    /* Keeps descenders inside the clipped gradient. */
    padding-bottom: 0.06em;
}

.hero-lead {
    max-width: 500px;
    margin-bottom: 32px;
    color: var(--text-soft);
    font-size: 17px;
    line-height: 1.55;
}

/* Services */
#services .eyebrow {
    margin-bottom: 18px;
}

.services {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.service-card {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    transition: transform var(--ease), border-color var(--ease);
}

.service-card:hover {
    transform: translateY(-2px);
}

.service-card--embedded {
    background: linear-gradient(160deg, #0f2230, #101018);
    border-color: #1d3646;
}

.service-card--embedded:hover {
    border-color: rgba(0, 200, 255, 0.45);
}

.service-card--ai {
    background: linear-gradient(160deg, #1e1640, #101018);
    border-color: #2f2660;
}

.service-card--ai:hover {
    border-color: rgba(124, 92, 255, 0.6);
}

.service-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-bottom: 16px;
    border-radius: 11px;
    font-size: 20px;
    line-height: 1;
}

.service-card--embedded .service-icon {
    background: rgba(0, 200, 255, 0.15);
    color: var(--cyan);
}

.service-card--ai .service-icon {
    background: rgba(124, 92, 255, 0.18);
    color: #9f8cff;
}

.service-card h3 {
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.service-card p {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
}

/* Work: filter chips and the bento grid */
#work {
    padding-top: 24px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}

.chip:hover {
    border-color: #3a3a58;
    color: var(--text);
}

.chip[aria-pressed="true"] {
    border-color: var(--text);
    background: var(--text);
    color: var(--bg);
}

.chip:focus-visible {
    border-radius: 999px;
}

/* One column on phones; the two- and three-column layouts are set in the media queries below. */
#project-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: dense;
    gap: 14px;
}

.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-tile);
    background: #13131d;
    container: tile / inline-size;
    transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

.tile--embedded:hover {
    border-color: rgba(0, 200, 255, 0.45);
}

.tile--ai:hover {
    border-color: rgba(124, 92, 255, 0.6);
}

.tile:focus-visible {
    border-radius: var(--radius-tile);
}

.tile-img,
.tile-icon {
    flex: none;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.tile-img {
    height: auto;
    object-fit: cover;
    background: #0f1a22;
}

.tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile--embedded .tile-icon {
    background: linear-gradient(135deg, #0f2a36, #13131d);
    color: var(--cyan);
}

.tile--ai .tile-icon {
    background: linear-gradient(135deg, #221a4a, #13131d);
    color: #9f8cff;
}

.tile-body {
    padding: 14px 16px 18px;
}

.tile-tag {
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.tile--embedded .tile-tag {
    color: var(--cyan);
}

.tile--ai .tile-tag {
    color: #9f8cff;
}

.tile-title {
    margin-bottom: 4px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.tile-summary {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

/* A wide tile puts its picture on the left, as in the mockup. */
@container tile (min-width: 480px) {
    .tile-img,
    .tile-icon {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 40%;
        height: 100%;
        aspect-ratio: auto;
    }

    .tile-img + .tile-body,
    .tile-icon + .tile-body {
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 170px;
        margin-left: 40%;
        padding: 20px 24px;
    }
}

/* Featured tile: no picture, a glow and big stat numbers. */
.tile--featured {
    isolation: isolate;
    justify-content: space-between;
    gap: 28px;
    padding: 28px;
    border-color: var(--purple-border);
    background: linear-gradient(145deg, #2a1d63, #14142a 70%);
}

.tile--featured::before {
    content: "";
    position: absolute;
    top: -60px;
    right: -60px;
    z-index: -1;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 200, 255, 0.35), transparent 70%);
    pointer-events: none;
}

.tile--featured .tile-body {
    padding: 0;
}

.tile--featured .tile-tag {
    margin-bottom: 10px;
}

.tile--featured .tile-title {
    margin-bottom: 10px;
    font-size: clamp(1.75rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.tile--featured .tile-summary {
    max-width: 36ch;
    color: var(--text-soft);
    font-size: 15px;
    line-height: 1.55;
}

.tile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 36px;
}

.stat-value {
    display: block;
    color: var(--cyan);
    font-size: clamp(1.75rem, 3.2vw, 2.25rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
}

.grid-error {
    grid-column: 1 / -1;
    padding: 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-card);
    color: var(--muted);
}

.grid-error a {
    color: var(--cyan);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/*
 * Hole-free spans. The featured tile, when present, is always first (display order in
 * data/projects.json). A tile left alone in the last row stretches to fill it.
 */
@media (min-width: 601px) and (max-width: 960px) {
    #project-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #project-grid > .tile--featured,
    #project-grid:has(> .tile--featured) > .tile:nth-child(2n):last-child,
    #project-grid:not(:has(> .tile--featured)) > .tile:nth-child(2n+1):last-child {
        grid-column: 1 / -1;
    }
}

@media (min-width: 961px) {
    #project-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    #project-grid:has(> .tile--featured) {
        grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(0, 1fr));
    }

    /* Two rows tall once at least three tiles sit beside it. */
    #project-grid > .tile--featured:nth-last-child(n+4) {
        grid-row: span 2;
        padding: 36px;
    }

    /* The tall tile: larger type up top, stats anchored at the bottom behind a divider. */
    #project-grid > .tile--featured:nth-last-child(n+4)::before {
        top: -80px;
        right: -80px;
        width: 340px;
        height: 340px;
    }

    #project-grid > .tile--featured:nth-last-child(n+4) .tile-title {
        margin-bottom: 14px;
        font-size: 2.5rem;
    }

    #project-grid > .tile--featured:nth-last-child(n+4) .tile-summary {
        font-size: 17px;
        line-height: 1.6;
    }

    #project-grid > .tile--featured:nth-last-child(n+4) .tile-stats {
        padding-top: 28px;
        border-top: 1px solid var(--purple-border);
    }

    #project-grid > .tile--featured:nth-last-child(n+4) .stat-value {
        font-size: 2.75rem;
    }

    #project-grid > .tile--featured:nth-last-child(n+4) .stat-label {
        font-size: 13px;
    }

    /* Featured plus one tile: featured takes two columns. */
    #project-grid > .tile--featured:nth-last-child(2) {
        grid-column: span 2;
    }

    #project-grid > .tile--featured:only-child {
        grid-column: 1 / -1;
    }

    /* Without a featured tile: rows of three. */
    #project-grid:not(:has(> .tile--featured)) > .tile:nth-child(3n+1):last-child {
        grid-column: 1 / -1;
    }

    #project-grid:not(:has(> .tile--featured)) > .tile:nth-child(3n+2):last-child {
        grid-column: span 2;
    }

    /* With a two-row featured tile: tiles 2-5 fill the two rows beside it, then rows of three. */
    #project-grid:has(> .tile--featured) > .tile:nth-child(4):last-child,
    #project-grid:has(> .tile--featured) > .tile:nth-child(3n+7):last-child {
        grid-column: span 2;
    }

    #project-grid:has(> .tile--featured) > .tile:nth-child(3n+6):last-child {
        grid-column: 1 / -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tile:hover {
        transform: none;
    }
}

@media (max-width: 720px) {
    .section {
        padding: 40px 0;
    }

    .hero {
        padding: 56px 0 64px;
    }

    .hero::before {
        bottom: -80px;
        background:
            radial-gradient(circle at 90% 8%, rgba(124, 92, 255, 0.42), transparent 55%),
            radial-gradient(circle at 5% 85%, rgba(0, 200, 255, 0.22), transparent 50%);
    }

    .hero-lead {
        font-size: 16px;
    }

    .services {
        grid-template-columns: 1fr;
    }

    .service-card {
        padding: 22px;
    }
}

/* Live strip */
.live-section {
    padding: 0 0 56px;
}

.live-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    border: 1px solid #2f2660;
    border-radius: var(--radius-tile);
    background: linear-gradient(90deg, rgba(124, 92, 255, 0.14), rgba(0, 200, 255, 0.08));
}

.live-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.live-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 2px;
}

.live-badge.is-live {
    color: var(--green);
}

.live-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    /* A long unbroken title wraps instead of widening the page. */
    overflow-wrap: anywhere;
}

.live-title:hover {
    text-decoration: underline;
}

.live-date {
    font-size: 12px;
    color: var(--faint);
}

@media (max-width: 600px) {
    .live-card {
        flex-direction: column;
        align-items: flex-start;
    }
}
