/* Interaction refinements within design.md's existing color, rail and motion system. */
html { scrollbar-gutter: stable; }
button, a, [role="button"] { touch-action: manipulation; }
button, [role="button"] { -webkit-user-select: none; user-select: none; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--racing-teal);
  outline-offset: 4px;
}
.carousel-track { transition: transform var(--motion-base) var(--motion-enter); }
.carousel-stage { touch-action: pan-y pinch-zoom; }
html .carousel-btn, .image-lightbox-close { width: 44px; height: 44px; }
.carousel-thumb { min-width: 44px; min-height: 44px; }
.carousel-btn, .image-lightbox-close, .chat-demo-replay, .back-btn {
  transition: color var(--motion-fast) ease, background var(--motion-fast) ease,
    transform var(--motion-fast) var(--motion-enter);
}
.image-lightbox-close:active, .chat-demo-replay:active { transform: scale(.98); }
.carousel-btn:active { transform: translateY(-50%) scale(.98); }
.scroll-top-btn { min-height: 44px; animation: none; opacity: 1; }
.scroll-top-btn[hidden] { display: none; }
.laptop-screen { overscroll-behavior: contain; }
.builds-jump { min-height: 44px; display: inline-flex; align-items: center; }
.simple-index .index-toggle, .simple-index .archive-tab { min-height: 44px; }
html .simple-index .index-home { min-width: 44px; min-height: 44px; }
.image-lightbox {
  display: grid;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast) ease, visibility var(--motion-fast);
}
.image-lightbox.open { visibility: visible; opacity: 1; pointer-events: auto; }
.image-lightbox img {
  max-height: 88dvh;
  transform: scale(.985);
  transition: transform var(--motion-base) var(--motion-enter);
}
.image-lightbox.open img { transform: scale(1); }
html[data-input="keyboard"] { scroll-behavior: auto; }
html[data-input="keyboard"] :is(.page.active,.d-wrap.enter,.motion-target,.carousel-track,.image-lightbox,.image-lightbox img,.coded-cover-preview) {
  animation: none !important;
  transition: none !important;
}
html[data-input="keyboard"] .motion-target { opacity: 1; transform: none; }
@media (hover: none) {
  /* A touch tap should never leave a floating preview covering reading content. */
  .coded-cover-preview, .preview { display: none !important; }
}
@media (pointer: coarse) {
  .carousel-btn { width: 44px; height: 44px; }
  .builds-jump { min-height: 44px; }
}
@media (max-width: 860px) {
  :root { --frame-pad: 24px; }
  #pg-gallery .site { padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right)); }
  #pg-gallery :is(.project-index > .work-category-copy,.repo-section-head,.project-table,.repo-table) {
    width: 100%;
  }
}
@media (max-width: 480px) {
  :root { --frame-pad: 16px; }
  #pg-gallery .site { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  #pg-gallery :is(.project-index > .work-category-copy,.repo-section-head,.project-table,.repo-table) {
    width: 100%;
  }
  #pg-gallery .project-row > .project-name, #pg-gallery .repo-card > h2 {
    font-size: 20px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  #pg-gallery .project-row > .project-description, #pg-gallery .repo-card > p {
    font-size: 12px;
    line-height: 1.6;
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .page.active, .d-wrap.enter, .motion-target, .carousel-track { animation: none !important; transition: none !important; }
  .motion-target { opacity: 1; transform: none; }
  .image-lightbox img { transform: none; transition: none; }
}

.page.active { animation-duration: var(--motion-base); }

/* Keep critical content visible, then use one brief entrance with a small stagger. */
.site:not(.is-loaded) :is(.title,.input-block,.project-index) { opacity: 1; transform: none; filter: none; }
.site.is-loaded .title { animation-duration: var(--motion-base); animation-delay: 0ms; }
.site.is-loaded .input-block:nth-child(1) { animation-duration: var(--motion-base); animation-delay: 40ms; }
.site.is-loaded .input-block:nth-child(2) { animation-duration: var(--motion-base); animation-delay: 80ms; }
.site.is-loaded .input-block:nth-child(3) { animation-duration: var(--motion-base); animation-delay: 120ms; }
.site.is-loaded .project-index, .site.is-loaded .footer-note { animation: none; }
html :is(.back-btn,.chat-demo-replay,.design-view-btn,.repo-detail-link,.aspa-scenario-tabs button) { min-height: 44px; }
@media (prefers-reduced-motion: reduce) {
  .site.is-loaded :is(.title,.input-block) { animation: none; opacity: 1; transform: none; }
}

/* Essential copy uses the existing ink/canvas pair; muted remains for metadata. */
#pg-gallery .project-row > .project-description,
#pg-gallery .repo-card > p,
#pg-gallery .work-category-copy p,
#pg-gallery .repo-section-head > p {
  color: color-mix(in srgb, var(--ink) 72%, var(--bg));
}
html[data-input="keyboard"] :is(.project-row,.repo-card,.repo-title) { transition: none !important; }
html[data-input="keyboard"] :is(.project-hover-pixels,.project-dither-layer,.repo-shader) { display: none; }
