/* The approved goblin, with a finite hand-drawn greeting and a quiet idle. */
.hero .castle-image { object-fit: contain; }
.grobim-companion .companion-portrait {
  align-self: center; justify-self: center; position: relative;
  width: min(100%, 350px); height: auto; aspect-ratio: 1; margin: 0;
}
.grobim-art { position: absolute; inset: 0; transform-origin: 50% 92%; }
.grobim-companion .grobim-art img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: none; filter: drop-shadow(0 8px 5px #53472f18);
}
.grobim-companion .grobim-art .grobim-success { object-fit: contain; }
.grobim-sheet {
  position: absolute; inset: 0 5.2% 0 -5.2%; visibility: hidden;
  background: 0 0 / 300% 200% no-repeat;
}
.grobim-success { visibility: hidden; }
[data-grobim-pose="wave"] .grobim-idle,
[data-grobim-pose="celebrate"] .grobim-idle { visibility: hidden; }
[data-grobim-pose="wave"] .grobim-sheet { visibility: visible; background-image: url('/assets/grobim-wave.png'); }
[data-grobim-pose="celebrate"] .grobim-success { visibility: visible; }
[data-grobim-active="true"][data-grobim-pose="idle"] .grobim-art {
  animation: grobim-breathe 5.8s ease-in-out infinite;
}
[data-grobim-active="true"][data-grobim-pose="wave"] .grobim-sheet {
  animation: grobim-wave 1.15s steps(1, end) 2;
}
[data-grobim-active="true"][data-grobim-pose="celebrate"] .grobim-art {
  animation: grobim-celebrate 1.8s ease-out both;
}
.grobim-spark { position: absolute; z-index: 1; color: #bb8b38; font-size: 23px; opacity: 0; pointer-events: none; }
.grobim-spark:nth-child(1) { left: 7%; top: 30%; --spark-turn: -22deg; }
.grobim-spark:nth-child(2) { right: 8%; top: 20%; --spark-turn: 25deg; }
.grobim-spark:nth-child(3) { right: 2%; top: 54%; --spark-turn: 12deg; }
[data-grobim-active="true"][data-grobim-pose="celebrate"] .grobim-spark { animation: grobim-spark 1.4s ease-out both; }
.grobim-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; }
.grobim-hello, .grobim-pause {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  min-height: 44px; border-radius: 9px; padding: 9px 14px;
}
.grobim-hello { color: #244e43; background: #f6eed9; border: 1px solid #b49b6b; box-shadow: 0 2px 0 #d6c29a; }
.grobim-pause { color: #705d40; border: 0; padding-inline: 0; background: transparent; text-decoration: underline; text-underline-offset: 4px; }
.grobim-controls [hidden] { display: none; }
.grobim-pause:disabled { cursor: default; text-decoration: none; opacity: .8; }
.grobim-hello:focus-visible, .grobim-pause:focus-visible { outline: 3px solid #244e43; outline-offset: 4px; }
.grobim-speech { min-height: 1.6em; margin-top: 12px; color: #596a40; font-size: 12px; font-weight: 500; }
.closing-art { background-image: url('/assets/grobim-hero.png'); }
@keyframes grobim-breathe {
  0%, 100% { transform: translateY(0) rotate(-.5deg); }
  50% { transform: translateY(-3px) rotate(.5deg); }
}
@keyframes grobim-wave {
  /* Register the drawn frames by their boot baseline to keep the body steady. */
  0% { background-position: 0% 0%; transform: translate(0, 0); }
  16.666% { background-position: 50% 0%; transform: translate(4.1%, .2%); }
  33.333% { background-position: 100% 0%; transform: translate(5.47%, .2%); }
  50% { background-position: 0% 100%; transform: translate(.2%, .8%); }
  66.666% { background-position: 50% 100%; transform: translate(4.1%, .8%); }
  83.333%, 100% { background-position: 100% 100%; transform: translate(5.76%, .8%); }
}
@keyframes grobim-celebrate {
  0% { transform: translateY(0) rotate(0); }
  16% { transform: translateY(-10px) rotate(-3deg); }
  30% { transform: translateY(0) rotate(2deg); }
  43% { transform: translateY(-4px) rotate(-1deg); }
  58%, 100% { transform: translateY(0) rotate(0); }
}
@keyframes grobim-spark {
  0% { opacity: 0; transform: translateY(8px) scale(.6); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-24px) rotate(var(--spark-turn)) scale(1.1); }
}
@media (max-width: 700px) {
  .grobim-companion .companion-portrait { width: min(100%, 280px); }
  .grobim-companion { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .grobim-art, .grobim-sheet, .grobim-spark { animation: none !important; }
}

/* A real sculpt with a quiet studio floor. The approved art is the fallback. */
.grobim-companion .companion-portrait { width: min(100%, 420px); overflow: visible; isolation: isolate; }
.grobim-companion .companion-portrait::before {
  content: ''; position: absolute; inset: 9% 3% 3%; z-index: -1; border-radius: 50%;
  background: radial-gradient(ellipse at 45% 40%, #f8edcc 0%, #e4e8cf80 50%, #e4e8cf00 73%);
}
.grobim-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; touch-action: pan-y; }
[data-grobim3d="ready"] .grobim-canvas { opacity: 1; pointer-events: auto; cursor: grab; }
[data-grobim3d="ready"] .grobim-canvas:active { cursor: grabbing; }
[data-grobim3d="ready"] .grobim-art,
[data-grobim3d="ready"] .grobim-spark { visibility: hidden !important; animation: none !important; }
[data-grobim3d="ready"] .grobim-art * { visibility: hidden !important; animation: none !important; }
.grobim-view-controls { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.grobim-view-controls[hidden] { display: none; }
.grobim-view-controls button { min-width: 44px; min-height: 44px; padding: 8px 13px; border: 1px solid #b3b58e; border-radius: 50px; background: #f7f3e7; color: #244e43; font: inherit; font-size: 12px; cursor: pointer; }
.grobim-view-controls button:hover { background: #e2e8cf; }
.grobim-view-controls svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.grobim-view-controls button:focus-visible { outline: 3px solid #244e43; outline-offset: 3px; }
.grobim-view-controls span { font-size: 10px; color: #777a5e; }
.grobim-3d-status { margin: 10px 0 0; font-size: 10px !important; line-height: 1.5; color: #777a5e; }
.grobim-3d-status:empty { display: none; }
[data-grobim3d="ready"] .grobim-3d-status { display: none; }
.grobim-companion .grobim-controls { gap: 6px 14px; }
@media (max-width: 700px) {
  .grobim-companion .companion-portrait { width: min(100%, 340px); }
  .grobim-view-controls { flex-wrap: wrap; }
}

/* A collectible portrait, with room for the sculpt and a restrained studio halo. */
.grobim-companion {
  grid-template-columns: 1fr 1fr; gap: 36px; padding: 38px 48px 32px 26px;
  background: radial-gradient(ellipse at 26% 41%,#fdf6dc 0%,#f4e6c7 40%,#eee2c4 100%);
  border: 1px solid #bcaa7d; box-shadow: 0 4px 0 #d4c296,0 20px 48px #62503512;
}
.grobim-companion .companion-portrait { width: min(100%,480px); }
.grobim-companion .companion-portrait::before {
  inset: 3% -4% 0; border: 1px solid #b4b78b38;
  background: radial-gradient(ellipse at 48% 37%,#fffbea 0%,#e9edcf80 45%,#d7ddbd24 65%,#e4e8cf00 75%);
}
.grobim-view-controls { gap: 7px; flex-wrap: wrap; }
.grobim-view-controls span { width: 100%; margin: 3px 0 0 6px; font-size: 10px; }
.grobim-view-controls button { background: #fff9e9a6; border-color: #a5ad8a; box-shadow: 0 1px 0 #fff9e9; }
.grobim-view-controls [data-grobim-detail] { border-color: #758368; color: #244e43; }
.grobim-view-controls [aria-pressed="true"] { background: #244e43; color: #fff5d7; border-color: #244e43; }
.grobim-companion .grobim-speech { padding-left: 12px; border-left: 2px solid #a5ad78; font-style: italic; line-height: 1.75; }
.grobim-stage { min-width: 0; display: grid; justify-items: center; gap: 15px; }
.grobim-stage .grobim-view-controls { justify-content: center; margin: 0; }
.grobim-stage .companion-portrait { width: min(100%,480px); }
.grobim-companion .companion-copy { min-width: 0; }
.grobim-companion .companion-copy > p { margin-top: 20px; max-width: 350px; }
.grobim-dialogue {
  position: relative; margin: 28px 0 24px; max-width: 410px; min-height: 98px;
  display: flex; align-items: center; padding: 21px 25px; border: 1px solid #bdac7e;
  border-radius: 22px 22px 22px 7px; background: #fff9e9; box-shadow: 0 4px 0 #dfcfaa66;
}
.grobim-dialogue::before {
  content: ''; position: absolute; left: -9px; top: calc(50% - 9px); width: 16px; height: 16px;
  background: #fff9e9; border-left: 1px solid #bdac7e; border-bottom: 1px solid #bdac7e; transform: rotate(45deg);
}
.grobim-companion .grobim-dialogue .grobim-speech {
  padding: 0; margin: 0; border: 0; color: #345142; font-size: 17px; line-height: 1.6;
  font-style: normal; font-weight: 500; max-width: none;
}
.grobim-companion .grobim-controls { margin: 0; gap: 10px; align-items: stretch; }
.grobim-controls .grobim-pause {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 17px; min-width: 116px; border: 1px solid #244e43; background: #244e43; color: #fff6df;
  box-shadow: 0 3px 0 #183a31; text-decoration: none; border-radius: 10px; font-size: 13px;
}
.grobim-controls .grobim-pause::before {
  content: ''; width: 11px; height: 12px; flex-shrink: 0; background: currentColor;
  clip-path: polygon(0 0,100% 50%,0 100%);
}
[data-grobim-playback="playing"] .grobim-pause::before { clip-path: polygon(0 0,35% 0,35% 100%,0 100%,0 0,65% 0,100% 0,100% 100%,65% 100%,65% 0); }
.grobim-controls .grobim-pause:hover { background: #326251; }
.grobim-controls .grobim-pause:disabled { opacity: .7; cursor: default; box-shadow: none; }
.grobim-controls .grobim-pause:disabled::before { display: none; }
.grobim-controls .grobim-hello { border-radius: 10px; padding: 11px 14px; }
.grobim-controls .grobim-hello:hover { background: #eee2c3; }
.grobim-controls .grobim-pause[hidden] { display: none; }
@media (max-width: 900px) and (min-width: 701px) {
  .grobim-companion { padding: 28px 30px; gap: 24px; grid-template-columns: .95fr 1.05fr; }
}
@media (max-width: 700px) {
  .grobim-companion { grid-template-columns: minmax(0,1fr); padding: 22px 25px 26px; gap: 26px; }
  .grobim-companion .companion-portrait { width: min(100%,360px); }
  .grobim-stage { gap: 13px; }
  .grobim-dialogue { margin-top: 24px; max-width: none; }
  .grobim-dialogue::before { left: 38px; top: -9px; transform: rotate(135deg); }
  .grobim-companion .grobim-dialogue .grobim-speech { font-size: 16px; }
  .grobim-controls .grobim-pause { flex-basis: 100%; }
  .grobim-controls .grobim-hello { flex: 1 1 auto; }
}
