/* ============================================================================
 * skills.css — the Skill grid (the agent's "opening move").
 *
 * On an EMPTY agent chat, the start-message card is followed by the agent's
 * hand of skills: tappable cards that stage a prompt in the composer. The card
 * rides the shared DS atom (.hz-card --raised --flat --lg --interactive) for
 * surface / shadow / radius / pointer-gated hover; everything here is interior
 * layout only, drawn exclusively from --hz-* tokens (no raw hex, no raw radius).
 * The icon tile reuses the existing .ag-chip-spark gradient tiles (app.css).
 *
 * Rendered by public/js/skills-grid.js. Cross-platform by construction:
 * responsive grid (2-up on phones → more on desktop), 44px tap floor on coarse
 * pointers, and a compositor-only deal-in entrance with a reduced-motion guard.
 * ========================================================================== */

.hz-skillgrid-wrap {
  margin: var(--hz-space-3) 0 var(--hz-space-2);
  padding: 0 var(--hz-space-1);
}

/* eyebrow: "<Agent>'s skills" — the hand belongs to the agent, not the app */
.hz-skillgrid-eyebrow {
  font-family: var(--hz-font-mono);
  font-size: var(--hz-text-2xs);
  font-weight: var(--hz-weight-semibold);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--hz-text-meta);
  margin: 0 var(--hz-space-1) var(--hz-space-2);
}

/* the grid — mirrors the store .cs-grid responsive pattern, tuned tighter for
   the in-thread width: two comfortable columns on a phone, more when there's room. */
.hz-skillgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--hz-space-2);
}
@media (max-width: 380px) {
  .hz-skillgrid { grid-template-columns: repeat(2, 1fr); }
}

/* the card interior — the .hz-card atom supplies surface/shadow/radius/hover */
.hz-skill {
  padding: var(--hz-space-3);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--hz-space-1);
  text-align: start;
  width: 100%;
  color: var(--hz-text);
  /* .hz-card is authored for <div> surfaces and never sets a font; a <button>
     does NOT inherit font-family from the UA sheet, so set it explicitly (as
     .hz-btn does) or the label renders in the system font, off from the chat. */
  font-family: var(--hz-font-body);
}

/* The byline: WHO does it — the agent's face tile and short name — on a surface
   that mixes agents (the Catalog's Tasks view). Meta ink, one line, ellipsised;
   the face is the avatar atom at a caption's height. Absent on an agent's own
   grid, where the eyebrow already names the agent. */
