/* ==========================================================================
   SiteWright — Responsive rules
   Typography and spacing are already fluid (clamp tokens). This file only
   changes LAYOUT at breakpoints. Desktop-first ranges:

   Large desktop  ≥ 1440px   (base styles, capped by --container-max)
   Desktop        1024–1439px
   Tablet          768–1023px
   Mobile          380–767px
   Small mobile   ≤ 379px
   ========================================================================== */

/* ---------- Large desktop: ≥ 1920 — let media breathe, keep text capped ---------- */
@media (min-width: 1920px) {
  :root { --header-height: 5rem; }
}

/* ---------- Desktop: ≤ 1279 ---------- */
@media (max-width: 1279px) {
  .capability { grid-template-columns: 3.5rem minmax(0, 1fr) minmax(0, 1fr) auto; }
  .site-footer__top { grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); }
}

/* ---------- Tablet: ≤ 1023 ---------- */
@media (max-width: 1023px) {
  /* Navigation collapses to the full-screen menu */
  .nav, .site-header__actions .btn { display: none; }
  .menu-toggle { display: inline-flex; }

  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .col-span-3, .col-span-4 { grid-column: span 3; }
  .col-span-5, .col-span-6, .col-span-7, .col-span-8 { grid-column: 1 / -1; }
  .col-start-2, .col-start-5, .col-start-7 { grid-column-start: auto; }

  .section-head--split { grid-template-columns: 1fr; row-gap: var(--space-6); }

  .capability { grid-template-columns: 3rem minmax(0, 1fr) auto; }
  .capability__desc { grid-column: 2 / -1; }
  .capability__cta { grid-row: 1; grid-column: 3; }

  .process { grid-template-columns: 1fr; row-gap: var(--space-12); }
  .process__aside { position: static; }

  .site-footer__top { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: var(--space-12); }
  .site-footer__brand { grid-column: 1 / -1; }

  .project-stack .project-card__media { height: min(70vh, 40rem); }
}

/* ---------- Mobile: ≤ 767 ---------- */
@media (max-width: 767px) {
  :root { --header-height: 4rem; }

  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid > [class*="col-span-"] { grid-column: 1 / -1; }

  .btn { --btn-h: 52px; }
  .cta-band__actions .btn,
  .hero__actions .btn { width: 100%; }

  .capability { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-3); }
  .capability__index { grid-column: 1 / -1; padding-top: 0; }
  .capability__title { grid-column: 1; }
  .capability__cta { grid-row: 2; grid-column: 2; width: 48px; height: 48px; }
  .capability__desc { grid-column: 1 / -1; }
  .capability:hover .capability__title { transform: none; }

  /* Stacked cards: shorter, portrait-friendly */
  .project-stack .project-card__media { height: min(72vh, 34rem); }
  .card-stack__item { top: calc(var(--header-height) + var(--space-3) + var(--i, 0) * 10px); }

  .site-footer__top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-footer__bottom { flex-direction: column; }

  .testimonial__quote { font-size: var(--fs-h4); }
}

/* ---------- Small mobile: ≤ 379 ---------- */
@media (max-width: 379px) {
  :root { --gutter: 1rem; }
  .btn { padding-inline: var(--space-5); }
  .site-footer__top { grid-template-columns: 1fr; }
  .tag { height: 26px; padding-inline: var(--space-2); }
}

/* ---------- Input capability ---------- */
/* Cursor-follow previews and hover-only effects only for precise pointers */
@media (hover: none), (pointer: coarse) {
  .cursor-preview { display: none; }
  .project-card:hover .project-card__media img,
  .article-card:hover .article-card__media img { transform: none; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .mobile-menu, .cursor-preview, .to-top, .marquee { display: none !important; }
  body { color: #000; background: #fff; }
  .theme-light, .flux::before, .grain::after { background: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* ---------- Homepage components ---------- */
@media (max-width: 1023px) {
  .hero__content { grid-template-columns: minmax(0, 1fr); }
  .hero__media { max-width: 44rem; }
  .hero__lower { padding-bottom: 0; max-width: 34rem; }
  .hero__bar { flex-direction: column; align-items: flex-start; }
  .scroll-cue { display: none; }
  .insight-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-2); }
  .insight-row__category { grid-column: 1 / -1; }
  .insight-row__meta { grid-row: 3; }
  .insight-row__arrow { grid-row: 2; grid-column: 2; }
  .stack-cloud__group { grid-template-columns: 1fr; gap: var(--space-4); }
  .stack-cloud__label { padding-top: 0; }
}
@media (max-width: 767px) {
  .hero__grid { background-size: 56px 56px; }
  .hero__services { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
}
@media (max-width: 1023px) {
  .hero__visual { width: min(52vw, 26rem); top: calc(var(--header-height) + 1rem); right: calc(var(--gutter) * -0.5); }
}
@media (max-width: 767px) {
  .hero__visual { width: 50vw; top: calc(var(--header-height) + 1.75rem); right: -2vw; }
  .hero__visual-label { display: none; }
}

/* ---------- Service cards ---------- */
@media (max-width: 1023px) {
  .service-card { grid-template-columns: 1fr; min-height: 0; }
  .service-card__visual { order: -1; min-height: 0; aspect-ratio: 16 / 9; }
  .service-card__content { gap: var(--space-8); }
  .service-card__title { max-width: none; }
}
@media (max-width: 767px) {
  .service-card__visual { aspect-ratio: 16 / 10; }
  .service-card__title { font-size: var(--fs-h3); }
  .service-card__desc { font-size: var(--fs-body); }
  .service-card__body { gap: var(--space-4); }
  .service-card__content { gap: var(--space-6); padding: var(--space-2); }
}

/* ---------- Tech grid ---------- */
@media (max-width: 1023px) {
  .tech-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .tech-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); border-radius: var(--radius-md); }
  .tech-tile--cta { grid-column: 1 / -1; min-height: 8rem; }
  .tech-tile, .tech-tile > a { gap: var(--space-2); padding: var(--space-2); }
  .tech-tile .chip__badge { width: 42px; height: 42px; }
  .tech-tile .chip__icon { width: 21px; height: 21px; }
  .tech-tile__name { font-size: 0.75rem; }
  .tech-tile__cat { display: none; }
  .tech-tile--cta .tech-tile__cat { display: inline-flex; }
  .tech__filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scrollbar-width: none; }
  .tech__filters::-webkit-scrollbar { display: none; }
  .tech__filters .filter { flex: none; }
}

