/* Only the portal and standalone study room load this opt-in stylesheet. */
@view-transition { navigation: auto; }

/* Directory anchors remain ordinary links. :target also works without JS. */
.portal-page .portal-index a[aria-current='location'] {
  background: var(--teal-light, #dbe7df);
  border-radius: 4px;
  text-decoration: underline;
  text-underline-offset: .3em;
}
.portal-page .portal-row:target {
  border-block-start-color: var(--teal, #12483f);
  box-shadow: inset 0 2px var(--teal, #12483f);
  animation: arrive-directory-arrive 240ms cubic-bezier(.2,.7,.25,1) both;
}
.portal-page .portal-row:focus-visible {
  outline: 2px solid var(--teal, #12483f);
  outline-offset: 4px;
}
@keyframes arrive-directory-arrive {
  from { transform: translateY(4px); opacity: .85; }
  to { transform: translateY(0); opacity: 1; }
}

/* A passive touch observer mirrors :active without delaying the original control. */
:is(.portal-ctas a, .portal-waypoints a, .portal-index a, .portal-row-links a,
    .study-room__action, .study-room__quiet-action, .study-hud-links a,
    [data-season-open], [data-season-apply], [data-site-press]):not(:disabled, [aria-disabled='true']) {
  transition: scale 90ms ease-out, background-color 90ms ease-out, color 90ms ease-out;
}
:is(.portal-ctas a, .portal-waypoints a, .portal-index a, .portal-row-links a,
    .study-room__action, .study-room__quiet-action, .study-hud-links a,
    [data-season-open], [data-season-apply], [data-site-press]):not(:disabled, [aria-disabled='true']):is(:active, [data-site-pressed]) {
  scale: .975;
  box-shadow: inset 0 0 0 1px currentColor;
}

/* Animate the chooser as a whole, never the form's fields or individual swatches. */
.site-season-dialog[open] { animation: arrive-dialog-reveal 220ms cubic-bezier(.2,.7,.25,1) both; }
@keyframes arrive-dialog-reveal {
  from { opacity: .75; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* A stable frame on narrow screens; buttons and feedback still work on touch. */
@media (max-width: 720px) {
  .portal-page .portal :is(.portal-art-img, .portal-art-vignette),
  html[data-arrive-season][data-season='winter'] .portal-frame::after { animation: none; }
}

/* Approach/withdraw by a few pixels, not a full-viewport slide. */
html:active-view-transition-type(arrive-enter-room, arrive-exit-room) {
  --arrive-distance: 8px;
  --arrive-duration: 240ms;
  --arrive-ease: cubic-bezier(.2,.65,.25,1);
}
html:active-view-transition-type(arrive-exit-room) { --arrive-distance: -8px; }
html:active-view-transition-type(arrive-enter-room, arrive-exit-room)::view-transition-group(root) {
  animation-duration: var(--arrive-duration);
}
html:active-view-transition-type(arrive-enter-room, arrive-exit-room)::view-transition-old(root) {
  animation: arrive-scene-leave var(--arrive-duration) var(--arrive-ease) both;
}
html:active-view-transition-type(arrive-enter-room, arrive-exit-room)::view-transition-new(root) {
  animation: arrive-scene-reveal var(--arrive-duration) var(--arrive-ease) both;
}
@keyframes arrive-scene-leave {
  to { opacity: 0; transform: translateX(calc(-1 * var(--arrive-distance))); }
}
@keyframes arrive-scene-reveal {
  from { opacity: 0; transform: translateX(var(--arrive-distance)); }
}

/* Keep the static selected/pressed cues and never animate form fields. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition { visibility: hidden; }
  ::view-transition-group(root), ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .portal-page .portal-row:target, .site-season-dialog[open] { animation: none; }
  :is(.portal-ctas a, .portal-waypoints a, .portal-index a, .portal-row-links a,
      .study-room__action, .study-room__quiet-action, .study-hud-links a,
      [data-season-open], [data-season-apply], [data-site-press]):not(:disabled, [aria-disabled='true']) {
    transition: none;
    scale: none !important;
    transform: none !important;
  }
}
html:is([data-motion='off'], [data-flat3d='1'])::view-transition { visibility: hidden; }
html:is([data-motion='off'], [data-flat3d='1']) .portal-page .portal-row:target,
html:is([data-motion='off'], [data-flat3d='1']) .site-season-dialog[open],
html:is([data-motion='off'], [data-flat3d='1']) .study-room *,
html:is([data-motion='off'], [data-flat3d='1']) .study-room *::before,
html:is([data-motion='off'], [data-flat3d='1']) .study-room *::after {
  animation: none !important;
  transition: none !important;
}
html:is([data-motion='off'], [data-flat3d='1']) :is(.portal-ctas a, .portal-waypoints a, .portal-index a, .portal-row-links a,
    .study-room__action, .study-room__quiet-action, .study-hud-links a,
    [data-season-open], [data-season-apply], [data-site-press]):not(:disabled, [aria-disabled='true']) {
  transition: none !important;
  scale: none;
  transform: none;
}
html:is([data-motion='off'], [data-flat3d='1']) .study-room :is(.study-room__weather, .study-room__burst) { display: none; }
.study-room:is([data-study-motion='still'], [data-study-motion-status='still']) :is(.study-enter, .study-room__world *),
.study-room:is([data-study-motion='still'], [data-study-motion-status='still']) .study-room__world *::before,
.study-room:is([data-study-motion='still'], [data-study-motion-status='still']) .study-room__world *::after,
html:has(.study-room:is([data-study-motion='still'], [data-study-motion-status='still'])) .site-season-dialog[open] {
  animation: none;
  transition: none;
}
html:has(.study-room:is([data-study-motion='still'], [data-study-motion-status='still'])) :is(
    .study-room__action, .study-room__quiet-action, .study-hud-links a, [data-season-open], [data-season-apply], [data-site-press]):not(:disabled, [aria-disabled='true']) {
  transition: none;
  scale: none;
  transform: none;
}
