/* Yu Yue's room: the floor under the machine. She sits with her laptop, wired
   to the machine; around her a lamp (the light), a stack of books with her tea
   on it (past conversations), a radio (her voice) and a plant. Everything is
   line: state shows as rays, hatching, notes and the dots running up the cable.
   The room is whatever height the machine leaves. */
.yard {
  --at: 45%;
  position: relative;
  flex: none;
  height: 300px;
  --ground-height: 30px;
  --figure-height: 196px;
  background: var(--bg);
  isolation: isolate;
}
/* The room takes what the machine leaves, and she is as tall as the room
   allows. Left with a strip, she keeps the corner and the furniture goes. */
@supports (container-type: size) {
  .yard {
    flex: 1 0 clamp(84px, 12.5vh, 112px);
    height: auto;
    container: yard / size;
    --ground-height: clamp(9px, 11cqh, 48px);
    --figure-height: clamp(60px, calc((100cqh - var(--ground-height) - 8px) / 1.32), clamp(150px, 26.5vh, 300px));
  }
}
@supports not (container-type: size) {
  .left.work .yard { display: none; }
  @media (max-width: 900px) { .app:not([data-tab="screen"]) .yard { display: none; } }
}
.footpath, .cable { position: absolute; left: 0; width: 100%; pointer-events: none; fill: none; stroke: var(--ink2); stroke-linecap: round; }
.footpath { bottom: calc(var(--ground-height) - 15px); height: 30px; opacity: .8; }
.footpath path { vector-effect: non-scaling-stroke; stroke-width: .85; }
.cable { top: 0; height: 100%; }
.cable .wire { stroke-width: .85; opacity: .68; }
/* A turn is running: dots travel from her laptop up to the machine. */
.cable .pulse { stroke: var(--ink); stroke-width: 2.4; stroke-dasharray: .1 30; opacity: 0; transition: opacity .4s; }
.yard.busy .cable .pulse { opacity: .85; animation: pulse 1.25s linear infinite; }
@keyframes pulse { to { stroke-dashoffset: 30.1; } }

