/* ════════════════════════════════════════════════════════════════
   AN INTELLIGENCE GRID · anig.css
   Spotify-card architecture · Dark Intelligence aesthetic
   Part of ANIE Suite — Agriculture Novel
   ════════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
    --anig-accent:       #3d9970;
    --anig-secondary:    #f39c12;

    /* Surface system */
    --anig-bg:           #0d0d0d;
    --anig-surface-0:    #111111;
    --anig-surface-1:    #1a1a1a;
    --anig-surface-2:    #242424;
    --anig-surface-3:    #2e2e2e;

    /* Typography */
    --anig-text-primary:   #f0f0f0;
    --anig-text-secondary: #a0a0a0;
    --anig-text-muted:     #606060;

    /* Fonts */
    --anig-font-display: 'Fraunces', Georgia, serif;
    --anig-font-body:    'DM Sans', -apple-system, sans-serif;
    --anig-font-mono:    'DM Mono', 'Courier New', monospace;

    /* Spacing */
    --anig-radius-sm:   6px;
    --anig-radius-md:   12px;
    --anig-radius-lg:   18px;
    --anig-radius-xl:   24px;

    /* Transitions */
    --anig-ease:        cubic-bezier(.25, .46, .45, .94);
    --anig-ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --anig-t-fast:      160ms;
    --anig-t-mid:       300ms;
    --anig-t-slow:      500ms;

    /* Card image aspect */
    --anig-card-aspect:  3/4;
    --anig-hero-aspect:  16/9;
}

/* ── EDITORIAL LIGHT theme overrides ─────────────────────────── */
.anig-wrapper[data-style="editorial"] {
    --anig-bg:           #f8f7f2;
    --anig-surface-0:    #ffffff;
    --anig-surface-1:    #f0ede6;
    --anig-surface-2:    #e8e4db;
    --anig-surface-3:    #ddd9ce;
    --anig-text-primary:   #1a1a1a;
    --anig-text-secondary: #4a4a4a;
    --anig-text-muted:     #9a9a9a;
}

/* ── LIQUID GLASS theme overrides ────────────────────────────── */
.anig-wrapper[data-style="glass"] {
    --anig-bg:           #080e14;
    --anig-surface-0:    rgba(255,255,255,.04);
    --anig-surface-1:    rgba(255,255,255,.07);
    --anig-surface-2:    rgba(255,255,255,.10);
    --anig-surface-3:    rgba(255,255,255,.14);
    --anig-text-primary:   rgba(255,255,255,.95);
    --anig-text-secondary: rgba(255,255,255,.60);
    --anig-text-muted:     rgba(255,255,255,.35);
}

/* ── WRAPPER ─────────────────────────────────────────────────── */
.anig-wrapper {
    font-family: var(--anig-font-body);
    background: var(--anig-bg);
    color: var(--anig-text-primary);
    padding: 40px 24px 80px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.anig-wrapper::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 15% 0%, color-mix(in srgb, var(--anig-accent) 8%, transparent) 0%, transparent 70%),
        radial-gradient(ellipse 40% 30% at 85% 100%, color-mix(in srgb, var(--anig-secondary) 5%, transparent) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── HERO ROW ────────────────────────────────────────────────── */
.anig-hero-row {
    display: grid;
    gap: 20px;
    margin-bottom: 60px;
    position: relative;
    z-index: 1;
}

.anig-hero-count-1 { grid-template-columns: 1fr; }
.anig-hero-count-2 { grid-template-columns: 1.4fr 1fr; }
.anig-hero-count-3 { grid-template-columns: 1.4fr 1fr 1fr; }

/* ── SECTION LABEL ───────────────────────────────────────────── */
.anig-section-label {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.anig-section-label__line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--anig-surface-3), transparent);
}

.anig-section-label__text {
    font-family: var(--anig-font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--anig-text-muted);
    white-space: nowrap;
}

/* ── GRID ────────────────────────────────────────────────────── */
.anig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    position: relative;
    z-index: 1;
}

