/* Components: chrome, cards, controls, step layout. */

/* Translucent chrome, content scrolls beneath it */
.chrome {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--chrome-bg);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
}

.chrome-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.brand {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 650;
  letter-spacing: -0.01em;
  /* The full wordmark has to share the header with two controls on a 320px
     phone, so it scales down there and is capped at body size on desktop. */
  font-size: clamp(0.8125rem, 3.6vw, 1rem);
}

.main {
  padding-block: var(--space-6) 8rem;
}

/* Step transition: only the incoming content animates, because the app renders
   by replacing the tree — the outgoing step is already gone by the time we
   could animate it. At 220ms the eye reads it as a slide either way.
   Under prefers-reduced-motion the global rule in base.css clamps the duration
   to 0.01ms, so this becomes an instant swap with no vestibular movement. */
.main.step-forward {
  animation: step-in-forward 220ms var(--ease-out) both;
}

.main.step-back {
  animation: step-in-back 220ms var(--ease-out) both;
}

@keyframes step-in-forward {
  from {
    opacity: 0;
    transform: translate3d(18px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes step-in-back {
  from {
    opacity: 0;
    transform: translate3d(-18px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Prompt length. Not a limit — generators differ too much to impose one. */
.char-count {
  margin: var(--space-2) 0 0;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  font-weight: 560;
  transition: transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

/* Feedback lands on press, not release */
.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  padding-inline: var(--space-5);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-quiet {
  color: var(--text-2);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--surface-2);
}

/* Header controls must read as controls: a bordered pill on the surface, not a
   bare glyph floating in the chrome. */
.btn-ghost {
  padding: 0 var(--space-3);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 560;
}

.btn-ghost:hover {
  border-color: var(--text-2);
}

.btn-ghost .icon {
  color: var(--text-2);
}

.icon {
  display: inline-flex;
}

/* Mode selection */
.mode-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
}

@media (min-width: 30rem) {
  .mode-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 132px;
  padding: var(--space-4);
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.mode-card:hover {
  border-color: var(--accent);
}

.mode-card:active {
  transform: scale(0.985);
}

.mode-card .icon {
  color: var(--accent);
}

.mode-title {
  font-size: 1.0625rem;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.mode-desc {
  display: block;
}

/* First-screen explainer. The box is reserved by aspect-ratio + width/height
   attributes, so nothing shifts when the poster frame arrives. */
.explainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-6) 0 0;
}

.explainer-video {
  width: 100%;
  max-width: 22.5rem;
  /* height:auto is required: the HTML height attribute (needed to reserve the
     box) otherwise wins as a literal 1280px, and aspect-ratio never applies. */
  height: auto;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.explainer-caption {
  text-align: center;
}

.explainer-summary {
  max-width: 22.5rem;
  text-align: center;
}

/* Steps */
.progress {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

.fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-top: var(--space-5);
}

/* Sticky action bar */
.actionbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 10;
  background: var(--chrome-bg);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.actionbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-3);
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: 0.875rem;
  font-weight: 580;
  letter-spacing: 0.005em;
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-3) var(--space-3);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.input:hover {
  border-color: var(--text-2);
}

.field-hint {
  margin: 0;
}

.field.is-invalid .input {
  border-color: var(--danger);
}

.field-error {
  margin: 0;
  color: var(--danger);
}

/* Progressive disclosure for optional fields */
.disclosure {
  align-self: flex-start;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  color: var(--text-2);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.875rem;
}

.disclosure:hover {
  color: var(--text);
  border-color: var(--text-2);
}

/* Prompt output */
.prompt-card {
  margin: 0;
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  user-select: text;
}

/* Preview and breakdown disclosures */
.preview > summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--text-2);
  font-size: 0.875rem;
  cursor: pointer;
}

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

.preview[open] > summary {
  color: var(--text);
}

.preview .prompt-card {
  margin-top: var(--space-2);
}

.action-row {
  flex-wrap: wrap;
}

.restore {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-2);
  color: var(--text-2);
}

.breakdown {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.breakdown li {
  display: grid;
  gap: 2px;
}

.breakdown-phrase {
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
