/* StoryDate Obsidian-Gold 3D Collector Character Card Optics
 * Apple Card Titanium + Leica Brass + A24 Dark Cinema restraint.
 * Zero gacha badges, zero face-obscuring rainbows, 60fps GPU-composited 3D. */

.collector-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px 12px 12px;
  color: #f5f3ee;
}

.collector-stage {
  position: relative;
  width: min(290px, 100%, 76vw);
  aspect-ratio: 2 / 3;
  perspective: 1100px;
  touch-action: pan-y;
  user-select: none;
  cursor: pointer;
}

/* Subtle dark-room spotlight beneath the floating collector artifact */
.collector-stage::before {
  content: "";
  position: absolute;
  inset: -14% -16%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 188, 137, 0.12), rgba(214, 188, 137, 0.03) 45%, transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.collector-card {
  --rx: 0deg;
  --ry: 0deg;
  --gx: 50%;
  --gy: 36%;
  --foil-x: 50%;
  --foil-y: 64%;
  --tilt-mag: 0;
  --flip-deg: 0deg;
  --accent: #d6bc89;
  --accent-edge: rgba(214, 188, 137, 0.42);
  --foil-gradient: linear-gradient(
    118deg,
    transparent 18%,
    rgba(214, 188, 137, 0.16) 38%,
    rgba(255, 246, 224, 0.24) 50%,
    rgba(196, 162, 102, 0.14) 62%,
    transparent 82%
  );
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.collector-card[data-finish="titanium-silver"] {
  --accent: #cfd7e3;
  --accent-edge: rgba(207, 215, 227, 0.44);
  --foil-gradient: linear-gradient(
    118deg,
    transparent 18%,
    rgba(196, 208, 224, 0.16) 38%,
    rgba(248, 251, 255, 0.24) 50%,
    rgba(162, 174, 192, 0.14) 62%,
    transparent 82%
  );
}

.collector-card[data-finish="whisper-pearl"] {
  --accent: #dfd0dc;
  --accent-edge: rgba(223, 208, 220, 0.42);
  --foil-gradient: linear-gradient(
    122deg,
    transparent 14%,
    rgba(206, 190, 232, 0.14) 32%,
    rgba(182, 224, 228, 0.16) 46%,
    rgba(246, 234, 208, 0.2) 56%,
    rgba(226, 196, 214, 0.13) 70%,
    transparent 86%
  );
}

.collector-card[data-flipped="true"] {
  --flip-deg: 180deg;
}

/* Decoupled 3D planes: outer plane runs pure 60fps spring tilt; inner plane runs smooth 180° flip. */
.collector-tilt {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  will-change: transform;
}

.collector-rotor {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(var(--flip-deg));
  transition: transform 0.66s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.collector-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #121215;
  border: 1px solid var(--accent-edge);
  box-shadow:
    0 28px 60px -16px rgba(0, 0, 0, 0.82),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.collector-face.is-front {
  transform: rotateY(0deg) translateZ(0.5px);
}

.collector-face.is-back {
  transform: rotateY(180deg) translateZ(0.5px);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(214, 188, 137, 0.07), transparent 58%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 7px),
    #101013;
}

.collector-card[data-finish="titanium-silver"] .collector-face.is-back {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(207, 215, 227, 0.07), transparent 58%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 7px),
    #111216;
}

.collector-card[data-finish="whisper-pearl"] .collector-face.is-back {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(218, 200, 226, 0.08), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 7px),
    #111015;
}

.collector-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.collector-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  transform: scale(1.05) translate3d(var(--art-x, 0px), var(--art-y, 0px), 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}

.collector-art img[src$="/seven-nights/p3.webp"] {
  object-position: 70% center;
}

.collector-orbit-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  pointer-events: none;
}

.collector-orbit-canvas[hidden] {
  display: none;
}

.collector-face.is-front::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10, 10, 12, 0.12) 0%, transparent 28%, rgba(8, 8, 10, 0.16) 58%, rgba(8, 8, 10, 0.92) 100%);
  pointer-events: none;
}

