/* AI playground (pages/ai-experiments/index.html): a fixed, staggered grid of experiment tiles.
   Tiles are absolutely placed at set columns by the packer in the page script (sizes: data-size="l" | "s").
   Each tile has an info button that slides a details panel in from the right; while it is open
   the other tiles blur and, on wide screens, the grid re-packs into the space left of the panel. */

:root {
  --pg-bg: #f3f3f0;
  --pg-tile: #ffffff;
  --pg-well: #f7f7f4;
  --pg-gap: clamp(12px, 1.3vw, 18px);
  --pg-panel-w: min(440px, 100vw);
  --pg-ease: cubic-bezier(.2, .7, .2, 1);
  --pg-ring: 0 0 0 1px rgb(var(--ink-rgb) / .07);
  --pg-shadow: 0 0 0 1px rgb(var(--ink-rgb) / .06), 0 1px 2px rgb(var(--ink-rgb) / .04), 0 18px 40px -26px rgb(var(--ink-rgb) / .28);
}
body.pg { background: var(--pg-bg); }

/* token game status colours (were on .tg in css/token-game.css) */
.pg-main { --tg-border: var(--line); --tg-border-strong: var(--muted); --tg-ok: #16683a; --tg-bad: #b42318;
  padding-top: calc(var(--header-clear) + 28px); padding-bottom: var(--section-y); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- the grid ---------- */
.pg-canvas { position: relative; min-height: 60vh; transition: height .55s var(--pg-ease); }
.pg-tile {
  position: absolute; top: 0; left: 0; display: flex; flex-direction: column;
  padding: 7px; border-radius: 22px; background: var(--pg-tile); box-shadow: var(--pg-shadow);
  opacity: 0; transform: translateY(14px) scale(.985);
  transition: opacity .6s var(--pg-ease), transform .6s var(--pg-ease), filter .45s var(--pg-ease);
}
.pg-canvas.is-ready .pg-tile { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 90ms); }
.pg-canvas.is-moving .pg-tile { transition: left .6s var(--pg-ease), top .6s var(--pg-ease), width .6s var(--pg-ease), opacity .45s var(--pg-ease), filter .45s var(--pg-ease); transition-delay: 0s; }
.pg-media { position: relative; overflow: hidden; border-radius: 16px; }

.pg-cap { display: flex; align-items: center; gap: 12px; min-height: 30px; padding: 9px 3px 2px 9px; }
.pg-cap__text { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.pg-cap__name { font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-cap__kind { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--label); white-space: nowrap; }
/* category sits in the bottom-right corner, beside the info button (or alone, on tiles without one) */
.pg-cap__kind { margin-left: auto; }
.pg-cap__kind:last-child { margin-right: 9px; }

/* the info button */
.pg-info {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
  box-shadow: inset 0 0 0 1px rgb(var(--ink-rgb) / .1);
  transition: color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.pg-info:hover { color: var(--ink); background: rgb(var(--ink-rgb) / .05); box-shadow: inset 0 0 0 1px rgb(var(--ink-rgb) / .16); }
.pg-info:active { transform: scale(.94); }
.pg-info[aria-expanded="true"] { color: var(--pg-tile); background: var(--ink); box-shadow: none; }
.pg-info:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 50%; }

/* ---------- game tile ---------- */
.game-stage { position: relative; aspect-ratio: 16 / 10; width: 100%; background: #2b1522; }
.game-stage iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
.game-stage:fullscreen, .game-stage:-webkit-full-screen { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; }
.game-stage::backdrop { background: #2b1522; }

/* Flower bloom: the scene runs inside this frame (flower-bloom/index.html); scrolling over it opens the flowers */
.flower-stage { position: relative; aspect-ratio: 4 / 5; width: 100%; background: #fff; }
.flower-stage iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
.game-fs {
  position: absolute; right: 12px; bottom: 12px; z-index: 2; display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #f7ecd6;
  background: rgba(43, 21, 34, .5); border: 1px solid rgba(247, 236, 214, .22);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background-color .25s var(--ease), transform .25s var(--ease);
}
.game-fs .ico-exit { display: none; }
.game-fs[aria-pressed="true"] .ico-enter { display: none; }
.game-fs[aria-pressed="true"] .ico-exit { display: block; }
.game-fs:active { transform: scale(.96); }
.game-fs:focus-visible { outline: 2px solid #78f2ff; outline-offset: 3px; border-radius: 999px; }
@media (hover: hover) { .game-fs:hover { background: rgba(43, 21, 34, .8); } }

/* ---------- colour system tile (compact token game) ---------- */
.pg-media--system { display: grid; gap: 16px; padding: 18px; background: var(--pg-well); box-shadow: inset 0 0 0 1px rgb(var(--ink-rgb) / .04); }
.pg-dare { margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 400; line-height: 1.35; letter-spacing: -.015em; color: var(--ink); text-wrap: balance; }
.pg-media--system .tg-preview { gap: 10px; }
.pg-media--system .tg-card { border-radius: 12px; box-shadow: 0 1px 2px rgb(var(--ink-rgb) / .05); }
.pg-media--system .tg-card-band { padding: 16px 14px; }
.pg-media--system .tg-card-kicker { font-size: 10.5px; }
.pg-media--system .tg-card-title { font-size: 19px; }
.pg-media--system .tg-card-body { padding: 11px 14px; font-size: 13px; }
.pg-media--system .tg-checks { gap: 6px; }
.pg-media--system .tg-chip { min-height: 24px; padding: 0 10px; font-size: 11.5px; font-weight: 500; border-color: rgb(var(--ink-rgb) / .1); background: var(--pg-tile); }
.pg-media--system .tg-controls { gap: 4px; margin: 0; }
.pg-media--system .tg-bar { gap: 2px; }
.pg-media--system .tg-bar-label { font-size: 12px; font-weight: 500; }
.pg-media--system .tg-range { height: 22px; }
.pg-media--system .tg-range::-webkit-slider-runnable-track { height: 8px; }
.pg-media--system .tg-range::-moz-range-track { height: 8px; }
.pg-media--system .tg-range::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -5px; border-width: 2.5px; }
.pg-media--system .tg-range::-moz-range-thumb { width: 13px; height: 13px; border-width: 2.5px; }
.pg-media--system .tg-actions { margin: 0; gap: 12px; }
.pg-media--system .tg-btn { min-height: 38px; padding: 0 18px; font-size: 14px; font-weight: 500; }
.pg-media--system .tg-reset { font-size: 12px; }
.pg-media--system .tg-rule { margin: 0; padding: 10px 12px; font-size: 13px; border-left-width: 3px; }

/* ---------- details panel ---------- */
.pg-scrim { position: fixed; inset: 0; z-index: 70; background: rgb(var(--ink-rgb) / .14); opacity: 0; pointer-events: none; transition: opacity .45s var(--pg-ease);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.pg-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 80; width: var(--pg-panel-w);
  display: flex; flex-direction: column; background: var(--pg-tile);
  box-shadow: -1px 0 0 rgb(var(--ink-rgb) / .06), -30px 0 60px -40px rgb(var(--ink-rgb) / .3);
  transform: translateX(102%); visibility: hidden;
  transition: transform .55s var(--pg-ease), visibility 0s linear .55s;
}
.pg-panel.is-open { transform: none; visibility: visible; transition: transform .55s var(--pg-ease), visibility 0s; }
.pg-panel__top { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 0 32px; }
.pg-panel__kind { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--label); }
.pg-close {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: rgb(var(--ink-rgb) / .05); color: var(--ink); cursor: pointer;
  transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.pg-close:hover { background: rgb(var(--ink-rgb) / .09); }
.pg-close:active { transform: scale(.94); }
.pg-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 50%; }
.pg-panel__scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 28px 32px 40px; }

.pg-doc { display: grid; gap: 30px; }
.pg-doc[hidden] { display: none; }
.pg-doc.is-in > * { animation: pg-in .5s var(--pg-ease) both; }
.pg-doc.is-in > :nth-child(2) { animation-delay: .04s; }
.pg-doc.is-in > :nth-child(3) { animation-delay: .08s; }
.pg-doc.is-in > :nth-child(4) { animation-delay: .12s; }
.pg-doc.is-in > :nth-child(n+5) { animation-delay: .16s; }
@keyframes pg-in { from { opacity: 0; transform: translateY(8px); } }
.pg-doc__title { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 400; line-height: 1.15; letter-spacing: -.03em; color: var(--ink); }
.pg-doc section { display: grid; gap: 8px; }
.pg-doc h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.pg-doc p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--body); text-wrap: pretty; }
.pg-doc p strong { color: var(--ink); font-weight: 600; }