.hz-skill-by {
  display: inline-flex;
  align-items: center;
  gap: var(--hz-space-1);
  max-width: 100%;
  min-width: 0;
  margin-top: var(--hz-space-1);
  font-size: var(--hz-text-2xs);
  font-weight: var(--hz-weight-medium);
  color: var(--hz-text-meta);
}
.hz-skill-by .hz-skill-by-av {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: var(--hz-radius-avatar);
  background: var(--hz-brand-soft);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.hz-skill-by .hz-skill-by-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hz-skill-by-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Deal-in ──────────────────────────────────────────────────────────────────
   The start message lands, then the agent's hand is dealt as ONE cascade in
   reading order: eyebrow → cards → "All skills". The renderer marks each step
   .hz-deal with its index (--deal-i); every timing value lives here.

   Built to hold 60fps on any device, old or new:
   • Compositor-only: opacity + a translate. No scale — a scaled layer is
     rasterised at the small size and re-rasterised crisp when it lands, a
     visible text "snap" on iOS. No filter / shadow / layout property animates.
   • Decelerate curve (ease-out): the card moves the instant its step begins
     and settles softly. The symmetric ease-in-out it replaces idled through
     the first third of a short animation and then jumped — each card read as
     a pop, the cascade as a slide-show.
   • Steps overlap heavily (step ≪ duration), so the hand moves as one wave,
     not a sequence of separate reveals.
   • `backwards` fill only: a step waits hidden for its turn, and once it has
     landed no animation stays attached — the layers are released.
   • A step is not tappable while it waits invisible (hz-deal-hold: a zero-
     length pointer-events hold on the same delay). It only gates hit-testing,
     never painting, so it cannot make the visuals depend on the main thread.
   • --deal-elapsed (set by the renderer) shifts the whole cascade back when a
     grid is rebuilt over the one already on screen, so a re-render continues
     the same deal instead of replaying it. */
.hz-skillgrid-wrap {
  --deal-lead:   var(--hz-dur-instant);   /* a beat after the message lands */
  --deal-step:   var(--hz-stagger);
  --deal-dur:    var(--hz-dur-slow);
  --deal-ease:   var(--hz-ease-out);
  --deal-travel: var(--hz-space-3);
}
.hz-skillgrid-wrap .hz-deal {
  animation-name: hz-skill-deal, hz-deal-hold;
  animation-duration: var(--deal-dur), 0s;
  animation-timing-function: var(--deal-ease);
  animation-fill-mode: backwards;
  animation-delay: calc(var(--deal-lead) + var(--deal-i, 0) * var(--deal-step) - var(--deal-elapsed, 0ms));
}
@keyframes hz-skill-deal {
  from { opacity: 0; transform: translate3d(0, var(--deal-travel), 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes hz-deal-hold {
  from { pointer-events: none; }
}

/* the icon tile reuses .ag-chip-spark (app.css); this only sizes it for the card */
.hz-skill .ag-chip-spark {
  width: 30px;
  height: 30px;
  border-radius: var(--hz-radius-10);
  margin-bottom: var(--hz-space-1);
}
.hz-skill .ag-chip-spark svg { width: 16px; height: 16px; }

.hz-skill-label {
  font-size: var(--hz-role-label-size);
  font-weight: var(--hz-weight-semibold);
  line-height: var(--hz-role-label-leading);
  letter-spacing: var(--hz-role-label-tracking);
  color: var(--hz-text);
  /* A long unbroken token must wrap, never widen the grid track (→ h-scroll). */
  min-width: 0;
  overflow-wrap: anywhere;
}

/* the "needs" hint — a document/photo attach requirement, shown so a tap is
   never a silent failure. A calm meta-gray line (not a pill) so it reads as a
   quiet requirement, not a second action. */
.hz-skill-needs {
  display: inline-flex;
  align-items: center;
  gap: var(--hz-space-1);
  font-size: var(--hz-text-2xs);
  font-weight: var(--hz-weight-medium);
  color: var(--hz-text-meta);
  margin-top: auto;
}

/* the "✦ All skills (N)" affordance — opens the full set in the ✦ tray. The
   .hz-btn hz-btn--ghost atom supplies the surface, pointer-gated hover, 44px
   tap floor, font and focus ring; this only positions it and rounds it fully. */
.hz-skillgrid-more {
  margin: var(--hz-space-3) 0 0;
  border-radius: var(--hz-radius-pill);
}

/* the ✦ tray body (rendered into an HzSheet): the agent's set renders as the SAME
   grid of cards the empty chat opens with, so the mid-conversation ✦ view is the
   same "hand" the person already knows — not a downgraded chip list. The tray has
   no deal-in (its cards carry no .hz-deal step — the sheet slides up as one) and
   no "All skills" cap. Only the personal "My skills" presets (.hz-saved) below
   stay rows — they carry a ✕ remove. */
.hz-skilltray {
  display: flex;
  flex-direction: column;
  gap: var(--hz-space-2);
  padding-bottom: var(--hz-space-2);
}
.hz-skilltray .hz-skillgrid { margin-top: var(--hz-space-1); }

/* the personal presets list — a card that grows + a ✕ remove, laid out as a row */
.hz-saved .hz-skill {
  flex-direction: row;
  align-items: center;
  gap: var(--hz-space-3);
}
.hz-saved .hz-skill .ag-chip-spark { margin-bottom: 0; }
.hz-saved .hz-skill-body { display: flex; flex-direction: column; gap: var(--hz-space-1); min-width: 0; }
.hz-saved .hz-skill-needs { margin-top: 0; }

/* ── Media-faced card (makes = image/video/audio/voice/music) ──────────────────
   The skill's RESULT is the cover: a small preview (preview_url) loaded lazily,
   inside the .hz-card atom's clipped surface. The cover gradient shows until the
   preview lands; aspect-ratio reserves the box (no layout shift). Every value is
   a token (overlay + onbrand), so the scrim/badge stay theme-consistent. */
.hz-skill--media { padding: 0; overflow: hidden; gap: 0; }
.hz-skill-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--hz-ai-gradient);           /* placeholder until the preview lands */
  display: grid;
  place-items: center;
  overflow: hidden;
}
.hz-skill-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hz-skill-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--hz-overlay-scrim), transparent 60%);
}
.hz-skill-badge {
  position: absolute;
  top: var(--hz-space-2);
  inset-inline-start: var(--hz-space-2);
  font-family: var(--hz-font-mono);
  font-size: var(--hz-text-2xs);
  font-weight: var(--hz-weight-bold);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--hz-text-onbrand);
  background: var(--hz-overlay-scrim);
  border-radius: var(--hz-radius-pill);
  padding: 2px var(--hz-space-2);
  backdrop-filter: var(--hz-overlay-blur);
  -webkit-backdrop-filter: var(--hz-overlay-blur);
}
.hz-skill-play {
  position: relative;
  z-index: 1;
  width: 38px;
  height: 38px;
  border-radius: var(--hz-radius-full);
  display: grid;
  place-items: center;
  color: var(--hz-text-onbrand);
  font-size: var(--hz-text-md);
  background: var(--hz-overlay-scrim);
  backdrop-filter: var(--hz-overlay-blur);
  -webkit-backdrop-filter: var(--hz-overlay-blur);
}
.hz-skill-eq {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
}
.hz-skill-eq i { width: 4px; border-radius: var(--hz-radius-2); background: var(--hz-text-onbrand); }
.hz-skill-eq i:nth-child(1) { height: 40%; }
.hz-skill-eq i:nth-child(2) { height: 90%; }
.hz-skill-eq i:nth-child(3) { height: 60%; }
.hz-skill-eq i:nth-child(4) { height: 100%; }
/* label + needs sit in a small footer band under the cover */
.hz-skill--media .hz-skill-label { margin: var(--hz-space-2) var(--hz-space-3) 0; }
.hz-skill--media .hz-skill-needs { margin: var(--hz-space-1) var(--hz-space-3) var(--hz-space-2); }
/* saved row: the media face is a small square thumbnail on the left (the agent's
   own set renders full cover cards via the grid — only .hz-saved presets are rows) */
