/* slidy-mobile.css — makes the W3C Slidy talk decks readable on a phone.
 *
 * Loaded LAST by the three SymSim decks and the 2026 G4G16 talk, after
 * slidy.css and the per-talk mystyle.css, so it wins on source order without
 * either file being touched. Everything lives inside the media queries below:
 * these decks are still presented from a laptop to a projector, and that
 * rendering must not change.
 *
 * The first block is the Slidy machinery all four decks share. The second is
 * the 2026 deck's own layout, which is built differently.
 *
 * Three things break on a narrow screen (github.com/vbulatov2011/symhub#1):
 *
 *  1. slidy.css ends with `@media screen and (max-device-width: 800px)
 *     { div.slide { font-size: 200% } }`. Slidy's own script has by then
 *     already stepped the body down to 10-12pt for a narrow window, and the
 *     200% compounds with `div.slide h1 { font-size: 160% }`: a slide title
 *     lands at 51px on a 375px screen and runs off the right edge.
 *  2. mystyle.css pins `div.slide h1 { height: 1.5em }`. Projected, a title
 *     is one line and fits the box. Wrapped to three lines on a phone it
 *     overflows and prints on top of the slide body — the reported symptom.
 *  3. Media widths are percentages of a 1024px slide (.video is 80% wide
 *     with an 8% left margin; .thumbnail is 24%, i.e. four to a row).
 *
 * On the query: a plain max-width would miss a large phone held in landscape,
 * where the viewport is wider than a small laptop window. Slidy's own
 * `max-device-width` cannot be borrowed for that — Chrome evaluates the
 * deprecated device-width feature inconsistently, and it was observed
 * matching at a 1280px viewport, which would have pulled these rules onto the
 * projector. `pointer: coarse` is the reliable stand-in: true on a touch
 * device, false on anything driven by a mouse.
 */

@media (max-width: 600px), ((hover: none) and (pointer: coarse) and (max-width: 960px)) {

  /* Size from the root element: Slidy's script rewrites the font size on
   * <body>, so anything relative to body moves under us. rem does not. */
  body.single_slide div.slide {
    bottom: auto;
    min-height: 100%;
  }

  div.slide {
    font-size: 1.05rem;
    line-height: 1.4;
    padding-left: 10px;
    padding-right: 10px;
    /* clears the fixed toolbar, which a slide taller than the phone would
     * otherwise scroll its last line underneath */
    padding-bottom: 3em;
  }

  /* Title: as tall as the words need, full width, and it may break. */
  div.slide h1 {
    height: auto;
    min-height: 0;
    width: auto;
    font-size: 1.35rem;
    line-height: 1.25;
    margin-right: 0;
    padding-left: 0.5em;
    padding-right: 0.5em;
    overflow-wrap: break-word;
  }

  div.slide h2, div.slide h3 {
    font-size: 1.1rem;
    line-height: 1.3;
  }

  /* One column. The percentages below are all fractions of a 1024px slide. */
  .video, .video_half,
  .img-70, .img-60, .img-50, .img-full-width, .img-half-width {
    width: 100%;
    margin-left: 0;
    box-sizing: border-box;
  }

  /* Four thumbnails to a row is 90px each on a phone; two is legible. */
  .thumbnail {
    width: 48%;
    box-sizing: border-box;
  }

  /* Nothing may push the slide sideways. */
  div.slide img, div.slide video {
    max-width: 100%;
    height: auto;
  }

  /* Slidy sets the toolbar font inline (toolbar.style.fontSize = "60%"),
   * which resolves to under 10px here; only !important reaches it. */
  div.toolbar {
    font-size: 0.75rem !important;
    height: auto;
    padding-top: 2px;
    padding-bottom: 2px;
  }
}

/* --- the 2026 G4G16 deck --------------------------------------------------
 * "Symmetry and Chaos" does not lay its slides out in flow at all. Each one
 * pins an .image* block at left: 2-20% and a .caption* block at left: 59%,
 * both position: absolute and both sized as a fraction of a 1024x768 slide.
 * Narrow the viewport and the two land on top of each other: the caption
 * prints over the picture in a column three characters wide.
 *
 * Unpin them and the slide stacks in document order, which is already picture
 * then caption. The !important is for the two blocks on the title slide that
 * carry their geometry inline, where nothing else would reach.
 *
 * The captions are set at a flat 24pt, a size chosen against a projector.
 * They inherit the slide's size here instead.
 */

@media (max-width: 600px), ((hover: none) and (pointer: coarse) and (max-width: 960px)) {

  .image, .image_left, .image_right,
  .image1, .image2, .image3, .image4, .image5,
  .image10, .image15_70, .image20,
  .video_container, .video1,
  .caption, .caption2, .caption20, .caption30, .caption50,
  .caption70, .caption71,
  .caption_left, .caption_left50, .caption_right70 {
    position: static !important;
    float: none !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    height: auto !important;
    max-width: 100%;
  }

  .caption, .caption2, .caption20, .caption30, .caption50,
  .caption70, .caption71,
  .caption_left, .caption_left50, .caption_right70 {
    font-size: inherit;
    line-height: 1.4;
    margin-top: 0.6em;
  }

  /* A tall figure would otherwise push its caption a screen and a half down.
   * Only one dimension is constrained, so the aspect ratio is kept. */
  .image > img, .image_left > img, .image_right > img,
  .image1 > img, .image2 > img, .image3 > img, .image4 > img, .image5 > img,
  .image10 > img, .image15_70 > img, .image20 > img {
    max-height: 70vh;
    width: auto;
  }

  .video2 {
    width: 100%;
    height: auto;
    max-height: none;
  }
}
