/* css/graph.css: Taste map. Floating mini-map (bottom-right) + expanded native <dialog>.
   Colours are tokens here; js/graph.js reads the same --gpg-* values for the canvas. */

:root {
  --gpg-vibe: #ff3e9d;
  --gpg-concern: #0fa072;
  --gpg-inspired: #8a63ff;
  --gpg-demo: #c3b0ff;
  --gpg-product: #4a1d4f;
  --gpg-custom: #e0157f;
}
:root[data-theme="dark"] {
  --gpg-vibe: #ff6fb5;
  --gpg-concern: #5fe0a5;
  --gpg-inspired: #b49dff;
  --gpg-demo: #7f6bc4;
  --gpg-product: #f1d4ee;
  --gpg-custom: #ff9fcd;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --gpg-vibe: #ff6fb5;
    --gpg-concern: #5fe0a5;
    --gpg-inspired: #b49dff;
    --gpg-demo: #7f6bc4;
    --gpg-product: #f1d4ee;
    --gpg-custom: #ff9fcd;
  }
}

/* ---------- mini-map ---------- */

.gpg {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: var(--gpg-bottom, 16px);
  z-index: 25;
  font-family: var(--font);
  color: var(--ink);
}
.gpg-card {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: var(--glass, blur(18px));
  backdrop-filter: var(--glass, blur(18px));
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.gpg[data-mode="card"] .gpg-card {
  width: 220px;
  height: 164px;
  border-radius: 20px;
  transition: transform .25s var(--spring, ease), box-shadow .25s;
}
.gpg[data-mode="card"] .gpg-card:hover { transform: translateY(-2px); }
.gpg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 8px 12px 0;
  font-size: .75rem;
  line-height: 1.2;
  pointer-events: none;
}
.gpg-title { font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.gpg-legend { display: inline-flex; gap: 4px; align-items: center; }
.gpg-badge {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sel, var(--soft));
  color: var(--accent-ink);
  font-size: .6875rem;
  font-weight: 700;
  white-space: nowrap;
}
.gpg-badge:empty { display: none; }
.gpg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.gpg-dot-vibe { background: var(--gpg-vibe); }
.gpg-dot-concern { background: var(--gpg-concern); }
.gpg-dot-inspired { background: var(--gpg-inspired); }
.gpg-dot-demo { background: var(--gpg-demo); }
.gpg-dot-product { background: var(--gpg-product); }
.gpg-dot-custom { background: transparent; box-shadow: inset 0 0 0 1.8px var(--gpg-custom); }

.gpg-canvas { flex: 1; width: 100%; min-height: 0; display: block; pointer-events: none; }
.gpg-open {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
}
/* the card's dots can be dragged, so a touch on it moves a dot instead of scrolling the page */
.gpg[data-mode="card"] .gpg-open { touch-action: none; }
.gpg-open:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: -3px; }

.gpg-icon { display: none; }
.gpg[data-mode="dot"] .gpg-card {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
}
.gpg[data-mode="dot"] .gpg-card { overflow: visible; }
.gpg[data-mode="dot"] .gpg-head,
.gpg[data-mode="dot"] .gpg-canvas { display: none; }
.gpg[data-mode="dot"] .gpg-icon { display: grid; place-items: center; color: var(--ink); pointer-events: none; }
.gpg[data-mode="dot"][data-picked]:not([data-picked=""]) .gpg-card::after {
  content: var(--gpg-count);
  position: absolute;
  top: -1px; right: -1px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--accent-bg);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  pointer-events: none;
}
/* Over a control the round button slides into the page gutter, leaving a tappable sliver; focus or scrolling clear of controls brings it back. */
.gpg[data-mode="dot"][data-shy]:not(:focus-within) { transform: translateX(calc(100% + 12px - 14px)); opacity: .6; }
.gpg { transition: transform .2s ease, opacity .2s; }
/* The round button must not sit on the last footer line of a short page. */
.gpg-dot-mode .foot { padding-right: 72px; }
.gpg-card-mode .foot { padding-right: 244px; }

/* ---------- expanded view ---------- */

dialog.gpg-dlg {
  box-sizing: border-box;
  width: min(1120px, calc(100vw - 24px));
  height: min(780px, calc(100dvh - 24px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: var(--glass, blur(22px));
  backdrop-filter: var(--glass, blur(22px));
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--font);
}
dialog.gpg-dlg:not([open]) { display: none; }
dialog.gpg-dlg[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: gpg-in .28s cubic-bezier(.16, 1, .3, 1);
}
dialog.gpg-dlg::backdrop {
  background: color-mix(in srgb, var(--ink) 38%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
:root:has(dialog.gpg-dlg[open]) { overflow: hidden; }
@keyframes gpg-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.gpg-dhead { display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 8px 20px; }
.gpg-dtext { flex: 1; min-width: 0; }
.gpg-dtitle { margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; }
.gpg-hint { margin: 2px 0 0; color: var(--mute); font-size: .8125rem; line-height: 1.45; word-break: keep-all; }

.gpg-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  color: var(--ink);
  font: 700 1.25rem/1 var(--font);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.gpg-btn:hover { background: var(--soft); }
.gpg-btn:active { transform: scale(.94); }

.gpg-stage { position: relative; min-height: 0; margin: 0 8px; border-radius: 20px; overflow: hidden; background: color-mix(in srgb, var(--card) 40%, transparent); }
.gpg-big { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.gpg-zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.gpg-info {
  position: absolute;
  left: 10px; bottom: 10px;
  max-width: calc(100% - 76px);
  margin: 0;
  padding: 7px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--line);
  font-size: .75rem;
  line-height: 1.4;
  pointer-events: none;
  word-break: keep-all;
}
.gpg-info:empty { display: none; }

.gpg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 18px; padding: 10px 20px 14px; }
.gpg-keys { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: .8125rem; }
.gpg-keys li { display: inline-flex; align-items: center; gap: 6px; }
.gpg-keys b { font-weight: 800; }
.gpg-note { margin: 0; color: var(--mute); font-size: .75rem; word-break: keep-all; }

.gpg-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.gpg-sr ul { list-style: none; margin: 0; padding: 0; }

@media (max-width: 520px) {
  dialog.gpg-dlg { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .gpg-dhead { padding: calc(10px + env(safe-area-inset-top)) 10px 6px 16px; }
  .gpg-hint { font-size: .75rem; }
  .gpg-stage { margin: 0 4px; border-radius: 16px; }
  .gpg-foot { padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); }
  .gpg-note { display: none; }
  .gpg-keys { font-size: .75rem; gap: 4px 12px; }
  .gpg-info { max-width: calc(100% - 72px); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .gpg-hint { display: none; }
  .gpg-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  dialog.gpg-dlg[open] { animation: none; }
  .gpg[data-mode="card"] .gpg-card, .gpg-btn, .gpg { transition: none; }
}
