/**
 * Nhà Cỏ — Mobile UX (≤768px)
 * File này là nguồn chính cho điện thoại; load sau site.css.
 */

.m-dock { display: none; }

@media (max-width: 768px) {
  :root {
    --header: 56px;
    --m-dock-h: 60px;
  }

  html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body {
    font-size: 1rem;
    line-height: 1.6;
    padding-bottom: calc(var(--m-dock-h) + env(safe-area-inset-bottom, 0px));
    -webkit-tap-highlight-color: rgba(201, 149, 58, .16);
    overscroll-behavior-y: contain;
  }

  img, video, iframe {
    max-width: 100%;
    height: auto;
  }
  img[class*="hero"],
  .home-hero-bg,
  .page-hero-bg,
  .stats-band-bg,
  .cat-tile img,
  .album-card img,
  .concept-card-media img,
  .col-item img,
  .svc-media img {
    height: 100%;
  }

  .wrap { width: min(100% - 1.15rem, var(--max)); }
  .wrap-wide { width: min(100% - .75rem, 1240px); }

  /* ========== Header ========== */
  .nc-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--header) + env(safe-area-inset-top, 0px));
    background: rgba(255, 252, 248, .98);
  }
  .nc-header-inner { gap: .5rem; }
  .nc-logo img { height: 34px; }
  .nc-burger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.65rem;
    border-radius: 8px;
    margin-right: -4px;
  }
  .nc-nav {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: min(88vw, 320px) !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
    z-index: 1001 !important;
  }
  .nc-nav ul {
    gap: .1rem !important;
    width: 100%;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    margin: 0 !important;
    padding: calc(var(--header) + env(safe-area-inset-top, 0px) + .65rem) 1.1rem calc(1.25rem + env(safe-area-inset-bottom)) !important;
  }
  .nc-nav > ul > li { width: 100%; flex-shrink: 0 !important; }
  .nc-nav a {
    display: flex !important;
    align-items: center;
    width: 100%;
    min-height: 46px;
    font-size: .95rem !important;
    padding: .5rem .1rem !important;
    letter-spacing: .02em;
    white-space: normal !important;
  }
  .nc-nav a::after { display: none !important; }
  .nc-nav .submenu {
    display: block !important;
    position: static !important;
    transform: none !important;
    width: 100%;
    min-width: 0 !important;
    padding: 0 0 .15rem !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  .nc-nav .submenu a {
    min-height: 38px;
    font-size: .88rem !important;
    color: var(--soft) !important;
    padding: .3rem .1rem .3rem .85rem !important;
  }
  .nc-nav .cta {
    margin-top: .65rem !important;
    justify-content: center !important;
    background: var(--yellow) !important;
    border: 1px solid var(--yellow) !important;
    color: #fff !important;
    border-radius: 6px;
    padding: .8rem 1rem !important;
    font-size: .9rem !important;
  }
  body.nav-open {
    overflow: hidden !important;
    /* Không khóa touch trên toàn trang — để menu kéo cuộn được */
    touch-action: auto;
  }
  body.nav-open .m-dock,
  body.nav-open .scroll-top { display: none !important; }

  /* ========== Admin bar ========== */
  body.has-admin-bar {
    padding-top: calc(88px + env(safe-area-inset-top, 0px));
  }
  body.has-admin-bar .nc-header {
    top: auto;
  }
  .nc-admin-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 11000;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .nc-admin-bar-inner {
    padding: .45rem .65rem;
    gap: .4rem;
  }
  .nc-admin-hint { display: none !important; }
  .nc-admin-btn {
    min-height: 36px;
    padding: .35rem .55rem;
    font-size: .68rem;
  }
  .nc-cms-img-btn {
    width: 2.4rem !important;
    height: 2.4rem !important;
    font-size: 1.05rem !important;
  }

  /* ========== Buttons ========== */
  .btn, .btn-ghost, .btn-light {
    min-height: 48px;
    padding: .85rem 1.15rem;
    font-size: .78rem;
    border-radius: 6px;
  }
  .btn-ghost { margin-left: 0 !important; }
  a.btn, button.btn { touch-action: manipulation; }

  /* ========== Heroes ========== */
  .home-hero {
    min-height: 100svh;
    min-height: 100dvh;
  }
  .home-hero::before {
    background: linear-gradient(180deg, rgba(0,0,0,.2) 8%, rgba(0,0,0,.74) 82%);
  }
  .home-hero-inner {
    width: min(100% - 1.25rem, var(--max));
    padding: calc(var(--header) + env(safe-area-inset-top, 0px) + 1.5rem) 0 calc(2.25rem + env(safe-area-inset-bottom));
    transform: none !important;
  }
  .home-hero h1 {
    font-size: clamp(2.2rem, 10.5vw, 3rem);
    line-height: 1.08;
    margin-bottom: .55rem;
  }
  .home-hero p {
    font-size: 1rem;
    line-height: 1.5;
    max-width: none;
  }
  .home-hero-actions {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: .55rem;
    margin-top: 1.25rem;
  }
  .home-hero-actions .btn { width: 100%; }

  .page-hero {
    min-height: 32vh;
    padding: calc(var(--header) + env(safe-area-inset-top, 0px) + 1.25rem) 0 1.5rem;
  }
  .page-hero h1 {
    font-size: clamp(1.65rem, 7vw, 2.1rem);
    line-height: 1.15;
  }
  .page-hero .eyebrow { font-size: .72rem; }

  /* ========== Sections ========== */
  .section { padding: 2.15rem 0; }
  .section-alt, .section-dark { padding: 2.15rem 0; }
  .sec-head { margin-bottom: 1.15rem; text-align: left; }
  .sec-head h2 {
    font-size: clamp(1.4rem, 6.2vw, 1.85rem);
    line-height: 1.2;
  }
  .sec-head p {
    margin-left: 0;
    margin-right: 0;
    font-size: .92rem;
  }
  .center.mt-2 {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: .55rem;
  }
  .center.mt-2 .btn,
  .section .center .btn {
    width: 100%;
    max-width: none;
  }

  .story { gap: 1.1rem; }
  .story-photo {
    aspect-ratio: 5 / 4;
    border-radius: 8px;
    overflow: hidden;
  }
  .story h3 { font-size: 1.28rem; line-height: 1.28; }
  .story p { font-size: .95rem; }
  .story .btn { width: 100%; }

  /* Services numbers */
  .svc-nums {
    grid-template-columns: 1fr 1fr !important;
    gap: .5rem !important;
  }
  .svc-num {
    padding: .9rem .55rem !important;
    border-radius: 8px;
    min-height: 104px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .svc-num:active {
    border-color: var(--yellow);
    background: #fff;
  }
  .svc-num b { font-size: 1.15rem !important; margin-bottom: .3rem !important; }
  .svc-num h3 { font-size: .82rem !important; margin: 0 0 .2rem; }
  .svc-num p { font-size: .74rem !important; margin: 0; }

  /* Albums / gallery hub */
  .album-grid,
  .col-hub {
    grid-template-columns: 1fr 1fr !important;
    gap: .5rem !important;
  }
  .album-card {
    aspect-ratio: 3 / 4;
    border-radius: 8px;
  }
  .album-card .ov { display: none !important; }
  .album-card .cap {
    opacity: 1 !important;
    font-size: .66rem;
    padding: .65rem .4rem;
    letter-spacing: .04em;
  }
  .album-card:hover img,
  .album-card:active img {
    transform: none !important;
    opacity: .92 !important;
  }

  /* Concept hub */
  .cat-hub {
    grid-template-columns: 1fr 1fr !important;
    gap: .5rem !important;
  }
  .cat-tile {
    min-height: 0 !important;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
  }
  .cat-hub .cat-tile:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 9;
  }
  .cat-tile-body { padding: .85rem .65rem; }
  .cat-tile-body h2 {
    font-size: clamp(1.15rem, 5.2vw, 1.45rem);
    margin: 0;
    text-shadow: 0 2px 12px rgba(0,0,0,.55);
  }

  /* Concept browse */
  .concept-toolbar {
    position: sticky;
    top: calc(var(--header) + env(safe-area-inset-top, 0px));
    z-index: 30;
    background: var(--bg) !important;
    padding: .45rem 0 .55rem !important;
    margin: 0 0 .35rem !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: .55rem !important;
    border: 0 !important;
    border-bottom: none !important;
    box-shadow: none !important;
    outline: none !important;
  }
  .concept-toolbar::before,
  .concept-toolbar::after {
    display: none !important;
    content: none !important;
  }
  .concept-toolbar > div:last-child {
    text-align: left !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #conceptCount { display: none !important; }
  .concept-back {
    min-height: 40px;
    font-size: .9rem;
  }
  .concept-toolbar > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .concept-filters {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: .35rem;
    width: 100%;
    max-width: 100%;
    margin: 0 auto !important;
    padding: .15rem 0 .2rem !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    scrollbar-width: none;
  }
  .concept-filters::-webkit-scrollbar { display: none; }
  .concept-filters button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: .45rem .75rem;
    font-size: .74rem;
    border-radius: 999px;
  }
  .concept-masonry,
  .concept-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: .5rem !important;
  }
  .concept-card { border-radius: 8px; }
  .concept-card:hover { transform: none; box-shadow: none; }
  .concept-card-cap { padding: 1.45rem .4rem .55rem; }
  .concept-card-cap h3 {
    font-size: .68rem;
    letter-spacing: .03em;
  }
  .concept-views { font-size: .6rem; }
  body.admin-mode .concept-card .admin-btns {
    opacity: 1 !important;
    gap: .25rem;
  }
  body.admin-mode .concept-card .admin-btns button {
    width: 36px;
    height: 36px;
  }

  /* Concept viewer */
  .cv-overlay { z-index: 12000; }
  .cv-top {
    flex-direction: column;
    align-items: stretch;
    gap: .55rem;
    padding: .7rem .75rem;
    padding-top: calc(.7rem + env(safe-area-inset-top));
  }
  .cv-top h2 { font-size: 1.05rem; }
  .cv-actions {
    width: 100%;
    display: flex;
    gap: .4rem;
  }
  .cv-actions .btn,
  .cv-actions .btn-light {
    flex: 1;
    min-height: 44px;
    font-size: .68rem;
    padding: .55rem .4rem;
  }
  .cv-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    font-size: 1.5rem;
  }
  .cv-body {
    padding: .55rem .45rem calc(1rem + env(safe-area-inset-bottom));
  }

  /* Services rows */
  .svc-row {
    grid-template-columns: 1fr !important;
    direction: ltr !important;
    gap: .85rem !important;
    padding: 1.5rem 0 !important;
  }
  .svc-row:nth-child(even) { direction: ltr !important; }
  .svc-media { border-radius: 8px; }
  .svc-row h3 { font-size: 1.35rem !important; }
  .svc-row p { font-size: .92rem; }
  .svc-row .btn,
  .svc-row .btn-ghost,
  .svc-row-actions .btn,
  .svc-row-actions .btn-ghost {
    display: flex !important;
    width: 100%;
    margin: .35rem 0 0 !important;
    justify-content: center;
  }
  .svc-row-actions {
    flex-direction: column !important;
    width: 100%;
  }

  /* Contact */
  .contact-grid { gap: 1.5rem; }
  .info-row {
    padding: .4rem 0;
    align-items: flex-start;
    gap: .75rem;
  }
  .info-row i { font-size: 1.2rem; margin-top: .15rem; }
  .chips {
    gap: .4rem;
    margin-top: .85rem;
  }
  .chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem .85rem;
    border-radius: 999px;
    background: var(--surface);
    font-size: .78rem;
  }
  .form-row { grid-template-columns: 1fr !important; gap: 0 !important; }
  .form input,
  .form select,
  .form textarea {
    font-size: 16px !important;
    min-height: 48px;
    padding: .85rem 0;
  }
  .form textarea { min-height: 130px; }
  .form .btn { width: 100%; margin-top: .5rem; }
  .faq-item button {
    min-height: 52px;
    font-size: .92rem;
    gap: .65rem;
    text-align: left;
  }
  .faq-item.open .ans {
    max-height: 420px;
    font-size: .92rem;
    line-height: 1.55;
  }

  /* Process / voices / stats / footer */
  .proc {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }
  .proc article {
    padding: .9rem 0;
    border-bottom: 1px solid var(--line);
  }
  .proc article:last-child { border-bottom: 0; }
  .voices {
    grid-template-columns: 1fr !important;
    gap: 1.15rem;
  }
  .voices blockquote { font-size: 1.05rem; }
  .stats-band { padding: 2rem 0; }
  .stats-band .grid {
    grid-template-columns: 1fr 1fr !important;
    gap: .85rem;
  }
  .stats-band strong { font-size: 1.65rem; }
  .stats-band span { font-size: .65rem; }

  .nc-footer { padding: 2.25rem 0 1.1rem; }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem;
  }
  .footer-grid .btn { width: 100%; }
  .footer-copy {
    font-size: .75rem;
    line-height: 1.55;
  }

  /* Gallery page */
  .col-back {
    min-height: 44px;
    position: sticky;
    top: calc(var(--header) + env(safe-area-inset-top, 0px));
    z-index: 20;
    background: linear-gradient(180deg, var(--bg) 70%, transparent);
    margin: 0 0 .5rem;
    padding: .35rem 0 .55rem;
  }
  .col-admin {
    padding: .85rem !important;
    margin-bottom: 1rem !important;
  }
  .col-layouts {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: .4rem !important;
  }
  .col-layout-btn {
    min-height: 64px;
    font-size: .62rem !important;
    padding: .35rem !important;
  }
  .col-admin label.col-upload {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }
  .col-gallery.layout-3,
  .col-gallery.layout-4,
  .col-gallery.layout-8 {
    grid-template-columns: 1fr 1fr !important;
    gap: .45rem !important;
  }
  .col-gallery.layout-7 { column-count: 2 !important; }
  .col-gallery.layout-9 .col-item {
    aspect-ratio: 16 / 9 !important;
    max-height: 42vh;
  }
  .col-item .col-del {
    width: 36px !important;
    height: 36px !important;
  }

  /* Floating / scroll */
  .floating-contact { display: none !important; }
  .scroll-top {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(var(--m-dock-h) + 10px + env(safe-area-inset-bottom));
    width: 42px;
    height: 42px;
    border-radius: 50%;
    z-index: 900;
  }

  /* Toast above dock */
  .nc-cms-toast,
  #colToast,
  .toast-container {
    bottom: calc(var(--m-dock-h) + 1rem + env(safe-area-inset-bottom)) !important;
  }

  /* Modals */
  .modal-dialog {
    margin: .5rem;
    max-width: calc(100% - 1rem);
  }
  .modal-content { border-radius: 10px; }
  .modal-body { padding: 1rem; }
  .modal-footer {
    flex-direction: column;
    gap: .45rem;
  }
  .modal-footer .btn { width: 100%; margin: 0 !important; }
  .nc-cms-modal { padding: .65rem; align-items: flex-end; }
  .nc-cms-dialog {
    width: 100%;
    max-height: min(88vh, 640px);
    overflow: auto;
    border-radius: 12px 12px 0 0;
    padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  }
  .nc-cms-dialog-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding-top: .65rem;
  }
  .nc-cms-textarea, .nc-cms-input, .nc-cms-file input {
    font-size: 16px !important;
  }

  /* ========== Bottom dock ========== */
  .m-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9500;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--m-dock-h) + env(safe-area-inset-bottom));
    padding: 0 0 env(safe-area-inset-bottom);
    background: rgba(255, 252, 248, .97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 24px rgba(0,0,0,.07);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .m-dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    color: var(--ink) !important;
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-decoration: none !important;
    min-height: var(--m-dock-h);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .m-dock-item i {
    font-size: 1.15rem;
    color: var(--yellow-dark);
    line-height: 1;
  }
  .m-dock-item.is-active { color: var(--yellow-dark) !important; }
  .m-dock-item.is-active i { color: var(--yellow); }
  .m-dock-item:active { background: rgba(201, 149, 58, .12); }
  .m-dock-main i {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--yellow);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 5px 14px rgba(201, 149, 58, .38);
    margin-top: -8px;
  }
  .m-dock-main span { margin-top: .1rem; }

  /* Upload progress */
  .upload-progress-container {
    left: .75rem !important;
    right: .75rem !important;
    bottom: calc(var(--m-dock-h) + .75rem + env(safe-area-inset-bottom)) !important;
    width: auto !important;
  }
}

