/* The Apps Hub's own layout, on top of p24-ui (p24-ui/v1/p24.css). Everything generic — colour,
   type, header, cards, buttons, inputs, badges, status dots — comes from p24-ui; what is here is
   particular to this page: the tall header, the sticky category bar, the catalogue sections, grid,
   cards and their tooltips, the sign-in and request-access panels, and the admin page's tables. */

/* The tall header, with the page's intro under the bar. Only the hub has one. Its title, lede and
   identity read the chrome tokens, the header's own colours: dark on the light bar, light on the dark one. */
.hub-header { padding-bottom: 20px; }
.hub-header .p24-header__inner { min-height: 72px; }
.hub-wordmark { height: 26px; }
.hub-title { margin: 0; font-size: 1.5rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--p24-chrome-ink); }
.hub-lede { color: var(--p24-chrome-muted); }

/* The header's tools group: the links, then the identity slot, Admin (super admins) and Sign out.
   Sign out is a ghost button, whose ink and hover come from the page tokens, so on the bar it takes
   the chrome ink instead, to stay legible whatever colour the header is. */
.hub-header .p24-header__tools { align-items: center; gap: 12px; }
.hub-header .p24-header__identity { color: var(--p24-chrome-muted); }
.hub-header .p24-header__link .p24-badge { margin-left: 4px; }
.hub-header .p24-header__tools .p24-btn--ghost { color: var(--p24-chrome-ink); }
.hub-header .p24-header__tools .p24-btn--ghost:hover { background: transparent; border-color: var(--p24-chrome-muted); }
.hub-header .p24-header__tools .p24-btn--ghost:focus-visible { outline-color: var(--p24-chrome-ink); }

/* Category nav and filter, sticky so a long page keeps its index. */
.hub-toolbar { position: sticky; top: 0; z-index: 2; background: var(--p24-bg); border-bottom: 1px solid var(--p24-line); }
.hub-toolbar__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-block: 12px; }
.hub-cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; flex: 1; }
.hub-filter .p24-input { min-width: 240px; }

.hub-main { padding-block: 8px 24px; }
.hub-status { margin: 16px 0; }
.hub-status.is-error { color: var(--p24-danger); }

/* Sign-in and request-access: one card, centred, in place of the catalogue. */
.hub-panel { padding-block: 24px; }
.hub-signin, .hub-request { max-width: 560px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: var(--p24-space-block, 1rem); }
.hub-signin .p24-h2, .hub-request .p24-h2 { margin: 0; }
.hub-google { min-height: 44px; }
.hub-request .p24-field { display: flex; flex-direction: column; gap: 6px; }

/* The signed-out screen. Shared: the hub handoff page (APPS-671) reuses these rules and their
   markup, so the class names are a contract between two pages; rename one and both change.
   Signed out, app.js sets is-signed-out on the body: the page is the header, the sign-in card
   centred in the space below it, and the footer. main, with its empty status line, takes no space. */
.p24-body.is-signed-out { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.is-signed-out .hub-main { display: none; }
.hub-panel--signin { flex: 1 0 auto; width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
.hub-signin { width: 100%; box-sizing: border-box; text-align: center; align-items: center; }
.hub-signin .hub-google { display: flex; justify-content: center; }
/* The card's status line: the card's gap spaces it, and while empty it leaves the flow, adding
   neither height nor a gap. Never display: none, so the live region is still announced. */
.hub-signin .hub-status { margin: 0; }
.hub-signin .hub-status:empty { position: absolute; }

/* Sections: one per category, separated by a rule. */
.hub-category { padding: 32px 0 36px; border-bottom: 1px solid var(--p24-line-strong); scroll-margin-top: 72px; }
.hub-category:last-child { border-bottom: 0; }
.hub-category > .p24-h2 { display: flex; align-items: baseline; gap: 12px; }
.hub-category > .p24-h2 a { text-decoration: none; }
.hub-category > .p24-h2 a:hover { text-decoration: underline; text-decoration-color: var(--p24-ink-muted); }
.hub-category > .p24-h2 a:focus-visible { outline: 2px solid var(--p24-focus); outline-offset: 2px; border-radius: 4px; }
.hub-blurb { margin: 0 0 20px; }
.hub-empty { margin: 0; font-style: italic; }
/* An empty category is one compact line, so the populated ones are not pushed below the fold. */
.hub-category.is-empty { padding: 12px 0; border-bottom: 1px dashed var(--p24-line-strong); }
.hub-category.is-empty > .p24-h2 { display: inline-flex; font-size: 1rem; margin: 0; }
.hub-category.is-empty .hub-blurb,
.hub-category.is-empty .hub-grid { display: none; }
.hub-category.is-empty .hub-empty { display: inline; margin-left: 10px; font-size: 0.875rem; }

/* Three cards a row at most (APPS-1050): a column is never narrower than a third of the row, less the
   two gaps, so a desktop screen fits three and never four. The 1px keeps three fitting where a browser
   rounds the third up. Below that the 280px minimum decides, so a narrower screen drops to two
   columns and a phone to one, with no horizontal scroll. */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(min(100%, 280px), calc((100% - 32px) / 3 - 1px)), 1fr)); gap: 16px; }
/* A card is one row: health dot, the name's column, Open. The column holds the name, its tooltip
   and, on a card open to the VPN, the label under the name (APPS-984). The name wraps rather than
   truncating, and Open stays pinned to the right. The grid's columns are unchanged, so the cards are
   simply shorter. */
.hub-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 16px 14px 20px; }
/* A card showing its tooltip sits above its neighbours, and still below the sticky toolbar. */
.hub-card:hover, .hub-card:focus-within { z-index: 1; }
/* The name's column takes the row's free width, as the bare name did. It is not positioned, so the
   tooltip still places itself against the card, and it sets no overflow, so the name's focus ring is
   never clipped. The gap applies only between the name and the label: the tooltip is out of flow. */
