/* =====================================================================
   mobile.css — Cool Charts phone layout (screens 768px wide and under)
   Desktop and tablet are untouched: every rule lives inside the
   media query below. Works together with mobile.js.
   ===================================================================== */

/* Top bar + backdrop are created by mobile.js; hidden on bigger screens */
.cc-topbar, .cc-drawer-backdrop, .cc-more-btn { display: none; }

@media (max-width: 768px) {

  /* ---------- Top bar ---------- */
  .cc-topbar {
    display: flex; align-items: center; gap: 6px;
    position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 1200;
    background: #000; color: #fff; padding: 0 8px;
    box-sizing: border-box;
  }
  .cc-menu-btn {
    width: 44px; height: 44px; border: 0; background: transparent; color: #fff;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer; padding: 0; flex-shrink: 0;
  }
  .cc-menu-btn:active { background: #1a1a1a; }
  .cc-topbar-logo {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--site-font); font-weight: 800; font-size: 17px;
    letter-spacing: 0.5px; text-transform: uppercase; cursor: pointer;
  }
  .cc-topbar-logo img { width: 22px; height: 22px; object-fit: contain; }

  /* ---------- Sidebar becomes a slide-out drawer ---------- */
  .sidebar,
  body[data-text-size] .sidebar {
    display: flex;
    width: 280px; max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1300;
    box-shadow: none;
  }
  body.cc-drawer-open .sidebar { transform: translateX(0); box-shadow: 8px 0 30px #0006; }
  body .sidebar .category-item { font-size: 14px; padding: 11px 16px; gap: 12px; }
  body .sidebar .subcategory-item { font-size: 13px; padding: 10px 16px 10px 48px; }
  body .sidebar .sub-subcategory-item { font-size: 12px; padding: 9px 16px 9px 64px; }
  .sidebar .search-bar { margin: 0 12px 12px; padding: 9px 10px; }
  .sidebar .search-input { font-size: 16px; } /* 16px stops iPhone from zooming in */
  #sidebarToggle { display: none; }
  .settings-popup { left: 12px; right: auto; width: calc(min(280px, 85vw) - 24px); z-index: 1400; }

  .cc-drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1250;
    background: #0008; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
  }
  body.cc-drawer-open .cc-drawer-backdrop { opacity: 1; pointer-events: auto; }
  body.cc-drawer-open { overflow: hidden; }

  /* ---------- Main content fills the screen under the top bar ---------- */
  body .content-main,
  body[data-text-size] .content-main {
    margin-left: 0;
    margin-top: 52px;
    height: calc(100dvh - 52px);
    padding: 14px 12px 0 12px;
  }

  /* ---------- Home page ---------- */
  .content-home[data-page] > .home-description { font-size: 16px; line-height: 1.4; margin-bottom: 18px; }
  .home-update-box { font-size: 15px; margin-bottom: 18px; }
  .update-text { margin-left: 8px; }
  .featured-plain .section-title { font-size: 16px; }

  /* The home page scrolls on phones; the featured chart gets a usable height */
  .content-home[data-page] { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
  /* The featured chart is a Google Sheet: on a phone it swallows swipes, so it's hidden */
  .content-home .featured-plain { display: none; }

  /* Free-preview sign-up: email box shrinks so the Notify button fits */
  .preview-banner { padding: 14px; font-size: 14px; gap: 12px; }
  .preview-banner .preview-text { flex: 1 1 100%; }
  .preview-form { flex: 1 1 100%; width: 100%; }
  .preview-form input[type=email] { flex: 1 1 auto; width: auto; min-width: 0; }
  .preview-form button { flex: 0 0 auto; padding: 0 14px; }

  /* Section titles above each chart */
  .section-title { font-size: 16px; }

  /* ---------- Chart pages ---------- */
  /* The page scrolls as a whole; the chart below gets almost a full screen */
  .content-main .content-body,
  .content-main .content-body.scrollable { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
  #pages > [data-page] { overflow: visible; height: auto; min-height: 0; flex: 0 0 auto; }
  #pages > [data-page] > iframe,
  #pages > [data-page] > object,
  #pages > [data-page] > .iframe-wrapper,
  #pages > [data-page] > .iframe-wrapper > iframe,
  #pages > [data-page] > .iframe-wrapper > object { flex: 0 0 auto; height: calc(100dvh - 52px - 24px); min-height: 0; }
  /* A desktop script sets a fixed pixel height on chart frames; on phones they always fill the screen */
  #pages > [data-page] > iframe,
  #pages > [data-page] > object,
  #pages > [data-page] > .iframe-wrapper,
  #pages > [data-page] > .object-wrapper,
  #pages > [data-page] > .object-wrapper > .iframe-wrapper { height: calc(100dvh - 52px - 24px) !important; max-height: none !important; flex: 0 0 auto !important; }
  #pages > [data-page] > .object-wrapper > .iframe-wrapper > iframe,
  #pages > [data-page] > .object-wrapper > .iframe-wrapper > object,
  #pages > [data-page] > .object-wrapper > iframe,
  #pages > [data-page] > .object-wrapper > object { height: 100% !important; max-height: none !important; }
  #pages > [data-page] > .iframe-wrapper > iframe,
  #pages > [data-page] > .iframe-wrapper > object { height: 100% !important; max-height: none !important; }
  /* Page title: icon + title always share one line; mobile.js shrinks long titles to fit */
  #pages .content-title > .section-emoji-large { flex: 0 0 auto; width: 32px; height: 32px; padding-top: 0; }
  #pages .content-title > .page-title-text {
    flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 19px; line-height: 1.2;
  }
  /* Chart buttons: "Take the Test" keeps its label, the others become icons */
  #pages .content-title { flex-wrap: wrap; row-gap: 8px; }
  #pages .content-title .button-container { margin-left: 0 !important; width: 100%; flex-wrap: wrap; row-gap: 6px; }
  #pages .content-title .button-container > button:not(.cct-launch):has(.cc-btn-ico) {
    font-size: 0 !important; gap: 0 !important; padding: 0 11px !important; flex: 0 0 auto;
  }
  #pages .content-title .button-container > button:not(.cct-launch) .cc-btn-ico { margin: 0 !important; }
  #pages .content-title .button-container > .cct-launch,
  #pages .content-title .button-container > button:not(:has(.cc-btn-ico)) { padding: 0 14px !important; font-size: 14px !important; white-space: nowrap; }
  #pages .content-title .button-container > .cct-launch { flex: 0 1 auto; white-space: nowrap; }

  /* Long descriptions are cut to 3 lines; tap "More" to read the rest */
  #pages > [data-page] > .description.cc-clamp {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
    overflow: hidden; font-size: 13px; line-height: 1.45; margin-bottom: 4px; padding-bottom: 0 !important; max-height: calc(3 * 1.45em);
  }
  .cc-more-btn {
    display: block; align-self: flex-start; border: 0; background: transparent; padding: 4px 0 12px;
    font-family: var(--site-font); font-size: 13px; font-weight: 800; color: #333;
    text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer;
  }
  #pages > [data-page] > .description:not(.cc-clamp) { font-size: 13px; line-height: 1.45; }

  /* ---------- Donate page ---------- */
  /* Fewer nested boxes, smaller headings; each payment method is one tappable row (no QR codes on phones) */
  .content-donate { padding: 4px 0 28px !important; }
  .content-donate > div { margin-bottom: 0 !important; }
  .content-donate > div > div { padding: 0 !important; box-shadow: none !important; background: transparent !important; border-radius: 0 !important; }
  .content-donate h2 { font-size: 22px !important; margin: 4px 0 14px !important; }
  .content-donate > div > div > div { padding: 16px !important; border-radius: 14px !important; margin-bottom: 14px !important; }
  .content-donate h3 { font-size: 15px !important; margin-bottom: 10px !important; text-align: left !important; }
  .content-donate ul { font-size: 14px !important; line-height: 1.55 !important; margin-left: 18px !important; padding-left: 0 !important; }
  .content-donate [style*="grid-template-columns"] { grid-template-columns: 1fr !important; gap: 10px !important; }
  .content-donate [onclick^="window.open"] {
    display: grid !important; grid-template-columns: 40px 1fr; column-gap: 12px; align-items: center;
    text-align: left !important; padding: 12px 14px !important; border: 0 !important; border-radius: 12px !important;
  }
  .content-donate [onclick^="window.open"] > img:first-child { grid-row: 1 / span 2; width: 36px !important; height: 36px !important; margin: 0 !important; }
  .content-donate [onclick^="window.open"] > div { margin: 0 !important; }
  .content-donate [onclick^="window.open"] img[alt$="QR"] { display: none !important; }
  .content-donate button { width: 100%; }

  /* ---------- Popups fit the screen ---------- */
  .appearance-popup { left: 12px; right: 12px; width: auto; bottom: 12px; }
}
