/* Avakode Hub: the Preview button of a plugin's card and the window it opens (lane 5.13, owner 16.10). Loaded only on pages that
   have such cards (inc/preview.php). Tokens of tokens.css only: no colour of its own (the backdrop is --bg as rgba, the page
   behind stays dark). Every selector here lives under .hub-preview*. */

/* ---- the button ---- */
/* the plate: a quiet text button in the card's foot, left of «Details →», the same size, colour and hover as that link;
   a 24 px tall hit area (WCAG 2.2) without changing the line */
.hub-preview-btn--text {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; margin: -4px 0; padding: 4px 0;
  border: 0; border-radius: 4px; background: none; font: inherit; color: var(--fg-2); cursor: pointer; white-space: nowrap;
  transition: color .3s var(--ease);
}
.hub-preview-btn--text:hover { color: var(--fg); }
.hub-preview-btn--text:focus-visible { outline: 2px solid var(--signal-hot); outline-offset: 3px; }
.hub-preview-btn__ico { display: inline-grid; place-items: center; line-height: 0; }
.hub-preview-btn__ico svg,
.hub-preview-btn .hub-btn__ico svg { display: block; }
/* the group of the plate's foot: Preview and Details side by side, at the right (the price keeps the left) */
.hub-preview-links { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 14px; }
.hub-preview-links > .hub-preview-btn--text { margin-right: 0; } /* board.css gives the card's links 28 px on a phone; only the last one keeps it */
/* /wordpress/: the same text button on the price line, at the right, in the price's type (three pills of a card would not
   fit one line in the narrowest card, cards-v2-fit); the foot is a two-column grid only when it has the button, its other
   lines take the whole width */
.hub-preview-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; justify-items: start; }
.hub-preview-foot > * { grid-column: 1 / -1; }
.hub-preview-foot > .hub-plugin__price { grid-column: 1; grid-row: 1; }
.hub-preview-foot > .hub-preview-btn { grid-column: 2; grid-row: 1; justify-self: end; font: 500 12.5px/1.4 var(--mono); letter-spacing: .04em; }
/* the board's product card (Inclusive, Renew in the Compliance zone): the same quiet button, at the end of the pills' row, at
   the right, in the type of /wordpress/'s (coordinator 16.10); as tall as the pills, its text in the middle, so the row is one
   line to the eye and to cards-v2-fit (one top), and the hit area is the pill's; the row keeps the phone's 28 px, not the button */
.hub-card__acts > .hub-preview-btn--text { align-self: stretch; margin: 0 0 0 auto; padding: 0; font: 500 12.5px/1.4 var(--mono); letter-spacing: .04em; }
/* the pill (.hub-btn--sm, its icon in the same circle) for a card that has the room: the wide and the full-block cards */
button.hub-preview-btn.hub-btn { font-family: var(--text); color: var(--fg); }
/* the script is not there (blocked, 404): the button would do nothing */
html.hub-preview-off .hub-preview-btn { display: none; }

/* ---- the window: one native <dialog>, filled by preview.js ---- */
html.hub-preview-open { overflow: hidden; scrollbar-gutter: stable; }
.hub-preview {
  /* the part of the viewport height the window keeps for the bar, the caption, its paddings and the margins around it */
  --hub-preview-chrome: 156px;
  --hub-preview-pad: 16px;
  width: fit-content; max-width: 92vw; max-height: calc(100vh - 24px); margin: auto; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); color: var(--fg);
  overscroll-behavior: contain; font: 400 14px/1.5 var(--text);
}
.hub-preview[open] { animation: hub-preview-in .22s var(--ease); }
.hub-preview::backdrop { background: rgba(7, 6, 11, .82); animation: hub-preview-fade .22s var(--ease); }
@keyframes hub-preview-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes hub-preview-fade { from { opacity: 0; } to { opacity: 1; } }
.hub-preview__box { display: grid; gap: 12px; padding: 14px var(--hub-preview-pad) var(--hub-preview-pad); }
/* the chrome reserve is a guess: a tall picture with a four-line caption on a 320 px phone can outgrow it. Then the window
   scrolls inside (the dialog's height less its border) instead of cutting the arrows off. */
.hub-preview__box { max-height: calc(100vh - 26px); overflow-y: auto; overscroll-behavior: contain; }
.hub-preview__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hub-preview__title { margin: 0; font: 600 20px/1.25 var(--display); letter-spacing: -.01em; color: var(--fg); }
.hub-preview__btn {
  appearance: none; display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--fg); cursor: pointer;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.hub-preview__btn:hover { border-color: var(--signal-hot); background: rgba(255, 255, 255, .06); }
.hub-preview__btn:focus-visible { outline: 2px solid var(--signal-hot); outline-offset: 3px; }
.hub-preview__btn svg { display: block; }
.hub-preview__stage { display: flex; justify-content: center; touch-action: pan-y; }
/* the picture, whole and in its own proportion: width = the least of its own size, 92vw less the paddings, and the height the
   window may give (82vh, less what the bar and the caption take) turned into a width by the picture's ratio (--hub-preview-w /
   --hub-preview-h are its manifest size, set by the script); the height follows from the ratio. No crop, no squeeze. */
.hub-preview__img {
  display: block; box-sizing: border-box; height: auto; border-radius: 8px; object-fit: contain; background: var(--bg);
  width: min(calc(var(--hub-preview-w, 1448) * 1px), calc(92vw - 2 * var(--hub-preview-pad) - 2px),
    calc(min(82vh, 100vh - var(--hub-preview-chrome)) * var(--hub-preview-w, 1448) / var(--hub-preview-h, 1086)));
  aspect-ratio: var(--hub-preview-w, 1448) / var(--hub-preview-h, 1086);
  outline: 1px solid var(--line); /* a hairline around the picture that takes no room (craft: box-shadow is for focus rules only) */
}
.hub-preview__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; min-width: 0; }
.hub-preview__cap { flex: 1 1 220px; min-width: 0; margin: 0; font: 400 13px/1.5 var(--text); color: var(--fg-2); }
.hub-preview__tag { margin-right: 6px; font: 500 11px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--signal-hot); }
.hub-preview__nav { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; }
.hub-preview__nav[hidden] { display: none; }
.hub-preview__count { min-width: 3.4em; text-align: center; font: 500 12px/1.4 var(--mono); letter-spacing: .06em; color: var(--muted); }

@media (max-width: 600px) {
  .hub-preview { --hub-preview-chrome: 204px; --hub-preview-pad: 12px; border-radius: 12px; }
  .hub-preview__title { font-size: 18px; }
  .hub-preview__btn { width: 40px; height: 40px; }
}
@media (max-width: 360px) {
  .hub-preview { --hub-preview-chrome: 236px; } /* up to four caption lines at 320-360 */
}

@media (prefers-reduced-motion: reduce) {
  .hub-preview,
  .hub-preview[open],
  .hub-preview::backdrop,
  .hub-preview__img,
  .hub-preview__btn,
  .hub-preview-btn--text { animation: none; transition: none; }
}
