/* Live timer: the running card in the sidebar and the start form on the
   timesheet. */
@layer components {
  .sidebar-timer {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin: var(--space-5) 0 0;
    padding: var(--space-3);
    border: 1px solid var(--color-ink);
    border-radius: var(--radius-md);
    background: var(--color-ground);
  }

  .sidebar-timer p {
    margin: 0;
  }

  .sidebar-timer__status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-positive);
    font-size: var(--text-xs);
    font-weight: 600;
  }

  .sidebar-timer__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
  }

  @media (prefers-reduced-motion: no-preference) {
    .sidebar-timer__dot {
      animation: sidebar-timer-pulse 2s ease-in-out infinite;
    }
  }

  @keyframes sidebar-timer-pulse {
    50% { opacity: 0.35; }
  }

  .sidebar-timer__code {
    font-size: var(--text-sm);
    font-weight: 500;
    overflow-wrap: anywhere;
  }

  .sidebar-timer__note {
    color: var(--color-muted);
    font-size: var(--text-xs);
    overflow-wrap: anywhere;
  }

  .sidebar-timer__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-1);
  }

  .sidebar-timer__elapsed {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .sidebar-timer__discard {
    align-self: flex-start;
    padding: var(--space-1) 0;
    border: 0;
    background: none;
    color: var(--color-muted);
    font: inherit;
    font-size: var(--text-xs);
    text-decoration: underline;
    cursor: pointer;
  }

  .sidebar-timer__discard:hover {
    color: var(--color-ink);
  }

  .timer-start {
    position: relative;
  }

  .timer-start > summary {
    list-style: none;
  }

  .timer-start > summary::-webkit-details-marker {
    display: none;
  }

  .timer-start__form {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: min(320px, calc(100vw - 2 * var(--space-4)));
    padding: var(--space-4);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
    background: var(--color-ground);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
  }

  .timer-start__form .field__hint {
    margin: 0;
  }
}
