/**
 * CCT PAK 20 — NEWS ARTICLE MOBILE NATIVE-APP SHEET (<= 991px)
 *
 * Dedicated mobile stylesheet loaded with media="(max-width: 991px)".
 * Built 100% on top of the real CCTPak20 Header (header.php) & Footer (footer.php)
 * to deliver a genuine Native-App reading experience on phones and tablets.
 *
 * Principles:
 * - ZERO forced-override anywhere (specificity via html body main.nws-page)
 * - Sticky Frosted-Glass Reader Sub-bar (.nws-m-subbar) with live reading progress
 * - Full-bleed/constrained RTE figures (min-width: 100% overrides inline width: 75% on phones)
 * - Compact horizontal Native-App cards for Related News
 * - Ergonomic touch targets (>= 40px)
 */

@media (max-width: 991px) {

  html body main.nws-page {
    --nws-body-size: 1.0625rem;
    --nws-body-lh:   1.85;
  }

  html body main.nws-page[data-font-size="sm"] {
    --nws-body-size: 0.96rem;
    --nws-body-lh:   1.78;
  }

  html body main.nws-page[data-font-size="md"] {
    --nws-body-size: 1.0625rem;
    --nws-body-lh:   1.85;
  }

  html body main.nws-page[data-font-size="lg"] {
    --nws-body-size: 1.2rem;
    --nws-body-lh:   1.92;
  }

  /* Hide fixed desktop top progress bar on mobile (integrated into .nws-m-subbar instead) */
  html body .nws-progress-fixed {
    display: none;
  }

  /* ==========================================================
     1. NATIVE-APP STICKY READER SUB-BAR (.nws-m-subbar)
        Sits directly beneath #header.header and sticks when scrolling
  ========================================================== */
  html body main.nws-page .nws-m-subbar {
    display: block;
    position: sticky;
    top: 60px;
    z-index: 980;
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  }

  /* Tablet 768px-991px has sticky #header (58px when scrolled) */
  @media (min-width: 768px) and (max-width: 991px) {
    html body main.nws-page .nws-m-subbar {
      top: 58px;
    }
  }

  html body main.nws-page .nws-m-subbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    padding: 6px 16px;
    max-width: 820px;
    margin: 0 auto;
  }

  html body main.nws-page .nws-m-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--nws-ink);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
  }

  html body main.nws-page .nws-m-back:active {
    transform: scale(0.96);
    background: #e2e8f0;
  }

  html body main.nws-page .nws-m-back i {
    font-size: 0.9rem;
    color: var(--nws-blue-deep);
  }

  html body main.nws-page .nws-m-scrolltitle {
    flex: 1;
    min-width: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--nws-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    visibility: hidden;
    text-align: center;
  }

  html body main.nws-page .nws-m-subbar.is-scrolled .nws-m-scrolltitle {
    opacity: 1;
    visibility: visible;
  }

  html body main.nws-page .nws-m-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  html body main.nws-page .nws-m-btn {
    appearance: none;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: var(--nws-ink);
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
  }

  html body main.nws-page .nws-m-btn:active {
    transform: scale(0.94);
    background: var(--nws-blue-pale);
    border-color: var(--nws-blue);
  }

  html body main.nws-page .nws-m-btn i {
    font-size: 0.98rem;
    color: var(--nws-blue-deep);
  }

  html body main.nws-page .nws-m-progress {
    height: 2px;
    width: 100%;
    background: transparent;
    overflow: hidden;
  }

  html body main.nws-page .nws-m-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(236, 72, 153, 0.85) 0%, rgba(244, 114, 182, 0.95) 100%);
    box-shadow: 0 1px 3px rgba(236, 72, 153, 0.25);
    transition: width 0.08s linear;
  }

  /* ==========================================================
     2. MOBILE HEADER & BYLINE CARD (.nws-head)
  ========================================================== */
  html body main.nws-page .nws-head {
    padding: 18px 0 20px;
  }

  /* Hide desktop breadcrumb on phones since .nws-m-subbar has native back button */
  html body main.nws-page .nws-crumbs {
    display: none;
  }

  html body main.nws-page .nws-head-col::before {
    width: 40px;
    height: 3.5px;
    margin-bottom: 12px;
  }

  html body main.nws-page .nws-eyebrow {
    justify-content: space-between;
    margin-bottom: 10px;
  }

  html body main.nws-page .nws-title {
    font-size: clamp(1.38rem, 5.4vw, 1.72rem);
    line-height: 1.42;
    margin-bottom: 16px;
  }

  html body main.nws-page .nws-meta-bar {
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8fafc;
    gap: 12px;
  }

  html body main.nws-page .nws-meta-avatar {
    width: 38px;
    height: 38px;
  }

  html body main.nws-page .nws-meta-org {
    font-size: 0.84rem;
  }

  html body main.nws-page .nws-byline {
    font-size: 0.76rem;
    gap: 6px;
  }

  html body main.nws-page .nws-byline .nws-chip {
    padding: 2px 8px;
    font-size: 0.72rem;
  }

  /* Hide duplicate font-switch inside byline card on mobile (already in sticky sub-bar) */
  html body main.nws-page .nws-meta-tools .nws-font-switch {
    display: none;
  }

  /* ==========================================================
     3. MOBILE READING CONTENT & IN-BODY FIGURES (.nws-read)
  ========================================================== */
  html body main.nws-page .nws-read {
    padding: 22px 0 34px;
  }

  html body main.nws-page .nws-lead {
    margin-bottom: 22px;
    padding: 14px 16px;
    font-size: 1rem;
    line-height: 1.7;
    border-radius: 0 12px 12px 0;
  }

  html body main.nws-page .nws-body p {
    margin-bottom: 18px;
  }

  html body main.nws-page .nws-body h2 {
    margin: 28px 0 12px;
    padding-left: 11px;
    border-left-width: 3.5px;
    font-size: 1.22rem;
    line-height: 1.45;
  }

  html body main.nws-page .nws-body h3 {
    margin: 24px 0 10px;
    font-size: 1.08rem;
  }

  html body main.nws-page .nws-body blockquote {
    margin: 22px 0;
    padding: 16px 18px;
    font-size: 1rem;
    line-height: 1.78;
    border-radius: 0 12px 12px 0;
  }

  /* Editorial figures: responsive figcaption styling */
  html body main.nws-page .nws-body .editorial-figure figcaption {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  /* On mobile (< 640px), editorial figures align centered with full responsive width */
  @media (max-width: 639.98px) {
    html body main.nws-page .nws-body .editorial-figure,
    html body main.nws-page .nws-body .editorial-figure.image-align-center,
    html body main.nws-page .nws-body .editorial-figure.image-align-left,
    html body main.nws-page .nws-body .editorial-figure.image-align-right {
      float: none;
      max-width: 100%;
      margin: 20px auto;
      text-align: center;
      clear: both;
    }

    html body main.nws-page .nws-body .editorial-figure figcaption {
      text-align: center;
    }
  }

  /* Mobile bottom share cluster */
  html body main.nws-page .cct-bottom-share {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    margin-top: 28px;
  }

  html body main.nws-page .cct-bottom-share-btns {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }

  html body main.nws-page .cct-share-btn {
    flex: 1;
    justify-content: center;
    padding: 9px 8px;
    font-size: 0.82rem;
  }

  /* ==========================================================
     4. MOBILE FOOTER, PAGER & COMPACT NATIVE RELATED CARDS
  ========================================================== */
  html body main.nws-page .nws-foot {
    padding: 28px 0 52px;
  }

  html body main.nws-page .nws-author {
    padding: 14px 16px;
    margin-bottom: 20px;
    border-radius: 14px;
  }

  html body main.nws-page .nws-author-logo {
    width: 42px;
    height: 42px;
  }

  html body main.nws-page .nws-pager {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 32px;
  }

  html body main.nws-page .nws-pager-item {
    padding: 14px 16px;
  }

  html body main.nws-page .nws-pager-item.is-next {
    text-align: left;
    align-items: flex-start;
  }

  /* Related News: Native-App Horizontal Compact Cards on Mobile */
  html body main.nws-page .nws-related-head {
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  html body main.nws-page .nws-related-head h2 {
    font-size: 1.08rem;
  }

  html body main.nws-page .nws-related-grid,
  html body main.nws-page .nws-related-grid.is-sparse,
  html body main.nws-page .nws-related-grid.is-single {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  html body main.nws-page .nws-rcard,
  html body main.nws-page .nws-related-grid.is-single .nws-rcard {
    flex-direction: row;
    align-items: stretch;
    padding: 10px;
    gap: 12px;
    border-radius: 14px;
  }

  html body main.nws-page .nws-rcard-thumb,
  html body main.nws-page .nws-related-grid.is-single .nws-rcard-thumb {
    flex: 0 0 104px;
    width: 104px;
    min-height: 78px;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
  }

  html body main.nws-page .nws-rcard-fallback {
    padding: 0 8px;
    font-size: 0.68rem;
  }

  html body main.nws-page .nws-rcard-fallback i {
    font-size: 1.2rem;
  }

  html body main.nws-page .nws-rcard-body,
  html body main.nws-page .nws-related-grid.is-single .nws-rcard-body {
    padding: 2px 4px;
    justify-content: center;
    gap: 4px;
  }

  html body main.nws-page .nws-rcard-date {
    font-size: 0.72rem;
  }

  html body main.nws-page .nws-rcard-body b,
  html body main.nws-page .nws-related-grid.is-single .nws-rcard-body b {
    font-size: 0.88rem;
    line-height: 1.48;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  /* ==========================================================
     5. NATIVE-APP SHARE & ACTION BOTTOM SHEET (.nws-sheet)
  ========================================================== */
  html body main.nws-page .nws-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: rgba(15, 23, 42, 0.48);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
  }

  html body main.nws-page .nws-sheet-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  html body main.nws-page .nws-sheet {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9995;
    max-width: 520px;
    margin: 0 auto;
    padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 22px 22px 0 0;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 -16px 44px rgba(15, 23, 42, 0.22);
    transform: translateY(105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.28s ease;
  }

  html body main.nws-page .nws-sheet.is-open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  html body main.nws-page .nws-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #cbd5e1;
    margin: 2px auto 14px;
  }

  html body main.nws-page .nws-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--nws-line);
  }

  html body main.nws-page .nws-sheet-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--nws-ink);
    margin: 0;
  }

  html body main.nws-page .nws-sheet-close {
    appearance: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--nws-line);
    background: #f1f5f9;
    color: var(--nws-ink-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
  }

  html body main.nws-page .nws-sheet-fonts {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid var(--nws-line);
  }

  html body main.nws-page .nws-sheet-fonts-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--nws-ink);
  }

  html body main.nws-page .nws-sheet-fonts-label i {
    color: var(--nws-blue);
    font-size: 1rem;
  }

  html body main.nws-page .nws-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  html body main.nws-page .nws-sheet-action {
    appearance: none;
    border: 1px solid var(--nws-line);
    background: #ffffff;
    border-radius: 14px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--nws-ink);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
  }

  html body main.nws-page .nws-sheet-action:active {
    transform: scale(0.95);
    background: #f1f5f9;
  }

  html body main.nws-page .nws-sheet-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
  }

  html body main.nws-page .nws-sheet-icon.is-fb {
    background: #eff6ff;
    color: #1877f2;
  }

  html body main.nws-page .nws-sheet-icon.is-line {
    background: #ecfdf5;
    color: #06c755;
  }

  html body main.nws-page .nws-sheet-icon.is-copy {
    background: var(--nws-blue-pale);
    color: var(--nws-blue-deep);
  }

  html body main.nws-page .nws-sheet-icon.is-more {
    background: var(--nws-gold-pale);
    color: #b45309;
  }
}

@media (max-width: 575.98px) {
  html body main.nws-page .nws-meta-bar {
    flex-direction: column;
    align-items: stretch;
  }

  html body main.nws-page .nws-meta-tools {
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--nws-line);
  }
}
