/*
 * case-studies-v2.css
 * Styles for the redesigned image-forward case study section.
 *
 * To activate, add to default.hbs (or wherever global CSS is linked):
 *   <link rel="stylesheet" href="{{asset "css/case-studies-v2.css"}}">
 *
 * Then in index.hbs replace the three {{#get}} sections with a single
 * .cs2-work section using {{> case-study-card-v2}} (see usage comment
 * at the bottom of this file for the full index.hbs swap).
 *
 * Table of contents
 * 1. Custom properties
 * 2. Section shell & heading
 * 3. Filter pills
 * 4. Grid layout
 * 5. Card base
 * 6. Card media (image + fallback)
 * 7. Overlays
 * 8. Tag pill
 * 9. Caption (title + excerpt)
 * 10. Category colour tokens (data-category bindings)
 * 11. Hover & focus states
 * 12. Hidden state (filter toggling)
 * 13. Responsive breakpoints
 * 14. prefers-reduced-motion
 */


/* ─────────────────────────────────────────────────────────────────────────────
   1. Custom properties
───────────────────────────────────────────────────────────────────────────── */
:root {
    --cs2-bg:              #090909;
    --cs2-card-radius:     16px;
    --cs2-gap:             20px;
    --cs2-transition:      0.4s ease;

    /* Category colours */
    --cs2-color-positioning-gtm:    #4ade80;
    --cs2-color-demand-gen:         #60a5fa;
    --cs2-color-sales-enablement:   #f472b6;
    --cs2-color-fallback:           #2a2a2a;

    /* Typography */
    --cs2-font-heading:    'Playfair Display', Georgia, serif;
    --cs2-font-body:       'Inter', system-ui, sans-serif;
}


/* ─────────────────────────────────────────────────────────────────────────────
   2. Section shell & heading
───────────────────────────────────────────────────────────────────────────── */
.cs2-work {
    background-color: var(--cs2-bg);
    padding: 96px 24px 120px;
    max-width: 1200px;
    margin-inline: auto;
}

.cs2-work__header {
    margin-bottom: 48px;
}

.cs2-work__heading {
    font-family: var(--cs2-font-heading);
    font-size: clamp(36px, 5vw, 48px);
    font-weight: 700;
    color: #ffffff;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 28px;
}


/* ─────────────────────────────────────────────────────────────────────────────
   3. Filter pills
───────────────────────────────────────────────────────────────────────────── */
.cs2-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.cs2-filter-pill {
    /* Reset button defaults */
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: var(--cs2-font-body);

    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: background-color var(--cs2-transition),
                color var(--cs2-transition),
                opacity var(--cs2-transition);

    /* Inactive default */
    background-color: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.45);
    outline-offset: 3px;
}

.cs2-filter-pill:hover {
    background-color: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.75);
}

.cs2-filter-pill:focus-visible {
    outline: 2px solid rgba(255,255,255,0.5);
}

/* Active state — JS adds .is-active */
.cs2-filter-pill.is-active[data-filter="positioning-gtm"] {
    background-color: var(--cs2-color-positioning-gtm);
    color: #000000;
}

.cs2-filter-pill.is-active[data-filter="demand-gen"] {
    background-color: var(--cs2-color-demand-gen);
    color: #000000;
}

.cs2-filter-pill.is-active[data-filter="sales-enablement"] {
    background-color: var(--cs2-color-sales-enablement);
    color: #000000;
}

/* "All" pill active state */
.cs2-filter-pill.is-active[data-filter="all"] {
    background-color: rgba(255,255,255,0.18);
    color: #ffffff;
}

/* Count badge inside pill */
.cs2-filter-pill__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    background-color: rgba(0,0,0,0.2);
    line-height: 1;
}


/* ─────────────────────────────────────────────────────────────────────────────
   4. Grid layout
   - 3 columns desktop
   - First card (hero) spans 2 columns
   - grid-auto-rows with named line span for masonry feel
───────────────────────────────────────────────────────────────────────────── */
.cs2-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 340px;
    gap: var(--cs2-gap);
}

/* Hero card: first child spans 2 columns and 2 rows → roughly 700px tall */
.cs2-grid .cs2-card:first-child {
    grid-column: span 2;
    grid-row:    span 2;
}


/* ─────────────────────────────────────────────────────────────────────────────
   5. Card base
───────────────────────────────────────────────────────────────────────────── */
.cs2-card {
    position: relative;
    display: block;
    border-radius: var(--cs2-card-radius);
    overflow: hidden;
    text-decoration: none;
    background-color: var(--cs2-color-fallback);

    /* Smooth entry for filter show/hide */
    transition: opacity var(--cs2-transition),
                transform var(--cs2-transition);
}

