/* worker/public/site/hub.css - the hub at "/" and its first-visit welcome (RULES.md 35.7 to 35.10).

   What it does: lays out the hub's line and tiles (src/site/hub.js) in the category tiles' manner,
   larger: the surface, a halo of the accent in the corner, the Phosphor-style icon in gold with its
   plate at a fifth. The tiles' motion: a tilt towards the pointer from the CSS variables --rx and
   --ry that public/site/hub.js sets, a soft gold light that sweeps across once and the icon's hop
   on .is-hover, a calm lift on keyboard focus, a bounce on .is-tapped (a touch). The welcome's
   overlay (public/site/intro.js) and the states it puts on <html data-intro>: "first" (set before
   paint by theme.js on a first visit: a black cover so the hub never flashes first; it lifts
   itself after four seconds should intro.js never run), "running" (the overlay up, the header's
   logo and wordmark and the hub's content held back), "reveal" (the logo handed over, the tiles
   arriving one by one). Under prefers-reduced-motion nothing moves: no tilt, sweep, hop, bounce
   or glide, and the tiles simply appear.
   Loaded on the hub alone (hub.js extraHead). The candle's own colours are the approved mockup's
   (docs/mockups/2026-11-21-candle-flicker.html) and are not theme tokens: it is a flame on black.
   What depends on it: src/site/hub.js, public/site/hub.js, public/site/intro.js. 2026-11-21. */

/* The sweep's light: warm gold on the dark theme, a warm near-white on the paper of the light one,
   following site.css's three theme selectors. */
:root { --hub-sweep: rgba(255, 214, 130, 0.26); }
:root[data-theme="light"] { --hub-sweep: rgba(255, 251, 236, 0.85); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) { --hub-sweep: rgba(255, 251, 236, 0.85); } }

.hub { padding: 1rem 0 2rem; }
.hub-line { font-family: "Poppins", system-ui, sans-serif; font-weight: 200; font-size: clamp(1.7rem, 4.4vw, 2.6rem); line-height: 1.2; letter-spacing: 0.01em; margin: 0.5rem 0 0.4rem; max-width: 34rem; }
.hub-sub { color: var(--dim); margin: 0 0 2rem; max-width: 34rem; }
.hub-line + .hub-tiles { margin-top: 2rem; }

/* Balanced at every width (the lead's look at the screenshots, 2026-11-21: five tiles in a
   four-across grid stranded the fifth). The list says how many it holds (data-count, --count).
   Wide: all on one row (six: three and three, as between). Between phone and wide, a grid of
   six: four tiles two and two, five three and two with the two centred, six three and three
   (the Podcast tile, 2026-11-21). Phone: one column. The sign-up tile, opened, takes a row. */
.hub-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.1rem; }
.hub-item { perspective: 900px; grid-column: span 3; }
.hub-tiles[data-count="5"] .hub-item { grid-column: span 2; }
.hub-tiles[data-count="5"] .hub-item:nth-child(4) { grid-column: 2 / span 2; }
.hub-tiles[data-count="5"] .hub-item:nth-child(5) { grid-column: 4 / span 2; }
.hub-tiles[data-count="6"] .hub-item { grid-column: span 2; }
@media (min-width: 1100px) {
  .hub-tiles { grid-template-columns: repeat(var(--count, 4), minmax(0, 1fr)); }
  .hub-tiles .hub-item, .hub-tiles[data-count="5"] .hub-item, .hub-tiles[data-count="5"] .hub-item:nth-child(4), .hub-tiles[data-count="5"] .hub-item:nth-child(5) { grid-column: auto; }
  .hub-tiles[data-count="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hub-tiles[data-count="6"] .hub-item { grid-column: span 2; }
}
.hub-tiles .hub-item-signup:has(details[open]), .hub-tiles[data-count="5"] .hub-item-signup:has(details[open]) { grid-column: 1 / -1; }

.hub-tile {
  --rx: 0deg; --ry: 0deg; --lift: 0px;
  position: relative; display: block; min-height: 11.5rem; border-radius: 18px;
  background: var(--surface); color: var(--text); text-decoration: none; overflow: hidden;
  border: 1px solid transparent;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 6%, transparent) inset;
  transform: rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  transform-style: preserve-3d;
  transition: transform 0.28s ease-out, border-color 0.3s, box-shadow 0.35s;
}
.hub-tile::before { content: ""; position: absolute; right: -2.2rem; top: -2.2rem; width: 11rem; height: 11rem; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 30%, transparent), transparent); pointer-events: none; }
.hub-tile-face { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 11.5rem; padding: 1.1rem 1.25rem 1.15rem; cursor: pointer; list-style: none; }
a.hub-tile { display: flex; flex-direction: column; justify-content: flex-end; padding: 1.1rem 1.25rem 1.15rem; }
.hub-tile-face::-webkit-details-marker { display: none; }
.hub-icon { position: absolute; right: 1rem; top: 0.9rem; width: 4.4rem; height: 4.4rem; color: var(--accent); }
.hub-icon-plate { opacity: 0.22; }
.hub-tile-title { position: relative; font-weight: 600; font-size: 1.25rem; line-height: 1.2; }
.hub-tile-line { position: relative; color: var(--dim); font-size: 0.92rem; line-height: 1.4; margin-top: 0.3rem; max-width: 15rem; }