@media (min-width: 900px) {
    .anig-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
    .anig-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ════════════════════════════════════════════════════════════════
   CARD — GRID VARIANT (Spotify album card)
   ════════════════════════════════════════════════════════════════ */
.anig-card {
    background: var(--anig-surface-1);
    border-radius: var(--anig-radius-md);
    overflow: hidden;
    position: relative;
    transition:
        transform var(--anig-t-mid) var(--anig-ease),
        box-shadow var(--anig-t-mid) var(--anig-ease),
        background var(--anig-t-mid) var(--anig-ease);
    cursor: pointer;
    will-change: transform;
}

.anig-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--anig-radius-md);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
    pointer-events: none;
    z-index: 2;
    transition: box-shadow var(--anig-t-mid) var(--anig-ease);
}

.anig-card:hover {
    transform: translateY(-6px) scale(1.012);
    background: var(--anig-surface-2);
    box-shadow:
        0 20px 60px rgba(0,0,0,.5),
        0 8px 20px rgba(0,0,0,.3);
}

.anig-card:hover::after {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}

/* IMAGE BLOCK */
.anig-card__image-wrap {
    position: relative;
    aspect-ratio: var(--anig-card-aspect);
    overflow: hidden;
    border-radius: var(--anig-radius-md) var(--anig-radius-md) 0 0;
    background: var(--anig-surface-2);
}

.anig-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--anig-t-slow) var(--anig-ease);
}

.anig-card:hover .anig-card__image {
    transform: scale(1.08);
}

.anig-card__image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 40%,
        rgba(0,0,0,.3) 70%,
        rgba(0,0,0,.55) 100%
    );
    transition: opacity var(--anig-t-mid) var(--anig-ease);
}

.anig-card:hover .anig-card__image-overlay {
    opacity: .7;
}

/* PLAY BUTTON — appears on hover (Spotify DNA) */
.anig-card__image-wrap::after {
    content: '→';
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--anig-accent);
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity var(--anig-t-fast) var(--anig-ease),
        transform var(--anig-t-fast) var(--anig-ease-spring);
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    z-index: 3;
    font-family: inherit;
    line-height: 1;
}

.anig-card:hover .anig-card__image-wrap::after {
    opacity: 1;
    transform: translateY(0);
}

/* BODY */
.anig-card__body {
    padding: 14px 16px 18px;
}

.anig-card__category {
    display: inline-block;
    font-family: var(--anig-font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .10em;
    text-transform: uppercase;
    color: var(--cat-color, var(--anig-accent));
    text-decoration: none;
    margin-bottom: 8px;
    transition: color var(--anig-t-fast) var(--anig-ease);
}

.anig-card__category:hover {
    color: var(--anig-text-primary);
}

.anig-card__title {
    font-family: var(--anig-font-display);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 10px;
    color: var(--anig-text-primary);
    letter-spacing: -.01em;

    /* 2-line clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.anig-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--anig-t-fast) var(--anig-ease);
}

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

.anig-card__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--anig-font-body);
    font-size: 11px;
    color: var(--anig-text-muted);
}

.anig-card__sep { opacity: .5; }

.anig-card__read-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

.anig-card__read-time svg { opacity: .7; }

/* HOVER STRIP — colored line at card bottom */
.anig-card__hover-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--cat-color, var(--anig-accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--anig-t-mid) var(--anig-ease);
    border-radius: 0 0 var(--anig-radius-md) var(--anig-radius-md);
}

.anig-card:hover .anig-card__hover-strip {
    transform: scaleX(1);
}

/* CARD LINK (invisible overlay for the image) */
.anig-card__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* ════════════════════════════════════════════════════════════════
   CARD — FEATURED VARIANT (hero/editorial)
   ════════════════════════════════════════════════════════════════ */
.anig-card--featured {
    background: var(--anig-surface-1);
}

.anig-card--featured .anig-card__image-wrap {
    aspect-ratio: var(--anig-hero-aspect);
    border-radius: var(--anig-radius-lg) var(--anig-radius-lg) 0 0;
}

.anig-card--featured .anig-card__image-overlay {
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0,0,0,.15) 50%,
        rgba(0,0,0,.65) 100%
    );
}

.anig-card--featured .anig-card__body {
    padding: 20px 24px 24px;
}

