/* Responsive structural refinements: prevent orphan cards and header overflow without changing archive data. */

/* The sitewide language and manual voice-guide bar receives one restrained
   Qinghua porcelain motif at every viewport. It is deliberately faint on a
   phone, strengthening only as the available horizontal space increases.
   The overlay never accepts pointer events and all controls remain in the
   foreground layer. */
.zf-mobile-market-bar {
  isolation: isolate;
  overflow: hidden;
}
.zf-mobile-market-bar::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  content: '';
  pointer-events: none;
  opacity: .09;
  background-image: url('blue-and-white-voice-guide-motif.png');
  background-repeat: repeat-x;
  background-position: center 52%;
  background-size: 460px auto;
  mix-blend-mode: screen;
}
.zf-mobile-market-bar > * { position: relative; z-index: 1; }

@media (min-width: 761px) {
  .zf-mobile-market-bar::before {
    opacity: .12;
    background-size: 700px auto;
  }
}

/* Six verified featured records remain visually balanced at every supported desktop width. */
@media (min-width: 1081px) {
  .zf-home-featured-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }

  /* A single residual record in a three-column archive is centered in the final row. */
  .zf-catalog-artifact-grid > .zf-artifact-card:last-child:nth-child(3n + 1) {
    grid-column: 2;
  }
}

