/* ==========================================================================
   FUSIA STUDIO - ROOM-SPECIFIC MOTION LAYER
   Loaded after style.css. Delete this file + motion.js to roll everything back.
   Proofcut = frame-stepped film gate, Resonia = ripple from the dock tab,
   Veranda = paper lift with a warm light sweep.
   Only transform, opacity, clip-path and gradients are animated.
   ========================================================================== */

@property --p {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

.stage-frame,
.room-panel {
  position: relative;
}

/* Per-room transitions replace the generic child cut while a panel is entering */
.room-panel.is-entering-forward .room-info > *,
.room-panel.is-entering-forward .room-playground,
.room-panel.is-entering-backward .room-info > *,
.room-panel.is-entering-backward .room-playground {
  animation: none;
}

/* ---------- 1a. Proofcut: 24 fps film gate wipe + SMPTE tick ---------- */
.room-panel[data-room-panel="proofcut"].is-entering-forward {
  animation: pcGateFwd 0.5s steps(12, jump-end) backwards;
}

.room-panel[data-room-panel="proofcut"].is-entering-backward {
  animation: pcGateBack 0.5s steps(12, jump-end) backwards;
}

.room-panel[data-room-panel="proofcut"].is-entering-forward::before,
.room-panel[data-room-panel="proofcut"].is-entering-backward::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: #A5B4FC;
  box-shadow: 0 0 14px rgba(129, 140, 248, 0.85);
}

.room-panel[data-room-panel="proofcut"].is-entering-forward::before {
  animation: pcEdgeFwd 0.5s steps(12, jump-end) forwards;
}

.room-panel[data-room-panel="proofcut"].is-entering-backward::before {
  animation: pcEdgeBack 0.5s steps(12, jump-end) forwards;
}

.room-panel[data-room-panel="proofcut"].is-entering-forward::after,
.room-panel[data-room-panel="proofcut"].is-entering-backward::after {
  content: "00:00:00:01";
  position: absolute;
  top: 10px;
  left: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: #A5B4FC;
  white-space: nowrap;
}

.room-panel[data-room-panel="proofcut"].is-entering-forward::after {
  animation: pcTagFwd 0.5s steps(12, jump-end) forwards;
}

.room-panel[data-room-panel="proofcut"].is-entering-backward::after {
  animation: pcTagBack 0.5s steps(12, jump-end) forwards;
}