.prop { position: absolute; bottom: calc(var(--ground-height) - 1px); padding: 0; border: 0; border-radius: 4px; background: none; color: var(--ink2); translate: -50% 0; transition: color .25s, opacity .3s; }
.prop svg { display: block; width: auto; height: 100%; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }
.prop .solid { fill: var(--bg); }
.prop .dot { fill: currentColor; stroke: none; }
button.prop:hover { color: var(--ink); }
.plant { left: 5.5%; height: calc(var(--figure-height) * .62); transform-origin: 50% 100%; animation: sway 6.5s ease-in-out infinite alternate; }
@keyframes sway { from { rotate: -.9deg; } to { rotate: .9deg; } }
.lamp { left: 16.5%; height: calc(var(--figure-height) * 1.28); }
.lamp .shade { fill: var(--bg); transition: fill .4s; }
.lamp .rays { stroke-dasharray: 2.5 7; opacity: 0; transition: opacity .6s; }
/* Night is the dark page: the lamp is on. */
:root[data-night] .lamp .shade { fill: url(#hA2); }
:root[data-night] .lamp .rays { opacity: .62; }
.books { left: 28%; height: calc(var(--figure-height) * .4); }
.books .steam { stroke-dasharray: 3 3.4; opacity: .75; animation: steam 2.8s linear infinite; }
@keyframes steam { to { stroke-dashoffset: -12.8; } }
.radio { left: 89.5%; height: calc(var(--figure-height) * .5); }
.clock { left: 89.5%; top: clamp(18px, 3.4vh, 34px); bottom: auto; height: calc(var(--figure-height) * .21); }
.clock .hour { stroke-width: 1.7; }
.radio .grille { fill: url(#hA2); }
.radio .notes { opacity: 0; }
:root[data-sound] .radio .notes { animation: note 2.6s ease-in-out infinite; }
:root[data-sound] .radio .notes.late { animation-delay: 1.3s; }
@keyframes note { 0% { opacity: 0; translate: 0 7px; } 30% { opacity: .95; } 100% { opacity: 0; translate: 7px -12px; } }

.operator {
  position: absolute;
  bottom: calc(var(--ground-height) - var(--figure-height) * .026);
  left: var(--at);
  translate: -50% 0;
  height: var(--figure-height);
  aspect-ratio: 384 / 416;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  mix-blend-mode: var(--pet-blend);
  transform-origin: 50% 100%;
  animation: breathe 4.4s ease-in-out infinite alternate;
  view-transition-name: yuyue;
}
@keyframes breathe { to { scale: 1 1.007; } }
.operator.away { visibility: hidden; view-transition-name: none; }
/* While she is out showing the page, the room is put away, so she never stands on its furniture. */
.yard:has(.operator.away) .prop, .yard:has(.operator.away) .cable { opacity: 0; }
.figure {
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  filter: var(--pet-ink);
  background-image: url(yuyue-seated.webp);
  background-size: 400% 100%;
  background-position: var(--gaze, 66.6667%) 0;
}
.operator.typing .figure {
  background-image: url(yuyue-typing.webp);
  background-size: 600% 100%;
  background-position: 0 0;
  animation: pet-frames 1.2s steps(6, jump-none) infinite;
}
/* Her shape, where cabin.css cuts the drawing to it, steps with the drawing. */
@keyframes pet-frames {
  from { background-position: 0% 0; -webkit-mask-position: 0% 0; mask-position: 0% 0; }
  to { background-position: 100% 0; -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
/* Dozing: a pair of small letters drifting off. */
.mood { position: absolute; left: 60%; top: 2%; width: 30%; height: 20%; pointer-events: none; font-style: italic; font-size: calc(var(--figure-height) * .07); color: var(--ink2); }
.mood::before, .mood::after { content: "z"; position: absolute; left: 0; bottom: 0; opacity: 0; }
.mood::after { left: 38%; bottom: 30%; font-size: 1.35em; }
.operator.doze .mood::before { animation: zed 3.2s ease-in-out infinite; }
.operator.doze .mood::after { animation: zed 3.2s 1.6s ease-in-out infinite; }
@keyframes zed { 0% { opacity: 0; translate: 0 8px; } 40% { opacity: .9; } 100% { opacity: 0; translate: 9px -12px; } }

/* What she says. */
.bubble {
  position: absolute;
  z-index: 3;
  left: calc(var(--at) + var(--figure-height) * .17);
  bottom: calc(var(--ground-height) + var(--figure-height) * .82);
  max-width: min(250px, 36%);
  padding: 7px 14px 8px;
  border: 1px solid var(--ink);
  border-radius: 14px 14px 14px 3px;
  background: var(--bg);
  box-shadow: 1.5px 2.5px var(--bg), 2.5px 3.5px var(--ink2);
  font-size: 15px;
  line-height: 1.5;
  transform-origin: 0 100%;
  animation: pop .46s var(--spring) both;
}
.bubble.leaving { animation: unpop .18s ease-in both; }
@keyframes pop { from { opacity: 0; scale: .7; translate: -4px 6px; } }
@keyframes unpop { to { opacity: 0; scale: .92; } }
.bubble .go { display: inline-block; margin: 2px 16px 0 0; padding: 0; border: 0; background: none; font-family: var(--sc); font-size: 13px; letter-spacing: .1em; color: var(--ink2); text-decoration: underline; text-decoration-color: var(--ink3); text-underline-offset: 4px; }
.bubble .go:hover { color: var(--ink); }
/* What she says on its own line, her offers side by side under it. */
.bubble > span { display: block; }

@container yard (max-height: 168px) {
  .yard > * { --figure-height: clamp(60px, calc(100cqh - 16px), 92px); --ground-height: 9px; --at: 67%; }
  .yard .prop { display: none; }
  .yard .operator { animation: none; }
  .yard .bubble { left: auto; right: calc(100% - var(--at) + var(--figure-height) * .52); bottom: calc(var(--ground-height) + var(--figure-height) * .3); max-width: 58%; border-radius: 14px 14px 3px 14px; transform-origin: 100% 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .yard .bubble > span, .yard .bubble .go { display: inline; }
  .yard .bubble .go { margin: 0 0 0 10px; }
}

/* ── The tour: she comes over and shows each part ─────────────── */
.tour { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.tour .veil { position: absolute; inset: 0; width: 100%; height: 100%; }
.tour .veil .shade { fill: var(--bg); fill-opacity: .74; pointer-events: fill; }
.tour .veil .ring { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.tour .veil .tick { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
.guide { position: absolute; display: flex; align-items: flex-end; gap: 4px; width: min(430px, calc(100vw - 24px)); pointer-events: auto; }
.guide .figure { flex: none; width: 84px; height: 91px; mix-blend-mode: var(--pet-blend); view-transition-name: yuyue; }
/* The floor she brought with her. */
.guide::after { content: ""; position: absolute; left: -6px; bottom: 1px; width: 100px; border-bottom: 1px solid var(--ink2); }
.guide.flip::after { left: auto; right: -6px; }
.guide.self::after { display: none; }
.guide .card { flex: 1; min-width: 0; margin-bottom: 26px; padding: 10px 14px 10px 16px; border: 1px solid var(--ink); border-radius: 14px 14px 14px 3px; background: var(--bg); box-shadow: 1.5px 2.5px var(--bg), 2.5px 3.5px var(--ink2); view-transition-name: guide-card; }
.guide.flip { flex-direction: row-reverse; }
.guide.self .figure { display: none; }
.guide.self .card { margin-bottom: 0; }
.guide.flip .card { border-radius: 14px 14px 3px 14px; }
.guide p { margin: 0 0 8px; font-size: 15.5px; line-height: 1.6; }
.guide .row { display: flex; align-items: center; gap: 14px; }
.guide .count { margin-right: auto; font-family: var(--han); font-size: 12.5px; color: var(--ink3); letter-spacing: .1em; }
.guide .btn { padding: 3px 16px; }

/* Narrow: beside the machine she has the room; above the other views, a strip. */
@media (max-width: 900px) {
  .app:not([data-tab="screen"]) .yard { flex: none; height: 92px; border-bottom: 1px solid var(--rule); }
}
@media (max-width: 560px) {
  .plant, .books { display: none; }
  .lamp { left: 11%; }
  .radio { left: 88%; }
  .yard { --at: 44%; }
  .bubble { max-width: 44%; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .operator, .operator .figure, .plant, .books .steam, .radio .notes, .cable .pulse, .mood::before, .mood::after, .bubble { animation: none !important; }
  .yard.busy .cable .pulse { opacity: .5; }
}