.anig-card--featured .anig-card__title {
    font-size: 22px;
    font-weight: 900;
    -webkit-line-clamp: 3;
    letter-spacing: -.02em;
    line-height: 1.2;
    margin-bottom: 12px;
}

.anig-card--featured .anig-card__excerpt {
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--anig-text-secondary);
    margin: 0 0 14px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.anig-card--featured .anig-card__featured-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: var(--anig-secondary);
    color: #0d0d0d;
    font-family: var(--anig-font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 4;
}

.anig-card--featured::after {
    border-radius: var(--anig-radius-lg);
}

/* ── EDITORIAL LIGHT: card overrides ────────────────────────── */
.anig-wrapper[data-style="editorial"] .anig-card {
    border: 1px solid rgba(0,0,0,.08);
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.anig-wrapper[data-style="editorial"] .anig-card:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
}

.anig-wrapper[data-style="editorial"] .anig-card__image-overlay {
    background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,.15) 100%);
}

/* ── LIQUID GLASS: card overrides ───────────────────────────── */
.anig-wrapper[data-style="glass"] .anig-card {
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    border: 1px solid rgba(255,255,255,.08);
}

.anig-wrapper[data-style="glass"] .anig-card:hover {
    border-color: rgba(255,255,255,.18);
    box-shadow:
        0 20px 60px rgba(0,0,0,.5),
        inset 0 1px 0 rgba(255,255,255,.15);
}

/* ── STAGGERED ENTRANCE ANIMATION ───────────────────────────── */
@keyframes anig-fade-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.anig-card {
    animation: anig-fade-up var(--anig-t-slow) var(--anig-ease) both;
}

/* Stagger each card via nth-child */
.anig-hero-row .anig-card:nth-child(1) { animation-delay: 0ms; }
.anig-hero-row .anig-card:nth-child(2) { animation-delay: 80ms; }
.anig-hero-row .anig-card:nth-child(3) { animation-delay: 160ms; }

.anig-grid .anig-card:nth-child(1)  { animation-delay: 100ms; }
.anig-grid .anig-card:nth-child(2)  { animation-delay: 140ms; }
.anig-grid .anig-card:nth-child(3)  { animation-delay: 180ms; }
.anig-grid .anig-card:nth-child(4)  { animation-delay: 220ms; }
.anig-grid .anig-card:nth-child(5)  { animation-delay: 260ms; }
.anig-grid .anig-card:nth-child(6)  { animation-delay: 300ms; }
.anig-grid .anig-card:nth-child(7)  { animation-delay: 340ms; }
.anig-grid .anig-card:nth-child(8)  { animation-delay: 380ms; }
.anig-grid .anig-card:nth-child(9)  { animation-delay: 420ms; }
.anig-grid .anig-card:nth-child(10) { animation-delay: 460ms; }
.anig-grid .anig-card:nth-child(n+11) { animation-delay: 500ms; }

/* ── HEADER BAR (rendered in homepage template) ──────────────── */
.anig-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 0 40px;
    position: relative;
    z-index: 1;
    gap: 20px;
    flex-wrap: wrap;
}

.anig-header__wordmark {
    font-family: var(--anig-font-display);
    font-size: clamp(28px, 5vw, 52px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -.03em;
    color: var(--anig-text-primary);
    text-decoration: none;
}

.anig-header__wordmark span {
    color: var(--anig-accent);
}

.anig-header__tagline {
    font-family: var(--anig-font-mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--anig-text-muted);
    margin-top: 6px;
}

.anig-header__search {
    display: flex;
    align-items: center;
    gap: 12px;
}

.anig-header__search input[type="search"] {
    background: var(--anig-surface-2);
    border: 1px solid var(--anig-surface-3);
    color: var(--anig-text-primary);
    border-radius: 40px;
    padding: 9px 18px;
    font-family: var(--anig-font-body);
    font-size: 13px;
    width: 220px;
    outline: none;
    transition: border-color var(--anig-t-fast) var(--anig-ease),
                background var(--anig-t-fast) var(--anig-ease);
}

.anig-header__search input[type="search"]:focus {
    border-color: var(--anig-accent);
    background: var(--anig-surface-3);
}

.anig-header__search input[type="search"]::placeholder {
    color: var(--anig-text-muted);
}

/* ── CATEGORY TABS ──────────────────────────────────────────── */
.anig-category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 32px;
    position: relative;
    z-index: 1;
    -ms-overflow-style: none;
}

