/* ================================================================
   Aurora — responsive & accessibility layer
   ================================================================ */

/* ---------------------------------------------------------------
   Wide tablets / small laptops
   --------------------------------------------------------------- */
@media (max-width: 1180px) {
  .wrap {
    width: min(var(--wrap), calc(100% - 40px));
  }

  .post-layout {
    grid-template-columns: minmax(0, 780px) minmax(220px, 250px);
    gap: 30px;
  }

  .post-hero-inner {
    max-width: 1060px;
  }

  .search-trigger-label,
  .search-kbd {
    display: none;
  }

  .search-trigger {
    width: 34px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 1080px) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 40px;
    margin-top: 16px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
  }

  .home-sidebar .side-block:last-child {
    grid-column: 1 / -1;
  }

  .post-layout,
  .post-layout--single {
    grid-template-columns: minmax(0, 820px);
  }

  .post-hero-inner,
  .post-hero-inner--single {
    max-width: 820px;
  }

  .post-aside {
    display: none;
  }

  .toc-fab {
    display: inline-flex;
  }

}

@media (max-width: 980px) {
  .nav-links {
    display: none;
  }

  .mobile-toggle {
    display: inline-flex;
  }

  .post-hero-inner {
    max-width: 100%;
  }

  .footer-grid {
    grid-template-columns: 1.5fr 1fr 1fr;
  }
}

/* ---------------------------------------------------------------
   Tablets
   --------------------------------------------------------------- */
@media (max-width: 820px) {
  .home-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }

  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--line);
  }

  .hero-stats > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    border-bottom: 0;
    padding: 11px 0;
  }

  .section {
    padding-bottom: 48px;
  }

  .category-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 26px;
  }

  .search-modal {
    padding: 6vh 16px 20px;
  }

  .search-panel {
    max-height: 84vh;
  }

  .search-keys {
    display: none;
  }

  .post-hero {
    padding-top: calc(var(--header-h) + 40px);
  }

  .post-title {
    font-size: clamp(1.65rem, 5.4vw, 2.2rem);
  }

  .post-pagination {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-pagination-item.is-empty {
    display: none;
  }

  .timeline-item {
    grid-template-columns: 48px 14px minmax(0, 1fr);
    gap: 10px;
  }

  .timeline-item::before {
    left: calc(48px + 10px + 7px - 0.5px);
  }

  .timeline-arrow {
    display: none;
  }

}

/* ---------------------------------------------------------------
   Phones
   --------------------------------------------------------------- */
