/* ============================================================
   WallNext — wn-animations.css
   UI mockup animations: Workspace · Server · Player
   Platform Diagram: sources > hub > outputs sequence
   Depends on: main.css (design tokens --c-*, --f-*)
   Reusable: link this file on any page that uses wn-anim-* components.
   ============================================================ */

/* ============================================================
   LOCAL TOKENS
   Status colours and ease not present in main.css
   ============================================================ */
:root {
  --wn-status-ok:    #3DBE82;
  --wn-status-warn:  #F0B040;
  --wn-status-alert: #E55A4D;
  --wn-cyan-soft:    rgba(54, 169, 225, 0.10);
  --wn-cyan-line:    rgba(54, 169, 225, 0.35);
  --wn-ease:         cubic-bezier(0.2, 0.0, 0.2, 1);
}

/* ============================================================
   ANIMATION VISIBILITY SYSTEM
   Elements start invisible; GSAP takes over when in viewport.
   ============================================================ */
[data-animate] {
  opacity: 0;
}

[data-animate].is-visible {
  opacity: 1;
}

/* ============================================================
   SHARED UTILITIES
   ============================================================ */
.wn-anim-wrapper {
  width: 100%;
  max-width: 560px;
}

/* Pulse animation for live indicators */
@keyframes wn-pulse-live {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.wn-live-pulse {
  animation: wn-pulse-live 2s ease-in-out infinite;
}

/* ============================================================
   FEATURE 1 — WallNext Workspace UI
   ============================================================ */

.workspace-frame {
  background: #1a1a1a;
  border: 1px solid #222;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 72px rgba(13, 26, 46, 0.55);
}

.workspace-topbar {
  background: #1a1a1a;
  border-bottom: 1px solid #2c2c2c;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ws-label {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}

.ws-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--wn-status-ok);
}

.ws-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  height: 320px;
}

.ws-sidebar {
  background: #222;
  border-right: 1px solid #2c2c2c;
  padding: 12px 0;
}

.ws-sidebar-section {
  padding: 0 12px;
  margin-bottom: 16px;
}

.ws-sidebar-label {
  font-family: var(--f-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 6px;
}

.ws-source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms;
}

.ws-source-item:hover { background: rgba(54,169,225,0.08); }
.ws-source-item.active {
  background: var(--wn-cyan-soft);
  border-left: 2px solid var(--c-accent);
}

.ws-source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ws-source-name {
  font-family: var(--f-body);
  font-size: 0.75rem;
  color: #ccc;
}

.ws-source-badge {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.06em;
  color: #555;
  text-transform: uppercase;
}

.ws-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 6px;
  background: #111;
}

.ws-panel {
  background: #1a1a1a;
  border: 1px solid #2c2c2c;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ws-panel.ws-panel-large {
  grid-column: 1 / 2;
  grid-row: 1 / 3;
}

.ws-panel-label {
  position: absolute;
  top: 8px;
  left: 8px;
  font-family: var(--f-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ccc;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 6px;
  border-radius: 3px;
}

.ws-panel-feed {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a2a1a 0%, #2a3a2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ws-panel-icon {
  opacity: 0.2;
  color: var(--c-accent);
}

.ws-panel-indicator {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wn-status-ok);
  box-shadow: 0 0 6px var(--wn-status-ok);
}

/* Workspace — full width when layout stacks to single column (matches main.css 860px breakpoint) */
@media (max-width: 860px) {
  .wn-anim-wrapper { max-width: 100%; }
  .workspace-frame { border-radius: 6px; }
  .ws-sidebar { display: none; }
  .ws-body { grid-template-columns: 1fr; height: 300px; }
  .ws-panel-label { font-size: 0.5625rem; padding: 3px 6px; }
}

/* ============================================================
   FEATURE 2 — WallNext Server UI
   ============================================================ */

.server-ui {
  background: #1a1a1a;
  border: 1px solid #222;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 72px rgba(13, 26, 46, 0.55);
  font-family: var(--f-body);
  display: flex;
  flex-direction: column;
}

/* Topbar */
.server-topbar {
  background: #1a1a1a;
  border-bottom: 1px solid #2c2c2c;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
}

/* Body */
.server-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Main content area */
.server-main {
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
}

.server-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #2c2c2c;
  flex-shrink: 0;
}

