/*
 * AMA India — Posts Archive
 * Shortcode: [ama_posts_archive]
 * Class prefix: .ama-archive-  .ama-post-card
 */

/* ── Design tokens (fall back if parent CSS vars not set) ─────── */
.ama-archive-wrap {
    --arc-navy:   var(--ama-navy,   #1a2744);
    --arc-maroon: var(--ama-maroon, #8a3a2a);
    --arc-cream:  var(--ama-cream,  #f5f0e8);
    --arc-border: var(--ama-border, #d6cfc4);
    --arc-muted:  var(--ama-muted,  #534c45);
    --arc-gold:   var(--e-global-color-accent, #c89b3c);
    font-family: inherit;
}

/* ════════════════════════════════════════════════════════════════
   HEADER  (title left · filters right)
   ════════════════════════════════════════════════════════════════ */

.ama-archive-header {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 20px;
}

h2.ama-archive-title {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 900;
    color: var(--arc-navy);
    margin: 0;
    line-height: 1.1;
    flex-shrink: 0;
}

/* ── Filters ──────────────────────────────────────────────────── */

.ama-archive-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.ama-archive-filter {
    padding: 6px 18px;
    border-radius: 999px;
    border: 2px solid var(--arc-navy);
    background: var(--arc-navy);
    color: rgba(255, 255, 255, .75); /* raised from .55 — WCAG 1.4.3 contrast ~8:1 on navy */
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s, opacity .15s;
    white-space: nowrap;
    line-height: 1;
}

.ama-archive-filter:hover {
    color: #fff;
    border-color: var(--arc-gold);
}

.ama-archive-filter--active {
    background: var(--arc-gold);
    border-color: var(--arc-gold);
    color: #fff;
}

/* ════════════════════════════════════════════════════════════════
   CONTROLS BAR  (column toggle)
   ════════════════════════════════════════════════════════════════ */

.ama-archive-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
}

.ama-archive-col-toggle {
    display: flex;
    gap: 3px;
    background: var(--arc-cream);
    border-radius: 6px;
    padding: 3px;
}

.ama-col-btn {
    /* 44×44 px minimum touch target — WCAG 2.5.8 */
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 4px;
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--arc-muted);
    cursor: pointer;
    transition: background .12s, color .12s;
    line-height: 1;
}

.ama-col-btn:hover {
    background: rgba(0, 0, 0, .08);
}

.ama-col-btn--active {
    background: var(--arc-navy);
    color: #fff;
}

/* ════════════════════════════════════════════════════════════════
   GRID
   ════════════════════════════════════════════════════════════════ */

.ama-archive-grid {
    display: grid;
    gap: 24px;
    transition: opacity .2s;
}

/* !important guards against Elementor container flex/grid resets */
.ama-archive-grid--cols-2 { grid-template-columns: repeat(2, 1fr) !important; }
.ama-archive-grid--cols-3 { grid-template-columns: repeat(3, 1fr) !important; }
.ama-archive-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

.ama-archive-grid--loading {
    opacity: .45;
    pointer-events: none;
}

/* ── Responsive breakpoints ──────────────────────────────────── */
@media (max-width: 1100px) {
    .ama-archive-grid--cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
    .ama-archive-grid--cols-3,
    .ama-archive-grid--cols-4 { grid-template-columns: repeat(2, 1fr); }
    .ama-archive-filters       { margin-left: 0; }
    .ama-archive-header        { flex-direction: column; }
}
@media (max-width: 540px) {
    .ama-archive-grid--cols-2,
    .ama-archive-grid--cols-3,
    .ama-archive-grid--cols-4 { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════════
   POST CARD
   ════════════════════════════════════════════════════════════════ */

.ama-post-card {
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
    transition: transform .18s ease, box-shadow .18s ease;
}

.ama-post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .11);
}

/* ── Image area ───────────────────────────────────────────────── */

/*
 * padding-top: 56.25% = 9/16 × 100% — creates a reliable 16:9 box
 * regardless of how browsers handle aspect-ratio with flex children.
 * All inner elements are positioned absolutely to fill the box.
 */
.ama-post-card__img-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    height: 0;
    background: var(--arc-navy);
    overflow: hidden;
    flex-shrink: 0;
}

.ama-post-card__img-wrap > a {
    position: absolute;
    inset: 0;
    display: block;
}

/* (0,2,1) — beats .elementor img (0,1,1) even when Kit inline style loads after */
.ama-post-card img.ama-post-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s ease;
}

.ama-post-card:hover img.ama-post-card__img {
    transform: scale(1.05);
}

/* Striped placeholder (matching design reference) */
.ama-post-card__img-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            -45deg,
            rgba(255, 255, 255, .05) 0px,
            rgba(255, 255, 255, .05) 4px,
            transparent 4px,
            transparent 14px
        );
}

/* Category chip — top-left overlay */
.ama-post-card__cat {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .07em;
    padding: 3px 8px;
    border-radius: 2px;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Card body ────────────────────────────────────────────────── */

.ama-post-card__body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* (0,2,1) — beats .elementor-kit-N h3 (0,1,1) */
.ama-post-card h3.ama-post-card__title {
    font-size: 1.2em;
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 6px;
    color: var(--arc-navy);
    text-transform: none;
    letter-spacing: normal;
}

/* (0,3,1) — beats .elementor-kit-N a:hover (0,2,1) */
.ama-post-card h3.ama-post-card__title a {
    color: inherit;
    text-decoration: none;
}

.ama-post-card h3.ama-post-card__title a:hover {
    color: var(--arc-maroon) !important;
    text-decoration: none !important;
}

.ama-post-card__author {
    font-size: 0.75rem;
    color: var(--arc-muted);
    margin: 0 0 14px;
    font-style: italic;
}

.ama-post-card__author span {
    font-style: normal;
}

/* ── Footer: date left · read-more right ─────────────────────── */

.ama-post-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--arc-border);
}

