/* Dogmeat brings the newspaper (assets/js/dogmeat.js). Bottom right, only while he is there. The clips share one
 * 734x362 frame. The newspaper lies at 2-21% of its width, he sits at 29-63%, and he walks in from (and off to) its
 * right edge, so the frame hangs 32% past the right edge of the screen: he enters and leaves off screen. The tossed
 * newspaper lands on the clips' newspaper, and the bubble floats above it. */
html.dm-here #back-to-top { opacity:0 !important; pointer-events:none; } /* he sits where the button is */

.dogmeat {
  --dm-w: 420px;
  --dm-news-left: 2.1%; --dm-news-w: 18.8%; --dm-ground: 2%; /* the newspaper on the ground, in the clips */
  position:fixed; z-index:1030; right:calc(var(--dm-w) * -.319); bottom:0; width:var(--dm-w); pointer-events:none;
}
.dogmeat[hidden] { display:none; }
.dogmeat .dm-dog { position:relative; aspect-ratio:734 / 362; }
.dogmeat .dm-clip,
.dogmeat .dm-still { position:absolute; inset:0; display:block; width:100%; height:100%; }
.dogmeat .dm-clip { opacity:0; }
.dogmeat .dm-clip.is-on { opacity:1; }
.dogmeat .dm-still { visibility:hidden; }
.dogmeat .dm-still { background:url('../img/fallout/dogmeat-sit-still.webp?v=5') center / 100% no-repeat; }
.dogmeat.is-static .dm-still { visibility:visible; }
.dogmeat.is-static .dm-clip { display:none; }

/* The tossed newspaper: a cut-out of the one in the clips, landing on it. */
.dogmeat .dm-toss { position:absolute; left:var(--dm-news-left); bottom:var(--dm-ground); z-index:1; width:var(--dm-news-w); visibility:hidden; }

/* The bubble: an icon floating above the newspaper on the ground, its tail pointing down at it. Hovered, focused
 * or tapped (.is-open), a small preview shows up a little higher: who found it, the title, and two small buttons. Its
 * right end stays above the newspaper, so the preview opens to the left, away from Dogmeat. */
.dogmeat .dm-bubble {
  position:absolute; right:calc(100% - var(--dm-news-left) - var(--dm-news-w) / 2 - 17px); bottom:calc(var(--dm-ground) + 24%); z-index:1;
  transform-origin:calc(100% - 17px) 100%; pointer-events:auto; visibility:hidden;
}
.dogmeat .dm-float { position:relative; animation:dm-bob 2.6s ease-in-out infinite alternate; }
@keyframes dm-bob { to { transform:translateY(-5px); } }
.dogmeat .dm-pop {
  position:relative; display:grid; place-items:center; width:36px; height:34px;
  border:1.5px solid var(--lab-accent, var(--link-color)); border-radius:17px; background:var(--card-bg);
  color:var(--lab-accent, var(--link-color)); font-size:14px; text-decoration:none; box-shadow:0 3px 10px #00000026;
}
.dogmeat .dm-pop::after { /* the tail, pointing down at the newspaper */
  content:''; position:absolute; right:12px; bottom:-6px; width:10px; height:10px; transform:rotate(45deg);
  background:var(--card-bg); border:solid var(--lab-accent, var(--link-color)); border-width:0 1.5px 1.5px 0;
}
.dogmeat .dm-preview {
  position:absolute; right:-8px; bottom:calc(100% + 16px); width:230px; padding:8px 12px 10px;
  background:var(--card-bg); border:1px solid var(--lab-accent, var(--link-color)); border-radius:10px; box-shadow:0 6px 18px #00000026;
  opacity:0; transform:translateY(6px); pointer-events:none; transition:opacity .2s ease, transform .2s ease;
}
.dogmeat .dm-preview::after { content:''; position:absolute; left:0; right:0; top:100%; height:18px; } /* keeps the hover on the way up */
.dogmeat .dm-bubble:hover .dm-preview,
.dogmeat .dm-bubble:focus-within .dm-preview,
.dogmeat .dm-bubble.is-open .dm-preview { opacity:1; transform:none; pointer-events:auto; }
.dogmeat .dm-kicker {
  display:block; margin-bottom:3px; padding-right:46px; color:var(--lab-accent, var(--link-color));
  font:700 10px/1.4 ui-monospace,Consolas,monospace; letter-spacing:1px; text-transform:uppercase;
}
.dogmeat .dm-headline {
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  color:var(--heading-color); font-weight:600; font-size:.88rem; line-height:1.3; text-decoration:none;
}
.dogmeat .dm-headline:hover { color:var(--lab-accent, var(--link-color)); text-decoration:underline; }
.dogmeat .dm-actions { position:absolute; top:6px; right:6px; display:flex; gap:4px; }
.dogmeat .dm-actions button {
  width:20px; height:20px; padding:0; border:0; border-radius:50%; background:transparent;
  color:var(--text-muted-color, var(--text-color)); font-size:13px; line-height:1; cursor:pointer;
}
.dogmeat .dm-actions button:hover { background:var(--lab-selected, var(--card-hover-bg)); color:var(--text-color); }
.dogmeat .dm-actions button[hidden] { display:none; }
.dogmeat .dm-bubble :focus-visible { outline:2px solid var(--lab-accent, var(--link-color)); outline-offset:2px; }

/* the clips swap with opacity; leaving the sitting loop they crossfade for a moment */
.dogmeat .dm-dog.is-xfade .dm-clip { transition:opacity .25s ease; }

@media (max-width:767.98px) {
  .dogmeat { --dm-w: 247px; }
  .dogmeat .dm-preview { width:min(230px, calc(100vw - 24px)); }
}
@media print { .dogmeat { display:none; } }
