/* ========================================
   THEME GALLERY — /temi/
   Extends public.css patterns (section-tag, section-title, container)
   ======================================== */

/* ── Hero ── */
.tg-hero {
    padding: 120px 0 64px;
    text-align: center;
    background: linear-gradient(180deg, var(--public-surface) 0%, var(--public-bg) 100%);
}

.tg-hero-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--public-white);
    letter-spacing: -1.5px;
    line-height: 1.15;
    margin: 16px 0;
}

.tg-hero-title em {
    font-style: italic;
    color: var(--public-accent);
}

.tg-hero-desc {
    font-size: 1.1rem;
    color: var(--public-text-muted);
    max-width: 580px;
    margin: 0 auto;
    line-height: 1.7;
}

.tg-hero-desc strong {
    color: var(--public-white);
    font-weight: 600;
}

.tg-hero-badges {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.tg-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--public-text);
    background: var(--public-surface);
    border: 1px solid var(--public-border);
    border-radius: 4px;
}

/* ── Category section ── */
.tg-category {
    padding: 64px 0;
    border-top: 1px solid var(--public-border);
}

.tg-category:nth-child(even) {
    background: var(--public-surface);
}

.tg-cat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.tg-cat-icon {
    font-size: 1.5rem;
}

.tg-cat-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--public-white);
    letter-spacing: -0.5px;
}

.tg-cat-count {
    padding: 3px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--public-text-muted);
    background: var(--public-surface-2);
    border: 1px solid var(--public-border);
    border-radius: 4px;
}

/* ── Grid ── */
.tg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* ── Card ── */
.tg-card {
    position: relative;
    background: var(--public-surface);
    border: 1px solid var(--public-border);
    border-radius: var(--public-radius);
    overflow: hidden;
    transition: all 0.3s ease;
}

.tg-card:hover {
    border-color: rgba(255,107,0,0.3);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.08);
}

/* ── Thumbnail (iframe miniature) ── */
.tg-card-thumb {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: var(--public-surface-2);
    border-bottom: 1px solid var(--public-border);
}

.tg-iframe {
    width: 1280px;
    height: 900px;
    border: none;
    transform-origin: top left;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    /* Scala calcolata da JS in base alla larghezza reale del container */
    transform: scale(0.26);
}

.tg-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    cursor: pointer;
    z-index: 1;
}

/* Loading spinner */
.tg-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--public-surface-2);
    z-index: 2;
    transition: opacity 0.4s ease;
}

.tg-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--public-border);
    border-top-color: var(--public-accent);
    border-radius: 50%;
    animation: tg-spin 0.7s linear infinite;
}

@keyframes tg-spin {
    to { transform: rotate(360deg); }
}

.tg-loading-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--public-text-dim);
}

/* Hide loading when iframe loaded */
.tg-card-thumb.loaded .tg-loading {
    opacity: 0;
    pointer-events: none;
}

/* ── Color dots ── */
.tg-card-colors {
    display: flex;
    gap: 6px;
    padding: 12px 16px 0;
}

.tg-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tg-dot-bordered {
    border: 1.5px solid var(--public-border);
}

/* ── Card info ── */
.tg-card-info {
    padding: 8px 16px 14px;
}

.tg-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--public-white);
    margin: 0;
}

.tg-card-font {
    display: block;
    font-size: 0.75rem;
    color: var(--public-text-dim);
    margin-top: 2px;
}

/* ── Preview button ── */
.tg-preview-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--public-accent);
    background: rgba(255,107,0,0.08);
    border: 1px solid rgba(255,107,0,0.2);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.25s ease;
    z-index: 2;
}

.tg-card:hover .tg-preview-btn {
    opacity: 1;
    transform: translateY(0);
}

.tg-preview-btn:hover {
    background: rgba(255,107,0,0.15);
    border-color: rgba(255,107,0,0.4);
}

/* ── Custom Theme CTA ── */
.tg-custom-cta {
    padding: 80px 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
}

.tg-custom-inner {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 48px;
    align-items: center;
}

.tg-custom-cta .section-tag {
    background: rgba(255,107,0,0.15);
    border-color: rgba(255,107,0,0.3);
    color: #fb923c;
}

.tg-custom-title {
    font-size: 2rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin: 12px 0;
}

.tg-custom-desc {
    font-size: 1rem;
    color: #94a3b8;
    line-height: 1.7;
    margin-bottom: 20px;
}

