/* UI refresh · ios
   iOS 平台布局层：body.ios-shell / body.platform-ios。安全区、iOS 风格底部标签栏（半透明模糊）、大标题、44pt 触控。
   只使用 refresh/foundation.css 中的 --ds-* 设计令牌；不得修改其他文件负责的选择器。 */

/* ---- Tokens ------------------------------------------------------------
   iOS tab bar: 49pt of content above the home indicator (83pt in total on
   Face ID iPhones), instead of the 80px bar + inset (~106px) phones had. */
body.ios-shell {
  --ds-bottomnav-h: 49px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---- Small text ---------------------------------------------------------
   10px labels are below iOS's legible minimum; lift them to the caption step. */
body.ios-shell .status-label,
body.ios-shell .book-comment-badge,
body.ios-shell .media-comment-badge,
body.ios-shell .reader-chapter-time,
body.ios-shell .reader-source-label,
body.ios-shell .toc-item-time,
body.ios-shell #readerReadingTime,
body.ios-shell.bookshelf-compact .bookshelf-card-progress.official-progress-line {
  font-size: var(--ds-text-caption);
}

/* ---- Phones (portrait, and landscape phones in the short query) -------- */
@media (max-width: 720px), (max-width: 980px) and (max-height: 500px) {
  /* Status bar / notch: content scrolls under the clock with viewport-fit=cover,
     so give the top safe area the same frosted material as the tab bar. */
  body.mobile-shell.ios-shell::before {
    content: "";
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 20;
    height: var(--safe-area-top);
    background: color-mix(in srgb, var(--ds-surface-nav) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    pointer-events: none;
  }

  /* Leave exactly the tab bar + home indicator free at the end of the page. */
  body.mobile-shell.ios-shell .app-shell {
    padding-bottom: calc(var(--ds-space-2) + var(--ds-bottomnav-h) + var(--mobile-nav-inset-bottom));
  }

  /* iOS tab bar: frosted, hairline on top, tinted icon + label, no pill. */
  body.mobile-shell.ios-shell .tabbar {
    grid-auto-rows: var(--ds-bottomnav-h);
    align-items: stretch;
    gap: 0;
    height: auto;
    min-height: 0;
    padding: 0 var(--safe-area-right) var(--mobile-nav-inset-bottom) var(--safe-area-left);
    border: 0;
    border-top: 1px solid var(--ds-border);
    border-radius: 0;
    background: color-mix(in srgb, var(--ds-surface-nav) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: none;
  }

  body.mobile-shell.ios-shell .tabbar .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: var(--ds-space-0);
    height: var(--ds-bottomnav-h);
    min-height: var(--ds-control-touch);
    padding: var(--ds-space-0) var(--ds-space-0) 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ds-text-subtle);
    font-size: var(--ds-text-caption);
    font-weight: var(--ds-weight-medium);
    line-height: 1.1;
    letter-spacing: 0;
    transition: color var(--ds-motion-fast) var(--ds-ease);
  }

  body.mobile-shell.ios-shell .tabbar .nav-item:hover {
    background: transparent;
  }

  body.mobile-shell.ios-shell .tabbar .nav-item:active {
    opacity: 0.6;
    transform: none;
  }

  body.mobile-shell.ios-shell .tabbar .nav-icon,
  body.mobile-shell.ios-shell .tabbar .nav-item.active .nav-icon {
    flex: 0 0 26px;
    width: 26px;
    max-width: none;
    height: 26px;
    border-radius: 0;
    background: transparent;
    color: inherit;
  }

  body.mobile-shell.ios-shell .tabbar .nav-icon svg {
    width: 24px;
    height: 24px;
  }

  body.mobile-shell.ios-shell .tabbar .nav-item.active {
    background: transparent;
    color: var(--ds-accent);
    font-weight: var(--ds-weight-strong);
  }

  /* Large-title feel for the panel heads (phones only drop them to 15px). */
  body.mobile-shell.ios-shell .section-title {
    font-size: var(--ds-text-title);
    font-weight: var(--ds-weight-strong);
    letter-spacing: -0.01em;
  }
}

/* Landscape iPhones: the bar is compact (iOS uses ~32pt); keep 44px for touch
   and lay icon and label side by side, and keep it clear of the notch. */
@media (max-width: 980px) and (max-height: 500px) {
  body.mobile-shell.ios-shell {
    --ds-bottomnav-h: var(--ds-control-touch);
  }

  body.mobile-shell.ios-shell .tabbar .nav-item {
    flex-direction: row;
    gap: var(--ds-space-1);
    padding: 0;
  }

  body.mobile-shell.ios-shell .tabbar .nav-icon,
  body.mobile-shell.ios-shell .tabbar .nav-item.active .nav-icon {
    flex-basis: 22px;
    width: 22px;
    height: 22px;
  }

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

/* ---- iPad (tablet.css owns the rail / two-pane layout) ------------------
   Keep the rail clear of the rounded corners and the home indicator. */
@media (min-width: 721px) and (min-height: 501px) {
  body.mobile-shell.ios-shell .app-shell {
    padding-bottom: calc(var(--ds-space-2) + var(--safe-area-bottom));
  }
}
