/**
 * Shared program card grammar (one copy for every surface).
 *
 * The complete card, glimpse overlay, and detail dialog / bottom sheet system
 * plus the grid container tracks, extracted 2026-07-30 from programs.css,
 * dashboard.css (.dash__grid), and landing.css (.lp-btn family) so the public
 * landing grid and the /account Explore page consume the exact same rules.
 * Landing pages load this file in the old programs.css slot; the account app
 * links it from index.html after /design-tokens.css. Consumes only Tier 1/2
 * vars (--theme-*, --accent-*, --space-*, --radius-*, --motion-*, --text-*,
 * --weight-*, --tracking-*, --font-display, --font-body) so it themes itself
 * on any page that loads /platform.css and /design-tokens.css first.
 *
 * Interaction grammar ported from uruguide's business grid and the grid.bz
 * glimpse overlay: hover elevation and cover zoom on fine pointers only, a
 * first-tap glimpse on hoverless devices (is-glimpsed), a See more CTA that
 * opens the detail dialog, and a Material 3 bottom sheet variant with
 * drag-dismiss on narrow viewports. Markup is rendered by dashboard.js on the
 * landing and by pages/explore.tsx in the account app; both emit identical
 * class structure.
 */

/* Generated cover art: deterministic gradient variants from the accent ramp.
   The renderer hashes the program id to pick one, so cards stay distinct. */
.prog-art--g0 { background: linear-gradient(135deg, var(--accent-500), var(--accent-800)); }
.prog-art--g1 { background: linear-gradient(160deg, var(--accent-400), var(--accent-700)); }
.prog-art--g2 { background: linear-gradient(215deg, var(--accent-600), var(--accent-950)); }
.prog-art--g3 { background: linear-gradient(120deg, var(--accent-700), var(--accent-400)); }

/* Shared cover fill layers (card and dialog) */
.prog-cover__img,
.prog-cover__art {
  position: absolute;
  inset: 0;
}

.prog-cover__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--motion-state);
}

.prog-cover__art {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  transition: transform var(--motion-state);
}

.prog-cover__monogram {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: 1;
  color: var(--accent-50);
}

.prog-cover__cat {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent-50) 75%, transparent);
}

/* Card: a square tile in the original corner-and-center grammar. The cover
   fills the tile, prioritized data pins to the four corners (TL rating stars,
   TR price, BL total time, BR days per week), title sits centered. */
.prog-card-stack {
  position: relative;
  min-width: 0;
}

.prog-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  /* Whisper outline at rest; interaction states below bring it up */
  border: 1px solid color-mix(in srgb, var(--theme-border-card, var(--theme-border)) 35%, transparent);
  border-radius: var(--radius-xs);
  background: var(--theme-bg-elevated);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform var(--motion-hover),
    border-color var(--motion-hover),
    box-shadow var(--motion-hover);
}

.prog-card:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

.prog-card__cover {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--theme-bg-subtle);
}

/* Whisper of a scrim (owner: ~10%): the photo reads true; title and corner
   legibility comes from the pill chips and text shadows instead */
.prog-card__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent-950) 10%, transparent) 0%,
    color-mix(in srgb, var(--accent-950) 4%, transparent) 32% 60%,
    color-mix(in srgb, var(--accent-950) 12%, transparent) 100%
  );
}

/* The generated art monogram is dialog-only; the card center belongs to the title */
.prog-card .prog-cover__monogram,
.prog-card .prog-cover__cat {
  display: none;
}

/* Base: the resting face (corner pills + centered title). Fades out under
   the glimpse on hover, grid.bz style. */
.prog-card__base {
  position: absolute;
  inset: 0;
  z-index: 1;
  transition: opacity var(--motion-hover);
}

.prog-card__corner {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent-950) 55%, transparent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  line-height: 1.2;
  white-space: nowrap;
}

/* 4px insets: the same --space-xs constant as the grid gap, page frame, and
   the glimpse overlay padding, so both card faces share one spacing rhythm */
.prog-card__corner--tl { top: var(--space-xs); left: var(--space-xs); }
.prog-card__corner--tr { top: var(--space-xs); right: var(--space-xs); }
.prog-card__corner--bl { bottom: var(--space-xs); left: var(--space-xs); }
.prog-card__corner--br { bottom: var(--space-xs); right: var(--space-xs); }

