/* TRK-952: New website's gallery of site previews (site-gallery-view.js), in the app's own tokens */

/* The dialog grows to hold the gallery and the full preview, at a fixed height so the list scrolls inside it */
dialog.site-new[open]:has(.sg-view, .sg-preview) { display: flex; flex-direction: column; width: min(1120px, calc(100vw - 32px)); height: min(900px, calc(100dvh - 32px)); max-height: none; overflow: hidden; }
dialog.site-new:has(.sg-view, .sg-preview) .fmap-goal-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sg-view, .sg-preview { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sg-view[hidden] { display: none; }

.sg-head > h2, .sg-head > .sub { padding-right: 32px; }
.sg-head > .sub { margin: 0; text-wrap: pretty; }
.sg-tools { display: grid; gap: 10px; margin-top: 14px; }
.sg-search { position: relative; display: block; }
.sg-search .sg-icon { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.sg-search input { width: 100%; height: 40px; padding: 0 12px 0 38px; font-size: 16px; border-radius: 999px; }
.sg-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* One row of chips at every width; it scrolls sideways on its own when the dialog is narrow */
.sg-chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -24px; padding: 2px 24px; scrollbar-width: none; }
.sg-chips::-webkit-scrollbar { display: none; }
.sg-chip { min-height: 32px; padding: 5px 13px; font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; touch-action: manipulation; }
.sg-chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
@media (hover: hover) and (pointer: fine) { .sg-chip:not([aria-pressed="true"]):hover { border-color: var(--muted); background: var(--surface); } }
.sg-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sg-chip:active { transform: scale(0.97); }

.sg-scroll { flex: 1; min-height: 0; margin: 14px -24px -24px; padding: 4px 24px 24px; overflow: auto; overscroll-behavior: contain; }
.sg-grid { --sg-scale: 0.25; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 36px 28px; }
.sg-tile { position: relative; display: grid; gap: 12px; align-content: start; min-width: 0; }
.sg-tile[hidden] { display: none; }

/* The preview: a fixed shape in the look's page color, so nothing moves while it draws */
.sg-shot { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--sg-bg, var(--sunken)); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgb(16 24 40 / 0.06); transition: border-color 150ms ease, box-shadow 150ms ease; contain: strict; }
.sg-shot iframe { position: absolute; top: 0; left: 0; border: 0; transform: scale(var(--sg-scale)); transform-origin: 0 0; pointer-events: none; opacity: 0; transition: opacity 200ms ease; }
.sg-shot.is-drawn iframe { opacity: 1; }
.sg-tile.is-blank .sg-shot { display: grid; place-items: center; background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); }
.sg-tile.is-blank .sg-icon { width: 28px; height: 28px; }

.sg-meta { display: grid; gap: 2px; min-width: 0; }
.sg-open { justify-self: start; padding: 0; font-size: 15px; font-weight: 600; text-align: left; color: var(--text); background: none; border: 0; border-radius: 0; }
.sg-open:hover { background: none; }
/* TRK-1064: no press nudge (styles.css moves every pressed button), since a moved button holds its ::after: the click
   area shrank to the name while pressed, the release landed on the picture, and no click fired */
.sg-open:active { transform: none; }
/* The name's button covers the whole tile, so the preview is clicked too */
.sg-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.sg-open:focus-visible { outline: none; }
.sg-tile:has(.sg-open:focus-visible) .sg-shot { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .sg-tile:hover .sg-shot { border-color: var(--muted); box-shadow: 0 6px 18px -8px rgb(16 24 40 / 0.28); } }
.sg-tile:active .sg-shot { transform: scale(0.99); }
.sg-line { font-size: 13px; text-wrap: pretty; }
.sg-look { font-weight: 400; color: var(--muted); }

.sg-empty { padding: 20px 0 26px; text-align: center; }
.sg-empty p { margin: 0 0 6px; }
.sg-empty .sg-empty-title { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.sg-empty button { margin-top: 8px; }
.sg-scroll .fmap-goal-more { margin: 22px 0 0; }

/* ---- The full preview ---- */
.sg-pbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "back back" "title actions"; align-items: end; gap: 2px 16px; padding-right: 32px; }
.sg-back { grid-area: back; justify-self: start; margin-bottom: 4px; }
.sg-ptitle { grid-area: title; min-width: 0; }
dialog.confirm-box .sg-ptitle h2 { margin: 0; overflow-wrap: anywhere; }
.sg-ptitle h2:focus { outline: none; }
dialog.confirm-box .sg-ptitle p { margin: 2px 0 0; }
.sg-pactions { grid-area: actions; display: flex; align-items: center; gap: 10px; }
.sg-devices { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--sunken); }
.sg-devices .pe-icon-button { width: 36px; height: 32px; }
.sg-devices .pe-icon-button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(16 24 40 / 0.12); }
.sg-use { min-height: 36px; padding: 6px 18px; }

.sg-pages { display: flex; gap: 4px; margin: 12px 0 10px; overflow-x: auto; scrollbar-width: none; }
.sg-pages::-webkit-scrollbar { display: none; }
.sg-page { flex-shrink: 0; min-height: 32px; padding: 5px 12px; font-size: 13px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 8px; }
.sg-page[aria-pressed="true"] { color: var(--text); font-weight: 600; background: var(--sunken); border-color: var(--border); }
@media (hover: hover) and (pointer: fine) { .sg-page:not([aria-pressed="true"]):hover { color: var(--text); background: var(--sunken); border-color: transparent; } }
.sg-page:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sg-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: var(--radius); background: var(--sunken); }
.sg-frame { display: block; border: 0; background: #fff; transform-origin: 0 0; }
.sg-stage.is-desktop .sg-frame { position: absolute; top: 0; left: 0; }
.sg-stage.is-phone { display: flex; justify-content: center; padding: 0; }
.sg-stage.is-phone .sg-frame { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }

@media (max-width: 560px) {
  dialog.site-new[open]:has(.sg-view, .sg-preview) { width: calc(100vw - 16px); height: calc(100dvh - 16px); padding: 18px 16px; }
  .sg-scroll { margin: 12px -16px -18px; padding: 4px 16px 18px; }
  .sg-chips { margin: 0 -16px; padding: 2px 16px; }
  .sg-grid { gap: 32px; }
  .sg-pbar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "back" "title" "actions"; gap: 6px; }
  .sg-pactions { justify-content: space-between; }
  .sg-use { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .sg-shot iframe { transition: none; } .sg-tile:active .sg-shot, .sg-chip:active { transform: none; } }
/* TRK-1154: Import a website's progress line and what didn't come over */
.site-import-status:empty { display: none; }
.site-import-notes { margin: 12px 0 20px; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; line-height: 1.45; }
/* TRK-1158: switch between a website address and a connected repo */
.site-import-swap { display: inline-block; margin: 4px 0 12px; }
.site-import-swap:has(+ .site-import-swap) { margin-bottom: 0; } /* TRK-1166: the zip link right under the repo link */
.site-import-swap + .site-import-swap { display: block; width: fit-content; }