.hz-saved .hz-skill--media { flex-direction: row; padding: var(--hz-space-2); gap: var(--hz-space-3); }
.hz-saved .hz-skill--media .hz-skill-cover {
  width: 56px;
  height: 56px;
  aspect-ratio: 1;
  border-radius: var(--hz-radius-8);
  flex: 0 0 auto;
}
.hz-saved .hz-skill--media .hz-skill-label,
.hz-saved .hz-skill--media .hz-skill-needs { margin-inline-start: 0; margin-inline-end: 0; }

/* ── Saved "My skills" in the ✦ tray ───────────────────────────────────────────
   The caller's own presets sit above the agent's set under a small header. Each
   is a Make-again row (the card wears its result face) with a ✕ remove at the end. */
.hz-skilltray-head {
  font-family: var(--hz-font-mono);
  font-size: var(--hz-text-2xs);
  font-weight: var(--hz-weight-bold);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--hz-text-meta);
  margin: var(--hz-space-2) var(--hz-space-1) 0;
}
.hz-skilltray-head:first-child { margin-top: 0; }
.hz-saved { display: flex; flex-direction: column; gap: var(--hz-space-2); }
/* a saved row = the card (grows) + the ✕ remove (fixed) */
.hz-saved-row { display: flex; align-items: center; gap: var(--hz-space-2); }
.hz-saved-row .hz-skill { flex: 1 1 auto; }
.hz-saved-x {
  flex: 0 0 auto;
  width: var(--hz-tap-min);
  height: var(--hz-tap-min);
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--hz-text-meta);
  font-size: var(--hz-text-md);
  border-radius: var(--hz-radius-full);
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .hz-saved-x:hover { color: var(--hz-text); background: var(--hz-surface-hover); }
}

/* Touch: guarantee a comfortable target on coarse pointers (phones/tablets)
   without inflating desktop density — matches the DS app-touch-targets rule. */
@media (pointer: coarse) {
  .hz-skill { min-height: var(--hz-tap-min); }
}

/* Reduced motion: the hand appears instantly, no deal-in. */
@media (prefers-reduced-motion: reduce) {
  .hz-skillgrid-wrap .hz-deal { animation: none; }
  .hz-skillgrid-more { transition: none; }
}

/* ============================================================================
 * SURFACE LAYOUTS (.hz-sc*) — the server-rendered skill cards for the landing
 * feed, a pack in feed mode, and the admin live-preview (skills/render-card.js).
 * A surface card is a LINK (opens an agent with the prompt staged). Distinct from
 * the in-chat .hz-skill button above (which pre-fills the composer) — a different
 * interaction, one stylesheet. Token-only; media covers reuse the visual language
 * of the .hz-skill cover. Cross-platform: responsive grids, 44px taps, lazy media.
 * ========================================================================== */

