/* UI refresh · Android layer (body.android-shell / body.platform-android)
   Builds on the shared phone frame (shell.css) with Material 3 for Android.
   The synthetic status strip, the system navigation inset
   (--mobile-nav-inset-bottom, issues #371 / #391) and the back gesture
   handling keep their behavior; this layer only restyles and re-spaces.
   Every selector is scoped to body.android-shell.

   Android conventions applied (390dp-wide phone as the reference):
   • status strip takes the window surface, like an M3 edge-to-edge status bar;
   • M3 small top app bar: flat, on the window surface, directly under the
     status strip, 64dp tall, title in "title large" (22sp), 48dp actions;
   • M3 navigation bar, compact: 56dp of content (30dp active indicator, 12sp
     labels) above the system navigation inset, surface-container colored all
     the way into the gesture / button area; the page reserves exactly that,
     not the old 88px guess;
   • the shell grid packs to the top, so short pages (短剧, 漫画) no longer
     stretch the top app bar to fill the screen;
   • nothing under 12sp (M3 "label medium" floor) except count badges;
   • the history, settings and bookshelf pages are laid out by their page
     layers (history.css, settings.css, bookshelf.css) on every platform;
     this file only adds what is Android-specific (system bars, the
     navigation bar, Material surfaces) so the two never stack;
   • touch targets stay ≥ 44px (README rule 4), nav items and app-bar
     actions 48px. */

/* ---- Status strip ------------------------------------------------------- */
body.android-shell .mobile-system-bar {
  border-bottom-color: transparent;
  background: var(--ds-bg);
  color: var(--ds-text);
  font-size: var(--ds-text-caption);
}

/* ---- Phones in portrait ------------------------------------------------- */
/* Landscape phones (max-height: 500px) keep the compact rail shell from
   responsive.css; everything below is the portrait phone frame. */
@media (max-width: 720px) and (min-height: 501px) {
  /* 46px of navigation bar content (was 56px): shorter than both the refresh
     bar (6 + 48 + 2) and the pre-refresh bar (50px), while every item stays a
     46px-tall, ~65px-wide touch target (>= 44px, README rule 4). */
  body.android-shell {
    --android-bottomnav-h: 46px;
  }

  /* Shell: top app bar sits right under the status strip; the bottom padding
     reserves the navigation bar content plus the system inset, nothing more.
     align-content: start keeps the auto rows (top bar, announcement) at their
     own height on pages shorter than the screen. */
  body.android-shell .app-shell {
    align-content: start;
    padding-top: calc(var(--safe-area-top) + var(--mobile-system-bar-height));
    padding-bottom: calc(var(--ds-space-4) + var(--android-bottomnav-h) + var(--mobile-nav-inset-bottom));
  }

  /* Top app bar. The extra :root / .panel-shell:not(.tabbar) weight beats the
     density presets in appearance.css, which pad every .panel-shell. */
  :root body.android-shell .app-shell > .topbar.panel-shell:not(.tabbar) {
    min-height: 64px;
    padding: var(--ds-space-2) var(--ds-space-1) var(--ds-space-2) var(--ds-space-3);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.android-shell .topbar-main {
    align-items: center;
    min-height: 48px;
  }

  body.android-shell .topbar .brand-title {
    font-size: var(--ds-text-headline);
    font-weight: 400;
    line-height: 28px;
    letter-spacing: 0;
  }

  body.android-shell .topbar-status {
    gap: var(--ds-space-1);
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.android-shell .topbar-status .status-label {
    display: none;
  }

  body.android-shell .topbar-status .status-value {
    color: var(--ds-text-muted);
    font-size: var(--ds-text-caption);
  }

  body.android-shell .theme-toggle {
    width: 48px;
    min-width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ds-text-muted);
  }

  body.android-shell .theme-toggle:active {
    background: var(--ds-state-press);
  }

  body.android-shell .language-select {
    min-height: 44px;
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-text-meta);
  }

  /* Navigation bar: the items fill the whole 46px strip above the system
     inset (3 + 26 icon + 16 label + 1), so there is no dead padding row and
     the full bar height is tappable. */
  body.android-shell .tabbar {
    min-height: 0;
    padding-top: 0;
    padding-bottom: var(--mobile-nav-inset-bottom);
    border-top: 0;
    background: var(--m3-surface-container);
    box-shadow: none;
  }

  body.android-shell .tabbar .nav-item {
    justify-content: flex-start;
    gap: 0;
    height: var(--android-bottomnav-h);
    min-height: var(--android-bottomnav-h);
    padding: 3px 2px 1px;
    font-size: var(--ds-text-caption);
    font-weight: var(--ds-weight-medium);
    line-height: 16px;
    letter-spacing: 0.02em;
  }

  body.android-shell .tabbar .nav-item > span:last-child {
    line-height: 16px;
  }

  body.android-shell .tabbar .nav-icon {
    width: 52px;
    height: 26px;
  }

  body.android-shell .tabbar .nav-icon svg {
    width: 20px;
    height: 20px;
  }

  body.android-shell .tabbar .nav-item.active {
    font-weight: var(--ds-weight-strong);
  }

  body.android-shell .tabbar .nav-item:active .nav-icon {
    background: var(--ds-state-press);
  }

  body.android-shell .tabbar .nav-item.active:active .nav-icon {
    background: color-mix(in srgb, var(--ds-on-accent-soft) 12%, var(--ds-accent-soft));
  }

  /* Scroll-to-top FAB: 16dp above the navigation bar (M3 FAB margin). */
  body.android-shell .scroll-top-fab {
    bottom: calc(var(--ds-space-4) + var(--android-bottomnav-h) + var(--mobile-nav-inset-bottom));
  }

  /* Page panels as M3 cards. */
  body.android-shell .view .panel-shell {
    border: 0;
    border-radius: var(--ds-radius-lg);
    background: var(--m3-surface-container-low);
    box-shadow: none;
  }

  /* History (history.css) and settings (settings.css) own their phone
     layouts; this layer does not restyle those pages. */
}

/* ---- 12sp floor for running text (all Android widths) ------------------- */
/* Legacy layers set 10–11px on these; M3's smallest label style is 12sp.
   Count badges (comment / paragraph counters) stay as small badges.
   Bookshelf, history and settings text sizes come from their page layers
   (bookshelf.css, history.css, settings.css), which already stay >= 12px. */
body.android-shell :is(
  .toc-item-meta,
  .toc-item-time,
  .reader-chapter-time,
  .reader-source-label,
  #readerReadingTime,
  .media-chip,
  .media-row-meta,
  .media-card-desc,
  .media-comment-time,
  .media-reply-time
) {
  font-size: var(--ds-text-caption);
}

/* Landscape phones keep the rail from responsive.css; match its indicator. */
@media (max-width: 980px) and (max-height: 500px) {
  body.android-shell .tabbar .nav-item.active {
    background: var(--ds-accent-soft);
    color: var(--ds-on-accent-soft);
  }
}
