/* 媧石皇家 demo 3 — 水晶探索 (prefix d3-) */

/* ---------- Opening ---------- */
.d3-open { padding-top: calc(var(--hd-h) + clamp(48px, 7vw, 112px)); padding-bottom: clamp(40px, 4vw, 64px); overflow: hidden; }
.d3-open__in { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: end; gap: 32px clamp(40px, 6vw, 112px); }
.d3-open__head { display: grid; gap: 28px; }
.d3-open__title { font-size: clamp(2.5rem, 5.6vw, 5.5rem); line-height: 1.18; letter-spacing: .06em; }
.d3-open__aside { display: grid; gap: 22px; padding-bottom: 10px; }
.d3-open__note { padding-left: 18px; border-left: 1px solid var(--burgundy); font-size: var(--fs-small); line-height: 1.9; color: var(--muted); max-width: 30em; }
.d3-open__note strong { font-weight: 500; color: var(--burgundy); }

/* need ribbon: vertical-type tiles, horizontal drag / swipe */
.d3-needs { margin-top: clamp(56px, 7vw, 104px); }
.d3-needs__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.d3-needs__h { font: 500 var(--fs-label)/1.4 var(--f-sans); letter-spacing: .32em; color: var(--burgundy); }
.d3-needs__hint { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-label); letter-spacing: .14em; color: var(--muted); }
.d3-drag-ico { position: relative; width: 34px; height: 1px; background: currentColor; }
.d3-drag-ico::before, .d3-drag-ico::after { content: ""; position: absolute; top: -3px; width: 7px; height: 7px; border-top: 1px solid currentColor; }
.d3-drag-ico::before { left: 0; border-left: 1px solid currentColor; transform: rotate(-45deg); }
.d3-drag-ico::after { right: 0; border-right: 1px solid currentColor; transform: rotate(45deg); }
.d3-needs__scroller {
  --pad: max(var(--gutter), calc((100% - 1440px) / 2 + var(--gutter)));
  position: relative; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--pad);
  padding-inline: var(--pad); padding-bottom: 28px; scrollbar-width: none; cursor: grab; outline-offset: -3px;
}
.d3-needs__scroller::-webkit-scrollbar { display: none; }
.d3-needs__scroller.is-dragging { cursor: grabbing; scroll-snap-type: none; }
.d3-needs__scroller.is-dragging a { pointer-events: none; }
.d3-needs__prog { height: 1px; margin-top: 4px; background: linear-gradient(var(--burgundy), var(--burgundy)) left / calc(var(--p, 0) * 100%) 100% no-repeat, var(--line); }
.d3-needs__track { display: flex; gap: clamp(14px, 1.6vw, 24px); width: max-content; }
.d3-need { scroll-snap-align: start; }
.d3-need__a {
  position: relative; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; gap: 18px 14px;
  width: clamp(250px, 22vw, 316px); height: 100%; padding: 22px; border-radius: var(--r-lg); background: var(--sand);
  transition: background-color .5s var(--ease), color .5s var(--ease); user-select: none; -webkit-user-select: none;
}
.d3-need__no { grid-column: 1; font-size: .875rem; color: var(--burgundy); transition: color .5s var(--ease); }
.d3-need__name { grid-column: 2; grid-row: 1 / 3; writing-mode: vertical-rl; text-orientation: upright; font: 500 clamp(1.6rem, 2.2vw, 2.1rem)/1.15 var(--f-zh-serif); letter-spacing: .18em; }
.d3-need__mat { grid-column: 1; grid-row: 2; align-self: end; display: block; aspect-ratio: 1; padding: 12px; border-radius: var(--r); background: var(--paper); overflow: hidden; }
.d3-need__mat img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; transition: transform 1.1s var(--ease); pointer-events: none; }
.d3-need__foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--line); font-size: var(--fs-small); letter-spacing: .1em; color: var(--muted); transition: color .5s, border-color .5s; }
.d3-need__foot b { font-weight: 400; font-size: 1.15rem; color: inherit; }
.d3-need__arrow { width: 26px; height: 26px; border-radius: 50%; border: 1px solid currentColor; position: relative; transition: transform .5s var(--ease); }
.d3-need__arrow::after { content: ""; position: absolute; left: 8px; top: 9px; width: 6px; height: 6px; border-top: 1px solid currentColor; border-right: 1px solid currentColor; transform: rotate(45deg); }
.d3-need__a:hover, .d3-need__a:focus-visible { background: var(--burgundy-deep); color: var(--on-dark); }
.d3-need__a:hover .d3-need__no, .d3-need__a:focus-visible .d3-need__no { color: #E9C9C3; }
.d3-need__a:hover .d3-need__foot { color: var(--on-dark-muted); border-color: rgba(244, 237, 227, .2); }
.d3-need__a:hover .d3-need__mat img { transform: scale(1.06); }
.d3-need__a:hover .d3-need__arrow { transform: translateX(4px); }

/* ---------- Explorer ---------- */
.d3-explore { padding-block: clamp(56px, 6vw, 96px) var(--sec); border-top: 1px solid var(--line); }
.d3-explore__top { display: flex; align-items: end; justify-content: space-between; gap: 24px 48px; flex-wrap: wrap; margin-bottom: clamp(28px, 3vw, 40px); }
.d3-explore__h { min-height: 1.3em; }
.d3-search { position: relative; flex: 0 1 440px; min-width: 0; }
.d3-search__ico { position: absolute; left: 0; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.d3-search__input {
  width: 100%; height: 52px; padding: 0 40px 0 34px; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent;
  font: 400 1rem/1 var(--f-sans); letter-spacing: .06em; color: var(--ink); -webkit-appearance: none; appearance: none;
}
.d3-search__input::placeholder { color: #8A8078; }
.d3-search__input::-webkit-search-cancel-button { display: none; }
.d3-search__input:focus { outline: none; border-bottom-color: var(--burgundy); box-shadow: 0 1px 0 var(--burgundy); }
.d3-search__clear { position: absolute; right: 0; top: 50%; width: 36px; height: 36px; transform: translateY(-50%); font-size: 1.4rem; line-height: 1; color: var(--muted); }
.d3-search__clear:hover { color: var(--burgundy); }

/* filter ledger */
.d3-panel { border-top: 1px solid var(--ink); }
.d3-panel__grab, .d3-panel__sheethead, .d3-panel__sheetfoot { display: none; }
.d3-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 16px 28px; padding-block: 18px; border-bottom: 1px solid var(--line); }
.d3-row__label { display: grid; gap: 2px; font: 500 var(--fs-small)/1.4 var(--f-zh-serif); letter-spacing: .24em; }
.d3-row__label small { font: 400 .75rem/1.4 var(--f-sans); letter-spacing: .08em; color: var(--muted); }

.d3-opt { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: var(--fs-small); letter-spacing: .08em; transition: color .3s, background-color .35s var(--ease), border-color .3s, opacity .3s; }
.d3-opt small { font-size: .75rem; color: var(--muted); transition: color .3s; }
.d3-opt.is-zero { opacity: .38; }
.d3-opt:focus-visible { outline-offset: 2px; }

/* need: segmented control */
.d3-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 99px; background: var(--sand); justify-self: start; }
.d3-opt--benefit { padding: 0 18px; border-radius: 99px; }
.d3-opt--benefit:hover { background: rgba(255, 255, 255, .6); }
.d3-opt--benefit[aria-checked="true"] { background: var(--burgundy); color: #fff; }
.d3-opt--benefit[aria-checked="true"] small { color: #E9C9C3; }

/* colour: spectrum */
.d3-spectrum { display: flex; align-items: stretch; gap: 14px; min-width: 0; }
.d3-spectrum > .d3-opt--colour { flex: none; padding: 0 16px 0 10px; border: 1px solid var(--line); border-radius: 99px; }
.d3-spectrum__bar { flex: 1; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); min-width: 0; }
.d3-spectrum__bar .d3-opt--colour { flex-direction: column; gap: 8px; justify-content: start; padding: 0 2px 2px; text-align: center; }
.d3-spectrum__bar .d3-sw { width: 100%; height: 30px; border-radius: 0; transition: transform .45s var(--ease), box-shadow .3s, border-radius .45s var(--ease); }
.d3-spectrum__bar .d3-opt--colour:first-child .d3-sw { border-radius: 99px 0 0 99px; }
.d3-spectrum__bar .d3-opt--colour:last-child .d3-sw { border-radius: 0 99px 99px 0; }
.d3-spectrum__bar .d3-opt--colour span { font-size: .8125rem; line-height: 1.3; letter-spacing: .04em; white-space: nowrap; }
.d3-spectrum__bar .d3-opt--colour small { display: none; }
.d3-spectrum__bar .d3-opt--colour:hover .d3-sw { transform: translateY(-3px); }
.d3-spectrum__bar .d3-opt--colour[aria-checked="true"] .d3-sw { transform: translateY(-5px) scaleY(1.12); border-radius: 6px; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--burgundy); }
.d3-spectrum__bar .d3-opt--colour[aria-checked="true"] span { color: var(--burgundy); font-weight: 500; }
.d3-spectrum > .d3-opt--colour[aria-checked="true"] { border-color: var(--burgundy); color: var(--burgundy); }
.d3-sw { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.d3-sw--all { width: 22px; height: 22px; background: conic-gradient(#C46F7E, #C99A4E, #4E8763, #41709D, #7A5A9A, #2A2523, #ECE7DF, #C46F7E); }

/* tags */
.d3-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.d3-opt--tag { padding: 0 14px; border: 1px solid var(--line); border-radius: 99px; }
.d3-opt--tag:hover { border-color: var(--ink); }
.d3-opt--tag[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.d3-opt--tag[aria-checked="true"] small { color: var(--on-dark-muted); }

/* status line */
.d3-status { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 22px clamp(28px, 3vw, 44px); }
.d3-status__count { display: inline-flex; align-items: baseline; gap: 6px; font-size: var(--fs-small); letter-spacing: .12em; color: var(--muted); }
.d3-status__count b { font-weight: 400; font-size: 1.6rem; color: var(--ink); }
.d3-status__active { display: flex; flex-wrap: wrap; gap: 8px; }
.d3-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 8px 0 14px; border-radius: 99px; background: var(--burgundy-tint); color: var(--burgundy); font-size: .875rem; letter-spacing: .06em; }
.d3-pill span[aria-hidden] { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 1rem; line-height: 1; transition: background-color .3s; }
.d3-pill:hover span[aria-hidden] { background: rgba(107, 29, 44, .12); }
.d3-status__reset { margin-left: auto; padding: 6px 0; border-bottom: 1px solid currentColor; font-size: .875rem; letter-spacing: .12em; color: var(--muted); visibility: hidden; }
.d3-filtered .d3-status__reset { visibility: visible; }
.d3-status__reset:hover { color: var(--burgundy); }

/* gallery: calm, cream-matted square crops */
.d3-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(36px, 4vw, 64px) clamp(16px, 2vw, 32px); }
.d3-item { min-width: 0; }
.d3-item[hidden] { display: none; }
.d3-card { display: grid; gap: 16px; }
.d3-anim .d3-card { opacity: 0; transform: translateY(32px); transition: opacity 1s var(--ease) var(--d, 0s), transform 1.1s var(--ease) var(--d, 0s); }
.d3-anim .is-in .d3-card { opacity: 1; transform: none; }
.d3-card__mat { position: relative; display: block; padding: clamp(12px, 7%, 22px); border-radius: var(--r); background: var(--sand); transition: background-color .6s var(--ease); }
.d3-card__img { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 3px; background: var(--stone); }
.d3-card__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease), opacity .8s var(--ease); }
.d3-card__alt { opacity: 0; }
.d3-card__n { position: absolute; right: clamp(16px, 9%, 28px); bottom: clamp(16px, 9%, 28px); padding: 3px 9px; border-radius: 99px; background: rgba(247, 242, 234, .9); font-size: .75rem; color: var(--ink); opacity: 0; transform: translateY(6px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.d3-card:hover .d3-card__mat, .d3-card:focus-visible .d3-card__mat { background: var(--stone); }
.d3-card:hover .d3-card__img img { transform: scale(1.04); }
.d3-card:hover .d3-card__alt { opacity: 1; }
.d3-card:hover .d3-card__n { opacity: 1; transform: none; }
.d3-card__meta { display: grid; gap: 6px; padding-inline: 2px; }
.d3-card__row { display: flex; align-items: center; gap: 10px; }
.d3-card__row .d3-sw { width: 10px; height: 10px; }
.d3-card__name { font: 500 1.2rem/1.4 var(--f-zh-serif); letter-spacing: .12em; transition: color .3s; }
.d3-card:hover .d3-card__name { color: var(--burgundy); }
.d3-card__sub { font-size: .8125rem; line-height: 1.7; letter-spacing: .06em; color: var(--muted); }

/* empty state */
.d3-empty { display: grid; justify-items: center; gap: 16px; max-width: 34em; margin: 24px auto 0; padding: 56px 24px; text-align: center; }
.d3-empty[hidden] { display: none; }
.d3-empty__ring { width: 72px; height: 72px; margin-bottom: 8px; border-radius: 50%; border: 1px dashed var(--brass); position: relative; animation: d3-spin 18s linear infinite; }
.d3-empty__ring::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--burgundy-tint); }
@keyframes d3-spin { to { transform: rotate(360deg); } }
.d3-empty__acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }

