/* Web-only layer over the local app's own styles (export.py links it after each page's <style>).
   Goal: usable at 375 px on a phone, without changing how the pages look on a laptop.
   Nothing here is toggled by state, so nothing jumps: rows have fixed heights, and the
   phone/desktop differences are decided once by the screen (width, pointer), not by clicks. */

/* A sideways two-finger swipe that reaches the end of a scrolling row (the card strip, the tab rows,
   the group buttons) must not turn into the browser's Back/Forward gesture. Pages here are viewers,
   not documents: nothing on them needs the sideways history swipe. */
html, body { overscroll-behavior-x: none; }
.strip, #groups, header #tabs, .view, #show { overscroll-behavior-x: none; }

/* touch-only hints and controls; keyboard hints only where there is a keyboard */
.touch, .web-grid { display: none; }
@media (pointer: coarse) {
  .touch { display: inline; }
  .keys, .tools .lbl:has(kbd), .help { display: none !important; }
  .web-grid { display: block; }
}

/* ---------- header: brand + two page links on row 1, the IK43 tabs on their own scrolling row 2 */
@media (max-width: 760px) {
  :root { --head: 88px; }
  header { flex-wrap: wrap; align-content: center; column-gap: 10px; row-gap: 8px; padding: 0 12px; overflow: hidden; }
  .brand { font-size: 17px; }
  .pages { margin-left: auto; gap: 2px; }
  .pages a { padding: 5px 9px; }
  .long { display: none; }
  header #tabs { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  header #tabs::-webkit-scrollbar { display: none; }
  header #tabs a, header #tabs button { flex: none; font-size: 13px; padding: 4px 7px; }
}

/* ---------- IK43 infographics (ik43.html) */
#main { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
@media (max-width: 760px) {
  #main { padding: 12px 12px 40px; gap: 16px 12px; }
  .intro b { font-size: 18px; }
}

/* ---------- the one-at-a-time viewers (infographics and IK40 galleries) */
@media (max-width: 760px) {
  .view .bar { gap: 6px; padding: 0 8px; }
  .view .bar button { padding: 6px 9px; }
  .view .bar .n { width: auto; min-width: 4.2em; }
  #vFull, .view #full { display: none; }
  .view .bar .t small { display: none; }
}

/* ---------- IK40 galleries (galeria.html) */
@media (max-width: 760px) {
  .tools { padding: 8px 12px; min-height: 0; }
  .tools .desc { min-width: 0; font-size: 13px; }
  div.grid .cell .cap { height: 50px; }
  div.grid .cell .cap b { font-size: 14px; }
  div.grid .cell .cap small { font-size: 12px; }
  div.grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px 8px; padding: 12px 12px 32px; }
}

/* ---------- card viewer (kartyak.html) */
body:has(#strip) { height: 100dvh; }
@media (max-width: 760px) {
  body:has(#strip) .tools { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  body:has(#strip) .tools .lbl { display: none; }
  body:has(#strip) #groups { flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  body:has(#strip) #groups::-webkit-scrollbar { display: none; }
  body:has(#strip) #groups button { flex: none; }
  body:has(#strip) #full { display: none; }
  body:has(#strip) .stage img { max-width: calc(100% - 16px); }
  body:has(#strip) .zone { width: 30%; font-size: 34px; }
  body:has(#strip) .info { padding: 0 12px; gap: 10px; font-size: 13px; }
  body:has(#strip) .strip { height: 92px; padding: 8px 12px; }
  body:has(#strip) .th { width: 112px; height: 74px; }
  body:has(#strip) .th img { width: 104px; height: 52px; }
  body:has(#strip) .th span { max-width: 104px; }
}
@media (hover: none) { .zone { color: rgba(255, 255, 255, .35); } }

/* ---------- slideshows (ik43-diak.html) */
.web-grid { position: absolute; top: 10px; left: 10px; width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1;
  background: rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .25); z-index: 5; }
@media (max-width: 760px) {
  #cap { height: 84px; padding: 0 12px 10px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto 18px;
    align-content: end; column-gap: 10px; row-gap: 4px; }
  #cap .sav { grid-area: 1 / 1; font-size: 15px; width: 2.8em; align-self: baseline; }
  #cap .cim { grid-area: 1 / 2; font-size: 24px; align-self: baseline; }
  #cap .n { grid-area: 1 / 3; font-size: 13px; width: 4.2em; align-self: baseline; }
  #cap .info { grid-area: 2 / 1 / 3 / 4; width: auto; text-align: left; font-size: 13px; height: 18px; overflow: hidden; white-space: nowrap; }
  #help { top: 22px; right: 12px; left: 60px; text-align: right; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #title .paper { width: 100%; height: 100%; aspect-ratio: auto; overflow-y: auto; padding: 66px 18px 40px; container-type: normal; background-size: cover; }
  #title h1 { font-size: 34px; margin-bottom: 6px; }
  #title .sub { font-size: 14px; margin-bottom: 16px; }
  #title .boxes { grid-template-columns: 1fr; gap: 10px; }
  #title .box { min-height: 0; padding: 10px 12px; border-radius: 6px; }
  #title .box h2 { font-size: 15px; margin-bottom: 4px; }
  #title .box p { font-size: 14px; }
  #title .credit { position: static; font-size: 11px; margin-top: 16px; }
  #show #grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 8px; padding: 60px 12px 24px; }
  #show #grid figcaption { font-size: 12px; }
  #show #grid .intro { font-size: 18px; }
}
