/* ==========================================================================
   Landing page design gallery (_gallery.blade.php) and full preview
   (_preview_modal.blade.php). Behaviour: public/refactor/js/FunnelGallery.js.
   Shared by "New landing page", "Add page" and "Change design".
   ========================================================================== */

/* ── Toolbar: search + category chips ─────────────────────────────────── */
.lpg-toolbar { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.lpg-search {
    display: flex; align-items: center; gap: var(--space-2);
    max-width: 360px; height: var(--input-height, 40px); padding: 0 var(--space-3);
    border: var(--space-px) solid var(--color-border); border-radius: var(--radius-input, var(--radius-md));
    background: var(--color-surface); color: var(--color-text-muted);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.lpg-search:focus-within { border-color: var(--color-border-focus, var(--color-primary)); box-shadow: var(--focus-ring); }
.lpg-search .material-symbols-rounded { font-size: 20px; }
.lpg-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--color-text); font: inherit; font-size: var(--text-sm); }
.lpg-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.lpg-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--space-3);
    border: var(--space-px) solid var(--color-border); border-radius: var(--radius-full);
    background: var(--color-surface); color: var(--color-text-secondary);
    font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.lpg-chip:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.lpg-chip.is-active { background: var(--color-text); border-color: var(--color-text); color: var(--color-bg); }
