/* ==========================================================================
   pplx-apple-transitions — demo stylesheet
   Vanilla CSS, no preprocessor, no build step.
   Every interaction pattern below is commented so it can be lifted
   independently. See docs/apple-transitions.md and
   docs/pplx-composer-patterns.md for the written-out recipes.
   ========================================================================== */

:root {
  /* ---- palette: warm near-black surface + teal accent ---- */
  --surface-0: #0c0d0d;          /* page background, warm near-black (not pure #000) */
  --surface-1: #151716;          /* composer body surface */
  --surface-2: #1c1f1e;          /* raised elements: pills, palette items */
  --hairline: rgba(255, 255, 255, 0.08);

  --teal: #2dd4bf;               /* primary accent, used sparingly */
  --teal-soft: rgba(45, 212, 191, 0.35);
  --teal-glow: rgba(45, 212, 191, 0.22);

  --ink-high: rgba(255, 255, 255, 0.92);
  --ink-mid: rgba(255, 255, 255, 0.62);
  --ink-low: rgba(255, 255, 255, 0.38);

  --gray-btn: #3a3d3c;           /* send button, disabled/idle gray */
  --gray-btn-hover: #464a49;

  /* ---- motion tokens: shared easing + durations ----
     see examples/easing-tokens.css for a standalone copy */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);   /* settle-in, macOS-ish */
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --dur-fast: 140ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;
  --dur-breathe: 4200ms;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-0);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(45, 212, 191, 0.06), transparent 55%);
  color: var(--ink-high);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  padding: 48px 20px;
}

.stage {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.stage__intro {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

.headline {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subhead {
  margin: 0;
  font-size: 14px;
  color: var(--ink-mid);
  line-height: 1.5;
}

.subhead a {
  color: var(--teal);
}

kbd {
  font-family: inherit;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}

.stage__note {
  text-align: center;
  font-size: 12px;
  color: var(--ink-low);
}

.stage__note code {
  color: var(--ink-mid);
}

/* ==========================================================================
   PATTERN 1 — composer opening animation
   The whole composer scales + fades + rises into place on load, like a
   macOS window/sheet settling rather than snapping into existence.
   ========================================================================== */
.composer {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  padding: 2px;
  animation: composer-open var(--dur-slow) var(--ease-spring) both;
}

@keyframes composer-open {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* ==========================================================================
   PATTERN 2 — breathing glow
   A soft teal glow pulses slowly behind the composer border, like the
   surface is idly "alive." Runs continuously but subtly; never distracting.
   ========================================================================== */
.composer__glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 1px var(--teal-soft), 0 0 24px 2px var(--teal-glow);
  opacity: 0.55;
  animation: composer-breathe var(--dur-breathe) ease-in-out infinite;
}

@keyframes composer-breathe {
  0%, 100% {
    opacity: 0.4;
    box-shadow: 0 0 0 1px var(--teal-soft), 0 0 18px 0px var(--teal-glow);
  }
  50% {
    opacity: 0.75;
    box-shadow: 0 0 0 1px var(--teal-soft), 0 0 32px 4px var(--teal-glow);
  }
}

/* Focus state amps the glow up and speeds the breathing slightly —
   see docs/pplx-composer-patterns.md "focus glow" */
.composer[data-state="focused"] .composer__glow {
  opacity: 0.9;
  animation-duration: 2600ms;
}

/* ==========================================================================
   PATTERN 3 — border light sweep
   A thin bright arc travels around the border on focus, like light
   catching a glass edge. Purely decorative, purely on `::before` layer.
   ========================================================================== */
.composer__sweep {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out-soft);
}

.composer__sweep::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 260deg,
    var(--teal) 300deg,
    transparent 340deg
  );
  animation: sweep-rotate 2600ms linear infinite;
}

@keyframes sweep-rotate {
  to { transform: rotate(360deg); }
}

.composer[data-state="focused"] .composer__sweep {
  opacity: 0.5;
}

/* ==========================================================================
   composer body / layout
   ========================================================================== */
.composer__body {
  position: relative;
  z-index: 1;
  background: var(--surface-1);
  border-radius: calc(var(--radius-lg) - 2px);
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer__pills {
  display: flex;
  gap: 6px;
}

/* pills: quick-action chips, Apple-segmented-control energy */
.pill {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-mid);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-soft),
              color var(--dur-fast) var(--ease-out-soft),
              border-color var(--dur-fast) var(--ease-out-soft);
}

.pill:hover {
  background: var(--surface-2);
  color: var(--ink-high);
}

.pill--active {
  background: var(--surface-2);
  color: var(--teal);
  border-color: var(--teal-soft);
}

.composer__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer__field {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-high);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  max-height: 160px;
  padding: 6px 4px;
}

.composer__field::placeholder {
  color: var(--ink-low);
}