@media (max-width: 640px) {
  :root {
    --header-h: 58px;
  }

  .wrap {
    width: calc(100% - 32px);
  }

  body {
    font-size: 15.5px;
  }

  .nav-actions {
    gap: 2px;
  }

  .search-trigger {
    display: none;
  }

  .lang-switch {
    width: 56px;
    height: 28px;
  }

  .theme-toggle,
  .mobile-toggle {
    width: 34px;
    height: 34px;
  }

  .intro-links {
    gap: 4px 18px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .section-title {
    font-size: 1.35rem;
  }

  .home-sidebar {
    display: none;
  }

  .pagination {
    margin-top: 30px;
  }

  .pagination .page-label {
    display: none;
  }

  .breadcrumb {
    margin-bottom: 14px;
  }

  .post-hero {
    padding: calc(var(--header-h) + 28px) 0 26px;
  }

  .post-title {
    font-size: clamp(1.45rem, 6.2vw, 1.8rem);
  }

  .post-lead {
    font-size: 13.8px;
  }

  .post-meta-row {
    font-size: 12px;
    gap: 8px 11px;
  }

  .post-meta-item--muted {
    display: none;
  }

  .meta-divider {
    display: none;
  }

  .post-layout {
    padding-top: 28px;
    padding-bottom: 44px;
  }

  .prose {
    font-size: 0.97rem;
    line-height: 1.85;
  }

  .prose h2 {
    font-size: 1.24rem;
  }

  .prose figure.highlight {
    margin-left: -4px;
    margin-right: -4px;
    border-radius: var(--radius-xs);
  }

  .prose figure.highlight .code {
    padding: 15px 15px;
  }

  .share-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .related-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .toc-fab {
    right: 14px;
    bottom: 68px;
  }

  .back-to-top {
    right: 14px;
    bottom: 14px;
  }

  .timeline-year {
    margin-bottom: 30px;
  }

  .timeline-item {
    grid-template-columns: 42px 12px minmax(0, 1fr);
    padding: 13px 0;
  }

  .timeline-item::before {
    left: calc(42px + 8px + 6px - 0.5px);
  }

  .timeline-date {
    font-size: 11px;
  }

  .timeline-body h3 {
    font-size: 0.96rem;
  }

  .category-card h2 {
    font-size: 1.1rem;
  }

  .tag-filter {
    width: 100%;
  }

  .tag-cloud-large {
    gap: 6px 12px;
  }

  .intro-title--post {
    font-size: 1.95rem;
  }

  html[data-lang="en"] .intro-title.intro-title--post {
    font-size: 1.85rem;
    max-width: none;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    padding-top: 34px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-bottom: 22px;
  }

  .search-modal {
    padding: 0;
  }

  .search-panel {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }

  .search-bar {
    padding: 14px 14px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .search-hint-row,
  .search-suggest {
    padding-left: 14px;
    padding-right: 14px;
  }

  .search-results {
    padding: 6px;
  }

  .search-foot {
    padding-left: 14px;
    padding-right: 14px;
  }

  .search-result-title time {
    display: none;
  }

  .notfound {
    min-height: 88vh;
  }

  .toast {
    bottom: 72px;
    max-width: calc(100vw - 32px);
    white-space: normal;
    text-align: center;
  }

  .lightbox {
    padding: 20px;
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
  }
}

@media (max-width: 380px) {
  .brand-text {
    display: none;
  }

  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------------------------------------------------------------
   Body scroll lock
   --------------------------------------------------------------- */
body.no-scroll {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0);
}

/* Broken images */
img.is-broken {
  display: none;
}

/* ---------------------------------------------------------------
   Reduced motion / no JS / print
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  html.js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

@media print {
  .site-header,
  .site-footer,
  .back-to-top,
  .toc-fab,
  .post-aside,
  .reading-progress,
  .share-row,
  .post-pagination,
  .related-posts,
  .search-modal,
  .lightbox,
  .toast {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .post-hero {
    padding: 0 0 20pt;
    border: 0;
  }

  .post-layout,
  .wrap {
    display: block;
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .prose a {
    color: #000;
    text-decoration: underline;
  }
}

/* Article rows */
@media (max-width: 640px) {
  .post-row {
    padding: 20px 0;
  }

  .post-row-title {
    font-size: 1.02rem;
  }

  .post-row-excerpt {
    font-size: 12.8px;
    -webkit-line-clamp: 2;
  }
}

/* About — stack the project table into readable rows on phones */
@media (max-width: 640px) {
  .about-projects-table {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .about-projects-table table,
  .about-projects-table tbody,
  .about-projects-table tr,
  .about-projects-table td {
    display: block;
    width: 100%;
  }

  .about-projects-table table {
    border: 0;
    border-radius: 0;
    font-size: 0.92rem;
  }

  .about-projects-table thead {
    display: none;
  }

  .about-projects-table tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }

  .about-projects-table tr:first-child {
    padding-top: 0;
  }

  .about-projects-table tr:last-child {
    border-bottom: 0;
  }

  .about-projects-table td {
    padding: 0;
    border: 0;
    text-align: left;
  }

  .about-projects-table td:first-child {
    min-width: 0;
    margin-bottom: 3px;
  }

  .about-projects-table td:nth-child(2) {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.65;
  }

  .about-projects-table td:nth-child(3),
  .about-projects-table td:nth-child(4) {
    display: inline-block;
    width: auto;
    margin-top: 7px;
    margin-right: 14px;
    font-size: 0.76rem;
  }

  .about-projects-table td.about-link-empty {
    display: none;
  }

  .about-projects-table td:nth-child(3)::before {
    content: "Live · ";
    color: var(--muted-2);
  }

  .about-projects-table td:nth-child(4)::before {
    content: "Repo · ";
    color: var(--muted-2);
  }

  html[data-lang="zh"] .about-projects-table td:nth-child(3)::before {
    content: "线上 · ";
  }

  html[data-lang="zh"] .about-projects-table td:nth-child(4)::before {
    content: "仓库 · ";
  }
}
