/* Agency on Autopilot template gallery. Tokens from brand/brand-tokens.css (style guide v1.1). */
:root {
  --red: #f41424;
  --ink: #111111;
  --white: #ffffff;
  --panel: #202024;
  --panel-2: #2a2a30;
  --mist: #b8b8bf;
  --line: rgba(255, 255, 255, .1);
  --font-display: Montserrat, Arial, sans-serif;
  --font-body: Inter, Arial, sans-serif;
  --r-card: 12px;
  --r-btn: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--white); font: 400 16px/1.55 var(--font-body); }
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--red); color: #000; padding: 8px 16px; border-radius: var(--r-btn); font-weight: 700; z-index: 10; }
.skip:focus { left: 16px; }
:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1280px; margin: 0 auto; padding: 24px 32px; }
.logo img { height: 40px; width: auto; }
.top-label { font: 700 12px/1.3 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--mist); }

main { max-width: 1280px; margin: 0 auto; padding: 0 32px 96px; }

/* Hero */
.hero { padding: 48px 0 40px; max-width: 860px; }
.eyebrow { margin: 0 0 16px; font: 700 12px/1.3 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.hero h1 { margin: 0; font: 900 clamp(36px, 5.4vw, 60px)/1.08 var(--font-display); letter-spacing: -.02em; }
.red { color: var(--red); }
.lede { margin: 24px 0 0; font-size: 18px; line-height: 1.56; color: var(--mist); max-width: 720px; }

/* Controls */
.controls { display: grid; gap: 16px; padding: 16px 32px; margin: 0 -32px 8px;
  background: var(--ink); border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 12px; max-width: 560px; height: 52px; padding: 0 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-btn); }
.search:focus-within { border-color: var(--red); }
.search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--mist); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; color: var(--white); font: 400 16px var(--font-body); outline: none; }
.search input::placeholder { color: var(--mist); opacity: .8; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex: none; min-height: 40px; padding: 8px 14px; background: var(--panel); color: var(--white); border: 1px solid var(--line); border-radius: 999px; font: 600 14px/1.3 var(--font-body); cursor: pointer; white-space: nowrap; }
.chip span { color: var(--mist); font-weight: 400; margin-left: 4px; }
.chip:hover { border-color: rgba(255, 255, 255, .3); }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #000; }
.chip[aria-pressed="true"] span { color: #000; }
.count { margin: 8px 0 16px; color: var(--mist); font-size: 14px; }

/* Grid */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; transition: transform .2s ease, border-color .2s ease; }
.card:hover { transform: translateY(-3px); border-color: rgba(244, 20, 36, .6); }
.card[hidden] { display: none; }
.card-link { display: flex; flex-direction: column; height: 100%; text-decoration: none; }
.thumb { position: relative; aspect-ratio: 16 / 10; background: var(--panel-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.badge { position: absolute; top: 12px; right: 12px; background: var(--ink); color: var(--white); font: 700 12px/1.3 var(--font-body); padding: 6px 10px; border-radius: 999px; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 20px; flex: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.num { font: 800 14px/1 var(--font-display); color: var(--red); }
.cat { font-size: 12px; color: var(--mist); text-align: right; }
.card h3 { margin: 0; font: 800 20px/1.2 var(--font-display); }
.card p { margin: 0; color: var(--mist); font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cta { margin-top: auto; padding-top: 8px; font: 700 14px/1.3 var(--font-body); color: var(--white); }
.card:hover .cta { color: var(--red); }
.empty { padding: 48px 0; text-align: center; }
.empty h2 { font: 800 28px/1.2 var(--font-display); margin: 0 0 8px; }
.empty p { color: var(--mist); max-width: 520px; margin: 0 auto; }

.foot { border-top: 1px solid var(--line); max-width: 1280px; margin: 0 auto; padding: 32px; color: var(--mist); font-size: 14px; }
.foot strong { color: var(--white); }
.foot .small { font-size: 12px; margin-top: 8px; }

/* Preview page */
body.pv { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.pv-bar { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--ink); }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px 0 8px; border-radius: var(--r-btn); background: var(--panel); text-decoration: none; font-weight: 600; font-size: 14px; }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pv-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.pv-title h1 { margin: 0; font: 800 18px/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-title .cat { text-align: left; white-space: nowrap; }
.devices { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: var(--r-btn); }
.devices button { display: grid; place-items: center; width: 40px; height: 36px; border: 0; border-radius: 6px; background: none; color: var(--mist); cursor: pointer; }
.devices button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.devices button[aria-pressed="true"] { background: var(--white); color: var(--ink); }
.open { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: var(--r-btn); background: var(--red); color: #000; font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap; }
.pv-info { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--mist); }
.pv-info p { margin: 0; flex: 1 1 320px; }
.pv-info strong { color: var(--white); }
.steps { display: flex; gap: 6px; }
.step { min-height: 36px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--white); font-weight: 600; font-size: 13px; cursor: pointer; }
.step[aria-selected="true"] { background: var(--white); color: var(--ink); }
.use { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.use code { font: 600 13px/1.4 var(--font-body); color: var(--white); background: var(--panel); padding: 6px 10px; border-radius: 6px; }
.copy { min-height: 36px; padding: 6px 14px; border: 1px solid var(--line); background: none; color: var(--white); border-radius: var(--r-btn); font-weight: 700; font-size: 13px; cursor: pointer; }
.stage { flex: 1; min-height: 0; width: 100%; max-width: none; margin: 0; padding: 16px; display: flex; justify-content: center; background: #0a0a0b; overflow: hidden; }
.frame-wrap { position: relative; height: 100%; transform-origin: top center; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 12px 40px rgba(0, 0, 0, .5); background: var(--white); }
.frame-wrap iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--white); }

@media (max-width: 860px) {
  .top { padding: 16px; }
  .logo img { height: 32px; }
  main { padding: 0 16px 64px; }
  .controls { margin: 0 -16px 8px; padding: 12px 16px; gap: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .hero { padding: 24px 0 24px; }
  .lede { font-size: 16px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .foot { padding: 24px 16px; }
  .pv-bar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .pv-title { order: 3; flex-basis: 100%; }
  .pv-title .cat { display: none; }
  .devices { display: none; }
  .open { margin-left: auto; }
  .pv-info { padding: 8px 12px; }
  .pv-info p { display: none; }
  .use span { display: none; }
  .use code { max-width: calc(100vw - 110px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stage { padding: 0; }
  .frame-wrap { border-radius: 0; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