/* Tablet content retains intentional complete rows rather than falling back to a two-plus-one pattern. */
@media (min-width: 761px) and (max-width: 1080px) {
  .zf-home-service-grid,
  .zf-service-paths {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .zf-home-service-grid a { min-height: 152px; padding: 18px; }
  .zf-home-service-grid strong { font-size: 18px; }
  .zf-home-service-grid small { font-size: 11px; }

  .zf-service-paths article { min-height: 224px; padding: 19px; }
  .zf-service-paths h3 { margin-top: 12px; font-size: 20px; }
  .zf-service-paths p { min-height: 0; font-size: 12px; }

  /* At two columns, an odd final catalog item is intentionally centered rather than left alone. */
  .zf-catalog-artifact-grid > .zf-artifact-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: calc((100% - 22px) / 2);
    max-width: calc((100% - 22px) / 2);
    justify-self: center;
  }

  /* Foldable and tablet landscape: preserve the complete 16:9 five-element
     atmosphere instead of forcing the wide source image into a tall left rail.
     This removes the cover-crop that previously hid the artwork's left edge. */
  .zf-elements-layout {
    grid-template-columns: minmax(0, .76fr) minmax(0, 1.24fr);
    gap: clamp(20px, 2.8vw, 30px);
  }

  .zf-elements-art {
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 9;
    align-self: start;
    background-color: #f1eadf;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% auto;
  }

  .zf-element-grid {
    min-width: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  /* The craft archive atmosphere is also a 16:9 composition. A narrow
     side-by-side cell previously forced a cover crop on unfolded screens.
     At foldable/tablet widths use the complete image as its own editorial
     panel, followed by the archive text; desktop keeps the paired layout. */
  .zf-home-craft { padding: 72px 0; }
  .zf-craft-layout {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .zf-craft-visual {
    min-height: 0;
    aspect-ratio: 16 / 9;
    background-color: #f7f1e7;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% auto;
  }

  .zf-craft-copy { padding: clamp(32px, 5vw, 54px); }

  /* The language and manual voice-guide bar is a primary visitor control,
     not a phone-only decoration. The original max-width:760px rule hid it
     after a foldable opened into tablet width. Preserve it throughout the
     unfolded range with roomier, safe-area-aware touch targets. */
  body.zf-site,
  body.zf-market-utility-enabled { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .zf-mobile-market-bar {
    position: fixed;
    z-index: 70;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex !important;
    min-height: calc(78px + env(safe-area-inset-bottom));
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 10px max(28px, calc((100% - 980px) / 2)) calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(226,202,142,.48);
    color: #f8f0dc;
    background: linear-gradient(105deg, #1e4866, #295979);
    box-shadow: 0 -8px 22px rgba(38,61,75,.16);
  }

  .zf-mobile-market-bar .zf-market-open { display: flex; min-width: 0; align-items: center; gap: 9px; padding: 0; border: 0; color: inherit; background: transparent; text-align: left; font: inherit; }
  .zf-mobile-market-bar .zf-market-open > span:first-child { display: inline-grid; flex: 0 0 30px; place-items: center; width: 30px; height: 30px; border: 1px solid currentColor; border-radius: 50%; font-size: 16px; }
  .zf-mobile-market-bar .zf-market-open > span:last-child { display: block; min-width: 0; }
  .zf-mobile-market-bar .zf-market-open strong { display: block; font-family: var(--zf-serif); font-size: 17px; letter-spacing: .08em; }
  .zf-mobile-market-bar .zf-market-open small { display: block; max-width: 220px; overflow: hidden; color: rgba(248,240,220,.78); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
  .zf-mobile-market-bar .zf-market-cta { display: inline-flex; min-height: 48px; flex: 0 0 auto; align-items: center; justify-content: center; gap: 7px; padding: 0 21px; border: 0; border-radius: 999px; color: #59431a; background: linear-gradient(135deg, #eed38f, #f5c64f); font-family: var(--zf-serif); font-size: 16px; font-weight: 700; letter-spacing: .06em; }
}

/* A narrower unfolded / tablet portrait view has insufficient room for a
   side-by-side five-card rail. Give the index a complete-width row instead of
   clipping the final card or compressing the illustration into a crop. */
@media (min-width: 761px) and (max-width: 900px) {
  .zf-elements-layout { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .zf-elements-copy { grid-column: 1; grid-row: 1; max-width: 690px; }
  .zf-elements-art { grid-column: 1; grid-row: 2; }
  .zf-element-grid { grid-column: 1; grid-row: 3; }
}

/* Desktop carries the same language and manual voice-guide controls. It is
   deliberately a compact, centered utility bar rather than a second header,
   so visitors can change language or open the guide from any eligible page. */
@media (min-width: 1081px) {
  body.zf-site,
  body.zf-market-utility-enabled { padding-bottom: 76px; }
  .zf-mobile-market-bar {
    position: fixed;
    z-index: 70;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex !important;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 8px max(32px, calc((100% - 1180px) / 2));
    border-top: 1px solid rgba(226,202,142,.48);
    color: #f8f0dc;
    background: linear-gradient(105deg, #1e4866, #295979);
    box-shadow: 0 -8px 22px rgba(38,61,75,.16);
  }

  /* A quiet Qinghua porcelain overlay gives the wide utility bar cultural
     texture without turning it into a large, flat single-colour strip. The
     decorative motif sits below all controls, preserving legibility. */
  .zf-mobile-market-bar {
    isolation: isolate;
    overflow: hidden;
  }
  .zf-mobile-market-bar::before {
    position: absolute;
    z-index: 0;
    inset: 0;
    content: '';
    pointer-events: none;
    opacity: .14;
    background-image: url('blue-and-white-voice-guide-motif.png');
    background-repeat: repeat-x;
    background-position: center 54%;
    background-size: 820px auto;
    mix-blend-mode: screen;
  }
  .zf-mobile-market-bar > * { position: relative; z-index: 1; }

  .zf-mobile-market-bar .zf-market-open { display: flex; min-width: 0; align-items: center; gap: 9px; padding: 0; border: 0; color: inherit; background: transparent; text-align: left; font: inherit; }
  .zf-mobile-market-bar .zf-market-open > span:first-child { display: inline-grid; flex: 0 0 28px; place-items: center; width: 28px; height: 28px; border: 1px solid currentColor; border-radius: 50%; font-size: 15px; }
  .zf-mobile-market-bar .zf-market-open > span:last-child { display: block; min-width: 0; }
  .zf-mobile-market-bar .zf-market-open strong { display: block; font-family: var(--zf-serif); font-size: 16px; letter-spacing: .08em; }
  .zf-mobile-market-bar .zf-market-open small { display: block; max-width: 260px; overflow: hidden; color: rgba(248,240,220,.78); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
  .zf-mobile-market-bar .zf-market-cta { display: inline-flex; min-height: 45px; flex: 0 0 auto; align-items: center; justify-content: center; gap: 7px; padding: 0 20px; border: 0; border-radius: 999px; color: #59431a; background: linear-gradient(135deg, #eed38f, #f5c64f); font-family: var(--zf-serif); font-size: 15px; font-weight: 700; letter-spacing: .06em; }
}

/* Desktop navigation begins to compress before it can overflow a tablet viewport. */
@media (min-width: 761px) and (max-width: 860px) {
  .zf-header-inner {
    width: min(100% - 48px, 760px);
    min-height: 66px;
    gap: 4px;
  }

  .zf-menu-toggle {
    display: inline-flex;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    color: var(--zf-ink);
    background: transparent;
    font-size: 24px;
  }

  .zf-brand {
    flex: 0 1 auto;
    gap: 5px;
    overflow: hidden;
    color: #244f70;
  }

  .zf-brand-mark {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-color: #244f70;
    color: #244f70;
    background: #f8fbfa;
    font-size: 15px;
  }

  .zf-brand-name {
    font-size: 22px;
    letter-spacing: .09em;
    white-space: nowrap;
  }

  .zf-header-tools {
    flex: 1 0 auto;
    justify-content: flex-end;
    gap: 0;
  }

  .zf-header-tools .zf-control {
    display: inline-flex;
    min-height: 33px;
    padding: 0 5px;
    font-size: 10px;
  }

  .zf-header-tools .zf-control:nth-child(1) { width: 43px; }
  .zf-header-tools .zf-control:nth-child(2) {
    display: inline-flex;
    width: 82px;
    overflow: hidden;
    border: 1px solid rgba(49,95,127,.42);
    border-radius: 3px;
    color: #244f70;
  }

  .zf-icon-link {
    min-width: 28px;
    padding: 0 3px;
    font-size: 20px;
  }

  .zf-icon-link small,
  .zf-header-tools .zf-icon-link:last-child { display: none; }

  .zf-nav {
    position: absolute;
    top: 66px;
    right: 0;
    left: 0;
    display: none;
    padding: 12px 24px 18px;
    border-bottom: 1px solid var(--zf-sand);
    background: var(--zf-paper);
    box-shadow: var(--zf-shadow);
  }

  .zf-nav.is-open { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .zf-nav a { padding: 13px 0; border-bottom: 1px solid var(--zf-line); }
  .zf-nav a::after { bottom: 7px; }
}

/* Phone grids use a centered same-width tail tile, preserving the two-column rhythm. */
@media (max-width: 760px) {
  .zf-catalog-artifact-grid > .zf-artifact-card:last-child:nth-child(odd),
  .zf-related-grid > .zf-artifact-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: calc((100% - 11px) / 2);
    max-width: calc((100% - 11px) / 2);
    justify-self: center;
  }
}

@media (max-width: 360px) {
  .zf-catalog-artifact-grid > .zf-artifact-card:last-child:nth-child(odd),
  .zf-related-grid > .zf-artifact-card:last-child:nth-child(odd) {
    width: calc((100% - 11px) / 2);
    max-width: calc((100% - 11px) / 2);
  }
}