.ama-post-card__date {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.ama-post-card__date-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--arc-muted);
    opacity: .8;
}

.ama-post-card__date strong {
    font-size: 0.75rem;
    color: var(--arc-muted);
    font-weight: 600;
}

a.ama-post-card__read-more {
    display: inline-block;
    padding: 6px 14px;
    background: var(--arc-gold);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s;
}

/* Hover is DERIVED from the resting colour, never a second hard-coded value.
   The button's background is var(--arc-gold), which resolves to the Elementor
   Kit's Accent colour — so when that Accent was changed to blue the button
   went blue and this hover, previously the literal #a87e2e (a hand-darkened
   copy of the old gold fallback), stayed orange. color-mix re-darkens whatever
   the Accent happens to be today. The plain declaration above it is the
   fallback for engines without color-mix: the same colour, undarkened, which
   is a far better wrong answer than the stale orange was. */
a.ama-post-card__read-more:hover {
    background: var(--arc-gold, var(--e-global-color-accent, #c89b3c));
    background: color-mix(in srgb, var(--arc-gold, var(--e-global-color-accent, #c89b3c)) 85%, #000);
    color: #fff !important;
}

/* ════════════════════════════════════════════════════════════════
   LOAD MORE
   ════════════════════════════════════════════════════════════════ */

.ama-archive-load-more-wrap {
    text-align: center;
    margin-top: 44px;
}

.ama-archive-load-more {
    padding: 12px 48px;
    background: transparent;
    border: 2px solid var(--arc-navy);
    color: var(--arc-navy);
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 3px;
    cursor: pointer;
    letter-spacing: .04em;
    transition: background .15s, color .15s;
}

.ama-archive-load-more:hover {
    background: var(--arc-navy);
    color: #fff;
}

.ama-archive-load-more:disabled {
    opacity: .5;
    cursor: default;
}

/* "More articles" link variant (load_more="link") — an <a> rather than a
   <button>, so it needs the bits a button gets for free. Shares every other
   style above, and the JS ignores this class so it navigates normally. */
a.ama-archive-load-more--link,
a.ama-archive-load-more--link:hover,
a.ama-archive-load-more--link:focus {
    display: inline-block;
    text-decoration: none;
    line-height: 1.4;
}
a.ama-archive-load-more--link:hover,
a.ama-archive-load-more--link:focus {
    background: var(--arc-navy);
    color: #fff;
}

/* ════════════════════════════════════════════════════════════════
   RELATED POSTS WIDGET  (.ama-rp-)
   ════════════════════════════════════════════════════════════════ */

.ama-rp-wrap {
    font-family: inherit;
}

.ama-rp__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 0 0 24px;
}

h2.ama-rp__heading {
    font-family: var(--font-sans, inherit);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--arc-navy, #1a2744);
    margin: 0;
    line-height: 1.2;
}

h2.ama-rp__heading span {
    color: var(--arc-maroon, #8a3a2a);
}

a.ama-rp__view-all {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1.5px solid var(--arc-navy, #1a2744);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--arc-navy, #1a2744) !important;
    text-decoration: none !important;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}

a.ama-rp__view-all:hover {
    background: var(--arc-navy, #1a2744);
    color: #fff !important;
    text-decoration: none !important;
}

/* Grid reuses .ama-archive-grid column classes — no extra rules needed */
.ama-rp__grid {
    display: grid !important;
    gap: 24px;
}

/* ════════════════════════════════════════════════════════════════
   POST DYNAMIC WIDGETS  (.ama-dyn-)
   ════════════════════════════════════════════════════════════════ */

/* ── Post Meta ─────────────────────────────────────────────────── */

.ama-dyn-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    font-size: 0.875rem;
    color: #534c45;
    line-height: 1.4;
}

.ama-dyn-meta--stacked {
    flex-direction: column;
    align-items: flex-start;
}

.ama-dyn-meta__sep {
    opacity: .5;
}

.ama-dyn-meta--stacked .ama-dyn-meta__sep {
    display: none;
}

/* Category chip */
.ama-dyn-meta__cat-chip {
    display: inline-block;
    background: #c89b3c;
    color: #fff;
    font-size: .85em;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 3px;
    line-height: 1.5;
}

.ama-dyn-meta__cat-chip a {
    color: inherit;
    text-decoration: none;
}

/* ── Post Title ────────────────────────────────────────────────── */

.ama-dyn-title {
    margin: 0;
    line-height: 1.2;
}

/* ── Post Content ──────────────────────────────────────────────── */

.ama-dyn-content p          { margin: 0 0 1.4em; }
.ama-dyn-content h2,
.ama-dyn-content h3,
.ama-dyn-content h4         { margin: 1.8em 0 .5em; }
.ama-dyn-content ul,
.ama-dyn-content ol         { margin: 0 0 1.4em 1.4em; }
.ama-dyn-content blockquote {
    margin: 1.8em 0;
    padding: 16px 20px 16px 24px;
    border-left: 4px solid #c89b3c;
    background: #f5f0e8;
    border-radius: 0 4px 4px 0;
    font-style: italic;
}
.ama-dyn-content img        { max-width: 100%; height: auto; }

/* ── Post Excerpt ──────────────────────────────────────────────── */

.ama-dyn-excerpt {
    margin: 0;
    line-height: 1.65;
}
