/* The #/waifu scene (docs/waifu-view-plan.md). Every rule is scoped under
   .waifu so style.css stays untouched. The layout follows the frame, not the
   other way round (decision 10): the bubble sits over the dark doorway beside
   her head; the input rides a dark bar along the bottom over the step. */

.waifu {
  /* the bubble's face and base text size; ?place=1 has a slider for the size */
  --waifu-font: "Yusei Magic", sans-serif;
  --waifu-text: 23px;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0b0d12;
  color: #f2f1ec;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.waifu-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* keep her and the doorway when the viewport is narrower than the frame,
     and the top of the frame when it is wider, so her head is not cropped */
  object-position: 60% 12%;
}

/* the app header, floated over the top edge and kept legible on the frame */
.waifu header {
  position: absolute;
  top: 0; left: 0; right: 0;
  margin: 0;
  padding: 0.9rem 1.5rem 2.5rem;
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
  border: 0;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.waifu header h1,
.waifu .tab,
.waifu button.link { color: #fff; }
.waifu .tab { opacity: 0.8; }
.waifu .tab.on, .waifu .tab:hover { opacity: 1; border-bottom-color: #fff; }

/* the chat bubble: a comic cloud (docs/waifu-view-plan.md, decision 11) in
   frosted white glass, mostly opaque, thin white rim, black text —
   placed with ?place=1, its swoosh tail at the bottom-right pointing at her.
   The glass layer is clipped to the cloud path (an objectBoundingBox
   clipPath in the SVG the view builds), and the same path is stroked on top
   as the rim, since a clipped element cannot draw its own border. */
.waifu-bubble {
  position: absolute;
  left: 31.3%;
  top: 14.4%;
  width: 18.3vw;
  min-width: 16rem;
  aspect-ratio: 1.55;
  margin: 0;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.35));
}
.waifu-bubble-glass {
  position: absolute;
  inset: 0;
  clip-path: url(#waifu-cloud);
  /* white, near-solid at the top and thinning toward the tail; still
     frosted, so the scene shows through faintly where it thins */
  background: linear-gradient(rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.7));
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}
.waifu-bubble-edge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  /* the thick comic outline from the reference */
  stroke: #15161a;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}
/* inset, not padding: percentage padding resolves against the scene's
   width, an absolute inset against the bubble's. More room at the bottom,
   where the tail is. */
.waifu-bubble-text {
  font-family: var(--waifu-font);
  position: absolute;
  left: 12%; right: 16%; top: 13%; bottom: 24%;
  display: grid;
  place-items: center;
  font-size: var(--waifu-text);
  font-weight: 400;
  line-height: 1.35;
  text-align: center;
  color: #15161a;
  overflow: hidden;
}
.waifu-bubble-text a {
  color: #2f6f5e;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* the step: a dark fade the input and its cost notice sit on */
.waifu-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 4rem 1.5rem 1.5rem;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.72) 55%);
}
.waifu-input {
  flex: 1;
  max-width: 42rem;
  min-height: 3.1rem;
  resize: none;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.4;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0.9rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 120ms, background 120ms;
}
.waifu-input::placeholder { color: rgba(255, 255, 255, 0.6); }
.waifu-input:hover { border-color: rgba(255, 255, 255, 0.45); }
.waifu-input:focus-visible {
  outline: none;
  border-color: #fff;
  background: rgba(255, 255, 255, 0.16);
}
.waifu-bar button[type="submit"] {
  padding: 0.8rem 1.3rem;
  font-weight: 600;
  color: #15161a;
  background: #fff;
  border: 0;
  border-radius: 0.9rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.waifu-bar button[type="submit"]:hover { background: #f0efea; }
.waifu-bar button[disabled] { opacity: 0.6; }
.waifu-bar .cost {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* narrow: the doorway moves under object-position, so the bubble anchors to
   the top-left instead, its tail pointing down, and the bar stacks */
@media (max-width: 52rem) {
  .waifu-bubble { left: 1rem; top: 4.5rem; width: min(22rem, 70vw); min-width: 0; }
  .waifu-bar { flex-wrap: wrap; padding-top: 3rem; }
  .waifu-input { max-width: none; flex-basis: 100%; }
}

/* ?place=1: the bubble is draggable and the readout shows its CSS */
.waifu-readout {
  position: absolute;
  left: 1.5rem;
  top: 4rem;
  margin: 0;
  padding: 0.6rem 0.8rem;
  font: 0.8rem/1.4 ui-monospace, Consolas, monospace;
  color: #fff;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 0.5rem;
  white-space: pre-wrap;
  max-width: 24rem;
  user-select: all;
}
.waifu.placing .waifu-bubble { user-select: none; outline: 2px dashed rgba(47, 111, 94, 0.9); }
/* the clipped glass does not hit-test outside the cloud, so the whole box
   takes the drag while placing */
.waifu-size {
  position: absolute;
  left: 1.5rem;
  top: 9.5rem;
  width: 16rem;
  accent-color: #2f6f5e;
}
.waifu.placing .waifu-bubble::before { content: ""; position: absolute; inset: 0; z-index: 1; }
