/* CardSwap + Masonry (vanilla ports of the React Bits components) and the design house studio. */
.card-swap-container {
  position: absolute;
  bottom: 0;
  right: 0;
  transform: translate(5%, 20%);
  transform-origin: bottom right;
  perspective: 900px;
  overflow: visible;
}
.card {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 12px;
  border: 1px solid #fff;
  background: #000;
  transform-style: preserve-3d;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.list { position: relative; width: 100%; }
.item-wrapper { position: absolute; will-change: transform, width, height, opacity; padding: 6px; cursor: pointer; top: 0; left: 0; outline: none; }
.item-wrapper > .item-img {
  position: relative; background-size: cover; background-position: center top; width: 100%; height: 100%;
  border-radius: 12px; border: 2px solid var(--ink, #6b4f45); background-color: #f3eadc; box-shadow: 0 10px 30px -14px rgba(107, 79, 69, 0.45);
}
.item-wrapper:focus-visible > .item-img { box-shadow: 0 0 0 3px #e48ea7; }
.item-img--doc { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; font-size: 13px; font-weight: 700; color: var(--ink, #6b4f45); background: repeating-linear-gradient(0deg, #fffdf8 0 22px, #f1e4d6 22px 23px) !important; }
.item-doc-badge { padding: 4px 10px; border: 1.5px solid var(--ink, #6b4f45); border-radius: 999px; background: var(--butter, #f8dc98); font-size: 11px; }
.item-caption {
  position: absolute; left: 14px; right: 14px; bottom: 14px; display: flex; gap: 6px; align-items: center; padding: 5px 10px;
  background: #fff8ecee; border: 1.5px solid var(--ink, #6b4f45); border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--ink, #6b4f45);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transform: translateY(6px); transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.item-caption b { flex: none; color: var(--pink-deep, #e48ea7); }
.item-wrapper:hover .item-caption, .item-wrapper:focus-visible .item-caption { opacity: 1; transform: none; }

/* ---------- studio overlay ---------- */
.design-studio {
  position: absolute; inset: 0; z-index: 12; overflow: hidden; color: var(--ink, #6b4f45);
  background:
    radial-gradient(ellipse at 85% 20%, #f8cdd866, transparent 50%),
    radial-gradient(ellipse at 10% 90%, #f8dc9866, transparent 50%),
    linear-gradient(180deg, #fff8ec, #fbefdc);
  opacity: 0; transition: opacity .35s ease;
}
.design-studio[data-open] { opacity: 1; }
.ds-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .2; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .31 0 0 0 0 .27 0 0 0 .55 -.18'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.ds-close {
  position: absolute; top: 22px; right: 26px; z-index: 5; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--ink, #6b4f45); background: var(--pink, #f8cdd8); color: var(--ink, #6b4f45);
  font-size: 26px; line-height: 1; box-shadow: 2px 3px 0 var(--ink, #6b4f45); cursor: pointer;
}
.ds-page { position: absolute; inset: 0; }
.ds-page[hidden] { display: none; }
.ds-page--categories { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 24px; padding: 64px 5vw 40px; }
.ds-kicker {
  display: inline-block; margin: 0; font-size: 10px; letter-spacing: .14em; font-weight: 700;
  background: var(--butter, #f8dc98); border: 1.5px solid var(--ink, #6b4f45); border-radius: 999px; padding: 5px 12px; transform: rotate(-1.5deg);
}
.design-studio h2 { font-family: var(--display, 'ZCOOL KuaiLe', sans-serif); font-weight: 400; font-size: clamp(32px, 3.4vw, 50px); margin: 14px 0 6px; }
.ds-sub { margin: 0 0 18px; font-size: 13px; line-height: 1.7; color: var(--ink-soft, #8d7266); }
.ds-copy { position: relative; z-index: 2; align-self: center; }
.ds-list { list-style: none; margin: 0; padding: 0; border-top: 2px dashed #e2cbbd; }
.ds-list button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; border-bottom: 2px dashed #ecdccf;
  background: none; color: var(--ink, #6b4f45); text-align: left; font: inherit; font-size: 13px; cursor: pointer; border-radius: 10px; transition: background .2s ease;
}
.ds-list button b { font-size: 12px; color: var(--pink-deep, #e48ea7); }
.ds-list button span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.ds-list button em { font-style: normal; font-size: 11px; color: var(--ink-soft, #8d7266); }
.ds-list button:hover, .ds-list button.is-front { background: #fdeef2; }
.ds-stage { position: relative; z-index: 1; min-height: 0; }
.ds-stage .card-swap-container { right: 34%; bottom: 30%; transform: none; }

/* category card: text only, a little paper "window" */
.design-studio .ds-card {
  display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  background: #fffdf8; border: 2px solid var(--ink, #6b4f45); border-radius: 18px; box-shadow: 0 14px 30px -18px #6b4f45aa;
}
.ds-card-bar { flex: none; display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 2px solid var(--ink, #6b4f45); }
.ds-card--0 .ds-card-bar { background: var(--pink, #f8cdd8); }
.ds-card--1 .ds-card-bar { background: var(--butter, #f8dc98); }
.ds-card--2 .ds-card-bar { background: #fbe0d2; }
.ds-dot { width: 10px; height: 10px; border-radius: 50%; background: #fffdf8; border: 1.5px solid var(--ink, #6b4f45); }
.ds-card-tag { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.ds-card-body {
  flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 18px 26px;
  background: repeating-linear-gradient(0deg, transparent 0 27px, #f1e4d6 27px 28px);
}
.ds-card-no { position: absolute; right: 18px; top: 6px; font-size: 64px; font-weight: 900; line-height: 1; color: #f8cdd866; }
.ds-card-title { position: relative; margin: 0; font-family: var(--display, 'ZCOOL KuaiLe', sans-serif); font-weight: 400; font-size: 25px; line-height: 1.35; }
.ds-card-kinds { position: relative; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.ds-card-kinds span { padding: 3px 10px; border: 1.5px solid var(--ink, #6b4f45); border-radius: 999px; background: #fff8ec; font-size: 11px; font-weight: 700; }
.ds-card-foot { flex: none; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 16px; border-top: 2px solid var(--ink, #6b4f45); background: #fff8ec; font-size: 13px; font-weight: 700; }
.ds-card-foot em { font-style: normal; font-size: 12px; color: var(--pink-deep, #e48ea7); }

/* works page */
.ds-page--works { overflow-y: auto; padding: 56px 5vw 48px; }
.ds-works-head { max-width: 760px; margin-bottom: 14px; }
.ds-back {
  display: block; margin-bottom: 14px; border: 2px solid var(--ink, #6b4f45); background: #fffdf8; color: var(--ink, #6b4f45); border-radius: 999px;
  padding: 7px 16px; font: inherit; font-size: 13px; font-weight: 700; box-shadow: 2px 3px 0 var(--ink, #6b4f45); cursor: pointer;
}
.ds-back:hover { background: var(--pink, #f8cdd8); }
.ds-masonry { position: relative; }

/* preview */
.ds-viewer { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 24px; background: #6b4f4580; }
.ds-viewer[hidden] { display: none; }
.ds-viewer-card { position: relative; width: min(980px, 100%); max-height: calc(100svh - 48px); display: flex; flex-direction: column; background: var(--paper, #fff8ec); border: 2px solid var(--ink, #6b4f45); border-radius: 22px; padding: 20px 22px 16px; box-shadow: 6px 8px 0 #6b4f4544; }
.ds-viewer-card h3 { margin: 0 56px 12px 0; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.ds-viewer-close { top: 12px; right: 12px; width: 40px; height: 40px; }
.ds-viewer-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-radius: 12px; background: #fff; }
.ds-viewer-body img { display: block; width: 100%; height: auto; }
.ds-viewer-body iframe { display: block; width: 100%; height: min(70vh, 760px); border: 0; }
.ds-viewer-body video { display: block; width: 100%; max-height: 70vh; background: #3d2f2a; }
.ds-viewer-doc { padding: 40px 24px; text-align: center; font-size: 14px; }
.ds-viewer-card > a {
  align-self: flex-start; margin-top: 12px; color: var(--ink, #6b4f45); background: var(--pink, #f8cdd8); border: 2px solid var(--ink, #6b4f45);
  border-radius: 999px; padding: 7px 16px; text-decoration: none; font-weight: 700; font-size: 13px;
}

@media (max-width: 760px) {
  .ds-page--categories { grid-template-columns: 1fr; grid-template-rows: auto 1fr; padding: 70px 18px 20px; overflow-y: auto; }
  .ds-list { display: none; }
  .ds-stage { min-height: 300px; }
  .ds-stage .card-swap-container { right: 50%; bottom: 34%; transform: translateX(50%); }
  .ds-page--works { padding: 64px 14px 32px; }
}
@media (prefers-reduced-motion: reduce) { .design-studio { transition: none; } }