/* Ensure card fills the grid cell completely */
.cs2-card,
.cs2-card__media {
    height: 100%;
}


/* ─────────────────────────────────────────────────────────────────────────────
   6. Card media (image + fallback)
───────────────────────────────────────────────────────────────────────────── */
.cs2-card__media {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--cs2-card-radius);
}

/* Actual <img> */
.cs2-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    transition: transform var(--cs2-transition);
    will-change: transform;
}

/* Fallback background when no feature_image */
.cs2-card__img-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Fallback: category background colour applied via data-category */
.cs2-card[data-category="positioning-gtm"]  .cs2-card__img-fallback { background-color: #0d2a1a; }
.cs2-card[data-category="demand-gen"]        .cs2-card__img-fallback { background-color: #0d1e2e; }
.cs2-card[data-category="sales-enablement"] .cs2-card__img-fallback { background-color: #2a0d1a; }

/* SVG pattern inside fallback — fills the container */
.cs2-card__fallback-pattern {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}


/* ─────────────────────────────────────────────────────────────────────────────
   7. Overlays
───────────────────────────────────────────────────────────────────────────── */

/*
 * Bottom gradient overlay — fades from transparent at top to category colour at bottom.
 * The actual gradient colour is set by the data-category rules below.
 */
.cs2-card__overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity var(--cs2-transition);
}

/* Category-specific gradient overlays */
.cs2-card[data-category="positioning-gtm"] .cs2-card__overlay {
    background: linear-gradient(
        to bottom,
        transparent 30%,
        rgba(0, 15, 7, 0.55) 60%,
        rgba(10, 45, 20, 0.92) 100%
    );
}

.cs2-card[data-category="demand-gen"] .cs2-card__overlay {
    background: linear-gradient(
        to bottom,
        transparent 30%,
        rgba(0, 10, 25, 0.55) 60%,
        rgba(5, 25, 55, 0.92) 100%
    );
}

.cs2-card[data-category="sales-enablement"] .cs2-card__overlay {
    background: linear-gradient(
        to bottom,
        transparent 30%,
        rgba(20, 0, 12, 0.55) 60%,
        rgba(50, 5, 30, 0.92) 100%
    );
}

/* Hover darkening layer — transparent by default, darkens on hover */
.cs2-card__hover-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0);
    pointer-events: none;
    z-index: 2;
    transition: background-color var(--cs2-transition);
}


/* ─────────────────────────────────────────────────────────────────────────────
   8. Tag pill (top-left of card)
───────────────────────────────────────────────────────────────────────────── */
.cs2-card__tag {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 4;

    font-family: var(--cs2-font-body);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;

    padding: 5px 10px;
    border-radius: 999px;

    /* Default — overridden by category below */
    background-color: rgba(255,255,255,0.15);
    color: #ffffff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Category tag colours */
.cs2-card[data-category="positioning-gtm"] .cs2-card__tag {
    background-color: rgba(74, 222, 128, 0.2);
    color: var(--cs2-color-positioning-gtm);
    border: 1px solid rgba(74, 222, 128, 0.35);
}

.cs2-card[data-category="demand-gen"] .cs2-card__tag {
    background-color: rgba(96, 165, 250, 0.2);
    color: var(--cs2-color-demand-gen);
    border: 1px solid rgba(96, 165, 250, 0.35);
}

.cs2-card[data-category="sales-enablement"] .cs2-card__tag {
    background-color: rgba(244, 114, 182, 0.2);
    color: var(--cs2-color-sales-enablement);
    border: 1px solid rgba(244, 114, 182, 0.35);
}


/* ─────────────────────────────────────────────────────────────────────────────
   9. Caption (title + excerpt)
───────────────────────────────────────────────────────────────────────────── */
.cs2-card__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    padding: 20px 22px 22px;
}

.cs2-card__title {
    font-family: var(--cs2-font-body);
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    margin: 0 0 8px;
    letter-spacing: -0.01em;

    /* Prevent overflow on long titles */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Hero card gets a larger title */
.cs2-grid .cs2-card:first-child .cs2-card__title {
    font-size: clamp(20px, 2.5vw, 24px);
}

.cs2-card__excerpt {
    font-family: var(--cs2-font-body);
    font-size: 13px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.72);
    margin: 0;

    /* Hidden by default; revealed on hover */
    opacity: 0;
    transform: translateY(6px);
    transition: opacity var(--cs2-transition),
                transform var(--cs2-transition);

    /* Clamp to 3 lines max */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ─────────────────────────────────────────────────────────────────────────────
   10. Category colour tokens are handled inline in data-category rules above.
       No extra block needed.
───────────────────────────────────────────────────────────────────────────── */


/* ─────────────────────────────────────────────────────────────────────────────
   11. Hover & focus states
───────────────────────────────────────────────────────────────────────────── */

/* Image zoom on hover */
.cs2-card:hover .cs2-card__img {
    transform: scale(1.05);
}

/* Darken overlay on hover */
.cs2-card:hover .cs2-card__hover-overlay {
    background-color: rgba(0, 0, 0, 0.28);
}

/* Reveal excerpt on hover */
.cs2-card:hover .cs2-card__excerpt {
    opacity: 1;
    transform: translateY(0);
}

/* Keyboard focus — visible outline on the card anchor itself */
.cs2-card:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 3px;
}