/* The gold light that crosses a tile once as the pointer arrives. */
.hub-sweep { position: absolute; top: -10%; bottom: -10%; left: 0; width: 55%; pointer-events: none; opacity: 0; transform: translateX(-140%) skewX(-18deg); background: linear-gradient(90deg, transparent, var(--hub-sweep) 50%, transparent); }
.hub-tile.is-hover { --lift: -3px; border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 14px 34px var(--shadow); }
.hub-tile.is-hover .hub-sweep { animation: hub-sweep 1.15s cubic-bezier(0.3, 0.1, 0.3, 1) 1 both; }
.hub-tile.is-hover .hub-icon { animation: hub-hop 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) 1; }
@keyframes hub-sweep { 0% { opacity: 0; transform: translateX(-140%) skewX(-18deg); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateX(260%) skewX(-18deg); } }
@keyframes hub-hop { 0% { transform: none; } 35% { transform: translateY(-11px) rotate(-7deg); } 65% { transform: translateY(1px) rotate(2deg); } 100% { transform: none; } }

/* Keyboard focus: a calm lift, no tilt. */
a.hub-tile:focus-visible, .hub-tile-signup > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
a.hub-tile:focus-visible, .hub-tile-signup:has(> summary:focus-visible) { --lift: -4px; border-color: var(--accent); box-shadow: 0 12px 28px var(--shadow); }
.hub-tile-signup > summary:focus-visible { border-radius: 18px; outline-offset: -3px; }

/* A tap on a touch screen: a small bounce. */
.hub-tile.is-tapped { animation: hub-bounce 0.42s cubic-bezier(0.3, 1.6, 0.5, 1) 1; }
@keyframes hub-bounce { 0% { transform: scale(1); } 35% { transform: scale(0.965); } 70% { transform: scale(1.015); } 100% { transform: scale(1); } }

/* The sign-up tile, open: the form under its face, across the row. */
.hub-tile-signup[open] { --rx: 0deg; --ry: 0deg; border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.hub-tile-signup[open] .hub-tile-face { min-height: 8rem; }
.hub-signup { position: relative; padding: 0 1.25rem 1.25rem; }
.hub-signup-label { display: block; font-size: 0.9rem; margin-bottom: 0.35rem; }
.hub-signup-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.hub-signup-row input { flex: 1 1 14rem; min-width: 0; font: inherit; padding: 0.6rem 0.8rem; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); background: var(--bg); color: var(--text); }
.hub-signup-done { margin: 0; font-weight: 600; }
.hub-signup .optin { margin: 0.75rem 0 0; font-size: 0.9rem; }
.hub-signup .signup-hint { color: var(--error); margin: 0.6rem 0 0; }

.hub-replay-row { margin: 1.75rem 0 0; text-align: center; }
.hub-replay { background: none; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); color: var(--dim); border-radius: 999px; padding: 0.35rem 0.95rem; font-size: 0.82rem; cursor: pointer; }
.hub-replay:hover { color: var(--text); border-color: var(--accent); }

@media (max-width: 600px) {
  .hub-tiles { grid-template-columns: 1fr; gap: 0.8rem; }
  .hub-tiles .hub-item, .hub-tiles[data-count="5"] .hub-item, .hub-tiles[data-count="5"] .hub-item:nth-child(4), .hub-tiles[data-count="5"] .hub-item:nth-child(5), .hub-tiles[data-count="6"] .hub-item { grid-column: auto; }
  .hub-tile, .hub-tile-face, a.hub-tile { min-height: 7.5rem; }
  .hub-icon { width: 3.4rem; height: 3.4rem; }
}

/* ---- The welcome (public/site/intro.js) ---------------------------------------------------- */

/* Before paint on a first visit: black, so the hub is not seen first. Lifts itself if intro.js never runs. */
html[data-intro="first"] body.hub-page::before { content: ""; position: fixed; inset: 0; z-index: 999; background: #000; animation: intro-cover-gone 0.6s ease 4s forwards; }
@keyframes intro-cover-gone { to { opacity: 0; visibility: hidden; } }

html[data-intro="running"], html[data-intro="running"] body { overflow: hidden; }
html[data-intro="running"] .site-header .brand-icon, html[data-intro="running"] .site-header .wordmark { opacity: 0; }
html[data-intro="reveal"] .site-header .brand-icon, html[data-intro="reveal"] .site-header .wordmark { opacity: 1; transition: opacity 0.9s ease; }
html[data-intro="running"] .hub-item, html[data-intro="running"] .hub-line, html[data-intro="running"] .hub-sub { opacity: 0; transform: translateY(18px) scale(0.97); }
html[data-intro="reveal"] .hub-item, html[data-intro="reveal"] .hub-line, html[data-intro="reveal"] .hub-sub { opacity: 1; transform: none; transition: opacity 0.9s ease, transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1); }
html[data-intro="reveal"] .hub-item { transition-delay: calc(0.35s + var(--i, 0) * 0.38s); }

