/* ============================================================
 * Arduino Library — Catalog Design System
 * Ported from the calculators-pro modern design system. All styles scoped
 * under .alp-catalog-archive / .alp-catalog-shortcode. LTR by default (uses
 * logical properties throughout so it self-adapts if a theme sets dir="rtl").
 * ============================================================ */

.alp-catalog-archive,
.alp-catalog-shortcode {
    --alp-c-primary: #4F46E5;
    --alp-c-primary-dark: #3730A3;
    --alp-c-accent: #06B6D4;
    --alp-c-ink: #0F172A;
    --alp-c-body: #475569;
    --alp-c-muted: #94A3B8;
    --alp-c-bg: #F6F7FB;
    --alp-c-bg-soft: #EEF1FA;
    --alp-c-white: #FFFFFF;
    --alp-c-border: #E4E9F2;
    --alp-c-green: #10B981;
    --alp-c-orange: #F59E0B;
    --alp-c-red: #EF4444;

    --alp-c-radius-lg: 28px;
    --alp-c-radius: 20px;
    --alp-c-radius-sm: 14px;
    --alp-c-radius-pill: 999px;

    --alp-c-shadow-sm: 0 2px 8px rgba(15,23,42,.06);
    --alp-c-shadow-md: 0 10px 26px -6px rgba(15,23,42,.12);
    --alp-c-shadow-lg: 0 26px 52px -16px rgba(79,70,229,.30);

    --alp-c-gradient-brand: linear-gradient(135deg, #4F46E5 0%, #7C3AED 55%, #06B6D4 100%);
    --alp-c-gradient-soft: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 45%, #ECFEFF 100%);
    --alp-c-ease: cubic-bezier(.16,1,.3,1);

    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--alp-c-ink);
    box-sizing: border-box;
}
.alp-catalog-archive *, .alp-catalog-shortcode * { box-sizing: border-box; }
.alp-catalog-archive ::selection, .alp-catalog-shortcode ::selection { background: var(--alp-c-primary); color: #fff; }

.alp-catalog-archive a:focus-visible, .alp-catalog-archive button:focus-visible, .alp-catalog-archive input:focus-visible,
.alp-catalog-shortcode a:focus-visible, .alp-catalog-shortcode button:focus-visible, .alp-catalog-shortcode input:focus-visible {
    outline: 2.5px solid var(--alp-c-primary); outline-offset: 3px; border-radius: 6px;
}

.alp-catalog-archive { width: 100%; max-width: 100%; margin: 0 auto; padding: 48px 40px 90px; background: var(--alp-c-bg); }
@media (max-width: 900px) { .alp-catalog-archive { padding: 36px 24px 72px; } }
@media (max-width: 600px) { .alp-catalog-archive { padding: 28px 14px 64px; } }

@keyframes alpCatalogFadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Directory hero ---------- */
.alp-catalog-dir-hero { text-align: center; max-width: 640px; margin: 0 auto 44px; }
.alp-catalog-hero-kicker {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--alp-c-white); color: var(--alp-c-primary);
    font-weight: 700; font-size: 13px; padding: 8px 18px;
    border-radius: var(--alp-c-radius-pill); margin-bottom: 18px;
    box-shadow: var(--alp-c-shadow-sm); border: 1px solid var(--alp-c-border);
}
.alp-catalog-hero-title {
    font-size: clamp(26px, 4vw, 40px); font-weight: 800; margin: 0 0 10px; line-height: 1.25; color: var(--alp-c-ink);
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
    .alp-catalog-hero-title {
        background: var(--alp-c-gradient-brand); -webkit-background-clip: text; background-clip: text;
        -webkit-text-fill-color: transparent; color: transparent;
    }
}
.alp-catalog-hero-desc { font-size: 15.5px; color: var(--alp-c-body); font-weight: 500; margin: 0 0 26px; line-height: 1.75; }