.tg-custom-features {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 28px;
}

.tg-custom-features li {
    font-size: 0.88rem;
    color: #cbd5e1;
}

.tg-custom-visual {
    display: flex;
    justify-content: center;
}

.tg-custom-mockup {
    width: 220px;
    height: 280px;
    background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.tg-custom-palette {
    display: flex;
    gap: 10px;
}

.tg-custom-palette span {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
}

.tg-custom-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* ── Bottom CTA ── */
.tg-bottom-cta {
    padding: 80px 0;
    background: linear-gradient(180deg, var(--public-bg) 0%, var(--public-surface) 100%);
    border-top: 1px solid var(--public-border);
    text-align: center;
}

.tg-new-themes-notice {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--public-accent-soft);
    border: 1px solid rgba(255,107,0,0.15);
    border-radius: var(--public-radius);
    margin-bottom: 32px;
}

.tg-notice-icon {
    font-size: 1.2rem;
}

.tg-new-themes-notice p {
    font-size: 0.88rem;
    color: var(--public-text);
    margin: 0;
    text-align: left;
}

.tg-cta-inner h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--public-white);
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.tg-cta-inner p {
    font-size: 1.05rem;
    color: var(--public-text-muted);
    margin-bottom: 24px;
}

/* ── Fullscreen Modal ── */
.tg-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
}

.tg-modal.hidden {
    display: none;
}

.tg-modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--public-surface);
    border-bottom: 1px solid var(--public-border);
    flex-shrink: 0;
}

.tg-modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--public-white);
}

.tg-modal-viewports {
    display: flex;
    gap: 4px;
}

.tg-vp {
    width: 36px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
}

.tg-vp:hover {
    background: var(--public-surface-2);
}

.tg-vp.active {
    background: var(--public-accent-soft);
    border-color: rgba(255,107,0,0.2);
}

.tg-modal-x {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--public-text-muted);
    background: none;
    border: 1px solid var(--public-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tg-modal-x:hover {
    color: var(--public-white);
    background: var(--public-surface-2);
}

.tg-modal-body {
    flex: 1;
    display: flex;
    justify-content: center;
    background: #e2e8f0;
    overflow: hidden;
}

.tg-modal-iframe {
    width: 100%;
    max-width: 100%;
    height: 100%;
    border: none;
    background: white;
    transition: max-width 0.35s ease;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .tg-hero-title { font-size: 2.4rem; }
    .tg-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 640px) {
    .tg-hero { padding: 100px 0 48px; }
    .tg-hero-title { font-size: 1.8rem; letter-spacing: -1px; }
    .tg-hero-desc { font-size: 0.95rem; }
    .tg-hero-badges { gap: 8px; }
    .tg-badge { font-size: 0.72rem; padding: 5px 12px; }
    .tg-category { padding: 48px 0; }
    .tg-grid { grid-template-columns: 1fr; gap: 16px; }
    .tg-card-thumb { height: 180px; }
    .tg-preview-btn { opacity: 1; transform: none; }
    .tg-custom-inner { grid-template-columns: 1fr; }
    .tg-custom-visual { display: none; }
    .tg-custom-title { font-size: 1.5rem; }
    .tg-custom-features { grid-template-columns: 1fr; }
    .tg-cta-inner h2 { font-size: 1.5rem; }
}

/* ── Filter Bar ── */
.tg-filters { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,0.95); backdrop-filter: blur(12px); border-bottom: 1px solid #e5e7eb; padding: 12px 0; }
.tg-filters-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tg-filter-pills { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.tg-pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 50px; border: 1px solid #e5e7eb; background: white; color: #4b5563; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.tg-pill:hover { border-color: #9333ea; color: #9333ea; }
.tg-pill.active { background: #9333ea; color: white; border-color: #9333ea; }
.tg-pill-count { font-size: 0.75rem; opacity: 0.7; }
.tg-pill.active .tg-pill-count { opacity: 0.9; }
.tg-search-box { flex-shrink: 0; }
.tg-search-input { padding: 6px 14px; border-radius: 50px; border: 1px solid #e5e7eb; font-size: 0.85rem; width: 200px; outline: none; transition: border-color 0.2s; }
.tg-search-input:focus { border-color: #9333ea; }
@media (max-width: 768px) {
    .tg-filters-row { flex-direction: column; align-items: stretch; }
    .tg-filter-pills { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
    .tg-search-input { width: 100%; }
}
