/* Interaction timing shared by the public blog and its reading pages. */
:root {
  --motion-feedback: 120ms;
  --motion-change: 180ms;
  --motion-panel: 240ms;
  --motion-settle: cubic-bezier(0.16, 1, 0.3, 1);
}

.site-header .site-nav .site-nav-links > a {
  position: relative;
  text-decoration: none;
  -webkit-tap-highlight-color: color-mix(in srgb, var(--accent) 16%, transparent);
}

.site-header .site-nav .site-nav-links > a::after {
  position: absolute;
  inset: auto 0 5px;
  width: min(100%, 2em);
  height: 2px;
  margin-inline: auto;
  border-radius: 8px;
  background: currentColor;
  opacity: 0;
  transform: scaleX(0.45);
  content: '';
  pointer-events: none;
}

.site-header .site-nav .site-nav-links > a[aria-current]::after {
  opacity: 1;
  transform: none;
}

.site-header[data-past-hero] {
  box-shadow: 0 8px 16px -14px var(--ink);
}

.site-nav.is-open .site-nav-links,
.theme-panel,
.weather-panel {
  overscroll-behavior: contain;
}

:is(
    .site-nav-toggle,
    .theme-entry,
    .tag-button,
    .category-button,
    .archive-pagination button,
    .discovery-page button,
    .reader-modes button,
    .reader-utilities button
  ):active:not(:disabled) {
  box-shadow: inset 0 0 0 1px currentColor;
}

.reading-progress {
  position: fixed;
  z-index: 45;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.reading-top {
  position: fixed;
  z-index: 42;
  inset: auto max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) auto;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font: 20px/1 var(--sans);
  cursor: pointer;
}

.reading-top::before {
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: conic-gradient(currentColor var(--reading-turn, 0turn), var(--line) 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  content: '';
  pointer-events: none;
}

.reading-top[hidden] {
  display: none;
}

.reading-top:hover,
.reading-top:focus-visible {
  border-color: var(--accent);
  background: var(--panel);
}

#categories.archive-map {
  position: relative;
}

#categories[data-indicator]::after {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--indicator-width);
  height: 2px;
  translate: var(--indicator-left) var(--indicator-top);
  border-radius: 2px;
  background: var(--accent);
  content: '';
  pointer-events: none;
}

#categories[data-indicator] .category-button:is(:hover, .selected) {
  border-bottom-color: transparent;
}

.motion-transition-title {
  margin: 0;
}

html[data-article-transition] #article :is(header h1, .motion-transition-title) {
  view-transition-name: article-title;
}

.motion-game-cover {
  display: none;
}

.player-stage:has(.motion-game-cover) {
  position: relative;
}

