.greeting-stage {
  --greeting-ink: #242f27;
  --greeting-accent: #356651;
  --greeting-portrait-background: #ebeee1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 1.15fr);
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid #dfdece;
  border-radius: 16px;
  background: #fffdf7;
  color: var(--greeting-ink);
}

.greeting-stage[data-greeting-tone="help"] {
  --greeting-accent: #89553e;
  --greeting-portrait-background: #f4e7d8;
}

.greeting-stage[data-greeting-tone="finish"] {
  --greeting-accent: #785323;
  --greeting-portrait-background: #f1e5c9;
}

.greeting-setting {
  display: grid;
  align-content: end;
  gap: 6px;
  padding: 10px;
  background:
    linear-gradient(180deg, #22272033, #20291d90),
    url('/assets/gruzingo-georgia-scenery-poster.jpg') 50% 45% / cover #647364;
}

.greeting-place {
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 20px;
  background: #252c23d9;
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
}

.greeting-cast {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.greeting-character {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #f5f2e5bb;
  border-radius: 10px;
  background: #252c23ed;
  color: #fff;
  text-align: center;
}

.greeting-character[data-greeting-active="true"] {
  border-color: #fff9dc;
  background: var(--greeting-accent);
  box-shadow: 0 0 0 1px #fff9dcb8;
}

.greeting-name {
  display: block;
  padding: 2px 4px;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
}

.greeting-portrait {
  position: relative;
  isolation: isolate;
  height: clamp(60px, 11vw, 95px);
  overflow: hidden;
  background: var(--greeting-portrait-background);
}

.greeting-portrait > img,
.greeting-portrait > canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  object-fit: cover;
  object-position: top center;
  pointer-events: none;
}

.greeting-portrait[data-greeting-portrait="inga"] > img,
.greeting-portrait[data-greeting-portrait="inga"] > canvas {
  mix-blend-mode: multiply;
}

.greeting-portrait > canvas { opacity: 0; }
.greeting-portrait:is(.has-speaking-face, [data-greeting-articulating]) > canvas { opacity: 1; }
.greeting-portrait:is(.has-speaking-face, [data-greeting-articulating]) > img { opacity: 0; }

.greeting-reply {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 3px;
  min-width: 0;
  padding: 10px 14px;
}

.greeting-reply p {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
}

.greeting-speaker {
  color: var(--greeting-accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  line-height: 1.4;
  text-transform: uppercase;
}

.greeting-line {
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 750;
  line-height: 1.35;
}

.greeting-caption {
  color: #505a4e;
  font-size: 13px;
  line-height: 1.4;
}

.greeting-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.greeting-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid #dfe3d8;
  border-radius: 8px;
  background: #f2f4ed;
  color: #315541;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.greeting-controls button:hover { background: #e5ecdf; }
.greeting-controls button:focus-visible { outline: 2px solid #315541; outline-offset: 2px; }
.greeting-play > span {
  flex: none;
  width: 0;
  height: 0;
  border-block: 5px solid transparent;
  border-inline-start: 7px solid currentColor;
}

.greeting-audio-status {
  color: #814234;
  font-size: 12px;
  line-height: 1.4;
}

@media (prefers-reduced-motion: no-preference) {
  .greeting-stage.greeting-react[data-greeting-tone="success"] .greeting-character[data-greeting-active="true"] {
    animation: greeting-nod 390ms ease-out;
  }

  .greeting-stage.greeting-react:is([data-greeting-lesson="polite-replies"], [data-greeting-lesson="mixed-greetings"])[data-greeting-tone="success"]
    [data-greeting-character="guri"][data-greeting-active="false"] {
    animation: greeting-nod 460ms ease-out 90ms;
  }

  .greeting-stage.greeting-react[data-greeting-tone="help"] .greeting-character[data-greeting-active="true"] {
    animation: greeting-attend 360ms ease-out;
  }

  .greeting-stage.greeting-react[data-greeting-tone="finish"] .greeting-character {
    animation: greeting-nod 500ms ease-out;
  }
}

@keyframes greeting-nod {
  35% { transform: translateY(-4px); }
  62% { transform: translateY(1px); }
}

@keyframes greeting-attend {
  42% { transform: rotate(-2deg); }
}

@media (max-width: 580px) {
  .greeting-stage { grid-template-columns: minmax(0, 1fr); margin-bottom: 12px; }
  .greeting-setting { padding: 6px 8px 8px; }
  .greeting-portrait { height: clamp(56px, 16vw, 86px); }
  .greeting-reply { padding: 8px 10px; }
}