/* True-3D orbit portraits stay razor-clear: keep scrim compact at the bottom and dial foil/glare down off the face. */
.collector-card[data-orbit-ready="true"] .collector-face.is-front::after {
  background: linear-gradient(180deg, transparent 0%, transparent 66%, rgba(8, 8, 10, 0.82) 100%);
}

.collector-card[data-orbit-ready="true"] .collector-foil {
  opacity: calc(0.06 + var(--tilt-mag) * 0.18);
}

.collector-card[data-orbit-ready="true"] .collector-glare {
  opacity: calc(0.08 + var(--tilt-mag) * 0.22);
}

/* Layer 2: diagonal etched foil band shifting opposite the tilt angle */
.collector-foil {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    var(--foil-gradient),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.03) 0 1px,
      transparent 1px 4px
    );
  background-size: 240% 240%, 100% 100%;
  background-position: var(--foil-x) var(--foil-y), 0 0;
  mix-blend-mode: soft-light;
  opacity: calc(0.28 + var(--tilt-mag) * 0.62);
}

.collector-foil.is-back-foil {
  opacity: calc(0.22 + var(--tilt-mag) * 0.45);
}

/* Specular light pool catching the machined surface */
.collector-glare {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(
    220px circle at var(--gx) var(--gy),
    rgba(255, 250, 240, 0.14),
    rgba(214, 188, 137, 0.04) 42%,
    transparent 70%
  );
  mix-blend-mode: screen;
  opacity: calc(0.35 + var(--tilt-mag) * 0.65);
}

/* Layer 3: 1px machined inner rim + delicate architectural corner marks */
.collector-bevel {
  position: absolute;
  inset: 8px;
  z-index: 4;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
  color: var(--accent);
  background:
    linear-gradient(currentColor 0 0) left top / 8px 1px no-repeat,
    linear-gradient(currentColor 0 0) left top / 1px 8px no-repeat,
    linear-gradient(currentColor 0 0) right top / 8px 1px no-repeat,
    linear-gradient(currentColor 0 0) right top / 1px 8px no-repeat,
    linear-gradient(currentColor 0 0) left bottom / 8px 1px no-repeat,
    linear-gradient(currentColor 0 0) left bottom / 1px 8px no-repeat,
    linear-gradient(currentColor 0 0) right bottom / 8px 1px no-repeat,
    linear-gradient(currentColor 0 0) right bottom / 1px 8px no-repeat;
  opacity: 0.72;
}

.collector-front-meta {
  position: absolute;
  inset: auto 20px 18px;
  z-index: 5;
  display: grid;
  gap: 4px;
  min-width: 0;
  pointer-events: none;
}

.collector-front-meta small {
  color: var(--accent);
  font: 500 11px/1.3 Inter, "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collector-front-meta strong {
  color: #f8f5ef;
  font: 500 24px/1.15 Georgia, "Songti SC", serif;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Backface museum letterpress dossier */
.collector-back-frame {
  position: relative;
  z-index: 5;
  box-sizing: border-box;
  height: 100%;
  padding: 26px 22px 22px;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.collector-back-head {
  display: grid;
  gap: 5px;
}

.collector-back-head small {
  color: var(--accent);
  font: 500 10.5px/1.3 Inter, "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.collector-back-head h3 {
  margin: 0;
  color: #f7f4ec;
  font: 500 22px/1.2 Georgia, "Songti SC", serif;
  letter-spacing: -0.01em;
}

.collector-back-quote {
  margin: 22px 0 0;
  color: #ebe4d6;
  font: italic 400 14px/1.65 Georgia, "Songti SC", serif;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.collector-rule {
  display: block;
  width: 34px;
  height: 1px;
  margin: 18px auto;
  background: var(--accent);
  opacity: 0.55;
}

.collector-back-notes {
  margin: 0;
  color: #b4afa6;
  font: 400 12.5px/1.7 Inter, "PingFang SC", system-ui, sans-serif;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: left;
}

.collector-back-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #7d7870;
  font: 500 10px/1.2 Inter, "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0.1em;
}

/* Minimal controls below the 3D card */
.collector-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.collector-flip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #e6dfd2;
  font: 500 13px/1 Inter, "PingFang SC", system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}

.collector-flip-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(214, 188, 137, 0.45);
  color: #fff;
}

