/* ==========================================================================
   06-catalog.css
   Catalogue UI: filter chips, toolbar, facet drawer, category tiles, sticky buy bar, catalogue breakpoints.
   Load order: 6 of 7 - see README.md ("Stylesheet layer order").
   ========================================================================== */

/* --------------------------------------------------------------------------
   25. Catalogue: header, chips, toolbar, facets
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.catalog { padding-block: clamp(1.5rem, 3vw, 2.25rem) clamp(3rem, 6vw, 5rem); }

/* Category / skill chips */
.cat-chips {
  display: flex; gap: .5rem; overflow-x: auto;
  padding-bottom: .5rem; margin-bottom: 1.25rem;
  scrollbar-width: thin;
}
.cat-chip {
  display: inline-flex; align-items: center; gap: .4rem; flex: none;
  padding: .5rem 1.05rem;
  background: var(--paper); color: var(--plum-800);
  border: 1px solid var(--line);
  font-size: .85rem; font-weight: 500; white-space: nowrap;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.cat-chip:hover { border-color: var(--plum-300); color: var(--plum-700); }
.cat-chip.is-active { background: var(--plum-700); border-color: var(--plum-700); color: #fff; }
.chip-count { font-size: .72rem; opacity: .65; }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 1rem;
  padding: .75rem 0 1rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1.25rem;
}
.toolbar-count { margin: 0; font-size: .86rem; color: var(--ink-soft); }
.toolbar-count strong { color: var(--plum-800); font-weight: 700; }
.toolbar-controls { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.sort-form { display: flex; align-items: center; gap: .45rem; }
.sort-label { font-size: .78rem; color: var(--slate-500); }
.sort-form select {
  font: inherit; font-size: .84rem;
  padding: .5rem 2rem .5rem .8rem;
  color: var(--plum-800); background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6178' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center; background-size: 14px;
}
html[dir="rtl"] .sort-form select { background-position: left .55rem center; }

.filter-open { position: relative; }
.filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--sun-500); color: var(--plum-900); font-size: .68rem; font-weight: 700;
}

/* Faceted sidebar - an off-canvas drawer until there is room for a column */
.catalog-layout { display: grid; gap: clamp(1.5rem, 3vw, 2.5rem); align-items: start; }

.facets {
  position: fixed; inset: 0 0 0 auto; z-index: 120;
  width: min(88vw, 340px);
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.25rem;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .32s var(--ease), visibility .32s;
}
.facets.is-open { transform: none; visibility: visible; }

.facets-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.facets-title { display: flex; align-items: center; gap: .5rem; font-size: 1rem; margin: 0; }
.facets-close {
  width: 34px; height: 34px; padding: 0; line-height: 1;
  font-size: 1.5rem; color: var(--slate-500);
  background: var(--cream-2); border: 0;
}

.facet { border: 0; padding: 0; margin: 0; }
.facet legend {
  padding: 0 0 .6rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--slate-500);
}
.facet-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .42rem 0;
  font-size: .88rem; cursor: pointer;
}
.facet-row input {
  appearance: none; flex: none;
  width: 18px; height: 18px; margin: 0;
  border: 1.5px solid var(--slate-300);
  background: var(--paper);
  transition: background-color .18s var(--ease), border-color .18s var(--ease);
}
.facet-row input:checked {
  background: var(--plum-700) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 12.5 5 5L20 6.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  border-color: var(--plum-700);
}
.facet-name { flex: 1; }
.facet-count { font-size: .75rem; color: var(--slate-500); }

.facets-backdrop {
  position: fixed; inset: 0; z-index: 119;
  background: rgba(36, 21, 57,.45);
  opacity: 0; visibility: hidden;
  transition: opacity .3s var(--ease), visibility .3s;
}
.facets-backdrop.is-open { opacity: 1; visibility: visible; }

.catalog-empty[hidden] { display: none; }
.catalog-empty {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: clamp(2.5rem, 6vw, 4rem) 1rem;
  text-align: center; color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   26. Category tiles & section rails
   -------------------------------------------------------------------------- */
/* The heading and its call to action sit on one line when there is room and
   stack when there is not - an unwrapped row pushes the button off a phone. */
.rail-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem;
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}
.rail-head > div { flex: 1 1 18rem; min-width: 0; }
.rail-head .btn { white-space: normal; }
.rail-head .section-title { margin-bottom: 0; font-size: clamp(1.4rem, 2.6vw, 2.1rem); }
.rail-head .link-arrow { white-space: nowrap; padding-bottom: .35rem; }
.rail-head .link-arrow:hover .icon { transform: translateX(4px); }

.cat-tiles {
  display: grid; gap: clamp(.85rem, 1.6vw, 1.25rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr));
}
/* Photograph on top, solid caption panel beneath. Stacking the caption instead
   of floating it over the image removes the scrim the old design needed. */
.cat-tile {
  display: flex; flex-direction: column;
  background: var(--plum-800); color: #fff;
  border: 1px solid var(--line-soft);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.cat-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow); color: #fff; }
.cat-tile-media { display: block; overflow: hidden; aspect-ratio: 4 / 3; background: var(--plum-700); }
.cat-tile-media img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 22%;
  transition: transform .7s var(--ease);
}
.cat-tile:hover .cat-tile-media img { transform: scale(1.06); }

