/*
  article_mobile.css
  ------------------
  Responsive frontend polish for article.php.
  Loaded late from article.php, after the theme header, so these rules can safely
  override older inline/header CSS on phones and small tablets.
*/

html{
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body{
  overflow-x: hidden;
}

/* Always keep rich article media inside the readable column. */
.articleBody{
  max-width: 74ch;
  margin-inline: auto;
  overflow-wrap: anywhere;
  word-break: normal;
}

.articleBody p,
.articleBody li{
  font-size: clamp(16px, 1.55vw, 18px);
  line-height: 1.75;
}

.articleBody h1,
.articleBody h2,
.articleBody h3,
.articleBody h4{
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.articleBody img,
.articleBody picture,
.articleBody video,
.articleBody canvas,
.articleBody svg,
.articleBody iframe,
.articleBody embed,
.articleBody object{
  max-width: 100% !important;
}

.articleBody img,
.articleBody video,
.articleBody canvas,
.articleBody svg{
  height: auto !important;
}

.articleBody img{
  display: block;
  margin: 14px auto;
  border-radius: 14px;
}

.articleBody figure{
  max-width: 100%;
  margin: 18px 0;
}

.articleBody figcaption{
  margin-top: 7px;
  font-size: .9rem;
  line-height: 1.45;
  opacity: .82;
}

.articleBody table{
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.articleBody pre,
.articleBody code{
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.articleBody iframe,
.articleBody embed,
.articleBody object{
  width: 100% !important;
}

.articleBody iframe[src*="youtube"],
.articleBody iframe[src*="youtu.be"],
.articleBody iframe[src*="vimeo"]{
  aspect-ratio: 16 / 9;
  height: auto !important;
}

/* Small tablets and phones. */
@media (max-width: 760px){
  body.theme-flash > .container.panel,
  body.theme-night > .container.panel,
  body.theme-day > .container.panel{
    width: calc(100% - 14px) !important;
    max-width: none !important;
    margin-inline: auto !important;
    padding: 8px 7px 44px !important;
    border-radius: 12px !important;
  }

  body.theme-flash .panel,
  body.theme-night .panel,
  body.theme-day .panel{
    padding: 10px !important;
    border-radius: 12px !important;
  }

  .cardBody{
    padding: 8px !important;
  }

  .articleHeader{
    display: block !important;
    max-height: none !important;
    margin: 10px 0 12px !important;
    padding: 10px !important;
    overflow: visible !important;
    border-radius: 14px !important;
  }

  body.theme-flash .articleHeader img,
  body.theme-night .articleHeader img,
  body.theme-day .articleHeader img,
  .articleHeader img{
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 55vh !important;
    aspect-ratio: 16 / 9;
    object-fit: cover !important;
    border-radius: 14px !important;
    border-width: 0 !important;
  }

  body.theme-flash .articleHeader__overlay,
  body.theme-night .articleHeader__overlay,
  body.theme-day .articleHeader__overlay,
  .articleHeader__overlay{
    margin-top: 10px !important;
    padding: 12px !important;
    border-radius: 12px !important;
  }

  .articleHeader__overlay h1,
  .panel > h1,
  .articleBody h1{
    font-size: clamp(1.55rem, 8vw, 2.15rem) !important;
    line-height: 1.12 !important;
  }

  .articleHeader__overlay p,
  .panel > p{
    font-size: 1rem !important;
    line-height: 1.5 !important;
  }

  .voteBox{
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    align-items: stretch !important;
  }

  .voteBox form,
  .voteBox .voteBtn{
    width: 100% !important;
  }

  .voteBtn{
    min-height: 44px;
    padding: 10px 8px !important;
    border-radius: 12px !important;
  }

  .voteStat,
  .shareBox{
    grid-column: 1 / -1;
    margin-left: 0 !important;
  }

  .shareBox{
    justify-content: flex-start;
    min-height: 32px;
  }

  .articlePager{
    flex-wrap: wrap;
    justify-content: center !important;
    gap: 8px !important;
  }

  .articlePager .btn{
    flex: 1 1 42%;
    text-align: center;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .articlePager .pagerStat{
    order: -1;
    flex: 1 0 100%;
    text-align: center;
  }

  .articleBody{
    max-width: none;
    width: 100%;
    font-size: 16px;
  }

  .articleBody p,
  .articleBody li{
    font-size: 1rem !important;
    line-height: 1.72 !important;
  }

  .articleBody h2{
    font-size: clamp(1.35rem, 6vw, 1.8rem) !important;
  }

  .articleBody h3{
    font-size: clamp(1.16rem, 5.3vw, 1.45rem) !important;
  }

  .articleBody blockquote{
    margin-left: 0;
    margin-right: 0;
    padding-left: 12px;
  }

  .articleBody img{
    max-width: 100% !important;
    height: auto !important;
  }

  .articleBody figure img{
    width: 100% !important;
    object-fit: contain !important;
  }

  .galleryGrid{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .galleryThumb{
    border-radius: 12px !important;
  }

  .galleryThumb img{
    height: min(34vw, 180px) !important;
    object-fit: cover !important;
  }

  /* Make gallery/lightbox usable on phones. */
  .lbx,
  .cardDlg{
    padding: 0 !important;
  }

  .lbxBox,
  .cardDlgBox{
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }

  .lbxBody,
  .cardDlgBody{
    max-height: calc(100dvh - 48px) !important;
    overflow: auto;
  }

  .lbxImg{
    min-height: 42vh !important;
  }

  .lbxImg img{
    max-height: 58vh !important;
    width: auto !important;
    height: auto !important;
  }

  .lbxMeta{
    border-left: 0 !important;
    border-top: 1px solid rgba(120,200,255,.18);
  }
}

/* Very narrow phones. */
@media (max-width: 420px){
  body.theme-flash > .container.panel,
  body.theme-night > .container.panel,
  body.theme-day > .container.panel{
    width: calc(100% - 8px) !important;
    padding-inline: 4px !important;
  }

  .galleryGrid{
    grid-template-columns: 1fr 1fr !important;
  }

  .articlePager .btn{
    flex-basis: 100%;
  }
}
