/* Mobile-first polish for TK Web Studio. Loaded after the core stylesheet. */
@media (max-width: 900px) {
  html { scroll-padding-top: 76px; }
  body { background: #222222; }
  body::before { position: absolute; opacity: .12; background-size: 48px 48px; }
  .header { background: rgba(23,23,23,.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .header__inner { min-height: 64px; }
  .brand img { width: 40px; height: 40px; max-width: 40px; }
  .menuBtn { width: 46px; height: 46px; flex-basis: 46px; touch-action: manipulation; }
  .nav { top: calc(100% + 6px); border-radius: 14px; box-shadow: 0 18px 42px rgba(0,0,0,.48); }
  .nav a { min-height: 46px; display: flex; align-items: center; }
  .hero, .hero--compact { padding-top: 52px; }
  .reveal { transform: translateY(8px); transition-duration: .28s; }
  .btn, .btn--submit, .success-actions a { min-height: 48px; touch-action: manipulation; }
}

@media (max-width: 620px) {
  /* Keep page content clear of the one shared contact FAB. */
  body { padding-bottom: 78px; }
  body::before { display: none; }
  .container, .hero--home .container { width: calc(100% - 32px); }
  .section { padding: 44px 0; }
  .section--tight { padding: 36px 0; }
  .head { margin-bottom: 22px; }
  .head h2, .automationFeature__intro h2 { font-size: clamp(27px, 8vw, 34px); line-height: 1.12; text-wrap: balance; }
  .head p, .automationFeature__intro p:not(.eyebrow), .sub, .lead { font-size: 16px; line-height: 1.65; }

  .hero--home { padding: 42px 0 44px; background: linear-gradient(155deg, #171717 0%, #222222 58%, #222222 100%); }
  .hero--home::before, .hero--home::after { display: none; }
  .hero--home .hero__content { text-align: left; }
  .hero--home .eyebrow { margin: 0 0 14px; }
  .hero--home h1 { max-width: none; margin: 0 0 16px; font-size: clamp(32px, 9.4vw, 42px); line-height: 1.06; text-wrap: balance; }
  .hero--home .lead { max-width: none; margin: 0; font-size: 16px; line-height: 1.62; }
  .hero--home .btnRow { width: 100%; margin: 24px 0 0; }
  .hero--home .credibility { max-width: none; margin: 16px 0 0; font-size: 13.5px; }

  .automationFeature { background: linear-gradient(160deg, #171717 0%, #222222 48%, #222222 100%); }
  .automationFeature::before { display: none; }
  .automationGrid { gap: 12px; }
  .automationCard, .card, .priceCard, .process-step, .sidebar-card, .form-section { padding: 18px; border-radius: 12px; }
  .automationCard { box-shadow: 0 12px 28px rgba(0,0,0,.2); }
  .automationIcon { margin-bottom: 14px; }
  .automationCta { padding: 18px; border-radius: 12px; box-shadow: 0 16px 34px rgba(0,0,0,.28); }

  .portfolioGrid, .pricingGrid, .processGrid { gap: 14px; }
  .portfolioGrid { align-items: start; }
  .portfolioGrid .workCard,
  [data-project-grid] .workCard {
    min-height: 0;
    height: auto;
    align-self: start;
    overflow: hidden;
    border-radius: 12px;
  }
  .workCard:hover { transform: none; }
  .project-media { background: #2b2b2b; }
  .project-media img,
  .project-media video,
  .workCard img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    object-position: top center;
  }
  .workBody,
  [data-project-grid] .workBody {
    flex: 0 1 auto;
    min-height: 0;
    padding: 16px;
  }
  [data-project-grid] .workBody h3,
  [data-project-grid] .workBody > p:not(.workMeta),
  [data-project-grid] .project-tech { min-height: 0; }
  .project-tech { gap: 6px; }
  .project-tech span { padding: 6px 9px; font-size: 11px; }
  .workActions,
  [data-project-grid] .workActions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
    padding-top: 0;
  }
  .workActions .btn { width: 100%; min-width: 0; min-height: 44px; padding: 9px 8px; font-size: 12px; text-align: center; }
  .workActions .btn:nth-child(3) { grid-column: 1 / -1; }
  .price { font-size: 32px; }
  .ribbon { position: static; display: inline-flex; margin-bottom: 12px; }
  .hostingBox { padding: 18px; border-radius: 12px; }

  /* AI panel remains responsive; floating trigger layout is owned by contact-fab.css. */
  body .aiPanel {
    top: auto;
    right: 8px;
    bottom: 62px;
    left: 8px;
    width: auto;
    height: min(72vh, 560px);
    max-height: calc(100dvh - 78px);
    border-radius: 16px;
    box-shadow: 0 22px 70px rgba(0,0,0,.55);
  }
  body .aiPanel.open { display: flex; flex-direction: column; }
  body .aiBody { flex: 1; min-height: 0; max-height: none; padding: 12px; }
  .aiTop { flex: 0 0 auto; padding: 11px 12px; }
  .aiTop strong { font-size: 14px; }
  .aiTools { gap: 4px; }
  .aiTools button:not(#aiClose) { display: none; }
  .aiTop button { padding: 7px 10px; font-size: 11px; }
  .aiHandoff { flex: 0 0 auto; padding: 0 12px 10px; }
  .aiInput { flex: 0 0 auto; padding: 10px; gap: 7px; }
  .aiInput input { min-height: 44px; min-width: 0; }
  .aiInput .btn { width: auto; flex: 0 0 auto; min-height: 44px; padding-inline: 14px; }
  .bubble { font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
  .bubble.bot p + p,
  .bubble.bot ul + p,
  .bubble.bot ol + p { margin-top: 9px; }
  .bubble.bot ul,
  .bubble.bot ol { display: grid; gap: 5px; margin: 8px 0 0; padding-left: 19px; }
  .bubble.bot strong { color: #fff; }
}

@media (max-width: 390px) {
  .container, .hero--home .container { width: calc(100% - 24px); }
  .hero--home h1 { font-size: 31px; }
  .hero--home .lead { font-size: 15.5px; }
  .workActions,
  [data-project-grid] .workActions { grid-template-columns: 1fr; }
  .workActions .btn:nth-child(3) { grid-column: auto; }
  body .aiPanel { height: min(74vh, 530px); }
}

@media (hover: none) and (pointer: coarse) {
  .btn:hover, .btn--submit:hover, .success-actions a:hover, .workCard:hover { transform: none; }
}

/* 2026 QA hardening: prevent accidental page-width overflow and keep controls usable. */
html, body { max-width: 100%; overflow-x: clip; }
main, section, header, footer, .container, .home-shell, .heroGrid, .sectionSplit,
.portfolioGrid, .pricingGrid, .processGrid, .quote-layout, .footer__inner { min-width: 0; }
img, video, iframe, svg, canvas { max-width: 100%; }
pre, code, .bubble, .workBody, .card, .sidebar-card, .form-section { overflow-wrap: anywhere; word-break: break-word; }
input, select, textarea, button { max-width: 100%; }

@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}

@media (max-width: 900px) {
  .nav.open { max-width: calc(100vw - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .nav a, .btn, .btn--submit, .home-btn, .success-actions a { white-space: normal; text-align: center; }
  .footer__inner, .footer__links { min-width: 0; max-width: 100%; }
  .footer__links { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .home-hero__grid, .home-fit, .quote-layout, .heroGrid, .sectionSplit { grid-template-columns: minmax(0, 1fr) !important; }
  .home-hero__actions, .btnRow, .success-actions { width: 100%; }
  .home-hero__actions > *, .btnRow > *, .success-actions > * { max-width: 100%; }
  .home-preview { width: 100%; max-width: 100%; min-width: 0; }
  table { display: block; width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 2026-09-11: improve mobile/tablet header visibility on the light homepage. */
@media (max-width: 1100px) {
  html body.home-page .header {
    background: rgba(250,247,242,.98) !important;
    border-bottom: 1px solid rgba(189,57,19,.30) !important;
    box-shadow: 0 8px 24px rgba(23,23,23,.12) !important;
    backdrop-filter: blur(14px) saturate(145%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(145%) !important;
  }

  html body.home-page .header__inner {
    min-height: 70px !important;
  }

  html body.home-page .brand,
  html body.home-page .brand__name {
    color: #171717 !important;
  }

  html body.home-page .brand img {
    opacity: 1 !important;
    filter: none !important;
  }

  html body.home-page .brand__name {
    font-weight: 800 !important;
    letter-spacing: .055em !important;
  }

  html body.home-page .menuBtn {
    background: #fff !important;
    color: #171717 !important;
    border: 1px solid rgba(189,57,19,.42) !important;
    box-shadow: 0 4px 14px rgba(23,23,23,.10) !important;
  }

  html body.home-page .menuBtn span {
    background: #171717 !important;
  }
}

@media (max-width: 700px) {
  html body.home-page .brand img {
    width: 44px !important;
    height: 44px !important;
    max-width: 44px !important;
  }
}
