/* A live recording in three presentations. The pane is one centred column: glyph or clock, level, phase,
   verbs. The pill is one floating strip whose verbs wrap under the rest when narrow, on the `AgentRun`
   pill's ground so two runs read as one family. The panel is the run over other work: mark and state,
   clock, destination, phase, each side's wave, verbs. */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-recording-run[data-variant="pane"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background-color: var(--card);
  }

  .lotics-recording-run__content {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--lotics-space-16);
    width: 100%;
    max-width: 480px;
    padding: var(--lotics-space-32) var(--lotics-space-16);
  }

  .lotics-recording-run[data-variant="pane"] .lotics-recording-run__head {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--lotics-space-8);
  }

  .lotics-recording-run__timer {
    flex-shrink: 0;
    font-variant-numeric: var(--lotics-font-numeric);
  }

  /* A few pixels carrying identity, so the solid shade. */
  .lotics-recording-run__dot {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border-radius: var(--lotics-radius-full);
    background-color: var(--lotics-tone-red-solid);
  }

  .lotics-recording-run__meters {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--lotics-space-12);
    width: 100%;
  }

  .lotics-recording-run__meter {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--lotics-space-4);
  }

  .lotics-recording-run__track {
    height: 4px;
    border-radius: var(--lotics-radius-full);
    background: var(--muted);
    overflow: hidden;
    /* `Progress`'s groove, so a silent side still reads as a meter. */
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lotics-shadow-color) 4%, transparent);
  }

  .lotics-recording-run__level {
    height: 100%;
    width: var(--lotics-recording-run-level);
    border-radius: var(--lotics-radius-full);
    background: var(--primary);
  }

  .lotics-recording-run__notice {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--lotics-space-6);
    min-width: 0;
  }

  .lotics-recording-run__prompt {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--lotics-space-8);
  }

  .lotics-recording-run__actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--lotics-space-8);
  }

  .lotics-recording-run[data-variant="pane"] .lotics-recording-run__actions {
    justify-content: center;
    margin-top: var(--lotics-space-8);
  }

  .lotics-recording-run__body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    align-self: stretch;
    min-width: 0;
  }

  /* ── THE PILL ─────────────────────────────────────────────────────────── */
  .lotics-recording-run[data-variant="pill"] {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--lotics-space-8);
    min-width: 0;
    padding: var(--lotics-space-8) var(--lotics-space-12);
    border-radius: var(--lotics-radius-card);
    background: var(--card);
    box-shadow: 0 6px 24px color-mix(in srgb, var(--lotics-shadow-color) 10%, transparent);
  }

  .lotics-recording-run[data-variant="pill"] .lotics-recording-run__head {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    column-gap: var(--lotics-space-12);
    row-gap: var(--lotics-space-8);
    min-width: 0;
    flex-shrink: 0;
  }

  /* A height-capped pill keeps its verbs and scrolls what is under them. */
  .lotics-recording-run[data-variant="pill"] .lotics-recording-run__body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* The words give way first, to a floor that still names the destination and lets a phone's strip seat
     clock, level and Stop on one row; below it the verbs wrap. */
  .lotics-recording-run[data-variant="pill"] .lotics-recording-run__label {
    flex: 1 1 var(--lotics-space-48);
    min-width: 0;
  }

  /* One length for both bars, so the sides compare at a glance. */
  .lotics-recording-run[data-variant="pill"] .lotics-recording-run__meters {
    flex: 0 0 var(--lotics-space-48);
    gap: var(--lotics-space-4);
  }

  /* The end, primary last, wrapped or not. */
  .lotics-recording-run[data-variant="pill"] .lotics-recording-run__actions {
    justify-content: flex-end;
    margin-inline-start: auto;
  }

  /* ── THE PANEL ────────────────────────────────────────────────────────── */
  /* A step more ground and lift than the pill: the one thing on screen that must not be missed. */
  .lotics-recording-run[data-variant="panel"] {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--lotics-space-12);
    min-width: 0;
    padding: var(--lotics-space-16);
    border-radius: var(--lotics-radius-card);
    background: var(--card);
    box-shadow:
      0 0 0 1px var(--border),
      0 12px 32px color-mix(in srgb, var(--lotics-shadow-color) 16%, transparent);
  }

  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__head {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--lotics-space-8);
    min-width: 0;
    flex-shrink: 0;
  }

  .lotics-recording-run__status {
    flex: 1;
    min-width: 0;
  }

  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__meters {
    gap: var(--lotics-space-8);
  }

  /* Samples grown from the centre line, so a silent side is a flat line, not an empty box; fixed sample
     widths read alike in a card and a sheet, a narrow card showing the newest. */
  .lotics-recording-run__wave {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: flex-start;
    justify-content: flex-end;
    gap: var(--lotics-space-2);
    width: fit-content;
    max-width: 100%;
    height: var(--lotics-space-24);
    overflow: hidden;
  }

  .lotics-recording-run__sample {
    flex: 0 0 var(--lotics-space-4);
    height: max(2px, var(--lotics-recording-run-level));
    border-radius: var(--lotics-radius-full);
    background: var(--primary);
  }

  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__actions {
    justify-content: flex-end;
  }

  /* Height-capped, the state, clock, destination and verbs stay whole; only the detail between scrolls. */
  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__label,
  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__actions {
    flex-shrink: 0;
  }

  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__detail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--lotics-space-12);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__detail:empty {
    display: none;
  }

  .lotics-recording-run__detail > .lotics-recording-run__meters,
  .lotics-recording-run__detail > .lotics-recording-run__notice,
  .lotics-recording-run__detail > .lotics-recording-run__prompt,
  .lotics-recording-run__detail > .lotics-recording-run__body {
    flex-shrink: 0;
  }

  /* The mark pulses wherever the run floats over other work, on `AgentRun`'s breath. */
  .lotics-recording-run[data-variant="panel"] .lotics-recording-run__dot,
  .lotics-recording-run[data-variant="pill"] .lotics-recording-run__dot {
    animation-name: lotics-recording-run-pulse;
    animation-duration: calc(var(--lotics-duration-slow) * 6.25);
    animation-timing-function: var(--lotics-ease-standard);
    animation-iteration-count: infinite;
  }

  /* The duration tokens cannot retime an infinite animation: at 1ms it strobes (docs/theming.md §2.3). */
  @media (prefers-reduced-motion: reduce) {
    .lotics-recording-run[data-variant="panel"] .lotics-recording-run__dot,
    .lotics-recording-run[data-variant="pill"] .lotics-recording-run__dot {
      animation: none;
    }
  }

  @keyframes lotics-recording-run-pulse {
    0% {
      opacity: 1;
    }
    50% {
      opacity: 0.35;
    }
    100% {
      opacity: 1;
    }
  }
}
