/* ═══════════════════════════════════════════════════════════════════════════
   Static /training page: creator hero + official / community catalogue.
   Builds on site.css. The cards mirror the app's TemplateCard (training.css).
   ═══════════════════════════════════════════════════════════════════════════ */

.tp-hero {
    position: relative;
    padding: calc(var(--nav-h) + clamp(40px, 6vw, 80px)) 0 clamp(48px, 6vw, 80px);
    overflow: clip;
    isolation: isolate;
}

.tp-hero::before {
    content: "";
    position: absolute;
    inset: -30% -10% auto;
    z-index: -1;
    height: 130%;
    background:
        radial-gradient(40% 50% at 78% 40%, rgba(var(--brand-glow), 0.26), transparent 70%),
        radial-gradient(30% 40% at 10% 0%, rgba(167, 139, 250, 0.1), transparent 70%);
    pointer-events: none;
}

.tp-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: clamp(32px, 5vw, 72px);
    align-items: center;
}

.tp-hero-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 22px;
}

.tp-hero-copy > * {
    animation: tp-rise 800ms var(--ease-out) both;
}

.tp-hero-copy > :nth-child(2) { animation-delay: 60ms; }
.tp-hero-copy > :nth-child(3) { animation-delay: 120ms; }
.tp-hero-copy > :nth-child(4) { animation-delay: 180ms; }

@keyframes tp-rise {
    from {
        opacity: 0;
        transform: translateY(16px);
        filter: blur(6px);
    }
}

.tp-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2.3rem, 5vw, 4rem);
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.035em;
    text-wrap: balance;
}

.tp-ctas {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* How the creator works: four steps on one rail */
.tp-steps {
    position: relative;
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.tp-steps::before {
    content: "";
    position: absolute;
    top: 30px;
    bottom: 30px;
    left: 33px;
    width: 2px;
    background: linear-gradient(var(--brand-bright), transparent);
    opacity: 0.4;
}

.tp-step {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--glass);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    animation: tp-rise 800ms var(--ease-out) both;
}

.tp-step:nth-child(1) { animation-delay: 150ms; }
.tp-step:nth-child(2) { animation-delay: 220ms; }
.tp-step:nth-child(3) { animation-delay: 290ms; }
.tp-step:nth-child(4) { animation-delay: 360ms; }

.tp-step-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    font-size: 15px;
    box-shadow: 0 0 0 5px var(--bg);
}

.tp-step b {
    display: block;
    font-size: 0.98rem;
    font-weight: 600;
}

.tp-step span {
    color: var(--text-2);
    font-size: 0.9rem;
    line-height: 1.5;
}

@media (max-width: 960px) {
    .tp-hero-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Catalogue ── */
.cat {
    padding: 0 0 clamp(72px, 9vw, 120px);
}

.cat-bar {
    position: sticky;
    top: var(--nav-h);
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding: 14px 0;
    background: linear-gradient(var(--bg) 70%, transparent);
}

.cat-bar h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.cat-search {
    position: relative;
    flex: 0 1 420px;
}

.cat-search i.bi-search {
    position: absolute;
    top: 50%;
    left: 16px;
    color: var(--text-3);
    transform: translateY(-50%);
    pointer-events: none;
}

.cat-search input {
    width: 100%;
    height: 48px;
    padding: 0 44px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

.cat-search input::placeholder {
    color: var(--text-3);
}

.cat-search input:focus {
    border-color: var(--brand-bright);
    box-shadow: 0 0 0 4px rgba(var(--brand-glow), 0.18);
}

.cat-clear {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transform: translateY(-50%);
}

.cat-clear[hidden] {
    display: none;
}

.cat-section + .cat-section {
    margin-top: 56px;
}

.cat-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: rgba(var(--brand-glow), 0.14);
    color: var(--accent-text);
    font-size: 20px;
}

.cat-section.is-community .cat-icon {
    background: rgba(167, 139, 250, 0.14);
    color: var(--violet);
}

.cat-head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.cat-head p {
    margin: 2px 0 0;
    color: var(--text-2);
    font-size: 0.92rem;
}

.cat-count {
    margin-left: auto;
    color: var(--text-3);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.cat-empty {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
    color: var(--text-2);
}

.cat-empty i {
    color: var(--text-3);
    font-size: 20px;
}

.cat-empty .btn {
    margin-left: auto;
}

.cat-more {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

/* ── Template cards ── */
.tc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.tc-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    transition: transform 250ms var(--ease-out), box-shadow 250ms ease, border-color 250ms ease;
    animation: tc-in 500ms var(--ease-out) both;
    animation-delay: var(--d, 0ms);
}

.tc-card:active {
    transform: scale(0.98);
}

@keyframes tc-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

@media (hover: hover) and (pointer: fine) {
    .tc-card:hover {
        transform: translateY(-4px);
        border-color: rgba(var(--brand-glow), 0.6);
        box-shadow: var(--shadow-md);
    }

    .tc-card:hover .tc-cover img {
        transform: scale(1.05);
    }
}

.tc-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, hsl(var(--tc-hue, 215) 45% 32%), hsl(calc(var(--tc-hue, 215) + 40) 50% 22%));
    color: rgba(255, 255, 255, 0.75);
    font-size: 34px;
}

.tc-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms var(--ease-out);
}

.tc-pill {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

.tc-pill.is-official {
    right: auto;
    left: 10px;
    background: rgba(34, 76, 150, 0.9);
}

.tc-body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 14px 16px 16px;
}

.tc-name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow-wrap: anywhere;
}

.tc-author {
    color: var(--text-2);
    font-size: 0.82rem;
}

.tc-desc {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-3);
    font-size: 0.82rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.tc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
    color: var(--text-2);
    font-size: 0.8rem;
}

.tc-skeleton {
    animation: none;
    pointer-events: none;
}

.skel {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: skel 1.3s ease-in-out infinite;
}

.tc-skeleton .tc-cover {
    border-radius: 0;
}

.skel-line {
    height: 12px;
}

.skel-line.is-short {
    width: 55%;
}

@keyframes skel {
    from { background-position: 100% 50%; }
    to { background-position: 0 50%; }
}

/* ── Closing band ── */
.tp-band {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: clamp(28px, 4vw, 44px);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(60% 120% at 100% 0%, rgba(var(--brand-glow), 0.2), transparent 60%),
        var(--surface);
}

.tp-band h2 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.6vw, 2rem);
    letter-spacing: -0.025em;
}

.tp-band p {
    margin: 0;
    color: var(--text-2);
}

@media (max-width: 560px) {
    .cat-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .cat-search {
        flex-basis: auto;
    }

    .cat-count {
        display: none;
    }

    .cat-empty {
        flex-wrap: wrap;
    }

    .cat-empty .btn {
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tp-hero-copy > *,
    .tp-step,
    .tc-card {
        animation: tp-fade 300ms ease both;
    }

    .skel {
        animation: none;
    }

    .tc-card:active,
    .tc-card:hover {
        transform: none;
    }
}

@keyframes tp-fade {
    from { opacity: 0; }
}

@media (prefers-reduced-transparency: reduce) {
    .tp-step {
        background: var(--surface);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}
