/*
 * Foundation: Base Styles
 *
 * Global reset, typography, and base element styling following Rails conventions.
 * Includes progressive enhancement and accessibility features.
 */

/* Note: The global reset (* selector), html, and body base styles are
 * defined in application.css as the canonical entry point.
 * This file extends those base styles with additional layout rules. */

/* Phone: a sheet or modal pushes the page back, as iOS does, so the task in
   front reads as a layer above it. The tab bar scales about the same point
   (the middle of the screen) so the two move as one surface. */
@media (max-width: 46.1875rem) {
  /* Only the transform animates, which the compositor can do alone. The
     corners round at once when the page goes back and square again once it
     has come forward: an animated radius repaints the whole page each frame. */
  .app-content {
    transition: transform var(--spring-dur) var(--spring), border-radius 0s var(--spring-dur);
  }

  .bottom-nav {
    transform-origin: 50% calc(100% - 50vh);
    transition: transform var(--spring-dur) var(--spring);
  }

  body:has(#panel .sheet-card.is-open) .app-content,
  body:has(dialog.modal-dialog[open]) .app-content {
    transform: scale(0.94);
    transform-origin: center center;
    border-radius: var(--r-sheet);
    overflow: hidden;
    transition: transform var(--spring-dur) var(--spring);
  }

  body:has(#panel .sheet-card.is-open) .bottom-nav,
  body:has(dialog.modal-dialog[open]) .bottom-nav {
    transform: scale(0.94);
  }

  /* With nothing moving there is nothing to wait for */
  @media (prefers-reduced-motion: reduce) {
    .app-content,
    .bottom-nav {
      transition-delay: 0s;
    }
  }
}

/* Custom thin scrollbar for Webkit browsers */
.app-content::-webkit-scrollbar {
  width: 6px;
}

.app-content::-webkit-scrollbar-track {
  background: transparent;
}

.app-content::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.app-content::-webkit-scrollbar-thumb:hover {
  background: var(--tx3);
}

/* Progressive Enhancement - CSS Feature Support */
@supports (container-type: inline-size) {
  .content-main {
    container-type: inline-size;
  }
}

/* Reduced motion preference support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Responsive Media */
img,
video,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

picture {
  display: contents;
}

iframe,
embed,
object {
  max-width: 100%;
}

/* Disable iOS long-press context menu on all links */
a {
  -webkit-touch-callout: none;
  user-select: none;
}

/* Horizontal dividers */
hr {
  border: none;
  border-top: var(--bw) solid var(--line);
  margin: var(--sp-6) 0 var(--sp-6);
}