/* Máy hẹp */
@media (max-width: 380px) {
  .svc-nums,
  .album-grid,
  .col-hub,
  .cat-hub,
  .concept-masonry,
  .concept-grid {
    gap: .4rem !important;
  }
  .album-grid,
  .col-hub,
  .cat-hub,
  .concept-masonry,
  .concept-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .home-hero h1 { font-size: 2.05rem; }
  .concept-card-cap h3 { font-size: .62rem; }
  .m-dock-item { font-size: .58rem; }
  .m-dock-item i { font-size: 1.05rem; }
  .col-layouts { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Landscape phone */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .home-hero {
    min-height: auto;
    padding: calc(var(--header) + 1rem) 0 1.5rem;
  }
  .home-hero-inner { padding-top: calc(var(--header) + .75rem); }
  .page-hero { min-height: 28vh; }
  .m-dock { height: 52px; padding-bottom: 0; }
  body { padding-bottom: 52px; }
  .m-dock-main i { margin-top: -4px; width: 34px; height: 34px; }
}

@media (min-width: 900px) {
  .team-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* Prefer reduced motion */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Hide dock when viewers/lightboxes open */
body:has(#conceptViewer.active) .m-dock,
body:has(.glightbox-open) .m-dock,
body.glightbox-open .m-dock,
body.nav-open .m-dock {
  display: none !important;
}
body:has(#conceptViewer.active),
body:has(.glightbox-open),
body.glightbox-open {
  padding-bottom: 0 !important;
}