.composer__footrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.char-hint {
  font-size: 11px;
  color: var(--ink-low);
  min-height: 14px;
}

/* ==========================================================================
   PATTERN 4 — model switch magnetic hover
   Button nudges toward the cursor slightly on hover via a CSS custom
   property set from JS (see src/app.js mousemove handler).
   ========================================================================== */
.model-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--ink-mid);
  font: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transform: translate(var(--magnet-x, 0px), var(--magnet-y, 0px));
  transition: transform var(--dur-fast) var(--ease-out-soft),
              border-color var(--dur-fast) var(--ease-out-soft),
              color var(--dur-fast) var(--ease-out-soft);
}

.model-switch:hover {
  border-color: var(--teal-soft);
  color: var(--ink-high);
}

.model-switch__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

/* ==========================================================================
   mic button + PATTERN 5 — mic shimmer
   A faint diagonal shimmer sweeps across the mic icon on hover/active,
   suggesting "listening" without full waveform simulation.
   ========================================================================== */
.mic-button {
  position: relative;
  overflow: hidden;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink-mid);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-soft),
              border-color var(--dur-fast) var(--ease-out-soft);
}

.mic-button:hover {
  color: var(--teal);
  border-color: var(--teal-soft);
}

.mic-button__shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(45, 212, 191, 0.35) 50%, transparent 60%);
  transform: translateX(-120%);
  opacity: 0;
}

.mic-button:hover .mic-button__shimmer,
.mic-button.is-active .mic-button__shimmer {
  opacity: 1;
  animation: mic-shimmer-sweep 1100ms var(--ease-in-out);
}

@keyframes mic-shimmer-sweep {
  to { transform: translateX(120%); }
}

/* ==========================================================================
   PATTERN 6 — send button charge
   Idle: flat gray, disabled. As the user types, a radial "charge" fill
   grows from the center and the button shifts toward the teal accent,
   like it's accumulating energy to fire.
   ========================================================================== */
.composer__send {
  position: relative;
  overflow: hidden;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-btn);
  color: rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  cursor: not-allowed;
  transition: background var(--dur-base) var(--ease-out-soft),
              color var(--dur-base) var(--ease-out-soft),
              transform var(--dur-fast) var(--ease-out-soft);
}

.composer__send-charge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, var(--teal) 0%, transparent 72%);
  transform: scale(0);
  opacity: 0;
  transition: transform var(--dur-base) var(--ease-spring), opacity var(--dur-base) ease;
}

/* charge level set via inline custom property --charge (0..1) from JS */
.composer__send[data-charging="true"] .composer__send-charge {
  transform: scale(var(--charge, 0));
  opacity: var(--charge, 0);
}

.composer__send:not(:disabled) {
  background: var(--teal);
  color: #06110f;
  cursor: pointer;
}

.composer__send:not(:disabled):hover {
  transform: scale(1.06);
}

.composer__send:not(:disabled):active {
  transform: scale(0.94);
}

/* ==========================================================================
   PATTERN 7 — slash palette bloom
   Palette expands from the top edge of the composer, scaling from a
   flattened state into full height, like it's blooming open rather
   than sliding or fading.
   ========================================================================== */
.slash-palette {
  position: relative;
  z-index: 1;
  margin: 0 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  transform-origin: top center;
  animation: palette-bloom var(--dur-base) var(--ease-spring) both;
}

@keyframes palette-bloom {
  from {
    opacity: 0;
    transform: scaleY(0.6) scaleX(0.96);
  }
  to {
    opacity: 1;
    transform: scaleY(1) scaleX(1);
  }
}

.slash-palette[hidden] {
  display: none;
}

.slash-palette__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink-mid);
  cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

.slash-palette__item:hover,
.slash-palette__item:focus-visible {
  background: var(--surface-1);
  color: var(--ink-high);
  outline: none;
}

.slash-palette__icon {
  color: var(--teal);
  width: 16px;
  text-align: center;
}

/* ==========================================================================
   PATTERN 8 — reduce motion support
   Every animated pattern above collapses to an instant or minimal-motion
   equivalent when the user has asked the OS for reduced motion. This is
   a blanket override placed last so it always wins.
   See examples/reduced-motion-snippet.css for a copy-paste version.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .composer,
  .composer__glow,
  .composer__sweep::before,
  .mic-button__shimmer,
  .slash-palette,
  .composer__send-charge {
    animation: none !important;
    transition-duration: 1ms !important;
  }

  .composer {
    opacity: 1;
    transform: none;
    filter: none;
  }

  .composer__glow {
    opacity: 0.55;
  }

  .composer__sweep {
    display: none;
  }

  .model-switch {
    transform: none !important;
  }
}

@media (max-width: 480px) {
  .headline {
    font-size: 22px;
  }
}
