/* Card editor (design.html): 3D preview effects. Driven by assets/editor-fx.js.
 *
 * Print safety: the PNG download renders #cz-preview-front / #cz-preview-back
 * themselves, so nothing here goes inside them. Light, finish and tilt sit on
 * the surrounding .card-frame (siblings of the card), and the 3D viewer works
 * on copies. */

/* ---------- live preview: tilt, light, material finish ---------- */
.preview-backdrop { position: relative; perspective: 1100px; }
.card-frame {
  transform-style: preserve-3d;
  transform: rotateX(var(--fx-rx, 0deg)) rotateY(var(--fx-ry, 0deg));
  transition: transform .5s cubic-bezier(.2,.8,.2,1), box-shadow .4s ease;
  /* a visible edge, like a real card has thickness */
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 2px 0 rgba(0,0,0,.35), 0 18px 50px rgba(0,0,0,.5) !important;
}
.card-frame.fx-tilting { transition: transform .08s linear, box-shadow .4s ease; }
.fx-light, .fx-finish {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
}
.fx-light {
  background: radial-gradient(75% 95% at var(--fx-lx, 28%) var(--fx-ly, 18%), rgba(255,255,255,var(--fx-shine, .22)), transparent 62%);
  mix-blend-mode: soft-light; opacity: .9; transition: opacity .3s;
}
.fx-light::after {   /* a thin bright line passes over now and then */
  content: ''; position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  background: linear-gradient(105deg, transparent 42%, rgba(255,255,255,var(--fx-sweep, .22)) 50%, transparent 58%) no-repeat;
  background-size: 260% 100%; background-position: 160% 0;
  animation: fx-sweep 8s ease-in-out infinite; mix-blend-mode: overlay;
}
@keyframes fx-sweep { 0%, 72% { background-position: 160% 0; } 100% { background-position: -60% 0; } }

/* The material picked at the top of the page changes how the preview catches light. */
.fx-pvc   { --fx-shine: .26; --fx-sweep: .34; }
.fx-clear { --fx-shine: .3;  --fx-sweep: .4; }
.fx-gold, .fx-silver { --fx-shine: .5; --fx-sweep: .45; }
.fx-matte { --fx-shine: .12; --fx-sweep: .12; }
.fx-gold .fx-finish, .fx-silver .fx-finish {
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, rgba(0,0,0,.04) 1px 2px, rgba(255,255,255,0) 2px 4px);
  mix-blend-mode: overlay;
}
.fx-matte .fx-finish {   /* soft-touch: a fine, flat grain */
  background:
    radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 3px 3px,
    radial-gradient(rgba(0,0,0,.05) 1px, transparent 1px) 1px 1px / 3px 3px;
  mix-blend-mode: overlay;
}
/* Picking a material turns the card over once to show it off. */
.card-frame.fx-spin { animation: fx-spin .9s cubic-bezier(.3,1.2,.4,1); }
@keyframes fx-spin { from { transform: rotateY(-180deg) scale(.94); } to { transform: rotateY(0) scale(1); } }