.anig-category-tabs::-webkit-scrollbar { display: none; }

.anig-cat-tab {
    flex-shrink: 0;
    font-family: var(--anig-font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 40px;
    background: var(--anig-surface-2);
    border: 1px solid var(--anig-surface-3);
    color: var(--anig-text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition:
        background var(--anig-t-fast) var(--anig-ease),
        color var(--anig-t-fast) var(--anig-ease),
        border-color var(--anig-t-fast) var(--anig-ease);
    white-space: nowrap;
}

.anig-cat-tab:hover,
.anig-cat-tab.is-active {
    background: var(--anig-accent);
    border-color: var(--anig-accent);
    color: #fff;
}

/* ── STATS BAR ──────────────────────────────────────────────── */
.anig-stats-bar {
    display: flex;
    gap: 32px;
    padding: 0 0 48px;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
}

.anig-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.anig-stat__value {
    font-family: var(--anig-font-display);
    font-size: 28px;
    font-weight: 900;
    color: var(--anig-text-primary);
    letter-spacing: -.03em;
    line-height: 1;
}

.anig-stat__value em {
    color: var(--anig-accent);
    font-style: normal;
}

.anig-stat__label {
    font-family: var(--anig-font-mono);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--anig-text-muted);
}

/* ── LOAD MORE BUTTON ────────────────────────────────────────── */
.anig-load-more {
    display: block;
    margin: 48px auto 0;
    padding: 12px 32px;
    background: transparent;
    border: 1px solid var(--anig-surface-3);
    border-radius: 40px;
    color: var(--anig-text-secondary);
    font-family: var(--anig-font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition:
        background var(--anig-t-fast) var(--anig-ease),
        border-color var(--anig-t-fast) var(--anig-ease),
        color var(--anig-t-fast) var(--anig-ease);
    position: relative;
    z-index: 1;
}

.anig-load-more:hover {
    background: var(--anig-surface-2);
    border-color: var(--anig-accent);
    color: var(--anig-accent);
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.anig-empty {
    text-align: center;
    color: var(--anig-text-muted);
    font-family: var(--anig-font-body);
    padding: 60px 20px;
    font-size: 15px;
}

/* ── REDUCE MOTION ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .anig-card {
        animation: none;
        transition: none;
    }
    .anig-card__image { transition: none; }
    .anig-card__hover-strip { transition: none; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .anig-wrapper { padding: 24px 16px 60px; }

    .anig-hero-count-2,
    .anig-hero-count-3 {
        grid-template-columns: 1fr;
    }

    .anig-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .anig-card--featured .anig-card__title { font-size: 18px; }

    .anig-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .anig-header__search input[type="search"] { width: 100%; }

    .anig-stats-bar { gap: 20px; }
    .anig-stat__value { font-size: 22px; }
}

@media (max-width: 480px) {
    .anig-grid {
        grid-template-columns: 1fr;
    }
}

/* ── LOOP POST (archive/category page cards) ────────────────── */
.anig-loop-post {
    background: var(--anig-surface-1) !important;
    border-radius: var(--anig-radius-md);
    overflow: hidden;
    transition: transform var(--anig-t-mid) var(--anig-ease),
                box-shadow var(--anig-t-mid) var(--anig-ease);
}

.anig-loop-post:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
}

/* ── SKELETON LOADING SHIMMER ──────────────────────────────── */
@keyframes anig-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.anig-card--skeleton .anig-card__image-wrap,
.anig-card--skeleton .anig-card__title,
.anig-card--skeleton .anig-card__meta {
    background: linear-gradient(
        90deg,
        var(--anig-surface-2) 25%,
        var(--anig-surface-3) 50%,
        var(--anig-surface-2) 75%
    );
    background-size: 800px 100%;
    animation: anig-shimmer 1.4s infinite linear;
    border-radius: 4px;
}