/* Fallback image zoom for no-img cards */
.cs2-card:hover .cs2-card__img-fallback .cs2-card__fallback-pattern {
    transform: scale(1.04);
    transition: transform var(--cs2-transition);
}


/* ─────────────────────────────────────────────────────────────────────────────
   12. Hidden state — JS toggles .cs2-card--hidden on filtered cards
───────────────────────────────────────────────────────────────────────────── */
.cs2-card--hidden {
    opacity: 0;
    pointer-events: none;
    /* Collapse space in grid by removing from layout */
    display: none;
}


/* ─────────────────────────────────────────────────────────────────────────────
   13. Responsive breakpoints
───────────────────────────────────────────────────────────────────────────── */

/* 2-column layout at 1024px */
@media (max-width: 1024px) {
    .cs2-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 320px;
    }

    /* Hero still spans 2 columns but only 1 extra row at this size */
    .cs2-grid .cs2-card:first-child {
        grid-column: span 2;
        grid-row:    span 1;
    }
}

/* 1-column layout at 768px */
@media (max-width: 768px) {
    .cs2-work {
        padding: 64px 16px 80px;
    }

    .cs2-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 300px;
    }

    /* Hero is full-width single row on mobile */
    .cs2-grid .cs2-card:first-child {
        grid-column: span 1;
        grid-row:    span 1;
    }

    .cs2-work__heading {
        font-size: 32px;
    }

    .cs2-filters {
        gap: 8px;
    }

    .cs2-filter-pill {
        font-size: 11px;
        padding: 5px 12px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .cs2-grid {
        grid-auto-rows: 260px;
    }

    .cs2-card__title {
        font-size: 16px;
    }
}


/* ─────────────────────────────────────────────────────────────────────────────
   14. prefers-reduced-motion
   Removes all transforms and transitions for users who prefer reduced motion.
   Cards still show/hide, but without animation.
───────────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cs2-card,
    .cs2-card__img,
    .cs2-card__hover-overlay,
    .cs2-card__overlay,
    .cs2-card__excerpt,
    .cs2-filter-pill {
        transition: none;
    }

    .cs2-card:hover .cs2-card__img {
        transform: none;
    }

    .cs2-card:hover .cs2-card__excerpt {
        opacity: 1;
        transform: none;
    }

    .cs2-card:hover .cs2-card__hover-overlay {
        background-color: rgba(0, 0, 0, 0);
    }
}


/*
 * ─────────────────────────────────────────────────────────────────────────────
 * USAGE NOTE — index.hbs swap
 *
 * Replace the three separate {{#get}} sections in index.hbs with:
 *
 * <section class="cs2-work" id="work">
 *   <div class="cs2-work__header">
 *     <h2 class="cs2-work__heading">Selected Work</h2>
 *     <div class="cs2-filters" role="group" aria-label="Filter by category">
 *       <button class="cs2-filter-pill is-active" data-filter="all">All</button>
 *       <button class="cs2-filter-pill" data-filter="positioning-gtm">Positioning &amp; GTM</button>
 *       <button class="cs2-filter-pill" data-filter="demand-gen">Demand Generation</button>
 *       <button class="cs2-filter-pill" data-filter="sales-enablement">Sales Enablement</button>
 *     </div>
 *   </div>
 *   <div class="cs2-grid">
 *     {{#get "posts" filter="tag:hash-case-study" limit="12" order="published_at desc" include="tags"}}
 *       {{#foreach posts}}
 *         {{> case-study-card-v2}}
 *       {{/foreach}}
 *     {{/get}}
 *   </div>
 * </section>
 *
 * Also add to default.hbs <head> (after the main style.css link):
 *   <link rel="stylesheet" href="{{asset "css/case-studies-v2.css"}}">
 *
 * And before </body>:
 *   <script src="{{asset "js/case-studies-v2.js"}}" defer></script>
 * ─────────────────────────────────────────────────────────────────────────────
 */
