/* Public flow landing page (/f/:slug).
 *
 * Kept out of landing.css so the home page's blast radius doesn't widen: that
 * file is home-page-specific selectors loaded by every landing-layout page.
 * Everything here is in @layer pages, which the layer order puts after
 * `components` -- that is what lets the example tiles override .media-tile
 * (declared in flow-run.css) without !important and without editing shared
 * component CSS.
 *
 * Reuses .hero-subtitle, .hero-actions, .section-header, .section-subtitle,
 * .faq*, .btn*, .badge, .media-tile* and .media-lightbox* as they are. New
 * selectors are namespaced so nothing on pages#home can be hit -- .use-case-card
 * is deliberately not .feature-card for the same reason.
 */
@layer pages {

  .flow-landing {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
  }

  .flow-landing h1,
  .flow-landing h2,
  .flow-landing h3 {
    text-wrap: balance;
  }

  .flow-landing :is(#examples, #pricing) {
    scroll-margin-top: var(--spacing-xl);
  }

  /* shared/_flash renders only whitespace when there is nothing to show, so an
     empty #flash would still take a flex gap and push the hero down a screen.
     :has(*) ignores text nodes, unlike :empty. */
  .flow-landing > #flash:not(:has(*)) {
    display: none;
  }

  /* --- Admin preview banner ------------------------------------------- */

  .flow-landing-preview-banner {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-radius: 0.75rem;
    background-color: var(--color-warning-soft);
    border: 1px solid color-mix(in oklab, var(--color-warning) 30%, transparent);
    color: var(--color-warning-strong);

    & p {
      margin: 0;
    }
  }

  /* --- Hero ------------------------------------------------------------ */

  .flow-landing-hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    align-items: center;
    padding-block-end: var(--spacing-lg);
  }

  /* Only go two-column when there is actually something to show on the
     right, so a flow with no cover or examples doesn't get an empty column. */
  @container (min-width: 48rem) {
    .flow-landing-hero:has(.flow-landing-visual) {
      grid-template-columns: 1.1fr 0.9fr;
    }
  }

  .flow-landing-hero h1 {
    font-size: clamp(2rem, 1.5rem + 2.5cqi, 3.25rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: var(--spacing-md);
    color: var(--text-light);
  }

  /* The shared .hero-subtitle centres itself; here it sits in a text column. */
  .flow-landing-hero .hero-subtitle {
    margin-left: 0;
    margin-right: 0;
  }

  .flow-landing-eyebrow {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    color: var(--color-text-muted);
  }

  .flow-landing-hero .hero-actions {
    justify-content: flex-start;
  }

  .flow-landing-proof {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    color: var(--text-secondary-light);
    font-size: 0.9375rem;
  }

  .flow-landing-proof-note {
    color: var(--color-text-muted);
    font-size: 0.875rem;
  }

  .flow-landing-visual {
    border-radius: 1rem;
    overflow: hidden;
    aspect-ratio: 4 / 3;

    & img {
      inline-size: 100%;
      block-size: 100%;
      object-fit: cover;
    }
  }

  .flow-landing-visual-gradient {
    min-block-size: 14rem;
  }

  /* --- Examples -------------------------------------------------------- */

  /* auto-fit, not auto-fill: a page with three examples should fill the row
     rather than leave two ghost columns hanging off the right. */
  .flow-landing-example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: var(--spacing-lg);
    max-inline-size: 64rem;
    margin-inline: auto;
  }

  .flow-landing-example {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  /* .media-tile hard-codes aspect-ratio: 1 in flow-run.css. A marketing image
     deserves more room, and @layer pages beats @layer components. */
  .flow-landing-example .media-tile {
    aspect-ratio: 4 / 5;
  }

  .flow-landing-example figcaption {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .flow-landing-example-caption {
    font-weight: 600;
    color: var(--text-light);
  }

  /* "You typed this -> you got that" is the most convincing element on the
     page, so it lives under the tile rather than clipped inside it. */
  .flow-landing-example-input {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary-light);

    & .material-symbols-outlined {
      font-size: 1rem;
      flex-shrink: 0;
    }
  }

  /* --- Why you need it / prose ----------------------------------------- */

  .flow-landing-why {
    max-width: 46rem;
    margin-inline: auto;
  }

  /* --- Use cases -------------------------------------------------------- */

  .use-case-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: var(--spacing-lg);
  }

  .use-case-card {
    background-color: var(--bg-card-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: var(--spacing-lg);
    transition: transform 0.2s, box-shadow 0.2s;

    & h3 {
      margin-bottom: var(--spacing-sm);
      color: var(--text-light);
    }

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 10px 15px -3px oklch(0% 0 0 / 0.1);
    }
  }

  /* --- How it works ----------------------------------------------------- */

  .flow-landing-steps {
    max-width: 46rem;
    margin-inline: auto;
  }

  .flow-landing-inputs {
    margin-top: var(--spacing-lg);

    & h3 {
      margin-bottom: var(--spacing-sm);
      color: var(--text-light);
    }

    & ul {
      display: flex;
      flex-wrap: wrap;
      gap: var(--spacing-sm);
      list-style: none;
      padding: 0;
      margin: 0;
    }
  }

  .input-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    background-color: var(--color-surface-muted);
    border: 1px solid var(--border-light);
    font-size: 0.875rem;
    color: var(--text-light);

    & .material-symbols-outlined {
      font-size: 1rem;
      color: var(--color-text-muted);
    }
  }

  /* --- Pricing ---------------------------------------------------------- */

  .flow-landing-pricing {
    padding: var(--spacing-xl);
    border-radius: 1rem;
    background-color: color-mix(in oklab, var(--color-primary) 6%, var(--color-white));
    border: 1px solid color-mix(in oklab, var(--color-primary) 15%, transparent);
  }

  .cost-headline {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    color: var(--text-secondary-light);
  }

  .cost-total {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-light);
  }

  .cost-breakdown {
    list-style: none;
    padding: 0;
    margin: 0 auto var(--spacing-lg);
    max-width: 34rem;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  /* Each row shows its SHARE of the total, driven by the --share custom
     property set inline. Per-step credit figures are each rounded up, so their
     sum can exceed the headline -- which is rounded once over the whole
     estimate. Showing a proportion instead keeps the two from contradicting
     each other on screen. */
  .cost-row {
    display: grid;
    grid-template-columns: minmax(9rem, auto) 1fr auto;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.9375rem;
  }

  .cost-row-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-light);

    & .material-symbols-outlined {
      font-size: 1.125rem;
      color: var(--color-text-muted);
    }
  }

  .cost-row-bar {
    block-size: 0.5rem;
    border-radius: 999px;
    background-color: color-mix(in oklab, var(--color-primary) 12%, transparent);
    position: relative;

    &::after {
      content: "";
      position: absolute;
      inset-block: 0;
      inset-inline-start: 0;
      inline-size: var(--share, 0%);
      border-radius: inherit;
      background-color: var(--color-primary);
    }
  }

  .cost-row-value {
    color: var(--text-secondary-light);
    white-space: nowrap;
  }

  .cost-runs-card {
    max-width: 34rem;
    margin-inline: auto;
    text-align: center;
    padding: var(--spacing-md);
    border-radius: 0.75rem;
    background-color: var(--color-white);
    border: 1px solid var(--border-light);

    & p {
      margin: 0;
    }

    & p:first-child {
      font-weight: 600;
      color: var(--text-light);
      margin-bottom: 0.25rem;
    }
  }

  /* --- Closing CTA ------------------------------------------------------ */

  .flow-landing-cta {
    text-align: center;
    padding: var(--spacing-xl) 0;

    & h2 {
      font-size: 2rem;
      margin-bottom: var(--spacing-lg);
      color: var(--text-light);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .use-case-card {
      transition: none;
    }

    .use-case-card:hover {
      transform: none;
    }
  }
}