@keyframes pcGateFwd {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes pcGateBack {
  from { clip-path: inset(0 0 0 100%); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes pcEdgeFwd {
  0% { left: 0; opacity: 1; }
  92% { opacity: 1; }
  100% { left: calc(100% - 2px); opacity: 0; }
}

@keyframes pcEdgeBack {
  0% { left: calc(100% - 2px); opacity: 1; }
  92% { opacity: 1; }
  100% { left: 0; opacity: 0; }
}

@keyframes pcTagFwd {
  0% { left: 8px; opacity: 1; }
  92% { opacity: 1; }
  100% { left: calc(100% - 90px); opacity: 0; }
}

@keyframes pcTagBack {
  0% { left: calc(100% - 90px); opacity: 1; }
  92% { opacity: 1; }
  100% { left: 8px; opacity: 0; }
}

/* ---------- 1b. Resonia: ripple reveal from the dock tab ---------- */
.room-panel[data-room-panel="resonia"].is-entering-forward,
.room-panel[data-room-panel="resonia"].is-entering-backward {
  animation: rsReveal 0.72s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.room-panel[data-room-panel="resonia"].is-entering-forward::before,
.room-panel[data-room-panel="resonia"].is-entering-backward::before,
.room-panel[data-room-panel="resonia"].is-entering-forward::after,
.room-panel[data-room-panel="resonia"].is-entering-backward::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
}

.room-panel[data-room-panel="resonia"].is-entering-forward::before,
.room-panel[data-room-panel="resonia"].is-entering-backward::before {
  background: radial-gradient(
    circle at var(--ox, 50%) var(--oy, 0px),
    rgba(167, 139, 250, 0) calc(var(--p) - 3px),
    rgba(196, 181, 253, 0.6) calc(var(--p) - 1px),
    rgba(139, 92, 246, 0) calc(var(--p) + 46px)
  );
  animation: rsRing 0.72s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.room-panel[data-room-panel="resonia"].is-entering-forward::after,
.room-panel[data-room-panel="resonia"].is-entering-backward::after {
  background: radial-gradient(
    circle at var(--ox, 50%) var(--oy, 0px),
    rgba(167, 139, 250, 0) calc(var(--p) - 3px),
    rgba(167, 139, 250, 0.32) calc(var(--p) - 1px),
    rgba(139, 92, 246, 0) calc(var(--p) + 30px)
  );
  animation: rsRing 0.72s cubic-bezier(0.2, 0.8, 0.2, 1) 0.09s both;
}

@keyframes rsReveal {
  from { clip-path: circle(0px at var(--ox, 50%) var(--oy, 0px)); }
  to { clip-path: circle(var(--rr, 1400px) at var(--ox, 50%) var(--oy, 0px)); }
}

@keyframes rsRing {
  from { --p: 0px; opacity: 1; }
  to { --p: var(--rr, 1400px); opacity: 0; }
}

/* ---------- 1c. Veranda: paper lift + warm light sweep ---------- */
.room-panel[data-room-panel="veranda"].is-entering-forward,
.room-panel[data-room-panel="veranda"].is-entering-backward {
  animation: vrLift 0.72s var(--mg-ease) backwards;
}

.room-panel[data-room-panel="veranda"].is-entering-forward::after,
.room-panel[data-room-panel="veranda"].is-entering-backward::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  transform: translateX(-120%);
  background: linear-gradient(104deg, transparent 32%, rgba(255, 232, 190, 0.5) 50%, transparent 68%);
  animation: vrSweep 0.95s cubic-bezier(0.3, 0.1, 0.2, 1) 0.06s both;
}

@keyframes vrLift {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes vrSweep {
  from { transform: translateX(-120%); }
  to { transform: translateX(120%); }
}

/* Stage shadow takes on each room's light (existing 0.35s transition applies) */
.stage-frame[data-active-room="resonia"] {
  box-shadow: 0 22px 56px rgba(91, 61, 245, 0.2);
}

.stage-frame[data-active-room="veranda"] {
  box-shadow: 0 20px 52px rgba(150, 110, 60, 0.14);
}

/* ---------- 2. Logo reacts to the active room (after first switch only) ---------- */
.studio-mark-svg .fusia-stroke {
  transition: opacity 0.45s var(--mg-ease);
}

.studio-mark-svg[data-room] .fusia-stroke {
  opacity: 0.3;
}

.studio-mark-svg[data-room] .fusia-stroke.is-active-arc {
  opacity: 1;
}

.studio-mark-svg[data-room] .fusia-stroke.is-active-arc.s4,
.studio-mark-svg[data-room] .fusia-stroke.is-active-arc.s5,
.studio-mark-svg[data-room] .fusia-stroke.is-active-arc.s6 {
  stroke-opacity: 0.72;
}

.studio-mark-svg[data-room="proofcut"] .fusia-stroke.is-active-arc { stroke: var(--accent-proofcut); }
.studio-mark-svg[data-room="resonia"] .fusia-stroke.is-active-arc { stroke: var(--accent-resonia); }
.studio-mark-svg[data-room="veranda"] .fusia-stroke.is-active-arc { stroke: var(--accent-veranda); }

.studio-mark-svg[data-room] .fusia-stroke.is-redraw {
  animation: fusiaStrokeHover 0.7s var(--mg-ease) forwards;
}

/* ---------- 3. Dock thumb: JS spring owns transform + width, CSS tints the accent ---------- */
.room-dock-thumb.is-spring {
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
  will-change: transform, width;
}

.room-dock[data-room="proofcut"] .room-dock-thumb {
  border-color: rgba(79, 70, 229, 0.38);
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.12);
}

.room-dock[data-room="resonia"] .room-dock-thumb {
  border-color: rgba(91, 61, 245, 0.38);
  box-shadow: 0 2px 10px rgba(91, 61, 245, 0.14);
}

.room-dock[data-room="veranda"] .room-dock-thumb {
  border-color: rgba(184, 58, 56, 0.36);
  box-shadow: 0 2px 10px rgba(184, 58, 56, 0.12);
}

/* ---------- 4. Rules counter digit roll ---------- */
.rules-count {
  display: inline-flex;
  align-items: flex-start;
}

.rc-window {
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
}

.rc-track {
  display: flex;
  flex-direction: column;
  transition: transform 0.55s var(--mg-ease);
}

.rc-track > span {
  display: block;
  height: 1.2em;
  line-height: 1.2em;
}

.rc-total {
  white-space: pre;
  line-height: 1.2em;
}

/* ---------- 5. Pointer-following room light (desktop only, created by JS) ---------- */
.room-light {
  position: absolute;
  left: 0;
  top: 0;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  transition: opacity 0.45s ease;
  will-change: transform;
}

.room-light.is-on {
  opacity: 1;
}

.stage-frame[data-active-room="proofcut"] .room-light {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.16), rgba(99, 102, 241, 0) 62%);
  mix-blend-mode: screen;
}

.stage-frame[data-active-room="resonia"] .room-light {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0) 62%);
  mix-blend-mode: screen;
}