html[data-game-transition] .motion-game-cover {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f4f2eb;
  view-transition-name: game-cover;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  body:has(.intro) .site-header {
    transition: box-shadow var(--motion-change) ease-out;
  }

  .site-header .site-nav .site-nav-links > a {
    transition: color var(--motion-feedback) ease-out;
  }

  .site-header .site-nav .site-nav-links > a::after {
    transition:
      opacity var(--motion-feedback) ease-out,
      transform var(--motion-panel) var(--motion-settle);
  }

  :is(#discoveries, #favorites) .favorite-card {
    transition: background-color var(--motion-feedback) ease-out;
  }

  .favorite-grid .favorite-card .favorite-icon {
    transition: opacity var(--motion-feedback) ease-out;
  }

  :is(
    .tag-button,
    .category-button,
    .archive-pagination button,
    .site-nav-toggle,
    .theme-entry,
    .discovery-page button,
    .reader-modes button,
    .reader-utilities button,
    :where(#graph-toggle),
    .share-article,
    .code-copy,
    .reading-top
  ) {
    transition:
      background-color var(--motion-feedback) ease-out,
      border-color var(--motion-feedback) ease-out,
      color var(--motion-feedback) ease-out,
      scale var(--motion-feedback) var(--motion-settle);
  }

  html:not([data-effects='false'])
    :is(
      .site-nav-toggle,
      .theme-entry,
      .tag-button,
      .category-button,
      .archive-pagination button,
      .discovery-page button,
      .reader-modes button,
      .reader-utilities button,
      :where(#graph-toggle),
      .share-article,
      .code-copy,
      .reading-top
    ):active:not(:disabled) {
    scale: 0.97;
  }

  html:not([data-effects='false']) #categories[data-indicator='ready']::after {
    transition:
      translate 300ms var(--motion-settle),
      width 300ms var(--motion-settle);
  }

  @media (max-width: 800px) {
    body:not(:has(.intro)) .site-nav.is-open .site-nav-links {
      transform-origin: top right;
      animation: blog-panel-in var(--motion-change) var(--motion-settle);
    }
  }

  html:not([data-effects='false'])
    :is(.theme-panel, .weather-panel, .music-panel, .archive-graph)[open] {
    animation: blog-panel-in var(--motion-panel) var(--motion-settle);
  }

  html:not([data-effects='false'])
    :is(.theme-panel, .weather-panel, .music-panel, .archive-graph)[open]::backdrop {
    animation: blog-scrim-in var(--motion-change) ease-out;
  }

  #archive-tag-index:not([hidden]),
  .reading-assist:not([hidden]),
  :is(
      .discovery-search,
      .resource-notes,
      .issue-update,
      .issue-filter-details,
      .sample-toggle,
      .expression-toggle,
      .model-toggle
    )[open]
    > :not(summary) {
    animation: blog-panel-in var(--motion-change) var(--motion-settle);
  }

  @supports (transition-behavior: allow-discrete) and (overlay: auto) {
    html:not([data-effects='false']) :is(.theme-panel, .weather-panel, .music-panel) {
      opacity: 0;
      scale: 0.96;
      transition:
        opacity var(--motion-feedback) ease-out,
        scale var(--motion-feedback) ease-out,
        display var(--motion-feedback) allow-discrete,
        overlay var(--motion-feedback) allow-discrete;
    }

    html:not([data-effects='false']) :is(.theme-panel, .weather-panel, .music-panel)[open] {
      opacity: 1;
      scale: 1;
      animation: none;
      transition-timing-function: var(--motion-settle);
      transition-duration: var(--motion-panel);
    }

    html:not([data-effects='false']) :is(.theme-panel, .weather-panel, .music-panel):not([open]) {
      pointer-events: none;
    }

    @starting-style {
      html:not([data-effects='false']) :is(.theme-panel, .weather-panel, .music-panel)[open] {
        opacity: 0.72;
        scale: 0.96;
      }
    }
  }

  @keyframes blog-panel-in {
    from {
      opacity: 0.72;
      scale: 0.96;
    }
  }

  @keyframes blog-scrim-in {
    from {
      opacity: 0;
    }
  }

  html:not([data-effects='false']) .reading-top:not([hidden]) {
    animation: blog-panel-in var(--motion-panel) var(--motion-settle);
  }

  @media (hover: hover) and (pointer: fine) {
    html:not([data-effects='false']) #post-list .archive-paper,
    html:not([data-effects='false']) #post-list .archive-paper :is(h3, .read-link span) {
      transition:
        opacity var(--motion-change) ease-out,
        translate var(--motion-panel) var(--motion-settle);
    }

    html:not([data-effects='false'])
      #post-list:has(> .living-post:hover):not(:has(:focus-visible))
      > .living-post:not(:hover)
      .archive-paper {
      opacity: 0.96;
    }

    html:not([data-effects='false']) #post-list > .living-post:hover h3 {
      translate: 4px 0;
    }

    html:not([data-effects='false']) #post-list > .living-post:hover .read-link span {
      display: inline-block;
      translate: 3px 0;
    }

    html:not([data-effects='false']) [data-paper-sheen] {
      position: relative;
    }

    html:not([data-effects='false']) [data-paper-sheen]::before {
      position: absolute;
      z-index: 1;
      inset: 0;
      border-radius: inherit;
      background: radial-gradient(
        ellipse 200px 125px at var(--sheen-x) var(--sheen-y),
        color-mix(in srgb, var(--season-glow) 28%, transparent),
        transparent 100%
      );
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--season-glow) 26%, transparent);
      opacity: 0;
      transition: opacity var(--motion-change) ease-out;
      content: '';
      pointer-events: none;
    }

    html:not([data-effects='false']) [data-paper-sheen]:hover::before {
      opacity: 1;
    }

    html:not([data-effects='false']) .living-post[data-paper-sheen]:hover::before {
      opacity: 0.42;
    }
  }

  @supports (animation-timeline: view()) {
    html:not([data-effects='false'])
      :is(#archive, #discoveries, #daily-english, #my-games, #favorites)
      > .section-heading,
    html:not([data-effects='false']) :is(.my-game-cover img, .prose img, .daily-prose img) {
      animation: paper-rise 1ms linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 78%;
    }

    @keyframes paper-rise {
      from {
        opacity: 0.86;
        translate: 0 12px;
        scale: 0.98;
      }
      to {
        opacity: 1;
        translate: none;
        scale: 1;
      }
    }
  }

  @view-transition {
    navigation: auto;
  }

  html:not([data-theme-reveal])::view-transition-group(*) {
    animation-duration: 320ms;
    animation-timing-function: var(--motion-settle);
  }

  html:not([data-theme-reveal])::view-transition-old(root) {
    animation: page-away 160ms ease-out both;
  }

  html:not([data-theme-reveal])::view-transition-new(root) {
    animation: page-arrive 250ms ease-out both;
  }

  html[data-ink-navigation]:not([data-theme-reveal])::view-transition-image-pair(root) {
    isolation: auto;
  }

  html[data-ink-navigation]:not([data-theme-reveal])::view-transition-old(root) {
    animation: none;
    mix-blend-mode: normal;
  }

  html[data-ink-navigation]:not([data-theme-reveal])::view-transition-new(root) {
    animation: paper-navigation-ink 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
    mix-blend-mode: normal;
  }

  @keyframes paper-navigation-ink {
    from {
      clip-path: circle(0px at var(--ink-x) var(--ink-y));
    }
    to {
      clip-path: circle(150vmax at var(--ink-x) var(--ink-y));
    }
  }

  html[data-game-transition]::view-transition-new(game-cover) {
    animation: game-cover-away 320ms ease-in both;
  }

  @keyframes page-away {
    to {
      opacity: 0;
    }
  }
  @keyframes page-arrive {
    from {
      opacity: 0.55;
    }
  }
  @keyframes game-cover-away {
    55% {
      opacity: 1;
    }
    to {
      opacity: 0;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