.alp-catalog-dir-search-box { max-width: 460px; margin: 0 auto; }
.alp-catalog-dir-search-box input {
    width: 100%; font-family: inherit; font-size: 15px; font-weight: 600; padding: 14px 22px;
    border: 1.5px solid var(--alp-c-border); border-radius: var(--alp-c-radius-pill); background: var(--alp-c-white);
    outline: none; color: var(--alp-c-ink); box-shadow: var(--alp-c-shadow-sm);
    transition: border-color .2s var(--alp-c-ease), box-shadow .2s var(--alp-c-ease);
}
.alp-catalog-dir-search-box input::placeholder { color: var(--alp-c-muted); font-weight: 500; }
.alp-catalog-dir-search-box input:focus { border-color: var(--alp-c-primary); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }

/* ---------- Filters bar (glassmorphism) ---------- */
.alp-catalog-filters-bar {
    background: rgba(255,255,255,.78);
    backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
    border: 1px solid rgba(226,232,240,.8); border-radius: var(--alp-c-radius);
    box-shadow: var(--alp-c-shadow-md); padding: 22px 24px; margin-bottom: 26px;
    position: sticky; top: 12px; z-index: 20;
}
.alp-catalog-search-box { margin-bottom: 16px; position: relative; }
.alp-catalog-search-box input {
    width: 100%; font-family: inherit; font-size: 15px; font-weight: 600; padding: 14px 20px;
    border: 1.5px solid var(--alp-c-border); border-radius: var(--alp-c-radius-sm); background: var(--alp-c-bg);
    outline: none; color: var(--alp-c-ink); transition: border-color .2s var(--alp-c-ease), background .2s var(--alp-c-ease), box-shadow .2s var(--alp-c-ease);
}
.alp-catalog-search-box input::placeholder { color: var(--alp-c-muted); font-weight: 500; }
.alp-catalog-search-box input:focus { border-color: var(--alp-c-primary); background: var(--alp-c-white); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }

.alp-catalog-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.alp-catalog-chip-row + .alp-catalog-chip-row { margin-top: 10px; }
@media (max-width: 640px) {
    .alp-catalog-chip-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-inline: -4px; padding: 2px 4px 4px; }
    .alp-catalog-chip-row::-webkit-scrollbar { display: none; }
    .alp-catalog-chip-row .alp-catalog-chip { flex: 0 0 auto; }
}
.alp-catalog-chip {
    font-family: inherit; font-weight: 600; font-size: 13.5px; background: var(--alp-c-bg); color: var(--alp-c-body);
    border: 1.5px solid transparent; border-radius: var(--alp-c-radius-pill); padding: 9px 18px; cursor: pointer;
    transition: background .18s var(--alp-c-ease), color .18s var(--alp-c-ease), box-shadow .18s var(--alp-c-ease), transform .18s var(--alp-c-ease);
}
.alp-catalog-chip:hover { background: #EEF2FF; color: var(--alp-c-primary); transform: translateY(-1px); }
.alp-catalog-chip.is-active { background: var(--alp-c-gradient-brand); color: var(--alp-c-white); box-shadow: 0 6px 16px -2px rgba(79,70,229,.4); }
.alp-catalog-chip--sm { font-size: 12.5px; padding: 7px 15px; }
.alp-catalog-chip--basic.is-active { background: var(--alp-c-green); box-shadow: 0 6px 16px -2px rgba(16,185,129,.4); }
.alp-catalog-chip--intermediate.is-active { background: var(--alp-c-orange); box-shadow: 0 6px 16px -2px rgba(245,158,11,.4); }
.alp-catalog-chip--advanced.is-active { background: var(--alp-c-red); box-shadow: 0 6px 16px -2px rgba(239,68,68,.4); }

.alp-catalog-results-meta { font-weight: 600; color: var(--alp-c-muted); margin-bottom: 18px; font-size: 14px; }

/* ---------- Grid ---------- */
.alp-catalog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; transition: opacity .25s var(--alp-c-ease), filter .25s var(--alp-c-ease); }
.alp-catalog-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.alp-catalog-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 1680px) { .alp-catalog-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px) { .alp-catalog-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .alp-catalog-grid { grid-template-columns: 1fr; gap: 16px; } }
.alp-catalog-grid.is-loading { opacity: .45; filter: blur(1px) saturate(70%); pointer-events: none; transform: scale(.99); }