/* ---------- "See it in 3D" button ---------- */
.fx3d-open {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 10px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.16); cursor: pointer;
  background: rgba(20,24,30,.72); color: #E9EEF3; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font: 600 12.5px/1 var(--font-ui, system-ui); transition: background .2s, transform .2s;
}
.fx3d-open:hover { background: rgba(13,197,180,.9); color: #04211E; transform: translateY(-1px); }
.fx3d-open svg { width: 15px; height: 15px; }
[dir="rtl"] .fx3d-open { right: auto; left: 10px; }
.preview-backdrop { padding-top: 52px !important; }
.fx3d-open--row { position: static; align-self: center; margin: 2px auto 0; }
@media (max-width: 880px) { .preview-backdrop { padding-top: 24px !important; } }

/* ---------- the 3D viewer ---------- */
.fx3d {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(70% 60% at 50% 40%, rgba(13,197,180,.16), transparent 70%), rgba(8,11,15,.86);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .3s ease;
}
.fx3d.is-open { opacity: 1; }
.fx3d__close {
  position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
[dir="rtl"] .fx3d__close { right: auto; left: 16px; }
.fx3d__stage { width: min(640px, 86vw); aspect-ratio: 1.586; perspective: 1400px; cursor: grab; touch-action: none;
  -webkit-user-select: none; user-select: none; }   /* dragging must not select the card's text */
.fx3d__stage:active { cursor: grabbing; }
.fx3d__card {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}
.fx3d__card.is-easing { transition: transform .8s cubic-bezier(.3,1.2,.4,1); }
.fx3d__face, .fx3d__edge { position: absolute; inset: 0; border-radius: 4.5% / 7.1%; }
.fx3d__face { overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; transform: translateZ(2px); }
.fx3d__back { transform: rotateY(180deg) translateZ(2px); }
.fx3d__edge { transform: translateZ(var(--z)); background: var(--edge, #2A2F37); }
.fx3d__face .preview-card { pointer-events: none; }
.fx3d__face .fx-light, .fx3d__face .fx-finish { z-index: 2; }
.fx3d__shadow {
  position: absolute; left: 10%; right: 10%; bottom: -14%; height: 18%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.55), transparent); filter: blur(10px);
  transform: translateZ(-60px) rotateX(80deg);
}
.fx3d__bar {
  position: absolute; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 999px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); white-space: nowrap;
}
.fx3d__bar button {
  border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer; background: transparent; color: #C9D1DB;
  font: 600 13px/1 var(--font-ui, system-ui);
}
.fx3d__bar button.is-on { background: #0DC5B4; color: #04211E; }
.fx3d__bar span { padding: 0 12px 0 6px; color: #8D9AAD; font: 500 12.5px/1 var(--font-ui, system-ui); }
@media (max-width: 520px) { .fx3d__bar span { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .fx-light::after { animation: none; }
  .card-frame.fx-spin { animation: none; }
}

/* ---------- "What you'll get": a small looping simulation ----------
   Left: a card is tapped on a phone and the assistant says hello.
   Right: the dashboard counts the tap. editor-fx.js adds .is-tap every few seconds. */
.capture-cards.sim { grid-template-columns: 1fr 1fr !important; gap: 12px; }
.sim-tile {
  position: relative; aspect-ratio: 1.586 / 1; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--line, #324158);
}
/* left tile */
.sim-card {
  position: absolute; left: 9%; top: 30%; width: 40%; aspect-ratio: 1.586; border-radius: 7px;
  background: linear-gradient(135deg, #1B4D6E, #0B2234); box-shadow: 0 8px 18px rgba(0,0,0,.35);
  padding: 7% 8%; display: flex; flex-direction: column; gap: 6%;
  transform: rotate(-8deg); transition: transform .7s cubic-bezier(.3,1.2,.4,1); z-index: 2;
}
.sim-card i { display: block; height: 7%; border-radius: 2px; background: rgba(255,255,255,.75); }
.sim-card i:nth-child(1) { width: 55%; height: 11%; background: #0DC5B4; }
.sim-card i:nth-child(2) { width: 38%; }
.sim-card i:nth-child(3) { width: 26%; opacity: .6; }
.sim-card svg { position: absolute; right: 8%; top: 10%; width: 18%; color: rgba(255,255,255,.7); }
.sim-phone {
  position: absolute; right: 8%; top: 12%; width: 34%; height: 76%; border-radius: 10px;
  border: 2px solid rgba(255,255,255,.22); background: rgba(10,14,20,.55);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; padding: 8% 7%;
}
.sim-bub {
  align-self: flex-start; max-width: 100%; padding: 4px 6px; border-radius: 7px 7px 7px 2px;
  background: rgba(13,197,180,.18); color: var(--text, #E9EEF3); font: 500 8px/1.2 var(--font-ui, system-ui); white-space: nowrap;
  opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .35s ease, transform .35s ease;
}
.sim-ring {
  position: absolute; left: 58%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  border: 2px solid #0DC5B4; opacity: 0; pointer-events: none;
}
.sim.is-tap .sim-card { transform: translateX(30%) rotate(-2deg); }
.sim.is-tap .sim-ring { animation: sim-ring .9s ease-out .45s; }
.sim.is-tap .sim-bub { opacity: 1; transform: none; transition-delay: .75s; }
.sim.is-tap .sim-bub--2 { transition-delay: 1.25s; }
@keyframes sim-ring { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(5); } }
/* right tile */
.sim-dash { padding: 9% 10%; display: flex; flex-direction: column; }
.sim-k { font: 600 9.5px/1 var(--font-ui, system-ui); color: var(--text-mute, #8D9AAD); letter-spacing: .02em; }
.sim-n { font: 700 26px/1.1 var(--font-display, system-ui); color: var(--text, #E9EEF3); margin-top: 4px; font-variant-numeric: tabular-nums; transition: color .3s; }
.sim.is-tap .sim-n { color: #0DC5B4; }
.sim-bars { flex: 1; display: flex; align-items: flex-end; gap: 6%; margin-top: 8%; }
.sim-bars i { flex: 1; border-radius: 3px 3px 0 0; background: rgba(141,154,173,.35); transition: height .6s cubic-bezier(.3,1.2,.4,1); }
.sim-bars i.sim-today { background: #0DC5B4; }
.sim-toast {
  position: absolute; right: 8%; top: 9%; padding: 4px 8px; border-radius: 999px;
  background: #0DC5B4; color: #04211E; font: 700 8.5px/1 var(--font-ui, system-ui);
  opacity: 0; transform: translateY(-8px); transition: opacity .3s ease, transform .3s ease;
}
.sim.is-tap .sim-toast { opacity: 1; transform: none; transition-delay: 1s; }
[dir="rtl"] .sim-toast { right: auto; left: 8%; }
@media (prefers-reduced-motion: reduce) {
  .sim-card, .sim-bub, .sim-toast, .sim-bars i { transition: none; }
  .sim .sim-bub, .sim .sim-toast { opacity: 1; transform: none; }
}
