/* =========================================================
   Full-Page Template Gallery — listing (/page-templates) + single
   (/page-templates/<slug>). System A / website chrome.
========================================================= */

/* ── Hero (matches the site's page-hero pattern — see .tools-hero / .ss-hero) ── */
.reveal {
    animation: pt-reveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    animation-delay: calc(var(--d, 0) * 80ms);
}
@keyframes pt-reveal {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pt-gallery { width: 100%; }
/* Hero is full-width (direct child of main); the toolbar + grid stay constrained. */
.pt-gallery-body { max-width: 1200px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
/* Hero uses the shared site hero — templates/page-hero.php +
   assets/css/components/page-hero.css (loaded globally via main.css).
   It is a full-width child of main now (see .pt-gallery / .pt-gallery-body). */

/* ── Toolbar: category filter pills (same primitive as Section Studio's) ── */
.pt-toolbar { display: flex; align-items: center; padding-bottom: var(--space-5); margin-bottom: var(--space-6); border-bottom: 1px solid var(--border-primary); }
.ss-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
/* The pills are <a> here (real links to the category landing pages), so they
   need the anchor resets a <button> didn't — the rest is the shared primitive. */
.ss-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 999px;
    padding: 0.4rem 0.95rem;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.ss-pill:hover { color: var(--text-primary); border-color: var(--border-secondary); text-decoration: none; }
.ss-pill.is-on { color: var(--text-inverse); background: var(--color-primary); border-color: transparent; }
.ss-pill.is-on:hover { color: var(--text-inverse); }
.ss-pill:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.pt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.25rem; }
.pt-tcard {
    display: flex;
    flex-direction: column;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.pt-tcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-secondary); }
.pt-tcard-media { display: block; text-decoration: none; }

/* ── Thumbnail (composed section preview, cropped to a peek — same window-chrome
   pattern as Section Studio's card thumbnails: .ss-chrome / .ss-card-thumb) ── */
.ss-chrome {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.7rem;
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-subtle);
}
.ss-chrome-dots { display: inline-flex; gap: 5px; flex: 0 0 auto; }
.ss-chrome-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-secondary); }
.ss-chrome-bar { flex: 1; height: 15px; border-radius: 8px; background: var(--surface-primary); border: 1px solid var(--border-subtle); }

.ss-card-thumb { position: relative; overflow: hidden; background: var(--surface-secondary); }
.pt-tcard-thumb { height: 210px; pointer-events: none; }

/* Generated screenshot (shipped default design language). Shown to visitors who
   have no design language of their own — for them it is identical to the live
   render — and to crawlers, which cannot see the iframe at all. Removed from the
   flow the moment a live preview paints, so a user with their own tokens never
   sees both. */
.pt-tcard-shot {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}
.pt-tcard-thumb.is-loaded .pt-tcard-shot { display: none; }
/* With a screenshot present the scale layer starts hidden, so the image is not
   briefly overlaid by an empty preview surface before it mounts. */
.pt-tcard-thumb.has-shot .ss-thumb-scale { opacity: 0; }
.pt-tcard-thumb.has-shot.is-loaded .ss-thumb-scale { opacity: 1; }
.ss-thumb-scale { position: relative; }
.ss-thumb-scale iframe { display: block; width: 100%; border: 0; }
.ss-thumb-skeleton { position: absolute; inset: 0; background: var(--surface-secondary); transition: opacity 0.25s ease; }
.pt-tcard-thumb.is-loaded .ss-thumb-skeleton { opacity: 0; }

/* Section count — an overlay badge on the thumbnail rather than a text row in
   the card body, since the preview underneath can be any template's own
   colors/theme: a fixed dark/blur chip stays legible regardless. */
.pt-tcard-count {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    z-index: 2;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(17, 17, 22, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.pt-tcard-body { display: flex; flex-direction: column; flex: 1; gap: 0.55rem; padding: 1.25rem 1.5rem 1.5rem; }
.pt-tcard-cat {
    align-self: flex-start;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
}
.pt-tcard-name { margin: 0.25rem 0 0; font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.pt-tcard-tag { margin: 0; font-size: 0.95rem; color: var(--text-secondary); }
.pt-tcard-flow { margin: 0.35rem 0 0; font-size: 0.82rem; line-height: 1.5; color: var(--text-muted); }

/* Two actions: a quiet "View template" (→ the SEO detail page) and the solid
   "Customize" primary (→ straight into the Page Builder, skipping the detail page). */
.pt-tcard-actions { margin-top: auto; padding-top: 0.85rem; display: flex; align-items: center; gap: 0.6rem; }
.pt-tcard-view {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}
/* color repeated (not just text-decoration) — .pt-tcard-view is an <a>, and the
   global `a:hover { color: var(--color-primary) }` in typography.css happens
   to match today, but only by coincidence; lock it so that stays true. */
.pt-tcard-view:hover { color: var(--color-primary); text-decoration: underline; }
.pt-tcard-customize {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-inverse);
    background: var(--color-primary);
    border: 0;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background 0.18s ease, box-shadow 0.18s ease;
}
.pt-tcard-customize:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); }
.pt-tcard-customize:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ── Single template page ────────────────────────────── */
.pt-page { padding-bottom: 5rem; }
.pt-page-inner { max-width: 1200px; margin: 0 auto; padding: 2.5rem 1.5rem 0; }

