/*
 * Ocean 主题 · 平板端适配
 * 适用范围：iPad 竖屏及小尺寸平板（640px – 1023px）
 * 目标：
 *   1. 正文不再被 1/4 宽的侧栏挤压，改为「正文在上、侧栏在下两列」
 *   2. 顶部导航改为汉堡菜单（竖屏放不下完整菜单）
 *   3. 修复文章「上一篇/下一篇」长标题导致的横向溢出
 *   4. 正文表格、代码块在平板上可横向滚动，不撑破页面
 * 手机端（≤639px）与桌面端（≥1024px）保持原有样式。
 */

/* 网格子项允许收缩，避免长内容撑破布局 */
#ocean-main-grid > .ocean-main-col {
  min-width: 0;
}

/* 上一篇 / 下一篇：允许收缩并用省略号截断长标题（所有尺寸生效） */
.ocean-post-nav > div {
  min-width: 0;
  flex: 1 1 0;
}
.ocean-post-nav > div > a {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.ocean-post-nav > div > a > span:not([class*="i-tabler"]) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 平板横屏 / 小尺寸笔记本（1024px – 1279px）：
   侧栏 1/4 只有约 190px，过窄，这里固定为 230px，正文相应略收窄 */
@media (min-width: 1024px) and (max-width: 1279.98px) {
  #ocean-main-grid {
    grid-template-columns: minmax(0, 1fr) 230px;
  }
  #ocean-main-grid > .ocean-main-col {
    grid-column: 1 / 2;
  }
  #ocean-main-grid > .ocean-sidebar-col {
    grid-column: 2 / 3;
    padding-left: 0;
    padding-right: 0;
  }
  /* 导航略压缩，给 Logo 与右侧图标留出余量 */
  #header-menu .hg-nav-item {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }
  #header-menu .hg-nav-link {
    font-size: 0.8125rem;
    white-space: nowrap;
  }
}

@media (min-width: 640px) and (max-width: 1023.98px) {
  /* ==============================
     1. 主体布局：单栏正文 + 底部两列侧栏
     ============================== */
  #ocean-main-grid > .ocean-main-col {
    grid-column: 1 / -1;
  }
  #ocean-main-grid > .ocean-sidebar-col {
    grid-column: 1 / -1;
    padding-left: 0;
    padding-right: 0;
  }
  #ocean-main-grid > .ocean-sidebar-col > aside {
    display: grid;
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 1rem;
    top: auto;
  }
  #ocean-main-grid > .ocean-sidebar-col > aside > * {
    min-width: 0;
  }
  /* 目录卡片在平板两列布局里不再限制高度 */
  #ocean-main-grid > .ocean-sidebar-col .toc {
    max-height: none;
  }

  /* ==============================
     2. 顶部导航：改为汉堡菜单
     （iPad 竖屏宽度放不下 Logo + 6 个菜单 + 右侧图标）
     ============================== */
  #header-menu .hg-desktop-nav,
  #header-menu .hg-nav-divider {
    display: none !important;
  }
  #header-menu .hg-mobile-toggle {
    display: block !important;
  }
  /* 不再让 Logo 被挤压变形 */
  #header-menu a[href="/"] {
    flex: none;
  }
  #header-menu a[href="/"] img {
    width: auto !important;
    max-width: 100%;
  }

  /* ==============================
     3. 首页 Banner 略降低高度
     ============================== */
  #header-menu ~ .h-96 {
    height: 20rem;
  }

  /* ==============================
     4. 文章正文容错
     ============================== */
  .ocean-post-card article {
    overflow-wrap: break-word;
  }
  .ocean-post-card article img,
  .ocean-post-card article video {
    max-width: 100%;
    height: auto;
  }
  .ocean-post-card article table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ocean-post-card article pre,
  .ocean-post-card article pre code {
    max-width: 100%;
    overflow-x: auto;
  }

  /* ==============================
     5. 上一篇 / 下一篇：竖排 + 标题省略
     ============================== */
  .ocean-post-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .ocean-post-nav > div {
    min-width: 0;
  }
  .ocean-post-nav > div > a {
    min-width: 0;
    max-width: 100%;
  }
  .ocean-post-nav > div > a > span:not([class*="i-tabler"]) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ==============================
     6. 首页列表卡片：配图略放大
     ============================== */
  #post-list > .flex-row > [class*="shrink-0"] img {
    width: 200px !important;
    height: 112px !important;
    object-fit: cover;
  }
}