/* live readouts from the token game, inside the panel */
.pg-doc .tg-detail { gap: 8px; }
.pg-doc .tg-detail + .tg-detail { padding-top: 0; border-top: 0; }
.pg-doc .tg-detail-text { font-size: 14px; }

/* link from a design-skill card's panel to the design system page (design-skill/index.html) */
.pg-ds-link {
  justify-self: start; margin-top: -16px; display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px 0 12px; border-radius: 999px; text-decoration: none;
  font-size: 13px; font-weight: 500; color: var(--primary); background: rgb(var(--primary-rgb) / .07);
  box-shadow: inset 0 0 0 1px rgb(var(--primary-rgb) / .16);
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease);
}
.pg-ds-link__arrow { transition: transform .25s var(--ease); }
.pg-ds-link:hover { background: rgb(var(--primary-rgb) / .12); box-shadow: inset 0 0 0 1px rgb(var(--primary-rgb) / .3); }
.pg-ds-link:hover .pg-ds-link__arrow { transform: translateX(3px); }
.pg-ds-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 999px; }
@media (prefers-reduced-motion: reduce) { .pg-ds-link, .pg-ds-link__arrow { transition: none; } }

.pg-meta { margin: 0; border-top: 1px dashed rgb(var(--ink-rgb) / .16); }
.pg-meta div { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 13px 0; border-bottom: 1px dashed rgb(var(--ink-rgb) / .16); }
.pg-meta dt { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--label); }
.pg-meta dd { margin: 0; font-size: 14px; color: var(--ink); text-align: right; }

/* open state */
body.pg-open .pg-tile:not(.is-active) { filter: blur(5px) saturate(.7); opacity: .35; pointer-events: none; }
body.pg-open .pg-canvas { cursor: zoom-out; }
body.pg-open .pg-tile.is-active { cursor: auto; }
@media (min-width: 1000px) {
  body.pg-open .pg-main { margin-right: var(--pg-panel-w); }
}
@media (max-width: 999.98px) {
  body.pg-open .pg-scrim { opacity: 1; pointer-events: auto; }
  body.pg-open { overflow: hidden; }
}

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .game-stage { aspect-ratio: 4 / 5; }
  .game-fs { width: 30px; padding: 0; justify-content: center; top: 12px; bottom: auto; }
  .game-fs__lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pg-panel__top { padding: 16px 16px 0 20px; }
  .pg-panel__scroll { padding: 24px 20px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-tile, .pg-canvas.is-moving .pg-tile, .pg-panel, .pg-panel.is-open, .pg-scrim, .pg-canvas { transition: none; }
  .pg-tile { transform: none; }
  .pg-doc.is-in > * { animation: none; }
}
