/* ══════════════════════════════════════════
   TEMPLATES PAGE
   ══════════════════════════════════════════ */

.tpl-hero {
    padding: 92px 24px 28px;
    text-align: center;
    background: linear-gradient(135deg, #EEF2FF 0%, #F5F0FF 50%, #FFF7ED 100%);
    position: relative;
    overflow: hidden;
}

.tpl-hero::before,
.tpl-hero::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.tpl-hero::before {
    width: 480px;
    height: 480px;
    background: rgba(26, 110, 245, .06);
    top: -140px;
    right: -100px;
}

.tpl-hero::after {
    width: 380px;
    height: 380px;
    background: rgba(124, 58, 237, .05);
    bottom: -120px;
    left: -80px;
}

.tpl-hero-inner {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.tpl-hero .pill {
    margin-bottom: 10px;
}

.tpl-hero h1 {
    font-size: clamp(32px, 5vw, 50px);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -1.4px;
    margin-bottom: 10px;
    color: var(--text);
}

.tpl-hero h1 .ac {
    color: var(--blue);
}

.tpl-hero p {
    font-size: 17px;
    color: var(--text2);
    line-height: 1.55;
    margin: 0 auto;
    max-width: 560px;
}

.tpl-toolbar {
    max-width: 1120px;
    margin: -20px auto 0;
    padding: 0 24px;
    position: relative;
    z-index: 5;
}

.tpl-toolbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.tpl-search {
    flex: 1 1 220px;
    min-width: 0;
}

.tpl-search input {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #f8fafc;
}

.tpl-search input:focus {
    border-color: var(--blue);
    background: #fff;
}

.tpl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tpl-chip {
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text2);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    width: auto;
}

.tpl-chip.active,
.tpl-chip:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--blue-light);
}

.tpl-count {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--text3);
    white-space: nowrap;
}

.tpl-section {
    padding: 24px 24px 64px;
}

.ctawrap {
    border-radius: 8px;
}

.tpl-grid {
    max-width: 95%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

.tpl-card {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tpl-live-banner {
    max-width: 1120px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ecfdf5;
    border: 1.5px solid #86efac;
    color: #047857;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

.tpl-card.tpl-live {
    border-color: #86efac;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.08);
}

.tpl-live-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 58px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
}

.tpl-live-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    min-width: 0;
}

.tpl-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    background: #fff;
    color: #047857;
    border: 1.5px solid #34d399;
    border-radius: 6px;
    padding: 5px 11px 5px 9px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .02em;
}

.tpl-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, .55);
    animation: tpl-live-pulse 1.6s ease-out infinite;
    flex-shrink: 0;
}

@keyframes tpl-live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.tpl-live-frame {
    --tpl-frame-h: 700px;
    height: var(--tpl-frame-h);
    background: #f4f7fc;
    flex-shrink: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

.tpl-live-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #fff;
}

/*
 * Multi-column test.navforms.com forms: form-chrome-stack is ~50% of the
 * iframe viewport. Widen the iframe so 2-col rows stay on one line, then
 * scale down so the preview is not zoomed-in relative to 1-col cards.
 */
.tpl-live-frame--fill {
    --tpl-form-wdh: 0.5;
    --tpl-zoom: 0.68;
    container-type: inline-size;
}

.tpl-live-frame--fill iframe {
    position: absolute;
    top: 0;
    left: 50%;
    width: calc(100cqw / var(--tpl-form-wdh));
    height: calc(100% / var(--tpl-zoom));
    transform: translateX(-50%) scale(var(--tpl-zoom));
    transform-origin: top center;
}

.tpl-card-body {
    display: flex;
    flex-direction: column;
    padding: 16px 18px 18px;
    flex: 1 1 auto;
}

.tpl-card-body p {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--text2);
    line-height: 1.65;
    flex: 1 1 auto;
}

.tpl-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.tpl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    width: auto;
}

.tpl-btn-primary {
    background: var(--blue);
    color: #fff;
}

.tpl-btn-primary:hover {
    color: #fff;
    background: var(--blue2);
}

.tpl-btn-ghost {
    background: var(--blue-light);
    color: var(--blue);
}

.tpl-btn-ghost:hover {
    color: var(--blue2);
}

.tpl-empty {
    display: none;
    max-width: 1120px;
    margin: 24px auto 0;
    text-align: center;
    color: var(--text3);
    font-size: 15px;
}

.tpl-card.is-hidden {
    display: none !important;
}

.tpl-card:not(.is-hidden).aos-animate,
.tpl-grid.is-filtered .tpl-card:not(.is-hidden) {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
}

@media (max-width: 991px) {
    .tpl-grid {
        grid-template-columns: 1fr;
    }

    .tpl-live-frame {
        --tpl-frame-h: 640px;
    }
}

@media (max-width: 767px) {
    .tpl-hero {
        padding: 80px 16px 22px;
    }

    .tpl-hero h1 {
        font-size: clamp(28px, 8vw, 36px);
        letter-spacing: -0.8px;
    }

    .tpl-hero p {
        font-size: 15px;
    }

    .tpl-toolbar {
        margin-top: -16px;
        padding: 0 16px;
    }

    .tpl-toolbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    /* Column flex makes the 220px basis a height, not a width. */
    .tpl-search {
        flex: 0 0 auto;
    }

    .tpl-count {
        margin-left: 0;
    }

    .tpl-section {
        padding: 20px 16px 48px;
    }

    .tpl-grid {
        gap: 16px;
    }

    .tpl-live-banner {
        font-size: 13px;
        padding: 10px 12px;
    }

    .tpl-live-bar {
        min-height: 52px;
        padding: 10px 14px;
    }

    .tpl-live-title {
        font-size: 14px;
    }

    .tpl-live-frame {
        /* 560px of form + room for the scrollbar the frame now always shows */
        --tpl-frame-h: 576px;
    }

    /*
     * A phone-width iframe would flip the form into its own mobile layout, so
     * pin the viewport to the desktop width and pan the preview instead.
     */
    .tpl-live-frame--fill {
        --tpl-frame-vw: 1080px;
        /* scroll, not auto, so the bar stays on screen as a visible cue */
        overflow-x: scroll;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: auto;
        scrollbar-color: var(--blue) #dbe3ee;
        border-bottom: 1px solid var(--border);
    }

    .tpl-live-frame--fill iframe {
        position: static;
        width: var(--tpl-frame-vw);
        height: calc(100% / var(--tpl-zoom));
        /* Trim the layout box to the scaled width so the scroll range matches. */
        margin-right: calc(var(--tpl-frame-vw) * (var(--tpl-zoom) - 1));
        transform: scale(var(--tpl-zoom));
        transform-origin: top left;
    }

    .tpl-live-frame--fill::-webkit-scrollbar {
        -webkit-appearance: none;
        height: 16px;
    }

    .tpl-live-frame--fill::-webkit-scrollbar-track {
        background: #dbe3ee;
        border-top: 1px solid var(--border);
    }

    .tpl-live-frame--fill::-webkit-scrollbar-thumb {
        min-width: 64px;
        background: var(--blue);
        border: 4px solid #dbe3ee;
        border-radius: 8px;
    }

    .tpl-card-body {
        padding: 14px 16px 16px;
    }

    .tpl-btn {
        width: 100%;
    }
}