/* Fractional 5-star rating, top left: bare white stars (no container, no
   tint), a 32% track under a fill row clipped to value/5 of the width. The
   rows are gap-free so the clip percentage maps exactly onto star fractions
   (4.6 = four full stars + 60% of the fifth). */
.prog-card__stars {
  position: absolute;
  top: calc(var(--space-xs) + 2px);
  left: var(--space-xs);
  z-index: 1;
  display: inline-block;
  line-height: 0;
  font-size: var(--text-sm);
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.stars__track,
.stars__fill {
  display: inline-flex;
  gap: 0;
}

.stars__track {
  opacity: 0.32;
}

.stars__fill {
  position: absolute;
  inset: 0 auto 0 0;
  overflow: hidden;
  white-space: nowrap;
}

.prog-card__stars svg {
  width: 1em;
  height: 1em;
  flex: none;
}

/* Centered title stack: compact lowercase display title over a body-font
   subtitle, both glowing softly for legibility against the photo */
.prog-card__titles {
  position: absolute;
  z-index: 1;
  inset-inline: var(--space-xs);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

/* Full available width inside the card padding, exactly one line, ellipsis
   past that. The SF body stack instead of the Syne display face: Syne's
   letterforms are too wide for a card-width single line; the system face is
   the Apple-aligned UI choice and stays inside the design system. */
.prog-card__title {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-body, var(--sans));
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: lowercase;
  letter-spacing: 0.01em;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 14px rgba(0, 0, 0, 0.45);
}

.prog-card__subtitle {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-body, var(--sans));
  font-size: var(--text-sm);
  font-weight: var(--weight-regular, 400);
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 14px rgba(0, 0, 0, 0.45);
}

/* Inline icon chrome (Framework7 SF-style glyphs) */
.ic {
  display: inline-flex;
  align-items: center;
  margin-right: 0.32em;
  vertical-align: -0.1em;
}

.ic svg {
  width: 1em;
  height: 1em;
}

/* Glimpse: the grid.bz hover/tap overlay. A near-opaque layer with the key
   data points and an Expand CTA that fades in over the base on hover/focus.
   The whole card stays one button, so the CTA pill is visual, not nested. */
.prog-card__glimpse {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: color-mix(in srgb, var(--accent-950) 92%, transparent);
  color: #fff;
  /* Tight leading: the page's 1.6 body leading inflates the stat rows past
     the square on small phones */
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity var(--motion-hover);
}

.prog-card__glimpse-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  font-size: var(--text-xs);
}

.prog-card__glimpse-cat {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.85);
  font-weight: var(--weight-medium);
}

.prog-card__glimpse-level {
  flex-shrink: 0;
  padding: 2px var(--space-xs);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent-500) 30%, transparent);
  color: #fff;
  font-weight: var(--weight-semibold);
}

.prog-card__stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs, 0.125rem);
}

.prog-card__stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
  padding-bottom: var(--space-2xs, 0.125rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.prog-card__stat-label {
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--text-xs);
}

.prog-card__stat-value {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
}

.prog-card__glimpse-cta {
  margin-top: auto;
  align-self: stretch;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border: 0;
  border-radius: var(--radius-xs);
  background: var(--accent-500);
  color: #fff;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-caps: all-small-caps;
  letter-spacing: var(--tracking-wide);
  cursor: pointer;
}

.prog-card__glimpse-cta:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Reveal states (all pointer types, original grid.bz behavior): keyboard
   focus-within and the JS tap class both swap the faces; the base dims to
   0.35 like grid.bz rather than disappearing. On touch, tap one shows the
   glimpse (is-glimpsed, wired by the renderer) and tap two hits Expand. */
.prog-card:focus-within .prog-card__glimpse,
.prog-card-stack.is-glimpsed .prog-card__glimpse {
  opacity: 1;
  pointer-events: auto;
}

.prog-card:focus-within .prog-card__base,
.prog-card-stack.is-glimpsed .prog-card__base {
  opacity: 0.35;
}

