/* Idaho Education Finance — phone and tablet layer.
   Loaded after styles/app.css. Everything here is scoped inside a media query
   or to markup that only appears on small screens, so the desktop reading
   layout is byte-for-byte what it was before. No color is introduced: every
   value resolves to a token already defined in styles/brand.css. */

/* ── top bar (small screens only) ──────────────────────────────────── */
.topbar { display: none; }

.map-shield {
  position: absolute; inset: 0; z-index: 900;
  display: none; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  cursor: pointer; border-radius: 6px;
}
.map-shield span {
  background: var(--accent); color: var(--accent-contrast);
  font-size: .82rem; font-weight: 600; padding: .5rem .9rem; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.pdf-mobile-note { display: none; }

@media (max-width: 900px) {

  /* ── shell ───────────────────────────────────────────────────────── */
  .shell { grid-template-columns: minmax(0, 1fr); }
  body { padding-top: 3.25rem; }

  .topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 65;
    display: flex; align-items: center; gap: .7rem;
    height: 3.25rem; padding: 0 .75rem;
    background: var(--accent); color: var(--accent-contrast);
    box-shadow: 0 1px 6px rgba(0,0,0,.18);
  }
  .topbar-menu {
    flex: none; width: 2.6rem; height: 2.6rem;
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 0; cursor: pointer; border-radius: 5px;
    color: var(--accent-contrast); padding: 0;
  }
  .topbar-menu:focus-visible { outline: 2px solid var(--accent-contrast); outline-offset: -2px; }
  .topbar-menu-bars { display: block; width: 20px; }
  .topbar-menu-bars i {
    display: block; height: 2px; margin: 4px 0; border-radius: 2px;
    background: currentColor;
  }
  .topbar-title {
    font-family: var(--font-display); font-weight: 700; font-size: 1rem;
    line-height: 1.2; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }

  /* ── rail becomes a slide-over menu ──────────────────────────────── */
  .rail {
    position: fixed; top: 3.25rem; left: 0; z-index: 55;
    width: min(20rem, 86vw); height: calc(100dvh - 3.25rem);
    border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 6px 0 20px rgba(0,0,0,.16);
  }
  .rail.open { transform: translateX(0); }
  .rail-scrim {
    position: fixed; inset: 3.25rem 0 0; z-index: 50;
    background: rgba(20,18,14,.34);
  }
  .rail-scrim[hidden] { display: none; }
  /* The rail already names the book in the top bar. */
  .rail-head { padding: .9rem 1rem .7rem; }
  .rail-item { padding: .62rem 1.1rem .62rem .95rem; font-size: .9rem; }
  .rail-part { padding-top: .8rem; }
  .ghost { min-height: 2.75rem; }

  /* The QC drawer must clear the top bar. */
  .drawer { z-index: 80; }

  /* ── reading column ──────────────────────────────────────────────── */
  .main { padding: 1.1rem .85rem 3rem; }
  .chapter { max-width: none; }
  .prose, .footnote, dl.terms dd { max-width: none; }
  .chapter h1 { font-size: clamp(1.4rem, 6vw, 1.9rem); }
  .chapter h2 { margin-top: 1.9rem; }

  .panel { padding: 1rem .95rem; }
  .intro-box, .notice { padding: .9rem 1rem; }
  .metrics { padding: .95rem 1rem; }
  .hero-banner { padding: 1.4rem 1.2rem; }
  .hero-subtitle { font-size: .95rem; }

  /* ── charts: hold a legible size and scroll sideways ─────────────── */
  .chart { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart > svg { min-width: 660px; }
  .chart .axis text { font-size: 15.5px; }
  .chart .lbl { font-size: 15px; }
  .chart .chart-title { font-size: 21px; }
  .chart .chart-legend { font-size: 15px; }
  /* The axis title is rotated inside a fixed 70-unit margin — enlarging it
     pushes the text off the left edge of the drawing, so it stays put. */
  .chart .chart-axis-title { font-size: 13px; }
  .chart .axis .pole { font-size: 15.5px; }
  .chart .axis .pole-zero { font-size: 14.5px; }
  .line-chart .line-end { font-size: 15px; }
  .line-chart .axis-note { font-size: 14.5px; }

  /* ── tables ──────────────────────────────────────────────────────── */
  /* A wide table would otherwise squeeze itself into the screen and wrap the
     figures over two lines. Let it take its natural width and scroll instead:
     a swipe is easier to read than a broken number. */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data { width: auto; min-width: 100%; }
  table.data td.num, table.data th.num,
  table.data td.idcell, table.data th.idcell { white-space: nowrap; }
  .table-tools input[type="search"] { min-width: 0; flex: 1 1 10rem; }
  .table-tools .count { margin-left: 0; flex-basis: 100%; }
  table.data th, table.data td { padding: .5rem .65rem; }
  table.data thead th { font-size: .64rem; }
  .scroll-body { max-height: 24rem; }

  /* ── tab strips scroll rather than stack ─────────────────────────── */
  .tablist {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tablist::-webkit-scrollbar { display: none; }
  .tab { flex: none; padding: .55rem .9rem; }

  /* ── maps ────────────────────────────────────────────────────────── */
  .map { height: 380px; }
  .map.guarded .map-shield { display: flex; }
  .map.guarded.live .map-shield { display: none; }

  /* ── the embedded PDF viewer is unusable on a phone ──────────────── */
  .pdf-body iframe { display: none; }
  .pdf-body .card-note { display: none; }
  .pdf-body .pdf-mobile-note { display: block; }
  .pdf-body .pdf-mobile-note a { font-weight: 600; }

  /* ── misc touch sizing ───────────────────────────────────────────── */
  .radio, .swatches div { min-height: 2rem; }
  .seg button { padding: .6rem .3rem; }
  .methods > summary, .definitions summary,
  .pdf-embed > summary, .full-table > summary { padding-top: .75rem; padding-bottom: .75rem; }
}

@media (max-width: 560px) {
  .metrics { grid-template-columns: 1fr; }
  .map { height: 320px; }
  .hero-banner { padding: 1.2rem 1rem; }
  .main { padding: 1rem .7rem 2.6rem; }
}

/* An installed home-screen copy sits under the status bar on iOS. */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(3.25rem + env(safe-area-inset-top)); }
  body { padding-top: calc(3.25rem + env(safe-area-inset-top)); }
  .rail { top: calc(3.25rem + env(safe-area-inset-top)); height: calc(100dvh - 3.25rem - env(safe-area-inset-top)); }
  .rail-scrim { top: calc(3.25rem + env(safe-area-inset-top)); }
}

@media print {
  .topbar, .rail-scrim, .map-shield { display: none !important; }
  body { padding-top: 0; }
  .pdf-mobile-note { display: none !important; }
}