.intro { --i: 1; position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; color: #f4f1ea; font-family: "Poppins", system-ui, sans-serif; }
.intro-backdrop { position: absolute; inset: 0; background: #000; transition: opacity 5.2s ease-in-out; }
.intro-room { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(60vmax 60vmax at 50% 38%, rgba(255, 176, 60, calc(0.05 + var(--i) * 0.05)), transparent 70%); transition: opacity 4.5s ease-in-out; }
.intro.is-faded { pointer-events: none; }
.intro.is-faded .intro-backdrop, .intro.is-faded .intro-room { opacity: 0; }
.intro-stage { position: relative; display: flex; flex-direction: column; align-items: center; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; font: inherit; -webkit-tap-highlight-color: transparent; pointer-events: auto; }
.intro-stage:focus-visible { outline: 1px solid rgba(232, 180, 74, 0.6); outline-offset: 12px; border-radius: 24px; }
.intro-logo { width: min(58vmin, 340px); height: auto; overflow: visible; transform-origin: 0 0; }
.intro-word { display: block; font-weight: 200; font-size: clamp(2.1rem, 7vmin, 3.2rem); line-height: 1.1; letter-spacing: 0.06em; margin-top: -1.2rem; opacity: 0.92; transform-origin: 0 0; white-space: nowrap; }
.intro-hint { margin-top: 1.4rem; font-family: Georgia, "Times New Roman", serif; font-variant-caps: all-small-caps; letter-spacing: 0.24em; font-size: 0.95rem; color: #9a9894; animation: intro-breathe 3.6s ease-in-out infinite; transition: opacity 1.2s ease; }
.intro-quiet { position: fixed; bottom: 2.2rem; left: 0; right: 0; margin: 0; text-align: center; transition: opacity 1.2s ease; }
.intro-quiet button { background: none; border: 0; color: #9a9894; font: 0.8rem Georgia, serif; letter-spacing: 0.08em; cursor: pointer; opacity: 0.7; padding: 0.6rem 1rem; }
.intro-quiet button:hover, .intro-quiet button:focus-visible { opacity: 1; color: #f4f1ea; }
.intro .is-gone { opacity: 0; pointer-events: none; }
.intro-hint.is-gone { animation: none; }
/* Once tapped, the candle is no longer a control: no focus ring follows it to the header. */
.intro.is-entered .intro-stage { outline: none; cursor: default; }
/* The app card waits until the welcome is over. */
html[data-intro] .app-card { visibility: hidden; }
@keyframes intro-breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.9; } }

/* The glide to the header's logo and wordmark: intro.js sets the transforms, these carry them. */
.intro.is-gliding .intro-logo, .intro.is-gliding .intro-word { transition: transform 4.2s cubic-bezier(0.65, 0, 0.25, 1), opacity 0.9s ease, color 4s ease; }
.intro.is-handed .intro-logo, .intro.is-handed .intro-word { opacity: 0; }
/* Reduced motion: one crossfade. */
.intro.is-crossfade { opacity: 0; transition: opacity 1.3s ease; pointer-events: none; }

.intro-mute { position: fixed; top: 5.5rem; right: 1.25rem; z-index: 1001; width: 2.75rem; height: 2.75rem; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(232, 180, 74, 0.45); background: rgba(18, 18, 18, 0.55); color: #f4f1ea; cursor: pointer; transition: opacity 0.6s ease; }
.intro-mute svg { width: 1.3rem; height: 1.3rem; }
.intro-mute .intro-mute-off { display: none; }
.intro-mute[aria-pressed="true"] .intro-mute-on { display: none; }
.intro-mute[aria-pressed="true"] .intro-mute-off { display: block; }
.intro-mute.is-gone { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .hub-tile, .hub-tile.is-hover, a.hub-tile:focus-visible { transform: none; transition: border-color 0.2s, box-shadow 0.2s; }
  .hub-tile.is-hover .hub-sweep, .hub-tile.is-hover .hub-icon, .hub-tile.is-tapped { animation: none; }
  html[data-intro="running"] .hub-item, html[data-intro="running"] .hub-line, html[data-intro="running"] .hub-sub { transform: none; }
  html[data-intro="reveal"] .hub-item, html[data-intro="reveal"] .hub-line, html[data-intro="reveal"] .hub-sub { transition: opacity 1.3s ease; transition-delay: 0s; }
  .intro-hint { animation: none; opacity: 0.75; }
  .intro-backdrop, .intro-room { transition: none; }
}