/* Outline comes up on any interaction: tap-glimpse, press, keyboard focus
   (hover joins in the fine-pointer block below) */
.prog-card:active,
.prog-card:focus-within,
.prog-card-stack.is-glimpsed .prog-card {
  border-color: var(--accent-500);
}

/* Hover adds the same swap plus elevation on fine pointers */
@media (hover: hover) and (pointer: fine) {
  .prog-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-500);
    box-shadow: 0 16px 48px var(--theme-shadow-lg);
  }

  .prog-card:hover .prog-cover__img,
  .prog-card:hover .prog-cover__art {
    transform: scale(1.04);
  }

  .prog-card:hover .prog-card__glimpse {
    opacity: 1;
    pointer-events: auto;
  }

  .prog-card:hover .prog-card__base {
    opacity: 0.35;
  }

  .prog-card:active {
    transform: translateY(-1px);
    transition: transform var(--motion-press);
  }
}

/* Site button grammar (moved from landing.css): the dialog action row is
   built from these, so they live with the sheet. Landing chrome (hero CTA,
   dock, blog/FAQ CTAs) uses the same classes; every landing-chrome page
   loads this file. Fallbacks cover pages without the .landingPage token
   scope (the account app). */
.lp-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--lp-space-2, 12px);
  min-height: var(--lp-touch, 48px);
  padding: 0 22px;
  border-radius: var(--radius-xs, 4px);
  border: 1px solid var(--border2);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lp-btn--primary {
  background: var(--accent);
  border-color: var(--pl-plate-dim);
  color: #fff;
}

.lp-btn--ghost {
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  border-color: var(--border2);
  color: var(--text-strong);
}

.lp-btn--block {
  width: 100%;
}

/* Body scroll lock while a program dialog is open (the renderer toggles it) */
html.prog-modal-open {
  overflow: hidden;
}

/* Detail dialog: centered card over a blurred backdrop (uruguide grammar).
   Font rhythm is pinned to the landing body values (1.0625rem, 1.65) so the
   sheet reads identically on surfaces with a different app body font. */
.prog-dialog {
  position: fixed;
  inset: 0;
  width: min(40rem, calc(100vw - 2 * var(--space-lg)));
  max-height: calc(100dvh - 2 * var(--space-2xl));
  margin: auto;
  padding: 0;
  border: 1px solid var(--theme-border-strong);
  border-radius: var(--radius-xl);
  background: var(--theme-bg-elevated);
  color: var(--theme-color);
  font-family: var(--font-body, var(--sans));
  font-size: 1.0625rem;
  line-height: 1.65;
  box-shadow: 0 16px 48px var(--theme-shadow-lg);
  overflow: hidden auto;
  overscroll-behavior: contain;
}

.prog-dialog[open] {
  animation: prog-dialog-in var(--motion-enter);
}

@keyframes prog-dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.prog-dialog::backdrop {
  background: color-mix(in srgb, var(--theme-bg) 55%, transparent);
  backdrop-filter: blur(6px);
}

.prog-dialog__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent-950) 55%, transparent);
  color: var(--accent-50);
  cursor: pointer;
  transition: background var(--motion-hover);
}

.prog-dialog__close:hover {
  background: color-mix(in srgb, var(--accent-950) 80%, transparent);
}

.prog-dialog__close svg {
  width: var(--space-md);
  height: var(--space-md);
}

/* Cover header: art or image behind a scrim, title overlaid at the bottom */
.prog-dialog__cover {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 11rem;
  padding: var(--space-lg);
  overflow: hidden;
  background: var(--theme-bg-subtle);
}

.prog-dialog__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 30%,
    color-mix(in srgb, var(--accent-950) 10%, transparent) 60%,
    color-mix(in srgb, var(--accent-950) 30%, transparent) 100%
  );
}

.prog-dialog__cover-text {
  position: relative;
  z-index: 1;
}

.prog-dialog__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  color: var(--accent-50);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 4px 18px rgba(0, 0, 0, 0.35);
}

.prog-dialog__subtitle {
  margin: var(--space-xs) 0 0;
  font-size: var(--text-sm);
  color: color-mix(in srgb, var(--accent-50) 85%, transparent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.prog-dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-lg);
}

