/* =========================================================
   Mobile & touch refinements
   Loaded last. Everything here is either scoped to small /
   touch screens or is a no-op at desktop widths.
   ========================================================= */

/* Grids: never let a card's minimum width exceed the screen (fixes 320px phones).
   At desktop widths min(300px, 100%) is still 300px, so nothing changes there. */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid > * { min-width: 0; }

/* Words that depend on the input type */
.touch-only { display: none; }
@media (hover: none) {
  .hover-only { display: none; }
  .touch-only { display: inline; }
}

/* Team avatars: on touch screens a tap flips the initials to the chess piece */
@media (hover: none) {
  .person:hover .av-inner { transform: none; }
  .person.flipped .av-inner { transform: rotateY(180deg); }
  .person .avatar { cursor: pointer; -webkit-tap-highlight-color: transparent; }
}

@media (max-width: 860px) {
  /* Safety net against any sideways scrolling on phones (clip keeps sticky elements working) */
  html, body { overflow-x: clip; }

  /* Timeline years slide sideways as you scroll: keep the box as wide as the text so it stays on screen */
  .timeline .year-label { width: fit-content; max-width: 100%; }

  /* Bigger tap targets in the footer */
  .site-footer ul { gap: 0; }
  .site-footer ul a { display: inline-block; padding: 9px 0; }

  /* Open menu: let it scroll if the phone is in landscape */
  .nav-links { max-height: calc(100dvh - 72px); overflow-y: auto; overscroll-behavior: contain; }
}

/* Flip cards (home facts, team avatars) on touch screens: also swap which face is visible
   halfway through the turn, so the reverse side can never show through mirrored
   (some phone browsers ignore backface-visibility when they drop to software rendering). */
@media (hover: none) {
  .fact-front, .fact-back, .av-front, .av-back { transition: visibility 0s linear .25s; }
  .fact-back, .av-back { visibility: hidden; }
  .fact[aria-pressed="true"] .fact-front, .person.flipped .av-front, .person:focus-within .av-front { visibility: hidden; }
  .fact[aria-pressed="true"] .fact-back, .person.flipped .av-back, .person:focus-within .av-back { visibility: visible; }
}

/* Cards with a 3D piece: the piece is positioned against its own card.
   (Before, only mouse users got position: relative via the .tilt effect, so on phones
   the piece jumped to the top of the whole section when the reveal animation ended or on tap.) */
.card { position: relative; }

@media (max-width: 700px) {
  /* Home "Play. Learn. Connect." band: small enough that the whole photo word fits on screen */
  .bt-row { font-size: 13.5vw; }
}

@media (max-width: 860px) {
  /* Home "Every move" board: a little smaller so its turning corners stay on screen */
  .scene-board { width: min(62vw, 38vh); }
  /* Pin the scene to the visible screen height (not the height behind the browser toolbars) */
  .scene.ready .scene-pin { height: 100vh; height: 100svh; }
}

/* "Three ways to get involved" 3D pieces on phones (fix 2026-11-17).
   Mobile Safari can stop repainting, or drop, a constantly-redrawn canvas that sits inside a CSS
   filter, which made the pieces vanish. On touch screens the piece keeps the contact shadow that is
   drawn in 3D and loses only the extra CSS drop-shadow. It is also given its own stable layer. */
@media (hover: none), (pointer: coarse) {
  .card-piece { filter: none; transform: translateZ(0); }
}

/* ---------- Mobile pass 2026-11-17 ---------- */

/* Award cards: Safari sized the photo grid from the photos' full natural width, so on phones the
   card was wider than the screen and its right side was cut off. Let every track shrink. */
.award { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.award-photos { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); min-width: 0; }
.award-photos button { min-width: 0; min-height: 0; }

/* Smallest text on the site: at least 12px so it stays readable on phones */
.tag, .media-note, .fact-front em, .brand small, .soon, .cc-left small { font-size: max(.75rem, 12px); }

@media (max-width: 860px) {
  /* bigger tap targets */
  .hero-links a { padding: 10px 0; }
  .filters button { min-height: 44px; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .socials a { width: 44px; height: 44px; }
  .nav-toggle { width: 48px; height: 48px; display: grid; place-items: center; margin-right: -8px; }
  /* long words / e-mail addresses never push the layout sideways */
  h1, h2, h3, p, li { overflow-wrap: break-word; }
  h1 { hyphens: manual; }
}

@media (max-width: 430px) {
  .container { padding: 0 16px; }
  .section { padding: 56px 0; }
  .section-head { margin-bottom: 30px; }
  .lead { font-size: 1.05rem; }
  .card { padding: 22px; }
  .event-body { padding: 18px 18px 22px; }
  .past-event .event-body { padding: 18px 18px 22px; }
  .btn { padding: 13px 20px; }
  .hero-btns .btn { width: 100%; }
  .cta-band { padding: 30px 22px; border-radius: 18px; }
  .chess-clock .cc-left { padding: 18px 18px 14px; }
  .cc-unit { min-width: 44px; }
  .footer-bottom { flex-direction: column; }
}
.event-media .media-note, .fmt .seen strong { font-size: max(.75rem, 12px); }

/* Join page points table: on phones each activity becomes its own card instead of a squeezed 3-column table */
@media (max-width: 600px) {
  .table-wrap { overflow: visible; box-shadow: none; border-radius: 0; }
  .table-wrap table { min-width: 0; background: none; }
  .table-wrap thead { display: none; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
  .table-wrap td { border: 0; padding: 4px 18px 12px; }
  .table-wrap td:first-child { background: var(--green); color: var(--white); font-family: var(--font-head); padding: 12px 18px; margin-bottom: 8px; }
  .table-wrap td:nth-child(n+2)::before { display: block; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--green-700); margin-bottom: 6px; }
  .table-wrap td:nth-child(2)::before { content: "Points"; }
  .table-wrap td:nth-child(3)::before { content: "How it works"; }
  .table-wrap td:last-child { padding-bottom: 18px; }
}