/* Hero reuses the site's tool-detail hero (.tool-hero-section, see
   components/tool-shell.css) — same pattern as every builder tool page.
   The old absolutely-positioned .pt-back link was replaced by the shared
   breadcrumb (templates/sections/breadcrumb.php, styled in
   components/page-hero.css), which carries the same link plus the category. */

/* Floating "Customize" — bottom-left, hidden until the hero scrolls out of
   view (same reveal pattern as Section Studio's .ss-floatbar). */
.pt-float-customize {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 900;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-inverse);
    background: var(--color-primary);
    border: 0;
    border-radius: 999px;
    padding: 0.75rem 1.3rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}
.pt-float-customize.is-visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: no-preference) {
    .pt-float-customize.is-visible { animation: ptFloatIn 0.34s cubic-bezier(0.34, 1.18, 0.64, 1); }
}
@keyframes ptFloatIn {
    from { transform: translateY(calc(100% + 40px)); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.pt-float-customize:hover { background: var(--color-primary-hover); }
.pt-float-customize:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.pt-preview-wrap {
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 0.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2.5rem;
}
.pt-preview { border-radius: 10px; overflow: hidden; background: var(--surface-primary); min-height: 320px; }
.pt-preview iframe { display: block; width: 100%; border: 0; }

/* Section headings, intros, the FAQ accordion and the cross-link grid are NOT
   defined here: both template pages use the shared SEO body sections
   (.tool-seo-*, assets/css/components/seo-sections.css) rendered by
   templates/seo-sections.php — the same components the builder pages use. */

/* Hero deck — the registry tagline, leading the longer description. */
.pt-deck {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.15em;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── "When to use" + "At a glance", side by side on desktop ── */
.pt-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 2rem; margin-bottom: 3rem; }
.pt-when-lead { margin: 0 0 0.85rem; font-size: 1.02rem; line-height: 1.65; color: var(--text-primary); }
.pt-when-detail { margin: 0; font-size: 0.97rem; line-height: 1.65; color: var(--text-secondary); }

.pt-specs-list { margin: 0; padding: 0; border-top: 1px solid var(--border-primary); }
.pt-spec-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.92rem;
}
.pt-spec-row dt { color: var(--text-secondary); }
.pt-spec-row dd { margin: 0; text-align: right; font-weight: 600; color: var(--text-primary); }

/* ── Section walkthrough ── */
.pt-included-intro { margin: 0 0 1.25rem; font-size: 0.97rem; line-height: 1.6; color: var(--text-secondary); max-width: 70ch; }
.pt-walk { list-style: none; margin: 0; padding: 0; counter-reset: pt; display: grid; gap: 0.6rem; }
.pt-walk-item {
    counter-increment: pt;
    position: relative;
    padding: 0.9rem 1.15rem 0.9rem 3.1rem;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
}
.pt-walk-item::before {
    content: counter(pt, decimal-leading-zero);
    position: absolute;
    top: 0.95rem;
    left: 1.15rem;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-primary);
}
.pt-walk-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.pt-walk-name { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.pt-walk-cat {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.pt-walk-summary { margin: 0; font-size: 0.93rem; line-height: 1.6; color: var(--text-secondary); }

/* ── Category landing body (page-type index + composition) ───────────────────
   Only used by /page-templates/<category>. The wrapper, headings, intros, FAQ
   and cross-links come from the shared .tool-seo-* component; only the two
   blocks with no shared equivalent — the page-type cards and the section-type
   chips — are defined here. */
.pt-types-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-3);
}
.pt-type {
    padding: var(--space-5) var(--space-5);
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
}
.pt-type-name { margin: 0 0 var(--space-2); font-size: var(--text-base); font-weight: var(--font-bold); color: var(--text-primary); }
.pt-type-copy { margin: 0 0 var(--space-4); font-size: var(--text-sm); line-height: var(--leading-relaxed); color: var(--text-secondary); }
.pt-type-links { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.pt-type-links li { display: flex; flex-direction: column; gap: 0.1rem; }
.pt-type-links a { font-size: var(--text-sm); font-weight: var(--font-semi-bold); color: var(--text-primary); text-decoration: none; }
.pt-type-links a:hover { color: var(--color-primary); text-decoration: underline; }
.pt-type-meta { font-size: var(--text-xs); line-height: 1.5; color: var(--text-muted); }

/* Section-type chips — the category's composition at a glance. */
.pt-built-types { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pt-built-type {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 999px;
}
.pt-built-type em { font-style: normal; font-weight: var(--font-bold); color: var(--text-primary); }

/* Trailing "see everything" link under a shared cross-link grid. */
.pt-built-foot,
.pt-seo-more { margin: 0; font-size: var(--text-sm); font-weight: var(--font-semi-bold); }
.pt-built-foot a,
.pt-seo-more a { color: var(--color-primary); text-decoration: none; }
.pt-built-foot a:hover,
.pt-seo-more a:hover { text-decoration: underline; }

@media (max-width: 860px) {
    .pt-cols { grid-template-columns: 1fr; gap: 2.25rem; }
}

@media (max-width: 560px) {
    .pt-page-title { font-size: 1.9rem; }
    .pt-tcard-thumb { height: 160px; }
    .pt-walk-item { padding-left: 1.15rem; padding-top: 2rem; }
    .pt-walk-item::before { top: 0.7rem; }
}