.prog-dialog__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.prog-dialog__author {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--theme-color-dim);
}

.prog-dialog__author a {
  color: var(--theme-color);
  font-weight: var(--weight-semibold);
}

.prog-dialog__rating {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--theme-bg-subtle);
  font-size: var(--text-sm);
}

.prog-dialog__rating b {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--accent-500);
}

.prog-dialog__rating small {
  color: var(--theme-color-muted);
}

.prog-dialog__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.prog-dialog__heading {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--theme-color-muted);
}

.prog-dialog__text {
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--theme-color-dim);
}

.prog-dialog__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: 0;
}

.prog-dialog__metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-md);
  background: var(--theme-bg-subtle);
}

.prog-dialog__metric dt {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--theme-color-muted);
}

.prog-dialog__metric dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--theme-color);
}

.prog-dialog__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.prog-dialog__badge {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid color-mix(in srgb, var(--accent-500) 35%, transparent);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent-500) 14%, transparent);
  color: var(--theme-color);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
}

.prog-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-lg);
}

/* Copy link confirmation (the renderer swaps the label and this class) */
.prog-dialog__copy.is-copied {
  border-color: var(--accent-500);
  color: var(--theme-color);
}

@media (min-width: 640px) {
  .prog-dialog__metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Grip: sheet-only drag handle, hidden on wide viewports */
.prog-dialog__grip {
  display: none;
}

/* Narrow viewports: a Material 3 modal bottom sheet. Anatomy per the M3 spec:
   extra-large (28px) top corners, elevated surface container, a 32x4 drag
   handle bar centered in its own strip at the top of the surface, and a 32%
   black scrim with no blur. Corners stay barely-rounded elsewhere; the sheet
   shape is the M3 sheet contract, not a pill. */
@media (max-width: 639.98px) {
  .prog-dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--space-3xl));
    margin: auto 0 0;
    border: 0;
    border-radius: 28px 28px 0 0;
    background: var(--theme-bg-elevated);
    box-shadow: 0 -8px 40px var(--theme-shadow-lg);
  }

  /* M3 motion: emphasized-decelerate entrance */
  .prog-dialog[open] {
    animation: prog-sheet-in 0.4s cubic-bezier(0.05, 0.7, 0.1, 1);
  }

  .prog-dialog::backdrop {
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: none;
  }

  /* Handle strip: full-width touch target floating over the cover (M3 keeps
     the handle on top of the sheet surface; ours overlays the image header),
     with the 32x4 bar (2px radius) kept visible via a light bar + shadow */
  .prog-dialog__grip {
    display: flex;
    justify-content: center;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 3;
    width: 100%;
    margin-bottom: calc(-1 * (4px + 2 * var(--space-sm)));
    padding: var(--space-sm) 0;
    background: transparent;
  }

  .prog-dialog__grip::after {
    content: "";
    width: 2rem;
    height: 4px;
    border-radius: var(--radius-2xs);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  }

  /* Taller image stage on the sheet */
  .prog-dialog__cover {
    min-height: 14rem;
  }

  /* Drag surfaces own their gestures; dialog content keeps native scroll */
  .prog-dialog__grip,
  .prog-dialog__cover {
    touch-action: none;
  }

  .prog-dialog {
    transition: transform var(--motion-state);
  }

  .prog-dialog.is-dragging {
    transition: none;
  }

  /* M3 accelerate exit */
  .prog-dialog.is-closing {
    transition: transform 0.2s cubic-bezier(0.3, 0, 0.8, 0.15);
  }

  .prog-dialog__actions {
    flex-direction: column;
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  }

  .prog-dialog__actions .lp-btn {
    width: 100%;
    justify-content: center;
  }
}

@keyframes prog-sheet-in {
  from {
    transform: translateY(100%);
  }
}

/* Grid container: uruguide grid pattern, 2 columns on phones, auto-fill 240px
   tracks from 40rem. The 4px gap is the site's thin-frame constant: each
   surface bleeds its page gutter down to this same value around the grid
   (landing.css dash bleed rule; account index.css bb-explore-bleed). */
.dash__grid {
  display: grid;
  gap: var(--space-xs);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 40rem) {
  .dash__grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}
