/* Phone and tablet refinements. Loaded after the other stylesheets so these
   win; desktop with a mouse looks exactly as before. */

html { -webkit-tap-highlight-color: transparent; }

/* Use the visible height on phones (it changes as the address bar slides). */
@supports (height: 100dvh) {
  .sheet { max-height: 92dvh; }
  .lightbox img, #lightbox-media img, #lightbox-media video { max-height: 82dvh; }
}

/* ───── Header and menu ───── */
@media (max-width: 820px) {
  .nav-links {
    max-height: calc(100dvh - 68px); overflow-y: auto; overscroll-behavior: contain;
    box-shadow: 0 24px 40px -28px rgb(40 30 20 / .35);
  }
  .nav-links a { padding: 14px 4px; }
}
/* Narrow phones: the admin pill shrinks to its key so the header fits. */
@media (max-width: 420px) {
  .nav { gap: 10px; }
  .admin-pill { width: 40px; height: 40px; padding: 0; justify-content: center; gap: 0; font-size: 0; }
  .admin-pill svg { width: 16px; height: 16px; }
}
@media (max-width: 360px) {
  .brand { font-size: 1rem; gap: 8px; }
  .brand svg { width: 24px; height: 24px; }
  .nav-tools { gap: 4px; }
}

/* ───── Layout on phones ───── */
@media (max-width: 820px) {
  .about-grid .portrait { max-width: 240px; font-size: 3rem; }
  .sheet-close { margin: 10px 10px -50px 0; }
}
@media (max-width: 600px) {
  .section-head { margin-bottom: 28px; }
  .list-item { gap: 6px 16px; padding: 18px 4px; }
  .photos { column-gap: 12px; }
  .photo { margin-bottom: 12px; }
}

/* ───── Games ───── */
.game-canvas { -webkit-touch-callout: none; }
@media (max-width: 719px) {
  .game-host { min-width: 0; width: 100%; border-radius: 14px; }
}
/* Phone held sideways: the header scrolls away so the game gets the screen. */
@media (pointer: coarse) and (max-height: 520px) {
  body:has(#games.playing) .site-header { position: relative; }
  .game-host { min-width: 0; width: min(100%, calc((100dvh - 24px) * 1.6)); }
}

/* ───── Touch screens: bigger targets ───── */
@media (pointer: coarse) {
  .btn.small { height: 42px; padding: 0 16px; }
  .key-link { width: 44px; height: 44px; }
  .admin-pill { height: 40px; }
  .about-meta a { min-height: 40px; }
  .edit-fab { height: 36px; padding: 0 14px; }
  .g-expand { width: 42px; height: 42px; }
  .lightbox .icon-btn { width: 46px; height: 46px; }
}

/* ───── Touch screens: no hover states that stick after a tap ───── */
@media (hover: none) {
  .card:hover, .game-card:hover { transform: none; box-shadow: none; border-color: var(--line); }
  .card:hover .card-media img, .card:hover .card-media .ph, .photo:hover img { transform: none; }
  .card:hover .arrow, .card:hover .media-badge { transform: none; }
  .card:active, .game-card:active { transform: scale(.985); transition-duration: .2s; }
  .btn:hover, .icon-btn:hover, .chip:hover, .about-meta a:hover, .key-link:hover { transform: none; box-shadow: none; }
  .btn:hover::before { transform: translateY(101%); }
  .btn:not(.primary):hover { color: inherit; border-color: var(--line-2); }
  .btn.primary:hover { color: var(--accent-ink); border-color: var(--accent); }
  .btn:hover svg { transform: none; }
  .list-item:hover { padding-left: 4px; background: none; }
  .list-item .arrow { opacity: .55; transform: none; }
  .g-thumb:hover { transform: none; }
  .g-thumb:not(.on):hover { opacity: .55; }
  /* Things that only appeared on hover are always shown */
  .photo figcaption, .edit-fab { opacity: 1; transform: none; }
}
