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

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

  .home-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 40px;
  }

  .post-layout {
    grid-template-columns: minmax(0, 800px) minmax(232px, 260px);
    gap: 32px;
  }

  .post-hero-inner {
    grid-template-columns: minmax(0, 800px) minmax(232px, 260px);
    gap: 32px;
    max-width: 1092px;
  }

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

  .search-trigger {
    width: 38px;
    height: 38px;
    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));
    align-items: start;
    margin-top: 12px;
  }

  .profile-card {
    grid-column: 1 / -1;
  }

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

  .post-hero-inner,
  .post-hero-inner--single {
    grid-template-columns: minmax(0, 840px);
    max-width: 840px;
  }

  .post-aside {
    display: none;
  }

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

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

  .about-aside {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .about-aside .side-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  :root {
    --header-h: 70px;
  }

  .nav-links {
    display: none;
  }

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

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

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    min-height: 0;
  }

  .hero-copy {
    max-width: 720px;
  }

  .hero-metrics {
    padding: 22px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .hero-metrics-kicker {
    margin-bottom: 12px;
  }

  .hero-metrics-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
  }

  .hero-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 0;
    border: 0 !important;
  }

  .hero-metric span {
    text-align: left;
  }

  .hero-visual {
    justify-self: center;
    max-width: 460px;
  }

  .hero-title {
    font-size: clamp(2.5rem, 8vw, 3.6rem);
  }

  .hero-foot {
    padding-top: 40px;
  }

  .topic-strip-all {
    display: none;
  }

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

  .about-hero-grid {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 44px;
    text-align: center;
  }

  .about-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .about-bio,
  .about-role {
    text-align: center;
  }

  .about-actions,
  .about-meta {
    justify-content: center;
  }

  .about-portrait {
    width: 190px;
    height: 190px;
  }

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

  .footer-note-col {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------
   Tablets
   --------------------------------------------------------------- */
@media (max-width: 820px) {
  .section {
    padding: 56px 0;
  }

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

  .post-grid > .post-card:last-child:nth-child(odd) {
    grid-column: auto;
    flex-direction: column;
  }

  .post-grid > .post-card:last-child:nth-child(odd) .post-card-media {
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 10.2;
  }

  .post-grid > .post-card:last-child:nth-child(odd) .post-card-body {
    padding: 21px 22px 20px;
  }

  .post-grid > .post-card:last-child:nth-child(odd) .post-card-title {
    font-size: 1.15rem;
  }

  .post-grid > .post-card:last-child:nth-child(odd) .post-card-excerpt {
    -webkit-line-clamp: 3;
  }

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

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

  .footer-cta {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .footer-cta-actions {
    width: 100%;
  }

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

  .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.95rem, 6.4vw, 2.8rem);
  }

  .post-meta-row {
    gap: 10px 12px;
  }

  .author-card {
    padding: 22px;
  }

  .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;
  }

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

  .about-aside .side-card:last-child {
    grid-column: auto;
  }
}

/* ---------------------------------------------------------------
   Phones
   --------------------------------------------------------------- */
