/* Splash — the only public surface: one full-screen picture and a name card.
 *
 * The picture always covers exactly one screen. The card sits in the lower
 * left on wide screens and across the bottom on phones. (The earlier photo
 * mosaic is kept in archive/splash-mosaic/; its media is still in
 * site/assets/mosaic/.)
 */

@layer pages {
  html[data-route="splash"],
  html[data-route="splash"] body {
    background: var(--splash-gutter);
  }

  /* On a cold load of /app/ the splash markup is still in the document until
     the router swaps it out; keep it from painting. */
  html[data-route="app"] .splash { display: none; }

  .splash {
    --edge: clamp(1rem, 4.5vw, 4rem);
    position: relative;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    display: grid;
    align-items: end;
    justify-items: start;
    padding: var(--edge);
    padding: max(var(--edge), env(safe-area-inset-top)) max(var(--edge), env(safe-area-inset-right))
             max(var(--edge), env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left));
    background: var(--splash-gutter);
  }

  /* ------------------------------------------------------------ picture */

  /* The picture is printed in the theme's palette — a gradient map. In
     greyscale it hard-lights the mid tone: black stays black, mid-grey becomes
     the mid tone, white goes white. Then the shadows are lifted to --tone-low
     (lighten) and the highlights capped at --tone-high (darken), so every
     pixel lands between the theme's own colours. */
  .splash-art {
    position: absolute;
    inset: 0;
    margin: 0;
    isolation: isolate;
    background: var(--tone-mid);
    animation: art-in 1.4s var(--ease-out) both;
  }

  .splash-art > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    /* Keep the lit trail in frame when a tall screen crops the sides. */
    object-position: 30% 50%;
    filter: var(--tone-filter);
    mix-blend-mode: hard-light;
  }

  .splash-art::before,
  .splash-art::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
  }
  .splash-art::before { background: var(--tone-low); mix-blend-mode: lighten; }
  .splash-art::after { background: var(--tone-high); mix-blend-mode: darken; }

  @keyframes art-in {
    from { opacity: 0; transform: scale(1.03); }
  }

  /* ---------------------------------------------------------- name card */

  .splash-card {
    position: relative;
    z-index: 1;
    width: min(26rem, 100%);
    display: grid;
    justify-items: start;
    row-gap: var(--space-2);
    padding: clamp(1.25rem, 3.5vw, 2rem) clamp(1.25rem, 3.5vw, 2.25rem);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--splash-card);
    color: var(--splash-ink);
    box-shadow: var(--shadow-lg);
    animation: card-in 900ms var(--ease-out) 250ms both;
  }

  @keyframes card-in {
    from { opacity: 0; transform: translateY(10px); }
  }

  .splash-kicker {
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--splash-ink-faint);
  }

  .splash-name {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.9rem, 5vw, 3rem);
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
  }

  .splash-line {
    font-size: clamp(var(--text-sm), 1.6vw, var(--text-lg));
    color: var(--splash-ink-soft);
    line-height: var(--leading-snug);
  }

  cbc-sign-in {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-top: var(--space-2);
  }

  .splash-signin {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.55rem 1.05rem 0.55rem 0.9rem;
    border-radius: var(--radius-full);
    background: var(--splash-button);
    color: var(--splash-button-ink);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    text-decoration: none;
    transition: background var(--transition-fast), transform var(--transition-fast);

    &:hover { background: var(--splash-button-hover); }
    &:active { transform: translateY(1px); }
    &:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 3px; }
    &[aria-busy="true"] { opacity: 0.7; cursor: progress; }
    svg { flex: none; }
  }

  .splash-status {
    flex-basis: 100%;
    font-size: var(--text-xs);
    color: var(--splash-ink-soft);
    max-width: 30ch;
    line-height: var(--leading-snug);
    &:empty { display: none; }
  }

  /* Short landscape phones: name and button side by side, tagline dropped. */
  @media (max-height: 480px) and (min-aspect-ratio: 4/3) {
    .splash-card {
      width: auto;
      grid-template-columns: auto auto;
      align-items: center;
      column-gap: var(--space-5);
      padding: var(--space-4) var(--space-5);
    }
    .splash-kicker, .splash-line { display: none; }
    .splash-name { font-size: var(--text-2xl); white-space: nowrap; }
    cbc-sign-in { margin-top: 0; }
  }

  @media (prefers-reduced-motion: reduce) {
    .splash-art, .splash-card { animation: none; }
  }
}
