/*
 * PDS-W5 Entry Experience
 * Presentation-only alignment. Runtime and Entry decision behavior stay frozen.
 */

.entry-workspace-page {
  --entry-clear: var(--phi-state-success, #25755e);
  --entry-pending: var(--phi-text-muted, #686e79);
  --entry-failed: var(--phi-state-danger, #a33b32);
}

/* Keep the internal stage model available to Runtime code without exposing a
 * second, technical journey model to customers on Entry. */
.entry-workspace-page [data-runtime-workspace] {
  display: none;
}

.entry-workspace-page .runtime-workspace-layout {
  display: block;
}

.entry-workspace-page .entry-intro-bar {
  align-items: center;
}

.entry-workspace-page .session-boundary {
  max-width: 22rem;
  border-radius: var(--phi-radius-lg, 1rem);
}

.entry-workspace-page .conversation-workspace {
  position: relative;
}

.entry-workspace-page .entry-question-label {
  display: block;
  margin: 0 0 var(--phi-space-3, .75rem);
  color: var(--phi-text-primary, #11141a);
  font-family: var(--phi-font-display, Newsreader, Georgia, serif);
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.2;
}

.entry-workspace-page .entry-composer {
  border-top-color: var(--phi-border-subtle, rgba(17, 20, 26, .14));
  box-shadow: 0 -12px 36px rgba(17, 20, 26, .05);
}

.entry-workspace-page .entry-composer textarea {
  min-height: 7.5rem;
  border-radius: var(--phi-radius-lg, 1rem);
  transition:
    border-color var(--phi-motion-fast, 160ms) ease,
    box-shadow var(--phi-motion-fast, 160ms) ease,
    background var(--phi-motion-fast, 160ms) ease;
}

.entry-workspace-page .entry-composer[data-entry-composer-state="inputting"] textarea {
  border-color: var(--phi-action-primary, #242f7a);
  box-shadow: 0 0 0 4px rgba(36, 47, 122, .1);
}

.entry-workspace-page .entry-composer[data-entry-composer-state="submitting"] textarea {
  background: var(--phi-surface-muted, #f1efe9);
}

.entry-workspace-page .entry-composer[data-entry-composer-state="failed"] textarea {
  border-color: var(--entry-failed);
  box-shadow: 0 0 0 4px rgba(163, 59, 50, .1);
}

.entry-experience-status {
  display: flex;
  align-items: center;
  gap: var(--phi-space-2, .5rem);
  min-height: 2.5rem;
  margin-top: var(--phi-space-2, .5rem);
  color: var(--phi-text-muted, #686e79);
  font-size: .76rem;
}

.entry-experience-status__indicator {
  flex: 0 0 auto;
  width: .5rem;
  height: .5rem;
  border-radius: 999px;
  background: var(--entry-pending);
}

[data-entry-composer-state="inputting"] .entry-experience-status__indicator,
[data-entry-composer-state="submitting"] .entry-experience-status__indicator {
  background: var(--phi-action-primary, #242f7a);
}

[data-entry-composer-state="submitting"] .entry-experience-status__indicator {
  animation: entry-status-pulse 1.1s ease-in-out infinite;
}

[data-entry-composer-state="failed"] .entry-experience-status {
  color: var(--entry-failed);
}

[data-entry-composer-state="failed"] .entry-experience-status__indicator {
  background: var(--entry-failed);
}

.entry-experience-status__return {
  min-height: 2.75rem;
  margin-left: auto;
  border: 0;
  background: transparent;
  color: currentColor;
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}

.entry-workspace-page .message {
  position: relative;
  box-shadow: 0 8px 24px rgba(17, 20, 26, .04);
}

.entry-workspace-page .message .role {
  font-weight: 650;
}

.entry-workspace-page .message.assistant + .message.assistant {
  margin-top: calc(var(--phi-space-2, .5rem) * -1);
}

.entry-clarity-legend {
  color: var(--phi-text-muted, #686e79);
  font-size: .7rem;
  text-align: right;
}

.entry-workspace-page .live-entry-block {
  position: relative;
  padding-right: 4.5rem;
  opacity: 1;
}

.entry-workspace-page .live-entry-block::after {
  position: absolute;
  top: 1.15rem;
  right: 0;
  padding: .2rem .45rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--entry-clear);
  content: attr(data-clarity-label);
  font-size: .62rem;
  font-weight: 650;
}

.entry-workspace-page .live-entry-block[data-clarity="clear"]::after {
  content: attr(data-clarity-label);
}

.entry-workspace-page .live-entry-block[data-clarity="pending"] {
  color: var(--entry-pending);
}

.entry-workspace-page .live-entry-block[data-clarity="pending"]::after {
  color: var(--entry-pending);
  content: attr(data-clarity-label);
}

.entry-workspace-page .live-entry-block[data-clarity="pending"] > p,
.entry-workspace-page .live-entry-block[data-clarity="pending"] > div:last-child {
  font-style: italic;
}

.entry-workspace-page .entry-ready-actions .entry-primary-action {
  min-height: 3rem;
}

.entry-workspace-page .entry-ready-actions .entry-secondary-action {
  min-height: 3rem;
}

@keyframes entry-status-pulse {
  50% { opacity: .35; transform: scale(.8); }
}

@media (max-width: 768px) {
  .entry-workspace-page .entry-composer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding-bottom: max(var(--phi-space-4, 1rem), env(safe-area-inset-bottom));
  }

  .entry-workspace-page .composer-footer,
  .entry-workspace-page .composer-actions {
    width: 100%;
  }

  .entry-workspace-page .entry-send-button {
    min-height: 3rem;
    margin-left: auto;
  }

  .entry-workspace-page .entry-ready-actions > * {
    justify-content: center;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .entry-experience-status {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .entry-experience-status__return {
    width: 100%;
    margin-left: 1rem;
    text-align: left;
  }

  .entry-workspace-page .live-entry-block {
    padding-right: 0;
    padding-top: 2.6rem;
  }

  .entry-workspace-page .live-entry-block::after {
    top: .85rem;
    left: 0;
    right: auto;
  }
}

@media (min-width: 1440px) {
  .entry-workspace-page .entry-workspace-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(25rem, .85fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-workspace-page .entry-composer textarea {
    transition: none;
  }

  [data-entry-composer-state="submitting"] .entry-experience-status__indicator {
    animation: none;
  }
}