/* per-`makes` accent — the face colour of a content card (mirrors the concept). */
.hz-sc--text  { --sc-grad: var(--hz-brand-gradient); }
.hz-sc--image { --sc-grad: linear-gradient(135deg, var(--hz-agent), var(--hz-spectrum-2)); }
.hz-sc--video { --sc-grad: linear-gradient(135deg, var(--hz-blue-500), var(--hz-accent-cyan)); }
.hz-sc--audio,
.hz-sc--voice { --sc-grad: linear-gradient(135deg, var(--hz-p2p), var(--hz-accent-cyan)); }
.hz-sc--music { --sc-grad: var(--hz-ai-gradient); }
.hz-sc--media { --sc-grad: var(--hz-ai-gradient); }   /* makesClass('media') fallback — only when a media card lacks a specific makes */

/* The surface is a query CONTAINER, so each layout below adapts to the width IT
   ACTUALLY HAS — not the viewport. Identical on full-width pages (landing / pack,
   where container ≈ viewport), but a NARROW embed (the admin live-preview, a side
   panel in a wide window) now gets sensible columns instead of the desktop grid
   crammed into ~half the width. Every consumer wraps render-card output in
   .hz-surface (landing #hzSkillsFeed, pack askSection, admin #skPreview). */
.hz-surface { display: flex; flex-direction: column; gap: var(--hz-space-4); container: hzsurface / inline-size; }