/* ---------- Name index ---------- */
.d3-index { padding-block: var(--sec); }
.d3-index__head { display: grid; gap: 18px; margin-bottom: clamp(40px, 5vw, 72px); }
.d3-index__sub { font-size: var(--fs-small); }
.d3-index__cols { columns: 4 220px; column-gap: clamp(24px, 3vw, 56px); }
.d3-index__col { break-inside: avoid; margin-bottom: 40px; }
.d3-index__h { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--ink); font: 500 var(--fs-small)/1.4 var(--f-sans); letter-spacing: .14em; }
.d3-index__h small { margin-left: auto; font-size: .8125rem; color: var(--muted); }
.d3-index__col li a { position: relative; display: block; padding: 8px 0; font: 400 1.15rem/1.5 var(--f-zh-serif); letter-spacing: .1em; transition: color .3s, padding-left .45s var(--ease); }
.d3-index__col li a::before { content: ""; position: absolute; left: 0; top: 50%; width: 0; height: 1px; background: var(--burgundy); transition: width .45s var(--ease); }
.d3-index__col li a:hover { color: var(--burgundy); padding-left: 22px; }
.d3-index__col li a:hover::before { width: 14px; }
.d3-peek { position: fixed; left: 0; top: 0; z-index: 70; width: 168px; padding: 8px; border-radius: var(--r); background: var(--paper); box-shadow: 0 18px 40px rgba(38, 32, 28, .18); pointer-events: none; opacity: 0; scale: .9; transition: opacity .3s var(--ease), scale .4s var(--ease); }
.d3-peek.is-on { opacity: 1; scale: 1; }
.d3-peek img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; }