.cat-tile-body {
  display: flex; flex-direction: column; gap: .25rem; flex: 1;
  padding: 1.05rem 1.15rem 1.15rem;
  background: var(--plum-800);
}
.cat-tile-body strong { font-size: 1.05rem; letter-spacing: -.02em; }
.cat-tile-body small { font-size: .78rem; color: rgba(255,255,255,.76); line-height: 1.5; }
.cat-tile-body em {
  display: inline-flex; align-items: center; gap: .35rem;
  margin-top: auto; padding-top: .6rem;
  font-style: normal; font-size: .74rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--sun-300);
}
.cat-tile:hover .cat-tile-body em .icon { transform: translateX(3px); }
.cat-tile-body em .icon { transition: transform .25s var(--ease); }

/* --------------------------------------------------------------------------
   27. Sticky buy bar (PDP, small screens)
   -------------------------------------------------------------------------- */
.buybar {
  position: fixed; inset: auto 0 0 0; z-index: 95;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem var(--gutter);
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 -8px 26px -18px rgba(36, 21, 57,.5);
  transform: translateY(100%);
  transition: transform .3s var(--ease);
}
.buybar.is-visible { transform: none; }
.buybar-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.buybar-info small {
  font-size: .72rem; color: var(--slate-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.buybar-info strong { font-size: 1.05rem; color: var(--plum-800); letter-spacing: -.02em; }

/* The dock would sit on top of the buy bar, so lift it while the bar is out. */
body.has-buybar .dock { bottom: 4.75rem; }

/* --------------------------------------------------------------------------
   28. Catalogue breakpoints
   -------------------------------------------------------------------------- */
@media (min-width: 700px) {
  .pdp-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (min-width: 900px) {
  .pdp-detail { grid-template-columns: minmax(0, 1.7fr) minmax(0, .85fr); }
  .pdp-side { position: sticky; top: 100px; }
}

@media (min-width: 1000px) {
  /* The drawer becomes a permanent filter column. */
  .catalog-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .facets {
    position: sticky; top: 96px; inset-inline: auto;
    width: auto; padding: 1.25rem;
    transform: none; visibility: visible;
    background: var(--paper); border: 1px solid var(--line-soft); box-shadow: var(--shadow-sm);
    max-height: calc(100vh - 120px);
  }
  .facets-close, .filter-open { display: none; }
  .facets-backdrop { display: none; }
  .buybar { display: none; }
  body.has-buybar .dock { bottom: clamp(.75rem, 2vw, 1.5rem); }
}

@media (min-width: 1100px) {
  .pdp-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
}

.rail-lead { margin: .5rem 0 0; max-width: 56ch; color: var(--ink-soft); font-size: .93rem; }

/* --------------------------------------------------------------------------
   29. Narrow-phone header fit
   -------------------------------------------------------------------------- */
.brand-name-short { display: none; }

@media (max-width: 420px) {
  .site-header .brand-name-full  { display: none; }
  .site-header .brand-name-short { display: inline; }
  .header-inner { gap: .6rem; }
  .header-actions { gap: .4rem; }
  /* Drop the globe glyph - the language code alone is unambiguous here. */
  .lang-trigger { padding: .5rem .6rem; }
  .lang-trigger .icon { display: none; }
}

/* --------------------------------------------------------------------------
   30. One-page storefront: catalogue block, filter bar, misc
   -------------------------------------------------------------------------- */
/* The service catalogue now sits inside the home page rather than on a page of
   its own, so it gets a horizontal filter bar instead of a facet column. */
.catalog-block { margin-top: clamp(1.5rem, 3vw, 2.25rem); }

.filterbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 1.25rem;
  padding-bottom: 1rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}
/* A flex item will not shrink below its content width without min-width: 0, so
   without this the chip row pushes the whole page sideways on a phone instead of
   scrolling inside itself. */
.filterbar .cat-chips { flex: 1 1 100%; min-width: 0; margin-bottom: 0; padding-bottom: .35rem; }
.filterbar-right { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.filterbar-right .toolbar-count { white-space: nowrap; }

.catalog-main { min-width: 0; }

/* Section anchors have to clear the sticky header when a #hash link lands. */
#dich-vu, #ktv, #bang-gia, #gioi-thieu, #lien-he { scroll-margin-top: 84px; }

.sub-title {
  font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--slate-500); margin: 2rem 0 1rem;
}
.sub-title:first-child { margin-top: 0; }

.why-grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

.section-action { margin-top: clamp(1.5rem, 3vw, 2.25rem); text-align: center; }
.section-404 .error-inner .section-title { margin-top: .2em; }

/* Advantages printed under the about photograph rather than floating over it. */
.split-caption {
  display: grid; gap: .55rem;
  margin: 0; padding: 1.15rem 1.25rem;
  background: var(--plum-800); color: rgba(255,255,255,.86);
}
.split-caption p { display: flex; gap: .6rem; align-items: flex-start; margin: 0; font-size: .84rem; }
.split-caption .icon { color: var(--sun-400); flex: none; margin-top: .3em; }

.intro-prose { max-width: 62ch; margin: 0 auto clamp(1.75rem, 3vw, 2.5rem); text-align: center; color: var(--ink-soft); }

@media (min-width: 860px) {
  /* Panel and photograph share the hero row; the picture takes the smaller half
     so the headline never has to wrap more than it wants to. */
  .hero { grid-template-columns: 1.15fr .85fr; }
  /* The source photo is a tall portrait; letting it set its own height would
     stretch the row far past the copy. The panel drives the height instead and
     the picture is absolutely positioned inside whatever it gets. */
  .hero-media { position: relative; aspect-ratio: auto; min-height: 32rem; }
  .hero-media img { position: absolute; inset: 0; }
  .split-media { display: flex; flex-direction: column; }
  .split-media img { flex: 1; }
}