.stage-frame[data-active-room="veranda"] .room-light {
  background: radial-gradient(circle, rgba(255, 205, 130, 0.3), rgba(255, 205, 130, 0) 62%);
}

/* ---------- 6a. Copy button: stroke-drawn checkmark ---------- */
.copy-ico {
  display: inline-grid;
}

.copy-ico > svg {
  grid-area: 1 / 1;
  transition: opacity 0.18s ease;
}

.copy-ico .copy-ico-check {
  opacity: 0;
}

.copy-ico .copy-ico-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.copy-btn.is-copied .copy-ico-copy {
  opacity: 0;
}

.copy-btn.is-copied .copy-ico-check {
  opacity: 1;
}

.copy-btn.is-copied .copy-ico-check path {
  animation: copyCheckDraw 0.45s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.copy-label {
  display: inline-grid;
}

.copy-label > span {
  grid-area: 1 / 1;
  transition: opacity 0.18s ease;
}

.copy-label .cl-b {
  opacity: 0;
}

.copy-btn.is-copied .copy-label .cl-a {
  opacity: 0;
}

.copy-btn.is-copied .copy-label .cl-b {
  opacity: 1;
}

@keyframes copyCheckDraw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* ---------- 6b. FileSwift footer link: folded-page icon on hover (no layout shift) ---------- */
.footer-rooms a[href*="fileswift.app"] {
  position: relative;
}

.footer-rooms a[href*="fileswift.app"]::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 11px;
  height: 13px;
  margin-top: -6.5px;
  background: currentColor;
  opacity: 0;
  transform: translateX(4px) scale(0.85);
  transition: opacity 0.22s ease, transform 0.3s var(--spring);
  pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M6 2h8l5 5v15H6z'/%3E%3Cpath d='M14 2v5h5'/%3E%3Cpath d='M12.5 10l-3 5h3l-1 4 3.5-5.5h-3z' fill='black' stroke-width='1'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M6 2h8l5 5v15H6z'/%3E%3Cpath d='M14 2v5h5'/%3E%3Cpath d='M12.5 10l-3 5h3l-1 4 3.5-5.5h-3z' fill='black' stroke-width='1'/%3E%3C/svg%3E") center / contain no-repeat;
}

.footer-rooms a[href*="fileswift.app"]:hover::before,
.footer-rooms a[href*="fileswift.app"]:focus-visible::before {
  opacity: 0.9;
  transform: none;
}

/* ---------- Reduced motion safety net for everything above ---------- */
@media (prefers-reduced-motion: reduce) {
  .room-panel.is-entering-forward,
  .room-panel.is-entering-backward {
    animation: none !important;
    clip-path: none !important;
  }

  .room-panel.is-entering-forward::before,
  .room-panel.is-entering-backward::before,
  .room-panel.is-entering-forward::after,
  .room-panel.is-entering-backward::after {
    display: none !important;
  }

  .studio-mark-svg[data-room] .fusia-stroke.is-redraw {
    animation: none !important;
  }

  .rc-track,
  .room-dock-thumb.is-spring,
  .copy-ico > svg,
  .copy-label > span,
  .footer-rooms a[href*="fileswift.app"]::before {
    transition: none !important;
  }

  .copy-btn.is-copied .copy-ico-check path {
    animation: none !important;
    stroke-dashoffset: 0;
  }

  .room-light {
    display: none !important;
  }
}