/* ── layout containers (mobile-first; breakpoints query the .hz-surface width) ── */
/* feed: a masonry of covers + tiles, mixed heights (Pinterest-like). */
.hz-sfeed { columns: 2; column-gap: var(--hz-space-3); }
@container hzsurface (min-width: 640px) { .hz-sfeed { columns: 3; } }
@container hzsurface (min-width: 1000px) { .hz-sfeed { columns: 4; } }
.hz-sfeed > .hz-sc { break-inside: avoid; margin-bottom: var(--hz-space-3); display: block; }
/* rail: a horizontal "make something" strip. */
.hz-srail { display: flex; gap: var(--hz-space-3); overflow-x: auto; padding-bottom: var(--hz-space-2); scrollbar-width: none; scroll-snap-type: x proximity; }
.hz-srail::-webkit-scrollbar { display: none; }
.hz-srail > .hz-sc { flex: 0 0 200px; scroll-snap-align: start; }
/* buttons: a compact grid (the pack/landing "ask" fallback). */
.hz-sbuttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--hz-space-3); }
@container hzsurface (min-width: 720px) { .hz-sbuttons { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* list: dense single column. */
.hz-slist { display: flex; flex-direction: column; gap: var(--hz-space-2); }
/* hero: a big spotlight + a column of supporting tiles (2-up once there's room). */
.hz-shero { display: grid; grid-template-columns: 1fr; gap: var(--hz-space-3); }
@container hzsurface (min-width: 720px) { .hz-shero { grid-template-columns: 1.5fr 1fr; } }
.hz-shero-side { display: flex; flex-direction: column; gap: var(--hz-space-3); }
.hz-shero-side .hz-sc { flex: 1; }

/* ── the card (rides the .hz-card atom; this is interior only) ───────────── */
.hz-sc {
  position: relative; display: block; overflow: hidden; padding: 0;
  text-decoration: none; color: var(--hz-text);
  border-radius: var(--hz-radius-lg);
  min-height: var(--hz-tap-min);
}
@media (prefers-reduced-motion: no-preference) {
  .hz-sc { transition: transform var(--hz-dur-fast) var(--hz-ease), box-shadow var(--hz-dur-fast) var(--hz-ease); }
}
@media (hover: hover) and (pointer: fine) {
  .hz-sc:hover { transform: translateY(-2px); box-shadow: var(--hz-card-shadow); }
}

/* media card: the result is the face — a cover fills the card. */
.hz-sc-cover {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 4 / 3; background: var(--sc-grad); color: var(--hz-text-onbrand);
}
.hz-srail .hz-sc-cover { aspect-ratio: 4 / 5; }
/* hero: the spotlight card fills its (taller) grid cell so its cover reaches the
   full height of the side column beside it — no dead space under the cover. */
.hz-shero > .hz-sc:first-child { display: flex; flex-direction: column; }
.hz-shero > .hz-sc:first-child .hz-sc-cover { aspect-ratio: 16 / 10; }   /* stacked (narrow) base */
@container hzsurface (min-width: 720px) {
  /* 2-up hero: the spotlight fills its taller cell so its cover reaches the full
     height of the side column beside it — no dead space under the cover. */
  .hz-shero > .hz-sc:first-child .hz-sc-cover { aspect-ratio: auto; flex: 1; min-height: 300px; }
}
.hz-sc-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.hz-sc-scrim { position: absolute; inset: 0; background: linear-gradient(to top, var(--hz-overlay-scrim, rgba(0,0,0,.5)), transparent 58%); }
.hz-sc-badge {
  position: absolute; top: var(--hz-space-2); inset-inline-start: var(--hz-space-2);
  font-family: var(--hz-font-mono); font-size: var(--hz-text-2xs); font-weight: var(--hz-weight-bold);
  letter-spacing: .06em; text-transform: uppercase; color: var(--hz-text-onbrand);
  background: var(--hz-overlay-scrim, rgba(0,0,0,.28)); border-radius: var(--hz-radius-pill);
  padding: 2px var(--hz-space-2);
  backdrop-filter: var(--hz-overlay-blur, blur(6px)); -webkit-backdrop-filter: var(--hz-overlay-blur, blur(6px));
}
.hz-sc-glyph { font-size: var(--hz-text-2xl); opacity: .9; }
.hz-sc-play {
  position: relative; z-index: 1; width: 40px; height: 40px; border-radius: var(--hz-radius-full);
  display: grid; place-items: center; color: var(--hz-text-onbrand); font-size: var(--hz-text-md);
  background: var(--hz-overlay-scrim, rgba(0,0,0,.32));
  backdrop-filter: var(--hz-overlay-blur, blur(6px)); -webkit-backdrop-filter: var(--hz-overlay-blur, blur(6px));
}
.hz-sc-eq { position: relative; z-index: 1; display: flex; align-items: flex-end; gap: 3px; height: 22px; }
.hz-sc-eq i { width: 4px; border-radius: var(--hz-radius-2); background: var(--hz-text-onbrand); opacity: .92; }
.hz-sc-eq i:nth-child(1) { height: 42%; } .hz-sc-eq i:nth-child(2) { height: 88%; }
.hz-sc-eq i:nth-child(3) { height: 60%; } .hz-sc-eq i:nth-child(4) { height: 100%; }
.hz-sc-cap {
  position: absolute; z-index: 1; left: var(--hz-space-3); right: var(--hz-space-3); bottom: var(--hz-space-3);
  font-weight: var(--hz-weight-bold); font-size: var(--hz-text-sm); color: var(--hz-text-onbrand);
  line-height: var(--hz-leading-snug); text-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.hz-shero > .hz-sc:first-child .hz-sc-cap { font-size: var(--hz-text-lg); }
.hz-sc-emph { color: var(--hz-text-onbrand); opacity: .92; font-weight: var(--hz-weight-semibold); }

/* text card: a spark tile + label + caption/prompt line. */
.hz-sc--text { display: flex; gap: var(--hz-space-3); align-items: center; padding: var(--hz-space-4); background: var(--hz-surface-raised); border: 1px solid var(--hz-border); }
.hz-sc-tile { flex: 0 0 auto; width: 34px; height: 34px; border-radius: var(--hz-radius-10); background: var(--sc-grad); box-shadow: var(--hz-shadow-brand); display: grid; place-items: center; color: var(--hz-text-onbrand); font-size: var(--hz-text-md); }
.hz-sc-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hz-sc-l { font-weight: var(--hz-weight-bold); font-size: var(--hz-text-sm); letter-spacing: var(--hz-tracking-snug); color: var(--hz-text); overflow-wrap: anywhere; }
.hz-sc-sub { font-size: var(--hz-text-xs); color: var(--hz-text-muted); line-height: var(--hz-leading-normal); }

/* Settings → General → "Stories": the row's icon tile, in the brand tint.
   The row itself is the shared .sp-row (skill-reco-addon.js). The stories row
   and viewer have their own sheet: public/css/stories.css. */
.hz-reco-set-ic {
  background: color-mix(in srgb, var(--hz-brand) 14%, transparent);
  color: var(--hz-brand);
}