.server-btn-add {
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.server-btn-secondary-group { display: flex; gap: 5px; }

.server-btn-secondary {
  background: transparent;
  color: #666;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Table header */
.server-table-header {
  display: grid;
  grid-template-columns: 26px 1fr 90px;
  gap: 8px;
  align-items: center;
  padding: 6px 16px;
  border-bottom: 1px solid #2c2c2c;
  background: #1e1e1e;
  flex-shrink: 0;
}

.server-th {
  font-family: var(--f-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #444;
}

/* Source list */
.server-source-list {
  flex: 1;
  overflow-y: auto;
}

.server-source-list::-webkit-scrollbar { display: none; }

.server-source-row {
  display: grid;
  grid-template-columns: 26px 1fr 90px;
  gap: 8px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid #252525;
  transition: background 150ms;
  background: #1a1a1a;
}

.server-source-row:hover { background: #212121; }
.server-source-row:last-child { border-bottom: none; }

.source-check-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

.source-checkbox {
  width: 13px;
  height: 13px;
  border: 1px solid #3a3a3a;
  border-radius: 2px;
  background: transparent;
  flex-shrink: 0;
}

.source-name-col {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.source-type-icon {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(54,169,225,0.08);
  flex-shrink: 0;
}

.source-name {
  font-size: 0.8125rem;
  color: #ccc;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-type-label {
  font-family: var(--f-mono);
  font-size: 0.625rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #555;
}

.source-type-col {
  font-size: 0.8125rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-state-col {
  display: flex;
  align-items: center;
}

.source-status-pill {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 3px;
  white-space: nowrap;
}

.source-status-pill.live {
  color: var(--wn-status-ok);
  background: rgba(61, 190, 130, 0.1);
  border: 1px solid rgba(61, 190, 130, 0.25);
}

.source-status-pill.standby {
  color: var(--wn-status-warn);
  background: rgba(240, 176, 64, 0.1);
  border: 1px solid rgba(240, 176, 64, 0.25);
}

.source-status-pill.offline {
  color: var(--wn-status-alert);
  background: rgba(229, 90, 77, 0.1);
  border: 1px solid rgba(229, 90, 77, 0.25);
}

.source-device-col {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  color: #666;
}

.source-inuse-col {
  font-family: var(--f-mono);
  font-size: 0.8125rem;
  color: #666;
  text-align: center;
}


/* ============================================================
   FEATURE 3 — WallNext Player UI
   ============================================================ */

.player-app {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 72px rgba(13, 26, 46, 0.55);
  border: 1px solid #222;
  background: #1a1a1a;
  font-family: var(--f-body);
  position: relative;
}

/* Animated cursor */
.demo-cursor {
  position: absolute;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 400;
  opacity: 0;
  transform-origin: top left;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Click ripple ring */
.demo-click-ring {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--c-accent);
  pointer-events: none;
  z-index: 399;
  opacity: 0;
  transform: scale(0.3);
  margin-left: -4px;
  margin-top: -4px;
}

/* Layout selector dropdown */
.demo-dropdown {
  position: absolute;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 4px 0;
  z-index: 300;
  min-width: 130px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0;
  transform-origin: top left;
  pointer-events: none;
  overflow: hidden;
}

.demo-dropdown-item {
  padding: 7px 12px;
  font-size: 0.75rem;
  color: #bbb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background 100ms;
  white-space: nowrap;
}

.demo-dropdown-item.is-current {
  color: #666;
}

.demo-dropdown-item.is-highlighted {
  background: rgba(54,169,225,0.15);
  color: var(--c-accent);
}

.demo-dropdown-item-badge {
  font-family: var(--f-mono);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #555;
  background: #333;
  padding: 1px 5px;
  border-radius: 2px;
}

/* APPLY button active state */
.player-sidebar-apply.is-active {
  background: var(--c-accent);
  color: #fff;
  cursor: pointer;
  transition: background 300ms var(--wn-ease);
}

/* Wall transition flash */
.player-wall.is-switching .pw-cell {
  transition: opacity 150ms ease;
  opacity: 0.3;
}

/* Replay / pause button */
.demo-replay-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(180, 180, 190, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 150;
  transition: background 200ms, transform 150ms;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.demo-replay-btn:hover {
  background: rgba(160, 160, 172, 0.90);
  transform: scale(1.08);
}

.demo-replay-btn:active {
  transform: scale(0.94);
}

.demo-replay-btn svg {
  display: block;
  color: rgba(50, 50, 60, 0.88);
  transition: opacity 150ms;
}

@keyframes wn-spin-once {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.demo-replay-btn.is-spinning svg {
  animation: wn-spin-once 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Player top bar */
.player-topbar {
  background: #1a1a1a;
  border-bottom: 1px solid #2c2c2c;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
}

.player-topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Player body: sidebar + canvas */
.player-body {
  display: flex;
  height: 340px;
}

/* Sidebar */
.player-sidebar {
  width: 150px;
  flex-shrink: 0;
  background: #222;
  border-right: 1px solid #2c2c2c;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.player-sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2c2c2c;
}

.player-sidebar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--c-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-heading);
  font-size: 0.625rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.player-sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.player-sidebar-username {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #ccc;
  line-height: 1.2;
}

.player-sidebar-role {
  font-size: 0.5625rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.player-sidebar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-sidebar-label {
  font-size: 0.5625rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-family: var(--f-mono);
}

.player-sidebar-select {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 0.6875rem;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 150ms;
}

.player-sidebar-select:hover { border-color: #555; }
.player-sidebar-select svg { color: #555; }

.player-sidebar-apply {
  background: #333;
  border: none;
  border-radius: 4px;
  padding: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  cursor: default;
}

.player-sidebar-volume {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-sidebar-volume svg { color: #555; flex-shrink: 0; }

.player-volume-track {
  flex: 1;
  height: 3px;
  background: #3a3a3a;
  border-radius: 2px;
  position: relative;
}

.player-volume-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 35%;
  background: var(--c-accent);
  border-radius: 2px;
}

.player-volume-thumb {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-accent);
  top: 50%;
  left: 35%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(54,169,225,0.2);
}

.player-sidebar-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-sidebar-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.625rem;
  color: #777;
  cursor: pointer;
}

.player-check-box {
  width: 12px;
  height: 12px;
  border: 1px solid #444;
  border-radius: 2px;
  background: transparent;
  flex-shrink: 0;
}

/* Video wall canvas */
.player-canvas {
  flex: 1;
  background: #111;
  padding: 6px;
  display: flex;
  align-items: stretch;
}

/* 4K07 layout: 3 cols, 3 rows */
.player-wall {
  flex: 1;
  display: grid;
  grid-template-columns: 54fr 23fr 23fr;
  grid-template-rows:    30fr 25fr 45fr;
  gap: 3px;
}

.pw-cell {
  background: #888;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cell positions */
.pw-a { grid-column: 1;     grid-row: 1 / 3; }
.pw-b { grid-column: 2;     grid-row: 1;     }
.pw-c { grid-column: 3;     grid-row: 1;     }
.pw-d { grid-column: 2;     grid-row: 2;     }
.pw-e { grid-column: 3;     grid-row: 2;     }
.pw-f { grid-column: 1;     grid-row: 3;     }
.pw-g { grid-column: 2 / 4; grid-row: 3;     }

.pw-source {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
}

.pw-source-label {
  font-family: var(--f-mono);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border-radius: 2px;
}

.pw-cell.is-active {
  outline: 1.5px solid var(--c-accent);
  outline-offset: -1.5px;
}

/* Subtle scanline texture */
.pw-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.04) 2px,
    rgba(0,0,0,0.04) 4px
  );
  pointer-events: none;
}

/* ============================================================
   PLATFORM DIAGRAM ANIMATION
   Sources -> Connector -> Hub -> Connector -> Outputs
   Trigger: data-observe="platform-diagram" (IntersectionObserver)
   ============================================================ */

/* Connector SVG paths: hidden initially for stroke-draw effect.
   GSAP reads getTotalLength() and overrides these values at runtime. */
[data-diag="connector-left"] svg line,
[data-diag="connector-left"] svg polyline,
[data-diag="connector-right"] svg line,
[data-diag="connector-right"] svg polyline {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
}

/* Connector wrapper: hidden until JS reveals */
[data-diag="connector-left"],
[data-diag="connector-right"] {
  opacity: 0;
}

/* Sources column: slides in from the left */
[data-diag="sources"] {
  opacity: 0;
  transform: translateX(-24px);
}

/* Outputs column: slides in from the right */
[data-diag="outputs"] {
  opacity: 0;
  transform: translateX(24px);
}

/* Hub: scales up from center */
[data-diag="hub"] {
  opacity: 0;
  transform: scale(0.88);
}

/* Individual cards within sources and outputs */
[data-diag-card] {
  opacity: 0;
  transform: translateY(10px);
}

/* Once JS triggers, transitions are handled by GSAP.
   CSS transforms here serve only as the pre-animation state.
   will-change hints for GPU compositing. */
[data-diag="sources"],
[data-diag="outputs"],
[data-diag="hub"],
[data-diag="connector-left"],
[data-diag="connector-right"],
[data-diag-card] {
  will-change: opacity, transform;
}