/* ---------- Card ---------- */
.alp-catalog-card {
    position: relative; background: var(--alp-c-white); border: 1px solid var(--alp-c-border); border-radius: var(--alp-c-radius);
    box-shadow: var(--alp-c-shadow-sm); overflow: hidden; display: flex; flex-direction: column;
    transition: transform .3s var(--alp-c-ease), box-shadow .3s var(--alp-c-ease), border-color .3s var(--alp-c-ease);
}
@media (prefers-reduced-motion: no-preference) {
    .alp-catalog-card { animation: alpCatalogFadeUp .5s var(--alp-c-ease) both; }
    .alp-catalog-grid > .alp-catalog-card:nth-child(1) { animation-delay: .02s; }
    .alp-catalog-grid > .alp-catalog-card:nth-child(2) { animation-delay: .06s; }
    .alp-catalog-grid > .alp-catalog-card:nth-child(3) { animation-delay: .10s; }
    .alp-catalog-grid > .alp-catalog-card:nth-child(4) { animation-delay: .14s; }
    .alp-catalog-grid > .alp-catalog-card:nth-child(5) { animation-delay: .18s; }
    .alp-catalog-grid > .alp-catalog-card:nth-child(6) { animation-delay: .22s; }
}
.alp-catalog-card::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; background: var(--alp-c-gradient-brand);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
    opacity: 0; transition: opacity .3s var(--alp-c-ease); pointer-events: none; z-index: 3;
}
.alp-catalog-card:hover { transform: translateY(-7px); box-shadow: var(--alp-c-shadow-lg); border-color: transparent; }
.alp-catalog-card:hover::after { opacity: 1; }
.alp-catalog-card.is-featured { border: 1.5px solid var(--alp-c-primary); }
.alp-catalog-card.is-featured::after { opacity: .55; }

