/* PulseDrivers helper Gar34 (2.0.152, 2.0.154, 2.0.155, 2.0.158, 2.0.160). Loaded only by templates/pd_mascot.html.
   Fixed bottom-right widget: a round porthole (light studio disc, gunmetal ring, red hairline) that reads the same on the
   dark and light themes. Everything is namespaced .pd-mascot*, nothing else on the page is restyled. */

.pd-mascot {
  --pd-mascot-size: 140px;
  --pd-mascot-base: max(1rem, calc(env(safe-area-inset-bottom, 0px) + .5rem));
  --pd-mascot-edge: max(1rem, calc(env(safe-area-inset-right, 0px) + .5rem));
  position: fixed;
  z-index: 1030;
  right: var(--pd-mascot-edge);
  bottom: calc(var(--pd-mascot-base) + var(--pd-mascot-dodge, 0px));
  width: 0; height: 0;
  font-family: var(--pd-font-body, system-ui, sans-serif);
  transition: opacity .2s ease, transform .2s ease;
}
.pd-mascot [hidden] { display: none !important; }
.pd-mascot-live {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pd-mascot-wrap { position: absolute; right: 0; bottom: 0; }

/* hidden while a modal, dialog, scanner, lightbox or the catalog filter sheet is open, or while the footer is in its corner */
.pd-mascot.is-suppressed, .pd-mascot.is-tucked { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s ease, visibility 0s linear .15s; }
/* the card toast sits bottom-right: step up out of its way while one is showing */
body:has(#pd-card-toast:not([hidden])) .pd-mascot { transform: translateY(-4.75rem); }

/* ---------- the porthole button ---------- */
.pd-mascot-btn {
  position: relative; display: block; width: var(--pd-mascot-size); height: var(--pd-mascot-size);
  margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .45));
  transition: transform .18s ease;
}
.pd-mascot-btn:hover { transform: scale(1.05); }
.pd-mascot-btn:active { transform: scale(.97); }
.pd-mascot-btn:focus-visible { outline: 3px solid var(--pd-accent-text, #ff5a5f); outline-offset: 3px; }
.pd-mascot-porthole {
  position: absolute; inset: 0; overflow: hidden; border-radius: 50%;
  background: #eceff2;
  /* gunmetal ring + red hairline + a faint outer rim so the disc separates from a dark page */
  box-shadow: inset 0 0 0 2px #d01820, 0 0 0 4px #2c3036, 0 0 0 5px rgba(255, 255, 255, .22);
  transition: transform .25s ease;
}
.pd-mascot-porthole::after {   /* red hairline sits above the video */
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 0 2px #d01820, inset 0 0 12px rgba(20, 24, 30, .18);
}
.pd-mascot.is-burning .pd-mascot-porthole { transform: scale(1.1); }
.pd-mascot-video, .pd-mascot-poster {
  position: absolute; left: 50%; top: 50%; width: 100%; height: 100%;
  transform: translate(-50%, -50%) scale(1.04); object-fit: cover; display: block;
  opacity: 0; transition: opacity .25s ease;
  pointer-events: none; user-select: none;
}
.pd-mascot-video.is-on, .pd-mascot-poster.is-on { opacity: 1; }
.pd-mascot-excited { z-index: 1; }
.pd-mascot-glasses { z-index: 3; }
.pd-mascot-reading { z-index: 2; }
.pd-mascot-burnout { z-index: 4; }

/* ---------- speech bubble (non-modal popover) ---------- */
.pd-mascot-bubble {
  position: absolute; right: 0; bottom: calc(var(--pd-mascot-size) + .85rem);
  width: min(21rem, calc(100vw - 2rem)); box-sizing: border-box; padding: .9rem 1rem .8rem;
  max-height: calc(100vh - var(--pd-mascot-size) - 3.5rem - env(safe-area-inset-top, 0px));
  max-height: calc(100dvh - var(--pd-mascot-size) - 3.5rem - env(safe-area-inset-top, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  color: var(--pd-text, #eceef0); background: var(--pd-surface, #15171a);
  border: 1px solid var(--pd-line-2, #3a3f46); border-top: 3px solid var(--pd-accent, #d01820);
  border-radius: var(--pd-radius, .5rem);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  font-size: .9rem; line-height: 1.4; text-align: left;
}
/* tail towards the porthole: drawn by the widget, not the bubble, so the scrolling bubble cannot clip it */
.pd-mascot.is-open::before {
  content: ""; position: absolute; z-index: 1; pointer-events: none;
  right: calc(var(--pd-mascot-size) / 2 - .5rem); bottom: calc(var(--pd-mascot-size) + .85rem - .55rem); width: 1rem; height: 1rem;
  background: var(--pd-surface, #15171a); border-right: 1px solid var(--pd-line-2, #3a3f46); border-bottom: 1px solid var(--pd-line-2, #3a3f46);
  transform: rotate(45deg);
}
.pd-mascot-title {
  margin: 0 1.6rem .2rem 0; font-family: var(--pd-font-display, "Barlow Condensed", sans-serif);
  font-style: italic; font-weight: 800; font-size: 1.35rem; line-height: 1.15; letter-spacing: .01em;
  color: var(--pd-text, #eceef0);
}
.pd-mascot-name { color: var(--pd-accent, #d01820); font-style: italic; text-transform: none; }
.pd-mascot-lead { margin: 0 0 .65rem; font-size: .9rem; line-height: 1.3; color: var(--pd-text-2, #c9cdd2); }
.pd-mascot-close {
  position: absolute; top: .35rem; right: .35rem; width: 2.25rem; height: 2.25rem; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1; color: var(--pd-text-2, #c9cdd2); background: transparent;
  border: 0; border-radius: 50%; cursor: pointer;
}
.pd-mascot-close:hover { color: var(--pd-text, #fff); background: var(--pd-surface-2, rgba(255, 255, 255, .08)); }
.pd-mascot-chip:focus-visible, .pd-mascot-all:focus-visible, .pd-mascot-go:focus-visible, .pd-mascot-close:focus-visible, .pd-mascot-hide:focus-visible { outline: 2px solid var(--pd-accent-text, #ff5a5f); outline-offset: 2px; }
.pd-mascot-note { margin: 0 0 .5rem; font-size: .82rem; color: var(--pd-text-2, #c9cdd2); }
.pd-mascot-hide {
  margin: 0; padding: .35rem .1rem; min-height: 2rem; font-size: .8rem; color: var(--pd-muted, #9aa1a9); background: none; border: 0;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.pd-mascot-hide:hover { color: var(--pd-text, #fff); }

/* light theme: the same bubble on a white card */
html[data-pd-theme="light"] .pd-mascot-bubble { box-shadow: 0 12px 28px rgba(20, 24, 30, .22); }
html[data-pd-theme="light"] .pd-mascot-btn { filter: drop-shadow(0 5px 10px rgba(20, 24, 30, .35)); }
html[data-pd-theme="light"] .pd-mascot-porthole { box-shadow: inset 0 0 0 2px #d01820, 0 0 0 4px #2c3036, 0 0 0 5px rgba(255, 255, 255, .6); }

/* the footer link that brings the helper back (added by JS only while hidden) */
.pd-mascot-restore { cursor: pointer; }

/* phones */
@media (max-width: 575.98px) {
  .pd-mascot { --pd-mascot-size: 90px; --pd-mascot-edge: max(.75rem, calc(env(safe-area-inset-right, 0px) + .5rem)); }
  .pd-mascot.is-open::before { bottom: calc(var(--pd-mascot-size) + .75rem - .55rem); }
  .pd-mascot-bubble { bottom: calc(var(--pd-mascot-size) + .75rem); width: min(21rem, calc(100vw - 1.5rem)); padding: .8rem .8rem .7rem; }
  .pd-mascot-chips { grid-template-columns: 1fr 1fr; }
  .pd-mascot.is-scrolling .pd-mascot-btn { opacity: .3; pointer-events: none; }
  .pd-mascot-btn { transition: transform .18s ease, opacity .2s ease; }
}
@media (max-width: 359.98px) { .pd-mascot { --pd-mascot-size: 80px; } .pd-mascot-title { font-size: 1.2rem; } }
@media (min-width: 1200px) { .pd-mascot { --pd-mascot-size: 150px; } }
@media (max-height: 420px) and (orientation: landscape) { .pd-mascot { --pd-mascot-size: 80px; } }

/* ---------- 2.0.154: search box, results, chips, Lets Go! ---------- */
.pd-mascot-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pd-mascot-title:focus { outline: none; }
.pd-mascot-search { margin: 0 0 .55rem; }
.pd-mascot-field {
  display: flex; align-items: center; gap: .35rem; padding: 0 .3rem 0 .6rem; min-height: 2.6rem;
  background: var(--pd-surface-2, #1d2024); border: 1px solid var(--pd-line-2, #3a3f46); border-radius: var(--pd-radius-sm, .35rem);
}
.pd-mascot-field:focus-within { border-color: var(--pd-accent, #d01820); box-shadow: 0 0 0 2px rgba(208, 24, 32, .25); }
.pd-mascot-field > .bi { color: var(--pd-muted, #9aa1a9); font-size: .95rem; }
.pd-mascot .pd-mascot-q {
  flex: 1 1 auto; min-width: 0; height: 2.4rem; padding: 0; font-size: 1rem; /* 16px: no iOS zoom */
  color: var(--pd-text, #eceef0); background: transparent; border: 0; outline: none; box-shadow: none;
}
.pd-mascot .pd-mascot-q::placeholder { color: var(--pd-muted, #9aa1a9); opacity: 1; }
.pd-mascot .pd-mascot-q::-webkit-search-cancel-button { cursor: pointer; }
.pd-mascot-go {
  flex: 0 0 auto; min-width: 2.6rem; height: 2rem; padding: 0 .6rem; border: 0; border-radius: var(--pd-radius-sm, .35rem); cursor: pointer;
  font-family: var(--pd-font-display, "Barlow Condensed", sans-serif); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: var(--pd-accent, #d01820);
}
.pd-mascot-go:hover { background: var(--pd-accent-hover, #e11d26); }
.pd-mascot-status { margin: .35rem 0 0; min-height: 0; font-size: .78rem; color: var(--pd-text-2, #c9cdd2); }
.pd-mascot-status:empty { display: none; }
.pd-mascot-status.is-error, .pd-mascot-status.is-empty { color: var(--pd-text, #eceef0); }
.pd-mascot-search.is-loading .pd-mascot-field > .bi { animation: pd-mascot-spin 1s linear infinite; }
@keyframes pd-mascot-spin { to { transform: rotate(360deg); } }
.pd-mascot-results { list-style: none; margin: .4rem 0 0; padding: 0; border: 1px solid var(--pd-line-2, #3a3f46); border-radius: var(--pd-radius-sm, .35rem); overflow: hidden; }
.pd-mascot-results > li + li { border-top: 1px solid var(--pd-line-2, #3a3f46); }
.pd-mascot .pd-mascot-hit {
  display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; min-height: 3.25rem;
  color: var(--pd-text, #eceef0); text-decoration: none;
}
.pd-mascot-results > li.is-active .pd-mascot-hit, .pd-mascot .pd-mascot-hit:hover { background: var(--pd-surface-3, #262a2f); color: var(--pd-text, #fff); }
.pd-mascot-results > li.is-active { box-shadow: inset 3px 0 0 var(--pd-accent, #d01820); }
.pd-mascot-thumb { flex: 0 0 48px; width: 48px; height: 48px; object-fit: cover; border-radius: .3rem; background: #eceff2; }
.pd-mascot-thumb.is-empty { background: var(--pd-surface-3, #262a2f); }
.pd-mascot-hit-text { display: flex; flex-direction: column; min-width: 0; }
.pd-mascot-hit-name { font-weight: 600; font-size: .88rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pd-mascot-hit-meta { font-size: .74rem; color: var(--pd-muted, #9aa1a9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-mascot .pd-mascot-all {
  display: inline-block; margin: .45rem 0 0; font-size: .84rem; font-weight: 600; color: var(--pd-accent-text, #ff5a5f);
  text-decoration: underline; text-underline-offset: 2px;
}
.pd-mascot-sub { margin: 0 0 .35rem; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--pd-muted, #9aa1a9); }
.pd-mascot-chips { list-style: none; margin: 0 0 .55rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.75rem, 1fr)); gap: .4rem; }
.pd-mascot-chips > li { display: flex; }
.pd-mascot-chips > li[hidden] { display: none; }
.pd-mascot .pd-mascot-chip {
  flex: 1 1 auto; display: flex; align-items: center; gap: .45rem; min-height: 2.6rem; padding: .3rem .6rem; text-align: left;
  font-size: .84rem; font-weight: 600; line-height: 1.15; text-decoration: none; cursor: pointer;
  color: var(--pd-text, #eceef0); background: var(--pd-surface-2, #1d2024); border: 1px solid var(--pd-line-2, #3a3f46); border-radius: 999px;
}
.pd-mascot .pd-mascot-chip > .bi { font-size: 1rem; color: var(--pd-accent-text, #ff5a5f); }
.pd-mascot .pd-mascot-chip > small { margin-left: auto; font-size: .66rem; font-weight: 500; color: var(--pd-muted, #9aa1a9); white-space: nowrap; }
.pd-mascot .pd-mascot-chip:hover { border-color: var(--pd-metal-hi, #8e959d); background: var(--pd-surface-3, #262a2f); color: var(--pd-text, #fff); }
.pd-mascot .pd-mascot-chip--primary { color: #fff; background: var(--pd-accent, #d01820); border-color: var(--pd-accent, #d01820); }
.pd-mascot .pd-mascot-chip--primary > .bi { color: #fff; }
.pd-mascot .pd-mascot-chip--primary:hover { color: #fff; background: var(--pd-accent-hover, #e11d26); border-color: var(--pd-accent-hover, #e11d26); }

/* "Lets Go!" speech bubble over the porthole while the burnout plays */
.pd-mascot-shout {
  position: absolute; right: calc(var(--pd-mascot-size) * .35); bottom: calc(var(--pd-mascot-size) + .4rem); margin: 0; padding: .35rem .8rem .4rem;
  font-family: var(--pd-font-display, "Barlow Condensed", sans-serif); font-style: italic; font-weight: 800; font-size: 1.45rem; line-height: 1;
  letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; color: #fff; background: #d01820;
  border: 2px solid #fff; border-radius: .6rem; box-shadow: 0 8px 18px rgba(0, 0, 0, .35); transform-origin: 85% 100%;
  animation: pd-mascot-pop .28s cubic-bezier(.2, 1.4, .4, 1) both; pointer-events: none;
}
.pd-mascot-shout::after {
  content: ""; position: absolute; right: 1rem; bottom: -.5rem; width: .8rem; height: .8rem; background: #d01820;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg);
}
@keyframes pd-mascot-pop { from { transform: scale(.4) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
.pd-mascot.is-letsgo .pd-mascot-btn { opacity: 1 !important; }
@media (max-width: 575.98px) { .pd-mascot-shout { font-size: 1.2rem; } }
@media (max-width: 359.98px) { .pd-mascot-chips { grid-template-columns: 1fr; } .pd-mascot-chips .pd-mascot-chip { min-height: 2.4rem; } }

@media (prefers-reduced-motion: reduce) {
  .pd-mascot, .pd-mascot-btn, .pd-mascot-porthole, .pd-mascot-video, .pd-mascot-poster { transition: none !important; }
  .pd-mascot-btn:hover, .pd-mascot-btn:active, .pd-mascot.is-burning .pd-mascot-porthole { transform: none; }
  .pd-mascot-shout, .pd-mascot-search.is-loading .pd-mascot-field > .bi { animation: none; }
}
@media print { .pd-mascot { display: none !important; } }

/* ---------- 2.0.158 / 2.0.161: fun-fact bubble, speak, See more / No I'm good ---------- */
/* 2.0.161: label is "Fun Fact about {casting name}" in normal case (no uppercase), wraps at 390. */
.pd-mascot-home[hidden], .pd-mascot-fact[hidden] { display: none !important; }
.pd-mascot-fact-label {
  margin: 0 0 .25rem; font-size: .72rem; font-weight: 700; letter-spacing: .02em; line-height: 1.35;
  color: var(--pd-muted, #9aa1a9);
  max-width: 100%; overflow-wrap: anywhere; word-break: break-word;
}
.pd-mascot-fact-text {
  margin: 0 0 .55rem; max-height: 9.5rem; overflow-y: auto; overscroll-behavior: contain;
  font-size: .95rem; line-height: 1.45; color: var(--pd-text, #eceef0);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.pd-mascot-speak {
  display: inline-flex; align-items: center; gap: .35rem; margin: 0 0 .7rem; padding: .3rem .7rem;
  min-height: 2rem; font-size: .8rem; font-weight: 600; cursor: pointer;
  color: var(--pd-text, #eceef0); background: var(--pd-surface-2, #1d2024);
  border: 1px solid var(--pd-line-2, #3a3f46); border-radius: 999px;
}
.pd-mascot-speak:hover { border-color: var(--pd-metal-hi, #8e959d); background: var(--pd-surface-3, #262a2f); }
.pd-mascot-speak.is-on { border-color: var(--pd-accent, #d01820); color: var(--pd-text, #fff); }
.pd-mascot-speak:focus-visible { outline: 2px solid var(--pd-accent-text, #ff5a5f); outline-offset: 2px; }
.pd-mascot-fact-ask { margin: 0 0 .45rem; font-size: .9rem; line-height: 1.35; color: var(--pd-text-2, #c9cdd2); }
.pd-mascot-fact-actions { display: flex; flex-direction: column; gap: .4rem; margin: 0 0 .55rem; }
.pd-mascot-fact-actions .pd-mascot-chip { justify-content: center; text-align: center; width: 100%; }
.pd-mascot .pd-mascot-fact-no {
  color: var(--pd-text, #eceef0); background: var(--pd-surface-2, #1d2024);
  border: 1px solid var(--pd-line-2, #3a3f46);
}
.pd-mascot .pd-mascot-fact-no:hover { border-color: var(--pd-metal-hi, #8e959d); background: var(--pd-surface-3, #262a2f); color: var(--pd-text, #fff); }
html[data-pd-theme="light"] .pd-mascot-fact-text { color: var(--pd-text, #1a1d21); }
html[data-pd-theme="light"] .pd-mascot-speak,
html[data-pd-theme="light"] .pd-mascot .pd-mascot-fact-no {
  color: var(--pd-text, #1a1d21);
}

@media (prefers-reduced-motion: reduce) {
  .pd-mascot-speak { transition: none !important; }
}