.hub-card__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hub-card__name { margin: 0; min-width: 0; overflow-wrap: anywhere; border-radius: 4px; cursor: default; }
.hub-card__name:focus-visible { outline: 2px solid var(--p24-focus); outline-offset: 2px; }
.hub-card__open { flex: none; margin-left: auto; }
/* Open to the VPN (APPS-934): a p24-ui warning badge on its own line under the name (APPS-984), on a
   card whose app checks no sign-in. It never shrinks or wraps, and keeps its natural width rather than
   stretching across the column, so the name keeps the row's whole width. */
.hub-card__vpn { flex: none; white-space: nowrap; align-self: flex-start; }
/* Where the app runs, what it is written in and, on an app with a demo and a live service, which one
   Open reaches (APPS-1029): p24-ui badges on one line under the name, wrapping onto a second line on a
   narrow card. A badge wider than the name's column (Claude Code (local) beside a third-party button)
   wraps inside itself rather than running under the button, overriding p24-ui's nowrap on a badge. */
.hub-card__meta { display: flex; flex-wrap: wrap; gap: 4px; }
.hub-card__label, .hub-card__mode { flex: 0 1 auto; max-width: 100%; white-space: normal; }
/* A third-party UI's button (APPS-1029): Open's shape in a third style, a ghost button with a dashed
   border and an arrow after the label, so it reads apart from Open (primary) and Docs (secondary) and
   says it leaves Powder24's apps. */
.hub-card__external { border: 1px dashed var(--p24-line-strong); color: var(--p24-ink); }
.hub-card__external:hover { border-color: var(--p24-ink); }

/* What the app does: a tooltip under the card, never over it, hidden until the name is hovered or
   focused. A light card in the toast tokens (a raised grey in dark), with a pointer at the app name.
   Not the title attribute, which shows on neither keyboard focus nor touch and cannot be themed.
   Hovering the tooltip itself keeps it open. */
.hub-tip {
  position: absolute; top: calc(100% + 10px); left: 12px; right: 12px; z-index: 1;
  display: block; padding: 10px 12px;
  background: var(--p24-toast-bg); color: var(--p24-ink);
  border: 1px solid var(--p24-line-input); border-radius: var(--p24-radius-input); box-shadow: var(--p24-shadow-raised);
  font-size: 0.875rem; line-height: 1.45;
  visibility: hidden; opacity: 0;
  transition: opacity 0.12s ease, visibility 0s linear 0.15s;
}
/* The pointer: a 10px square turned 45° on the tip's top edge, under the start of the app name. */
.hub-tip::before {
  content: ""; position: absolute; top: -6px; left: 24px; width: 10px; height: 10px;
  background: var(--p24-toast-bg);
  border-top: 1px solid var(--p24-line-input); border-left: 1px solid var(--p24-line-input);
  transform: rotate(45deg);
}
/* A transparent bridge over the 10px gap between card and tip. It does not cover the card body below the
   name, which in a row stretched by a taller neighbour can be tens of pixels, and on a card open to the
   VPN adds the label's line, so moving from the name to the tip relies on the 0.15s hide delay to cross
   that part. */
.hub-tip::after { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 12px; }
.hub-card__name:hover + .hub-tip,
.hub-card__name:focus-within + .hub-tip,
.hub-tip:hover { visibility: visible; opacity: 1; transition-delay: 0s; }
/* Why a card has no page (APPS-1022): the same tooltip, opened from the wrapper of the Docs or
   third-party button that stands in for Open (APPS-1029). The wrapper is not positioned, so the tip
   still places itself against the card; its pointer sits at the right, under the button. */
.hub-card__nopage:hover .hub-tip,
.hub-card__nopage:focus-within .hub-tip { visibility: visible; opacity: 1; transition-delay: 0s; }
.hub-card__nopage .p24-btn:focus-visible { outline: 2px solid var(--p24-focus); outline-offset: 2px; }
.hub-tip--nopage::before { left: auto; right: 24px; }
/* Escape hides a hover-opened tooltip until the pointer leaves the card (app.js). */
.hub-card.is-tip-dismissed .hub-tip { visibility: hidden; opacity: 0; }
.hub-tip__summary { display: block; }
.hub-tip__note { display: block; margin-top: 6px; color: var(--p24-ink-muted); }

/* The request-access form's buttons. */
.hub-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }

/* The admin page: stacked groups, each a table with an inline form above it. */
/* The page rhythm from p24-ui, with literal fallbacks for a stale or missing p24.css. */
.hub-admin { display: flex; flex-direction: column; gap: var(--p24-space-section, 3rem); padding-block: 16px 32px; }
.hub-admin__group { display: flex; flex-direction: column; gap: var(--p24-space-heading, 1rem); }
.hub-admin__group > .p24-h2 { margin: 0; display: flex; align-items: baseline; gap: 12px; }
.hub-admin__form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.hub-admin__form .p24-field { display: flex; flex-direction: column; gap: 4px; }
.hub-admin__form .p24-input, .hub-admin__form .p24-select { min-width: 220px; }
.hub-admin .p24-table td { vertical-align: top; }
.hub-grants { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hub-grants li { display: inline-flex; align-items: center; gap: 4px; }
.hub-grants .p24-btn { padding-inline: 6px; }
.hub-muted-row { color: var(--p24-ink-muted); }

/* On a phone the category bar wraps to several rows, so it scrolls with the page rather than sticking. */
@media (max-width: 799px) {
  .hub-toolbar { position: static; }
  .hub-filter, .hub-filter .p24-input { width: 100%; min-width: 0; }
}

[hidden] { display: none !important; }