.alp-catalog-band { display: block; height: 6px; width: 100%; position: relative; z-index: 1; }
.alp-catalog-band--basic { background: linear-gradient(90deg, var(--alp-c-green), #34D399); box-shadow: 0 3px 14px -3px rgba(16,185,129,.65); }
.alp-catalog-band--intermediate { background: linear-gradient(90deg, var(--alp-c-orange), #FBBF24); box-shadow: 0 3px 14px -3px rgba(245,158,11,.65); }
.alp-catalog-band--advanced { background: linear-gradient(90deg, var(--alp-c-red), #F87171); box-shadow: 0 3px 14px -3px rgba(239,68,68,.65); }
.alp-catalog-band--none { background: var(--alp-c-gradient-brand); opacity: .55; }

.alp-catalog-ribbon {
    position: absolute; top: 14px; inset-inline-start: 14px; background: var(--alp-c-primary); color: var(--alp-c-white);
    font-weight: 700; font-size: 11.5px; padding: 6px 14px; border-radius: var(--alp-c-radius-pill); z-index: 2;
    box-shadow: 0 6px 14px -2px rgba(79,70,229,.45);
}
.alp-catalog-ribbon--alt { background: var(--alp-c-ink); }

.alp-catalog-card-media { background: var(--alp-c-bg); aspect-ratio: 16/10; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.alp-catalog-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--alp-c-ease); }
.alp-catalog-card:hover .alp-catalog-card-media img { transform: scale(1.07); }
.alp-catalog-card-media--placeholder {
    font-size: 46px; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
    text-decoration: none; background: var(--alp-c-gradient-soft); transition: transform .4s var(--alp-c-ease);
}
.alp-catalog-card:hover .alp-catalog-card-media--placeholder { transform: scale(1.07); }

.alp-catalog-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 9px; flex: 1; }

.alp-catalog-diff-badge { align-self: flex-start; font-size: 11.5px; font-weight: 700; color: var(--alp-c-white); padding: 4px 12px; border-radius: var(--alp-c-radius-pill); }
.alp-catalog-diff-badge--basic { background: var(--alp-c-green); }
.alp-catalog-diff-badge--intermediate { background: var(--alp-c-orange); }
.alp-catalog-diff-badge--advanced { background: var(--alp-c-red); }

.alp-catalog-card-title { font-size: 17.5px; font-weight: 700; margin: 0; line-height: 1.45; }
.alp-catalog-card-title a { color: var(--alp-c-ink); text-decoration: none; transition: color .2s var(--alp-c-ease); }
.alp-catalog-card-title a:hover { color: var(--alp-c-primary); }
.alp-catalog-card-excerpt { font-size: 13.5px; color: var(--alp-c-body); font-weight: 500; margin: 0; flex: 1; line-height: 1.7; }

.alp-catalog-card-btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center; margin-top: 10px;
    background: var(--alp-c-bg); color: var(--alp-c-primary); font-weight: 700; font-size: 14px; padding: 12px 18px;
    border-radius: var(--alp-c-radius-sm); text-decoration: none; border: none;
    transition: background .25s var(--alp-c-ease), color .25s var(--alp-c-ease), box-shadow .25s var(--alp-c-ease);
}
.alp-catalog-card-btn span { display: inline-block; transition: transform .25s var(--alp-c-ease); }
.alp-catalog-card-btn:hover { background: var(--alp-c-gradient-brand); color: var(--alp-c-white); box-shadow: 0 8px 20px -4px rgba(79,70,229,.45); }
.alp-catalog-card-btn:hover span { transform: translateX(4px); }

/* ---------- No results ---------- */
.alp-catalog-no-results {
    grid-column: 1 / -1; text-align: center; padding: 68px 20px; font-weight: 600; font-size: 15px; color: var(--alp-c-muted);
    background: var(--alp-c-white); border: 1.5px dashed var(--alp-c-border); border-radius: var(--alp-c-radius);
}
.alp-catalog-no-results::before { content: "🔍"; display: block; font-size: 34px; margin-bottom: 12px; }

/* ---------- Shortcode embed variant ---------- */
.alp-catalog-shortcode { margin: 24px 0; }

/* ============================================================
 * Directory (sitemap category boxes)
 * ============================================================ */
.alp-catalog-directory { column-count: 5; column-gap: 22px; }
.alp-catalog-directory--single { column-count: 1; max-width: 560px; margin: 0 auto; }
@media (min-width: 1680px) { .alp-catalog-directory { column-count: 6; } }
@media (max-width: 1200px) { .alp-catalog-directory { column-count: 4; } }
@media (max-width: 980px)  { .alp-catalog-directory { column-count: 3; } }
@media (max-width: 680px)  { .alp-catalog-directory { column-count: 2; } }
@media (max-width: 460px)  { .alp-catalog-directory { column-count: 1; } }

.alp-catalog-dir-box {
    break-inside: avoid; display: inline-block; width: 100%; margin-bottom: 22px; background: var(--alp-c-white);
    border: 1px solid var(--alp-c-border); border-radius: 18px; box-shadow: var(--alp-c-shadow-sm); overflow: hidden;
    transition: box-shadow .25s var(--alp-c-ease), border-color .25s var(--alp-c-ease), transform .25s var(--alp-c-ease);
}
@media (prefers-reduced-motion: no-preference) { .alp-catalog-dir-box { animation: alpCatalogFadeUp .5s var(--alp-c-ease) both; } }
.alp-catalog-dir-box::before { content: ""; display: block; height: 4px; width: 100%; background: var(--alp-c-gradient-brand); opacity: .8; }
.alp-catalog-dir-box:hover { box-shadow: var(--alp-c-shadow-md); border-color: transparent; transform: translateY(-3px); }

.alp-catalog-dir-box-header { padding: 16px 18px 13px; border-bottom: 1px solid var(--alp-c-bg-soft); font-weight: 700; font-size: 15px; color: var(--alp-c-ink); }
.alp-catalog-dir-box-header a { color: inherit; text-decoration: none; }
.alp-catalog-dir-box-header a:hover { color: var(--alp-c-primary); }

.alp-catalog-dir-box-list { list-style: none; margin: 0; padding: 6px 0; }
.alp-catalog-dir-item { border-bottom: 1px solid var(--alp-c-bg-soft); }
.alp-catalog-dir-item:last-child { border-bottom: none; }
.alp-catalog-dir-item--empty { padding: 14px 18px; color: var(--alp-c-muted); font-weight: 500; font-size: 13.5px; }

.alp-catalog-dir-item a {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 18px; color: var(--alp-c-body);
    text-decoration: none; font-size: 13.8px; font-weight: 600;
    transition: background .18s var(--alp-c-ease), color .18s var(--alp-c-ease), padding-inline-start .18s var(--alp-c-ease);
}
.alp-catalog-dir-item a:hover { background: var(--alp-c-bg-soft); color: var(--alp-c-primary-dark); padding-inline-start: 22px; }
.alp-catalog-dir-item-text { flex: 1; }
.alp-catalog-dir-item-arrow { color: var(--alp-c-muted); font-size: 15px; font-weight: 700; transition: transform .18s var(--alp-c-ease), color .18s var(--alp-c-ease); }
.alp-catalog-dir-item a:hover .alp-catalog-dir-item-arrow { color: var(--alp-c-primary); transform: translateX(3px); }

.alp-catalog-dir-box-more {
    display: block; text-align: center; padding: 12px; font-size: 13px; font-weight: 700; color: var(--alp-c-primary);
    background: var(--alp-c-bg-soft); text-decoration: none; border-top: 1px solid var(--alp-c-border); transition: background .2s var(--alp-c-ease);
}
.alp-catalog-dir-box-more:hover { background: #E2E8FF; }

.alp-catalog-dir-box.is-hidden { display: none; }
.alp-catalog-dir-item.is-hidden { display: none; }

/* ============================================================
 * Listing ad zones (class-alp-catalog-ads.php)
 * ============================================================ */
.alp-catalog-ad-zone {
    position: relative; background: var(--alp-c-white); border: 1px solid var(--alp-c-border);
    border-radius: var(--alp-c-radius-sm); box-shadow: var(--alp-c-shadow-sm); padding: 10px; text-align: center; overflow: hidden;
}
.alp-catalog-ad-zone img { max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: calc(var(--alp-c-radius-sm) - 6px); }
.alp-catalog-ad-label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--alp-c-muted); margin-bottom: 8px; }

.alp-catalog-card--ad { display: flex; align-items: center; justify-content: center; padding: 18px; background: var(--alp-c-bg); }
.alp-catalog-card--ad .alp-catalog-ad-zone { width: 100%; border: none; box-shadow: none; background: transparent; }

.alp-catalog-dir-box--ad { display: flex; align-items: center; justify-content: center; padding: 14px; }
.alp-catalog-dir-box--ad .alp-catalog-ad-zone { width: 100%; border: none; box-shadow: none; background: transparent; }

.alp-catalog-ad-listing-banner { margin: 0 0 22px; }
.alp-catalog-ad-listing-banner--listing_bottom { margin: 22px 0 0; }
.alp-catalog-ad-listing-banner .alp-catalog-ad-zone { max-width: 728px; margin: 0 auto; }