.lpg-chip:focus-visible, .lpg-thumb:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.lpg-chip-count { font-size: var(--text-xs); opacity: .65; font-variant-numeric: tabular-nums; }
.lpg-goal-pill {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 var(--space-3);
    border-radius: var(--radius-full); background: var(--color-primary-light); color: var(--color-primary);
    font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.lpg-goal-pill .material-symbols-rounded { font-size: 16px; }
.lpg-goal-pill button {
    display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
    border: 0; border-radius: var(--radius-full); background: transparent; color: inherit; cursor: pointer;
}
.lpg-goal-pill button:hover { background: var(--color-primary-ring); }

/* ── Grid and cards ───────────────────────────────────────────────────── */
.lpg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-5); }
.lpg-card { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.lpg-card[hidden] { display: none; }
.lpg-thumb {
    position: relative; aspect-ratio: 4 / 3; overflow: hidden; cursor: zoom-in;
    border: var(--space-px) solid var(--color-border); border-radius: var(--radius-lg);
    background: var(--color-bg-subtle);
    transition: border-color var(--transition-fast), box-shadow var(--transition-normal), transform var(--transition-normal);
}
.lpg-thumb .mc-live-thumb { position: absolute; inset: 0; }
.lpg-card:hover .lpg-thumb { border-color: var(--color-border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.lpg-card.is-selected .lpg-thumb { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-ring); }
.lpg-zoom {
    position: absolute; left: 50%; bottom: var(--space-3); transform: translate(-50%, 6px);
    display: inline-flex; align-items: center; gap: 6px; padding: 6px var(--space-3);
    border-radius: var(--radius-full); background: rgba(16, 24, 40, .82); color: #fff;
    font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.lpg-zoom .material-symbols-rounded { font-size: 16px; }
.lpg-card:hover .lpg-zoom, .lpg-thumb:focus-visible .lpg-zoom { opacity: 1; transform: translate(-50%, 0); }
.lpg-check {
    position: absolute; top: var(--space-2); right: var(--space-2);
    display: none; align-items: center; justify-content: center; width: 28px; height: 28px;
    border-radius: var(--radius-full); background: var(--color-primary); color: var(--color-primary-fg, #fff);
    box-shadow: var(--shadow-sm);
}
.lpg-check .material-symbols-rounded { font-size: 18px; }
.lpg-card.is-selected .lpg-check { display: inline-flex; }
.lpg-blank {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: repeating-linear-gradient(45deg, transparent 0 10px, var(--color-bg-muted, var(--color-hover-bg)) 10px 11px);
    color: var(--color-text-tertiary, var(--color-text-muted));
}
.lpg-blank .material-symbols-rounded { font-size: 44px; }
.lpg-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.lpg-meta-text { display: flex; flex-direction: column; min-width: 0; }
.lpg-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lpg-tag { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lpg-use { flex: none; }
.lpg-desc {
    margin: calc(-1 * var(--space-1)) 0 0; font-size: var(--text-xs); line-height: 1.45; color: var(--color-text-muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lpg-card.is-selected .lpg-use { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-fg, #fff); }
.lpg-empty {
    display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: var(--space-10) var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm);
    border: var(--space-px) dashed var(--color-border); border-radius: var(--radius-lg);
}
.lpg-empty[hidden] { display: none; }

/* Inside popups the gallery scrolls on its own. */
.mc-modal .lpg-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4); max-height: 52vh; overflow-y: auto; padding: 4px; }

/* ── Preview modal ────────────────────────────────────────────────────── */
html.lpv-open { overflow: hidden; }
.lpv {
    position: fixed; inset: 0; z-index: calc(var(--z-modal, 1050) + 10);
    display: flex; padding: var(--space-4);
    background: rgba(9, 9, 20, .72); backdrop-filter: blur(4px);
}
.lpv[hidden] { display: none; }
.lpv-panel {
    display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden;
    border-radius: var(--radius-xl); background: var(--color-surface); box-shadow: var(--shadow-xl);
}
.lpv-bar {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4); border-bottom: var(--space-px) solid var(--color-border);
}
.lpv-heading { display: flex; flex-direction: column; min-width: 0; }
.lpv-heading strong { font-size: var(--text-md, var(--text-base)); color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lpv-heading span { font-size: var(--text-xs); color: var(--color-text-muted); }
.lpv-devices { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--color-bg-subtle); }
.lpv-device {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 30px;
    border: 0; border-radius: calc(var(--radius-md) - 2px); background: transparent; color: var(--color-text-muted); cursor: pointer;
}
.lpv-device .material-symbols-rounded { font-size: 20px; }
.lpv-device:hover { color: var(--color-text); }
.lpv-device.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-xs); }
.lpv-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-2); }
.lpv-close {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
    border: 0; border-radius: var(--radius-full); background: transparent; color: var(--color-text-muted); cursor: pointer;
}
.lpv-close:hover { background: var(--color-hover-bg); color: var(--color-text); }
.lpv-device:focus-visible, .lpv-close:focus-visible, .lpv-step:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.lpv-steps {
    display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-4); overflow-x: auto;
    border-bottom: var(--space-px) solid var(--color-border); background: var(--color-bg-subtle);
}
.lpv-steps[hidden] { display: none; }
.lpv-step {
    display: inline-flex; align-items: center; gap: var(--space-2); flex: none; height: 32px; padding: 0 var(--space-3) 0 4px;
    border: var(--space-px) solid var(--color-border); border-radius: var(--radius-full);
    background: var(--color-surface); color: var(--color-text-secondary); font: inherit; font-size: var(--text-sm); cursor: pointer;
}
.lpv-step-n {
    display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
    border-radius: var(--radius-full); background: var(--color-bg-subtle); font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.lpv-step.is-active { border-color: var(--color-primary); color: var(--color-primary); }
.lpv-step.is-active .lpv-step-n { background: var(--color-primary); color: var(--color-primary-fg, #fff); }
.lpv-stage {
    flex: 1; min-height: 0; display: flex; justify-content: center; padding: var(--space-4);
    background: var(--color-bg-subtle); overflow: hidden;
}
.lpv-wrap {
    position: relative; overflow: hidden; background: #fff;
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    transition: width var(--transition-normal);
}
.lpv[data-device="mobile"] .lpv-wrap, .lpv[data-device="tablet"] .lpv-wrap {
    border-radius: 28px; outline: 8px solid var(--gray-900, #101828); outline-offset: 0;
}
.lpv-wrap iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #fff; }

@media (max-width: 700px) {
    .lpv { padding: 0; }
    .lpv-panel { border-radius: 0; }
    .lpv-bar { grid-template-columns: 1fr auto; }
    .lpv-devices { display: none; }
    .lpg-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-4); }
    .lpg-meta { flex-direction: column; align-items: stretch; }
    .lpg-use { width: 100%; justify-content: center; }
}
@media (hover: none) {
    .lpg-zoom { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .lpg-thumb, .lpg-zoom, .lpv-wrap { transition: none; }
    .lpg-card:hover .lpg-thumb { transform: none; }
}
