/* =============================================
   Pagáček Mascot — Grain of Design
   Only for Pagáč articles (Signature Stories)
   Spritesheet: 8 cols × 11 rows, cell 192×208 px
   Display at 0.5× → cell 96×104 px, atlas 768×1144 px
   ============================================= */

#pagac-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transform: translateX(140px);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

#pagac-wrap.pm-on {
  transform: translateX(0);
  pointer-events: auto;
}

/* ---- Sprite ---- */
#pagac-sprite {
  width: 96px;
  height: 104px;
  background-image: url('pagac-sprite.webp');
  background-size: 768px 1144px;
  background-repeat: no-repeat;
  background-position: 0px 0px;
  cursor: pointer;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  flex-shrink: 0;
  border-radius: 4px;
}

/* ---- Idle  – row 0, 6 frames ---- */
@keyframes pm-idle {
  from { background-position-x: 0; }
  to   { background-position-x: -576px; }
}

/* ---- Waving – row 3, 4 frames ---- */
@keyframes pm-wave {
  from { background-position-x: 0; }
  to   { background-position-x: -384px; }
}

#pagac-sprite.pm-idle {
  background-position-y: 0px;
  animation: pm-idle 1.2s steps(6) infinite;
}

#pagac-sprite.pm-wave {
  background-position-y: -312px; /* row 3 × 104 px */
  animation: pm-wave 0.9s steps(4) 3;
}

/* ---- Speech bubble ---- */
#pagac-bubble {
  display: none;
  position: relative;
  background: #fff;
  border: 1px solid #ddd6cd;
  border-radius: 10px;
  padding: 10px 32px 10px 12px;
  font-family: 'Source Sans Pro', 'Helvetica Neue', sans-serif;
  font-size: 0.82rem;
  color: #3a3330;
  line-height: 1.5;
  max-width: 180px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.09);
}

#pagac-bubble.pm-open {
  display: block;
}

/* tail pointing down-right */
#pagac-bubble::before {
  content: '';
  position: absolute;
  bottom: -9px;
  right: 27px;
  border: 9px solid transparent;
  border-top-color: #ddd6cd;
  border-bottom: 0;
}
#pagac-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 28px;
  border: 8px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}

/* ---- Close button ---- */
#pagac-close {
  position: absolute;
  top: 5px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: #bbb;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  transition: color 0.15s;
}
#pagac-close:hover { color: #888; }

/* ---- Mobile: smaller, won't overlap text ---- */
@media (max-width: 600px) {
  #pagac-wrap {
    bottom: 14px;
    right: 10px;
    transform: translateX(120px) scale(0.78);
    transform-origin: bottom right;
  }
  #pagac-wrap.pm-on {
    transform: translateX(0) scale(0.78);
  }
}

/* ---- Reduced motion: static idle frame 0,0 ---- */
@media (prefers-reduced-motion: reduce) {
  #pagac-sprite {
    animation: none !important;
    background-position: 0px 0px !important;
  }
  #pagac-wrap {
    transition: none !important;
  }
}

/* ---- Shared Pagáč article typography ---- */
.article-container .article-header .article-title {
  font-size: 32px !important;
  line-height: 1.2;
  margin: 0.7rem 0 0.45rem;
}

.article-container .article-header > .article-category {
  display: inline-block;
  margin-bottom: 0.55rem;
}

.article-container .article-header > .article-subtitle,
.article-container .article-header > p:not(.gd-media-credit):not(.article-note) {
  font-size: 18px !important;
  line-height: 1.4;
  margin: 0.75rem 0 0.35rem !important;
}

.article-container .article-header > .article-note,
.article-container .article-header > .gd-media-credit,
.article-container .article-content .gd-media-credit {
  font-size: 14px !important;
  line-height: 1.45;
  margin: 0.55rem 0 0 !important;
}

@media (max-width: 600px) {
  .article-container .article-header .article-title {
    font-size: 26px !important;
  }

  .article-container .article-header > .article-subtitle,
  .article-container .article-header > p:not(.gd-media-credit):not(.article-note) {
    font-size: 16px !important;
  }
}