@media (max-width: 640px) {
  :root {
    --header-h: 66px;
    --radius-lg: 22px;
    --radius-xl: 26px;
  }

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

  body {
    font-size: 15.5px;
  }

  .brand {
    gap: 9px;
    font-size: 16px;
  }

  .brand-mark {
    width: 33px;
    height: 33px;
    border-radius: 11px;
    font-size: 15px;
  }

  .nav-actions {
    gap: 6px;
  }

  .search-trigger {
    display: none;
  }

  .lang-switch {
    width: 76px;
    height: 34px;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  .mobile-toggle {
    width: 36px;
    height: 36px;
  }

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

  .hero-grid {
    gap: 44px;
  }

  .hero-title {
    font-size: clamp(2.15rem, 10.2vw, 3rem);
    margin: 18px 0;
  }

  .hero-subtitle {
    font-size: 14.5px;
    line-height: 1.8;
  }

  .hero-actions {
    gap: 9px;
    margin-top: 24px;
  }

  .hero-actions .btn {
    flex: 1;
    min-width: 140px;
    padding: 0 16px;
  }

  .hero-metrics-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
  }

  .hero-metric strong {
    font-size: 1.35rem;
  }

  .hero-visual {
    max-width: 100%;
    padding: 0;
  }

  .hero-float {
    display: none;
  }

  .hero-feature {
    border-radius: 22px;
  }

  .hero-feature-body {
    padding: 18px 19px 20px;
  }

  .hero-feature-badge {
    top: 11px;
    left: 11px;
    padding: 5px 10px;
    font-size: 9.5px;
  }

  .hero-feature-media .cover-index {
    display: none;
  }

  .hero-feature-media .cover-word {
    font-size: clamp(1.55rem, 8vw, 2.15rem);
    max-width: 84%;
  }

  .hero-foot {
    padding-top: 30px;
  }

  .topic-strip-inner {
    gap: 12px;
    min-height: 56px;
  }

  .topic-strip-label {
    font-size: 10px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 26px;
  }

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

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

  .profile-card {
    grid-column: auto;
  }

  .post-card-body {
    padding: 18px 18px 17px;
  }

  .post-card-title {
    font-size: 1.08rem;
  }

  .pagination {
    margin-top: 34px;
  }

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

  .page-hero {
    padding: calc(var(--header-h) + 36px) 0 38px;
  }

  .page-hero-title {
    font-size: clamp(1.85rem, 9vw, 2.5rem);
  }

  .page-hero-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  .page-hero-title-row {
    gap: 12px;
  }

  .page-hero-stats {
    gap: 7px;
  }

  .page-hero .hero-stat {
    padding: 7px 11px;
  }

  .breadcrumb {
    margin-bottom: 14px;
    font-size: 10.5px;
  }

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

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

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

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

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

  .meta-divider {
    display: none;
  }

  .post-layout {
    padding-top: 30px;
    padding-bottom: 48px;
  }

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

  .prose h2 {
    font-size: 1.3rem;
    padding-left: 11px;
  }

  .prose figure.highlight {
    margin-left: -4px;
    margin-right: -4px;
    border-radius: 12px;
  }

  .prose figure.highlight .gutter {
    display: none;
  }

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

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

  .author-card {
    flex-direction: column;
    gap: 14px;
    padding: 20px;
  }

  .author-card-avatar {
    width: 54px;
    height: 54px;
    border-radius: 17px;
  }

  .author-card-avatar img {
    border-radius: 14px;
  }

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

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

  .post-end {
    margin: 40px 0 26px;
  }

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

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

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

  .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: 10px;
  }

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

  .category-card {
    padding: 21px;
  }

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

  .category-card-arrow {
    display: none;
  }

  .tag-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .tag-filter {
    width: 100%;
  }

  .tag-cloud-large {
    gap: 7px;
  }

  .tag-pill {
    font-size: calc(0.86rem * var(--tag-scale, 1));
  }

  .about-portrait {
    width: 160px;
    height: 160px;
  }

  .about-hero {
    padding: calc(var(--header-h) + 42px) 0 42px;
  }

  .about-intro h1 {
    font-size: clamp(2rem, 10vw, 2.6rem);
  }

  .about-bio {
    font-size: 13.8px;
  }

  .about-facts {
    grid-template-columns: repeat(3, 1fr);
  }

  .page-content-wrap {
    max-width: 100%;
  }

  .footer-cta {
    padding: 26px 22px;
    border-radius: 24px;
  }

  .footer-cta h2 {
    font-size: 1.6rem;
  }

  .footer-cta-actions .btn {
    flex: 1;
  }

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

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

  .footer-note-col {
    grid-column: 1 / -1;
  }

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

  .footer-bottom p {
    font-size: 10.5px;
  }

  .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: 92vh;
  }

  .notfound-code {
    font-size: clamp(5rem, 30vw, 8rem);
  }

  .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: 360px) {
  .brand-text {
    display: none;
  }

  .hero-actions .btn {
    min-width: 0;
  }

  .hero-stats {
    gap: 14px;
  }

  .post-card-foot {
    flex-wrap: wrap;
  }

  .about-facts {
    grid-template-columns: 1fr 1fr;
  }

  .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,
  .author-card,
  .post-pagination,
  .related-posts,
  .search-modal,
  .lightbox,
  .toast,
  .footer-cta {
    display: none !important;
  }

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

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

  .post-hero-bg,
  .page-hero-bg {
    display: none;
  }

  .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 {
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 12px;
    padding: 20px 2px;
  }

  .post-row-index {
    display: none;
  }

  .post-row::before {
    left: -8px;
    top: 18px;
    bottom: 18px;
  }

  .post-row:hover {
    padding-left: 6px;
  }

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

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

  .post-row-arrow {
    width: 30px;
    height: 30px;
  }

  .post-row--compact {
    grid-template-columns: minmax(0, 1fr) 30px;
  }
}

@media (max-width: 720px) {
  .footer-minimal {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }

  .footer-minimal-nav {
    gap: 8px 16px;
  }
}