.collector-flip-btn:active {
  transform: scale(0.975);
}

.collector-flip-btn:focus-visible,
.collector-swatch:focus-visible,
.collector-fuse-link:focus-visible,
.fw-collector-trigger:focus-visible {
  outline: 2px solid #d6bc89;
  outline-offset: 3px;
}

.collector-finishes {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.collector-swatch {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.collector-swatch i {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
}

.collector-swatch:hover i {
  transform: scale(1.14);
}

.collector-swatch[aria-pressed="true"] i {
  transform: scale(1.16);
  box-shadow: 0 0 0 2px #121215, 0 0 0 3.5px #d6bc89;
}

.collector-fuse-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: #d6bc89;
  font: 500 13px/1 Inter, "PingFang SC", system-ui, sans-serif;
  text-decoration: none;
  transition: color 0.16s ease;
}

.collector-fuse-link:hover {
  color: #f4e2bc;
}

/* Profile page subtle Collector Card entry trigger */
.fw-collector-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  margin-left: auto;
  border: 1px solid rgba(214, 188, 137, 0.3);
  border-radius: 999px;
  background: rgba(214, 188, 137, 0.06);
  color: #dfd0b2;
  font: 500 12px/1 Inter, "PingFang SC", system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.14s ease;
}

.fw-collector-trigger:hover {
  background: rgba(214, 188, 137, 0.14);
  border-color: rgba(214, 188, 137, 0.6);
  color: #faf3e4;
}

.fw-collector-trigger:active {
  transform: scale(0.97);
}

@media (max-width: 767px) {
  .fw-collector-trigger {
    min-height: 38px;
    padding: 0 12px;
    margin-left: 0;
  }
}

.collector-modal {
  padding: 8px 4px 4px;
}

.builder-editor:has(.builder-preview.is-open) .builder-mobile-preview {
  display: none;
}

/* Gallery & Fusion Deck subtle 3D physical micro-tilt + metallic foil sweep */
@media (hover: hover) and (pointer: fine) {
  [data-fw-page="characters"] .fw-card[data-tilt-active="1"],
  .fusion-room .fusion-card[data-tilt-active="1"] {
    transform: perspective(900px) rotateX(var(--card-rx, 0deg)) rotateY(var(--card-ry, 0deg)) translateY(-3px) scale(1.014);
    transition: box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  [data-fw-page="characters"] .fw-card[data-tilt-active="1"] .fw-card-portrait::before,
  .fusion-room .fusion-card[data-tilt-active="1"]::before {
    background:
      linear-gradient(
        118deg,
        transparent 22%,
        rgba(214, 188, 137, 0.12) 45%,
        rgba(255, 248, 232, 0.16) 52%,
        transparent 74%
      ),
      radial-gradient(
        220px circle at var(--sheen-x, 50%) var(--sheen-y, 35%),
        rgba(248, 243, 232, 0.08),
        transparent 68%
      );
    background-size: 220% 220%, 100% 100%;
    background-position: var(--foil-x, 50%) var(--foil-y, 50%), 0 0;
    opacity: 1;
  }
}

/* Strict reduced-motion discipline: clean flat flip with zero 3D vertigo */
@media (prefers-reduced-motion: reduce) {
  .collector-tilt,
  .collector-rotor,
  .collector-art img {
    transition: none !important;
    transform: none !important;
  }
  .collector-face.is-front {
    transform: none !important;
  }
  .collector-face.is-back {
    transform: none !important;
    display: none;
  }
  .collector-card[data-flipped="true"] .collector-face.is-front {
    display: none;
  }
  .collector-card[data-flipped="true"] .collector-face.is-back {
    display: block;
  }
  .collector-foil,
  .collector-glare {
    display: none !important;
  }
  [data-fw-page="characters"] .fw-card[data-tilt-active="1"],
  .fusion-room .fusion-card[data-tilt-active="1"] {
    transform: none !important;
  }
}