/* ---------- CTA ---------- */
.d3-cta { padding-block: var(--sec); }
.d3-cta__in { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 48px clamp(48px, 8vw, 140px); }
.d3-cta__txt { display: grid; gap: 26px; justify-items: start; }
.d3-cta__acts { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.d3-cta__qr { display: grid; gap: 14px; justify-items: center; padding: 18px 18px 16px; border-radius: var(--r-lg); background: var(--paper); color: var(--ink); }
.d3-cta__qr img { width: 180px; height: 180px; }
.d3-cta__qr figcaption { font-size: .8125rem; letter-spacing: .12em; color: var(--muted); }

/* ---------- Floating summary button ---------- */
.d3-float {
  position: fixed; left: 50%; bottom: 22px; z-index: 85; display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 22px 0 18px;
  border-radius: 99px; background: var(--ink); color: var(--paper); box-shadow: 0 14px 34px rgba(29, 24, 22, .28); font-size: var(--fs-small); letter-spacing: .12em;
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none; transition: transform .6s var(--ease), opacity .4s var(--ease);
}
.d3-float.is-show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.d3-float svg { width: 20px; height: 20px; }
.d3-float__n { padding-left: 10px; border-left: 1px solid rgba(247, 242, 234, .3); color: var(--on-dark-muted); }
.d3-float__n b { font-weight: 400; color: #fff; }
html.d3-sheet-open .d3-float { opacity: 0; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1199px) {
  .d3-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .d3-spectrum { flex-wrap: wrap; }
  .d3-spectrum__bar { flex-basis: 100%; }
}
@media (max-width: 991px) {
  .d3-open__in { grid-template-columns: minmax(0, 1fr); }
  .d3-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .d3-row__label { grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 12px; }
  .d3-cta__in { grid-template-columns: minmax(0, 1fr); }
  .d3-cta__qr { justify-self: start; }
}
@media (max-width: 760px) {
  .d3-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 14px; }
  .d3-card { gap: 12px; }
  .d3-card__mat { padding: 9px; }
  .d3-card__name { font-size: 1.05rem; letter-spacing: .08em; }
  .d3-card__n { display: none; }
  .d3-search { flex-basis: 100%; }
  .d3-explore__top { margin-bottom: 8px; }

  /* the ledger becomes a bottom sheet */
  .d3-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 120; max-height: 86vh; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 0 var(--gutter) calc(16px + env(safe-area-inset-bottom)); border-top: 0; border-radius: 20px 20px 0 0; background: var(--paper);
    box-shadow: 0 -20px 50px rgba(29, 24, 22, .2); transform: translateY(105%); visibility: hidden; transition: transform .5s var(--ease), visibility 0s .5s;
  }
  .d3-panel.is-open { transform: none; visibility: visible; transition: transform .5s var(--ease), visibility 0s; }
  .d3-sheet-veil { position: fixed; inset: 0; z-index: 110; background: rgba(29, 24, 22, .45); }
  .d3-sheet-veil[hidden] { display: none; }
  .d3-panel__grab { display: grid; place-items: center; position: sticky; top: 0; z-index: 2; height: 30px; margin-inline: calc(var(--gutter) * -1); background: var(--paper); touch-action: none; cursor: grab; }
  .d3-panel__grab span { width: 44px; height: 4px; border-radius: 4px; background: var(--line); }
  .d3-panel__sheethead { display: flex; align-items: center; justify-content: space-between; padding-bottom: 6px; }
  .d3-panel__sheettitle { font: 500 1.25rem/1.4 var(--f-zh-serif); letter-spacing: .14em; }
  .d3-panel__close { width: 44px; height: 44px; margin-right: -10px; font-size: 1.6rem; line-height: 1; }
  .d3-panel__sheetfoot { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto 1fr; gap: 10px; padding-block: 14px calc(16px + env(safe-area-inset-bottom)); margin-bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
  .d3-panel__sheetfoot .btn { padding: 0 18px; }
  .d3-panel__sheetfoot .btn--ghost::after { display: none; }
  .d3-row { padding-block: 16px; }
  .d3-row:last-of-type { border-bottom: 0; }
  .d3-seg { display: flex; padding: 0; background: none; gap: 8px; }
  .d3-opt--benefit { padding: 0 14px; border: 1px solid var(--line); }
  .d3-opt--benefit[aria-checked="true"] { border-color: var(--burgundy); }
  .d3-spectrum__bar { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 8px; }
  .d3-spectrum__bar .d3-sw { height: 34px; border-radius: 8px !important; }
  .d3-status { padding-block: 16px 24px; }
  .d3-status__count b { font-size: 1.35rem; }
  .d3-float { bottom: 18px; }
  .d3-cta__qr { display: none; }
  .d3-need__a { width: 236px; padding: 18px; }
  .d3-index__cols { columns: 2; column-gap: 20px; }
  .d3-index__h { font-size: .8125rem; letter-spacing: .06em; }
  .d3-index__col li a { font-size: 1.05rem; }
}
@media (max-width: 400px) {
  .d3-gallery { gap: 28px 12px; }
  .d3-card__sub { font-size: .75rem; }
}