/* ---------- Insight cards ---------- */
@media (max-width: 1023px) {
  .insight-card { grid-template-columns: 1fr; min-height: 0; }
  .insight-card__media { order: -1; aspect-ratio: 16 / 7; }
}
@media (max-width: 767px) {
  .insight-card__title { font-size: var(--fs-h4); }
  .insight-card__media { aspect-ratio: 16 / 8; }
  .insight-card__content { padding: var(--space-2); gap: var(--space-4); }
}

/* ---------- Inner pages ---------- */
@media (max-width: 1023px) {
  .page-hero__grid { grid-template-columns: 1fr; }
  .page-hero__media { aspect-ratio: 16 / 10; }
  .service-section { grid-template-columns: 1fr; }
  .service-section__media { position: relative; top: 0; aspect-ratio: 16 / 10; }
  .service-section:nth-of-type(even) .service-section__media { order: 0; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .faq-layout { grid-template-columns: 1fr; row-gap: var(--space-10); }
  .faq-layout__aside { position: static; }
  .related-grid { grid-template-columns: 1fr; }
  .related-card { grid-template-columns: 12rem minmax(0, 1fr); align-items: center; }
  .tech-grid--fixed { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .check-list { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature { min-height: 0; }
  .feature__title { padding-top: var(--space-2); }
  .related-card { grid-template-columns: 7rem minmax(0, 1fr); }
  .related-card__body { padding: 0; }
  .page-hero__jump a { height: 40px; padding-inline: var(--space-4); }
}

/* ---------- Work / Company / Blog / Contact ---------- */
@media (max-width: 1023px) {
  .work-grid { grid-template-columns: 1fr; }
  .work-grid > :first-child .work-card__media { aspect-ratio: 16 / 10; }
  .work-card__body { grid-template-columns: 1fr; }
  .work-card__tags { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .case-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-section, .story { grid-template-columns: 1fr; row-gap: var(--space-6); }
  .case-section__label { position: static; }
  .values { grid-template-columns: 1fr; }
  .value { min-height: 0; }
  .value__title { margin-top: var(--space-4); }
  .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clocks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .featured-post { grid-template-columns: 1fr; }
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: 1fr; }
  .toc { position: static; }
  .contact-layout { grid-template-columns: 1fr; }
  .contact-aside { position: static; }
}
@media (max-width: 767px) {
  .case-meta { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .case-gallery { grid-template-columns: 1fr; }
  .post-grid { grid-template-columns: 1fr; }
  .contact-form { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .filter-bar__filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scrollbar-width: none; }
  .filter-bar__filters .filter { flex: none; }
  .article-cover { aspect-ratio: 16 / 10; }
  .work-card__view { width: 52px; height: 52px; opacity: 1; transform: none; }
}


/* ---------- Hero tagline on one line (mobile) ---------- */
@media (max-width: 767px) {
  .hero__title .display-xl { white-space: nowrap; font-size: calc((100vw - var(--gutter) * 2) / 9.4); line-height: 1; }
  .hero__title .display-xl > span { display: inline; }
}
@media (max-width: 767px) { .clocks { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }

/* Mobile overflow guards: nothing may make the page wider than the screen
   (otherwise mobile browsers zoom the whole page out). Pinch-zoom in still works. */
body { overflow-x: clip; }
@media (max-width: 1023px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-layout > *, .toc { min-width: 0; }
  .toc a { overflow-wrap: anywhere; }
}
@media (max-width: 767px) {
  .filter-bar > * { min-width: 0; }
  .filter-bar__filters, .tech__filters { width: calc(100% + 2 * var(--gutter)); max-width: none; }
}
