/* Homepage-only enhancement. Original HTML and native controls remain the fallback. */
.home-inspect-trigger { display: none; }
.creature-context a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: #f0c47d; text-underline-offset: 4px; }
.home-interactive .home-inspect-trigger[hidden] { display: none; }
.home-inspector:not([open]) { display: none; }
.home-interactive {
  --home-ease: cubic-bezier(.22, .68, .24, 1);
  --home-focus: #8ad7c3;
}
.home-interactive main[id],
.home-interactive main [id] {
  scroll-margin-top: calc(var(--home-header-offset, 0px) + 12px);
}
/* One source of anchor clearance, measured by the homepage controller. */
html.home-flow-ready { scroll-padding-top: 0; }
.home-flow-ready .home-interactive main[id],
.home-flow-ready .home-interactive main [id] {
  scroll-margin-top: var(--home-anchor-offset, 24px);
}

/* Content is always visible; these classes only animate a section's first entry. */
.home-interactive .home-enter-once.home-entered {
  animation: home-section-in 480ms var(--home-ease) both;
}
@keyframes home-section-in {
  from { opacity: .86; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.home-interactive.home-providers-offscreen .provider-track { animation-play-state: paused; }

/* Preserve the familiar fan before adding a few degrees of pointer-driven depth. */
.home-interactive .creature-card.home-tilt {
  --home-card-rotation: 0deg;
  --home-card-rx: 0deg;
  --home-card-ry: 0deg;
  --home-card-lift: 0px;
  --home-light-x: 50%;
  --home-light-y: 25%;
  transform: perspective(950px) translateY(var(--home-card-lift)) rotate(var(--home-card-rotation)) rotateX(var(--home-card-rx)) rotateY(var(--home-card-ry));
  transition: transform 170ms var(--home-ease), border-color 180ms ease, box-shadow 180ms ease;
}
.home-interactive .hero-card.home-tilt.fan-left { --home-card-rotation: -13deg; }
.home-interactive .hero-card.home-tilt.fan-right { --home-card-rotation: 13deg; }
.home-interactive .hero-card.home-tilt.fan-center { --home-card-rotation: 1deg; }
.home-interactive .hero-card.home-tilt.is-pointed { z-index: 8; }
.home-interactive .hero-card.home-tilt:has(.home-inspect-trigger:focus-visible) { z-index: 8; }
.home-interactive .creature-gallery > .creature-card { position: relative; }
.home-interactive .creature-card.home-tilt::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(ellipse at var(--home-light-x) var(--home-light-y), #ffffff21, #ffffff05 35%, transparent 67%);
  opacity: 0;
  transition: opacity 200ms ease;
}
.home-interactive .creature-card:focus-within {
  border-color: var(--home-focus);
}
.home-interactive .home-tilt .creature-details { display: none; }
.home-interactive .home-inspect-trigger {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.home-interactive .home-inspect-trigger:focus-visible {
  outline: 3px solid var(--home-focus);
  outline-offset: -5px;
}
.home-inspect-glyph {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid #d7e7f53d;
  border-radius: 50%;
  background: #102238c7;
  color: #f6dfb8;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 2px 8px #0002;
}
@media (hover: hover) and (pointer: fine) {
  .home-interactive .creature-card.home-tilt:hover {
    will-change: transform;
    border-color: #ffe0a3;
    box-shadow: 0 27px 46px -13px #000c, 0 0 0 1px #f0c47d60, 0 0 26px -12px #f0c47d54;
  }
  .home-interactive .creature-card.home-tilt:hover::after,
  .home-interactive .creature-card.home-tilt:focus-within::after { opacity: 1; }
  .home-interactive .creature-gallery > .creature-card:hover .creature-art img { transform: none; }
}

/* Keep the header fixed in geometry; its treatment reacts to position, not size. */
.home-interactive .site-header {
  transition: background-color 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.home-interactive.home-is-scrolled .site-header {
  background: #0b1726f7;
  border-bottom-color: #a4c0d232;
  box-shadow: 0 9px 22px -16px #000d;
}
.home-interactive .site-header::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  pointer-events: none;
  background: #f0c47d9c;
  transform: scaleX(var(--home-read-progress, 0));
  transform-origin: left center;
}
.home-interactive .site-header nav a,
.home-interactive .site-header .button-small,
.home-interactive .evolution-viewer > label {
  min-height: 44px;
}
.home-interactive .site-header nav a:focus-visible {
  border-radius: 6px;
  outline: 3px solid var(--home-focus);
  outline-offset: -2px;
}
.home-interactive .site-header nav a[aria-current="location"] {
  color: #f0c47d;
  text-decoration: underline;
  text-decoration-color: #f0c47d8a;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

/* Radio selection stays native; only the image hand-off changes after enhancement. */
.home-interactive .evolution-display {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
}
.home-interactive .evolution-display .evolution-stage {
  display: block;
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 0s linear 240ms;
}
.home-interactive #trex-stage-0:checked ~ .evolution-display .stage-0,
.home-interactive #trex-stage-1:checked ~ .evolution-display .stage-1,
.home-interactive #trex-stage-2:checked ~ .evolution-display .stage-2 {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* The inspector is a single intentional surface; opening it never expands a grid row. */
.home-inspector {
  --home-rarity: #f0c47d;
  --home-type: #8ad7c3;
  width: min(800px, calc(100vw - 40px));
  max-width: 800px;
  max-height: calc(100vh - 48px);
  max-height: min(740px, calc(100svh - 48px));
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #d8ba784d;
  border-radius: 25px;
  background: #102236;
  color: #f5f2e9;
  font: inherit;
  box-shadow: 0 32px 100px #0009, inset 0 1px 0 #ffffff0c;
  scrollbar-width: thin;
  scrollbar-color: #6d889c70 transparent;
}
.home-inspector[data-rarity="common"] { --home-rarity: #c0cad4; }
.home-inspector[data-rarity="uncommon"] { --home-rarity: #83cdb7; }
.home-inspector[data-rarity="rare"] { --home-rarity: #7cbef2; }
.home-inspector[data-rarity="epic"] { --home-rarity: #c3a1fa; }
.home-inspector[data-rarity="legendary"] { --home-rarity: #f0c47d; }
.home-inspector[data-type="fierce"] { --home-type: #fa9179; }
.home-inspector[data-type="tenacious"] { --home-type: #ea9dc5; }
.home-inspector[data-type="cunning"] { --home-type: #c0a0ff; }
.home-inspector[data-type="guardian"] { --home-type: #71d4b2; }
.home-inspector[data-type="agile"] { --home-type: #7ecbff; }
.home-inspector[data-type="breaker"] { --home-type: #edc472; }
.home-inspector[open] { display: grid; animation: home-inspector-in 180ms var(--home-ease, ease-out); }
.home-inspector::backdrop { background: #030d18cf; }
.home-inspector-shell {
  position: relative;
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  padding: 28px;
}
.home-inspector-close {
  position: sticky;
  grid-area: 1 / 1;
  align-self: start;
  justify-self: end;
  z-index: 30;
  top: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 12px 12px 0 0;
  border: 1px solid #bdcfdd38;
  border-radius: 50%;
  background: #0b1c2ddf;
  color: #e4edf4;
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.home-inspector-close svg { width: 19px; height: 19px; }
.home-inspector-close:hover { background: #223b4e; border-color: #c8dce861; }
.home-inspector-visual { min-width: 0; }
.home-inspector-art {
  display: grid;
  place-items: center;
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #a0cfff33;
  border-radius: 19px;
  background: #07346a;
  box-shadow: 0 14px 28px -20px #000b;
  touch-action: pan-y pinch-zoom;
}
.home-inspector-art img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}
.home-inspector-art img[hidden] { display: none !important; }
.home-inspector-art img.is-entering { animation: home-art-in 220ms ease-out; }
.home-inspector-navigation {
  display: grid;
  grid-template-columns: 44px minmax(58px, 1fr) 44px;
  align-items: center;
  width: min(100%, 210px);
  min-height: 46px;
  margin: 10px auto 0;
  border: 1px solid #abc5d525;
  border-radius: 999px;
  background: #091b2bb3;
}
.home-inspector-navigation button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #efce97;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 150ms ease, background-color 150ms ease;
}
.home-inspector-navigation button:hover { background: #f0c47d12; color: #ffe3b6; }
.home-inspector-navigation button:active { background: #f0c47d20; }
.home-inspector-navigation button:disabled { color: #668093; background: transparent; cursor: default; }
.home-inspector-navigation button svg { width: 18px; height: 18px; pointer-events: none; }
.home-inspector-position {
  min-width: 0;
  color: #b9ccda;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  letter-spacing: .6px;
  text-align: center;
}
.home-inspector-image-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  margin: 0;
  color: #c0d1df;
  font-size: clamp(18px, 3vw, 25px);
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}
.home-inspector-copy { min-width: 0; padding-top: 27px; }
.home-inspector-rarity {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  margin: 0 0 12px;
  border: 1px solid #f0c47d45;
  border-radius: 7px;
  background: #f0c47d0a;
  color: var(--home-rarity);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .85px;
  line-height: 1.4;
  text-transform: uppercase;
}
.home-inspector-name {
  margin: 0;
  font-size: clamp(26px, 3.5vw, 36px);
  font-weight: 800;
  line-height: 1.09;
  letter-spacing: -1px;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.home-inspector-type {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 12px 0 19px;
  color: var(--home-type);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.home-inspector-type svg { width: 17px; height: 17px; }
.home-inspector-stages {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  margin: 0;
  border: 1px solid #abc5d525;
  border-radius: 13px;
  background: #0819299c;
}
.home-inspector-stages button {
  min-width: 0;
  min-height: 44px;
  padding: 8px 5px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #afc1ce;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.home-inspector-stages button:hover { background: #1b3347; color: #eef3f6; }
.home-inspector-stages button[aria-pressed="true"] {
  border-color: #f8d494;
  background: #f0c47d;
  color: #102236;
  box-shadow: 0 2px 7px #0002;
}
.home-inspector-stages button[data-loading="true"] { border-color: #f0c47d70; }
.home-inspector-strength {
  margin: 17px 0 0;
  color: #aec3d2;
  font-size: 12px;
  line-height: 1.65;
}
.home-inspector-strength strong { color: #e4edf4; font-weight: 600; }
.home-inspector-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 21px;
  padding: 10px 14px;
  border: 1px solid #f0c47d55;
  border-radius: 11px;
  color: #f0c47d;
  background: #f0c47d05;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  touch-action: manipulation;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.home-inspector-link:hover { background: #f0c47d10; border-color: #f0c47d9c; }
.home-inspector :is(button, a):focus-visible {
  outline: 3px solid #8ad7c3;
  outline-offset: 3px;
}
.home-inspector-open { overflow: hidden; padding-right: var(--home-scrollbar-width, 0px); }
@keyframes home-inspector-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes home-art-in {
  from { opacity: .55; transform: scale(1.018); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 800px) {
  .home-interactive .hero-card.home-tilt.fan-left { --home-card-rotation: -11deg; }
  .home-interactive .hero-card.home-tilt.fan-right { --home-card-rotation: 11deg; }
  .home-interactive .site-header .header-inner { padding-bottom: 5px; }
  .home-interactive .collection-numbers dt {
    max-width: 120px;
    font-size: 11px;
    line-height: 1.5;
  }
  .home-interactive .home-guide-category { font-size: 11px; }
  .home-interactive .home-guide-read { min-height: 44px; font-size: 12px; }
  .home-interactive .team-visual img {
    aspect-ratio: 7 / 4;
    object-fit: contain;
  }
  .home-interactive .team-visual > p {
    position: static;
    padding: 12px 16px;
    border-top: 1px solid #ffffff16;
    background: #10263a;
    font-size: 12px;
    line-height: 1.55;
  }
  .home-interactive .community-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-interactive .community-card {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-rows: 36px 18px minmax(52px, 1fr) 44px;
    align-items: center;
    gap: 6px 9px;
    min-height: 202px;
    padding: 12px;
  }
  .home-interactive .community-brand { display: contents; }
  .home-interactive .community-logo {
    grid-column: 1;
    grid-row: 1;
    width: 36px;
    height: 36px;
    padding: 6px;
    border-radius: 9px;
  }
  .home-interactive .community-logo img,
  .home-interactive .community-logo-symbol > svg { width: 24px; height: 24px; }
  .home-interactive .community-platform { grid-column: 2; grid-row: 1; min-width: 0; }
  .home-interactive .community-platform h3 {
    font-size: clamp(14px, 3.7vw, 17px);
    line-height: 1.3;
    letter-spacing: -.2px;
  }
  .home-interactive .community-handle {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
  }
  .home-interactive .community-audience {
    grid-column: 1 / -1;
    grid-row: 3;
    margin: 2px 0 0;
  }
  .home-interactive .community-audience strong {
    font-size: 30px;
    line-height: 1.05;
    letter-spacing: -.7px;
  }
  .home-interactive .community-audience > span { margin-top: 3px; font-size: 11px; line-height: 1.4; }
  .home-interactive .community-action {
    grid-column: 1 / -1;
    grid-row: 4;
    min-height: 44px;
    margin: 0;
    padding-top: 7px;
    font-size: 11px;
    line-height: 1.35;
  }
  .home-interactive .community-outbound,
  .home-interactive .community-context { display: none; }
}
@media (max-width: 700px) {
  .home-interactive .creature-gallery .creature-rarity { font-size: 9px; letter-spacing: .35px; }
  .home-interactive .creature-gallery .creature-card strong { font-size: 12px; }
  .home-interactive .hero-card .creature-rarity { font-size: 8px; }
  .home-interactive .home-inspect-glyph { top: 7px; right: 7px; width: 23px; height: 23px; font-size: 13px; }
}
@media (max-width: 360px) {
  .home-interactive .community-card { grid-template-columns: 30px minmax(0, 1fr); column-gap: 6px; }
  .home-interactive .community-logo { width: 30px; height: 30px; padding: 5px; }
  .home-interactive .community-logo img,
  .home-interactive .community-logo-symbol > svg { width: 20px; height: 20px; }
}
@media (max-width: 620px) {
  .home-inspector {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    max-height: 90svh;
    margin: 0 auto;
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
  }
  .home-inspector-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 20px 20px max(18px, env(safe-area-inset-bottom));
  }
  .home-inspector-visual { width: min(100%, 320px); margin-inline: auto; }
  .home-inspector-art {
    width: 100%;
    height: clamp(150px, 32vh, 260px);
    height: clamp(150px, 32svh, 260px);
    aspect-ratio: auto;
    margin-inline: auto;
    border-radius: 16px;
  }
  .home-inspector-copy { padding: 0 2px; }
  .home-inspector-rarity { margin-bottom: 9px; }
  .home-inspector-name { font-size: 29px; line-height: 1.12; letter-spacing: -.7px; }
  .home-inspector-type { margin-top: 8px; margin-bottom: 13px; }
  .home-inspector-strength { margin-top: 12px; }
  .home-inspector-link { margin-top: 15px; }
}
@media (max-width: 620px) and (max-height: 660px) {
  .home-inspector-shell { gap: 11px; padding: 16px 18px max(16px, env(safe-area-inset-bottom)); }
  .home-inspector-art { height: clamp(126px, 23svh, 160px); }
  .home-inspector-navigation { margin-top: 8px; }
  .home-inspector-name { font-size: 26px; }
  .home-inspector-rarity { margin-bottom: 7px; }
  .home-inspector-type { margin-bottom: 10px; }
  .home-inspector-strength { margin-top: 10px; }
  .home-inspector-link { margin-top: 12px; }
}

/* A hidden page spends no frames on its decorative motion. */
.home-page-hidden :is(.hero-fan, .provider-track, .home-inspector[open], .home-inspector-art img.is-entering, .home-enter-once.home-entered) {
  animation-play-state: paused;
}
.home-page-hidden :is(.creature-card.home-tilt, .evolution-stage, .site-header),
.home-page-hidden .creature-card.home-tilt::after {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .home-interactive .creature-card.home-tilt {
    transform: rotate(var(--home-card-rotation));
    transition: none;
  }
  .home-interactive .creature-card.home-tilt::after { display: none; }
  .home-interactive .site-header,
  .home-interactive .evolution-display .evolution-stage,
  .home-inspector-close,
  .home-inspector-navigation button,
  .home-inspector-stages button,
  .home-inspector-link { transition: none; }
  .home-inspector[open], .home-inspector-art img.is-entering { animation: none; }
  .home-interactive .home-enter-once.home-entered { animation: none; }
}
