/*
 * 3D depth layer. Every rule here targets classes added by the depth3d-*.js files,
 * so removing the include lines removes all of it. Timing and easing are shared.
 */
:root {
  --d3-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --d3-slow: 0.45s;
}

/* ---------- Card depth ---------- */
/* Cards keep no transform at rest, so text renders exactly as before. */
.depth3d-card {
  transition:
    transform var(--d3-slow) var(--d3-ease),
    box-shadow var(--d3-slow) var(--d3-ease),
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.depth3d-card.is-tilting {
  transition:
    transform 0.12s linear,
    box-shadow var(--d3-slow) var(--d3-ease),
    border-color 0.2s ease,
    background-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .depth3d-card:hover,
  .depth3d-card.is-tilting {
    transform: perspective(900px) rotateX(var(--d3-rx, 0deg)) rotateY(var(--d3-ry, 0deg)) translateY(-3px);
    box-shadow: 0 22px 44px -22px rgba(2, 6, 23, 0.85), 0 0 0 1px rgba(147, 197, 253, 0.12);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .depth3d-card:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 18px 38px -22px rgba(2, 6, 23, 0.8), 0 0 0 1px rgba(147, 197, 253, 0.16);
  }
}

@media (prefers-reduced-motion: reduce) {
  .depth3d-card {
    transition: border-color 0.2s ease, background-color 0.2s ease;
  }
}

/* ---------- Homepage cell ---------- */
.depth3d-host {
  position: relative;
}

.depth3d-cell {
  position: absolute;
  top: 14px;
  right: 22px;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 1.2s var(--d3-ease), transform 1.2s var(--d3-ease);
}

.depth3d-cell.is-ready {
  opacity: 1;
  transform: none;
}

.depth3d-cell canvas {
  display: block;
}

@media (max-width: 1099.98px) {
  .depth3d-cell {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .depth3d-cell {
    transition: none;
    transform: none;
  }
}

/* ---------- YAP/TAZ 3D circuit ---------- */
.y3d {
  margin: 0 0 1rem;
}

.y3d-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}

.y3d-tag {
  color: #93c5fd;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.y3d-btn {
  min-height: 34px;
  padding: 0.35rem 0.8rem;
  border: 1px solid rgba(147, 197, 253, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #e8f1ff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.y3d-btn:hover {
  border-color: rgba(147, 197, 253, 0.7);
  background: rgba(37, 99, 235, 0.28);
}

.y3d-btn:focus-visible,
.y3d-stage:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: 2px;
}

.y3d-icon {
  width: 34px;
  padding: 0;
  font-size: 1.1rem;
}

.y3d-stage {
  position: relative;
  height: clamp(320px, 38vw, 430px);
  overflow: hidden;
  border: 1px solid rgba(147, 197, 253, 0.18);
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(37, 99, 235, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(8, 13, 24, 0.9), rgba(5, 9, 18, 0.95));
  touch-action: pan-y;
}

.y3d-stage[hidden] {
  display: none;
}

.y3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.8s var(--d3-ease);
}

.y3d-stage.is-ready .y3d-canvas {
  opacity: 1;
}

.y3d-stage.is-dragging .y3d-canvas {
  cursor: grabbing;
}

.y3d-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.y3d-label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem 0.22rem 0.3rem;
  border: 1px solid color-mix(in srgb, var(--y3d-color, #93c5fd) 35%, transparent);
  border-radius: 999px;
  background: rgba(6, 11, 22, 0.78);
  color: #dbe7fb;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
  transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.y3d-label b {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.25rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--y3d-color, #93c5fd) 18%, transparent);
  color: var(--y3d-color, #93c5fd);
  font-size: 0.7rem;
}

.y3d-label.is-active {
  border-color: var(--y3d-color, #93c5fd);
  background: rgba(10, 18, 34, 0.94);
  color: #ffffff;
}

.y3d-label[hidden] {
  display: none;
}

.y3d-stage.is-compact .y3d-label span {
  display: none;
}

.y3d-stage.is-compact .y3d-label {
  padding: 0.2rem;
}

.y3d-tools {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  display: flex;
  gap: 0.4rem;
}

.y3d-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: #b0c2df;
  font-size: 0.9rem;
}

.y3d-status[hidden] {
  display: none;
}

.y3d-note {
  margin: 0.55rem 0 0;
  color: #b0c2df;
  font-size: 0.82rem;
  line-height: 1.5;
}

.y3d-note[hidden] {
  display: none;
}

@media (max-width: 599.98px) {
  .y3d-stage {
    height: 250px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .y3d-canvas {
    transition: none;
  }
}

/* Context stages (not selectable): shown for orientation only. */
.y3d-label.is-context {
  pointer-events: none;
  cursor: default;
  opacity: 0.85;
  border-style: dashed;
}

/* Homepage highlighted study: 3D view above Figure 1, aligned with the figure. */
.c3d-home {
  margin: 0 1.1rem 0.9rem;
}

.c3d-home .y3d-stage {
  height: clamp(300px, 34vw, 380px);
}

.circuit-node.is-3d-focus {
  border-color: rgba(147, 197, 253, 0.7);
  box-shadow: inset 0 -2px 0 #60a5fa;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

@media (max-width: 767.98px) {
  .c3d-home {
    margin: 0 0.75rem 0.8rem;
  }
}

@media (max-width: 599.98px) {
  .c3d-home .y3d-stage {
    height: 250px;
  }
}

/* ---------- YAP/TAZ thought experiment: realistic 3D cell ---------- */
#thought-cell-stage {
  position: relative;
}

.t3d {
  position: relative;
  display: none;
  min-height: 320px;
  overflow: hidden;
}

#thought-cell-stage.t3d-on .t3d {
  display: block;
}

#thought-cell-stage.t3d-on > svg {
  display: none;
}

.t3d-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.9s var(--d3-ease);
  touch-action: pan-y;
}

.t3d.is-ready .t3d-canvas {
  opacity: 1;
}

.t3d.is-dragging .t3d-canvas {
  cursor: grabbing;
}

.t3d-tag {
  position: absolute;
  top: 0.7rem;
  left: 0.8rem;
  z-index: 2;
  color: #93c5fd;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
}

.t3d-labels {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.t3d-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.15rem 0.45rem;
  border: 1px solid rgba(147, 197, 253, 0.3);
  border-radius: 999px;
  background: rgba(4, 10, 22, 0.66);
  color: #dbe7fb;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
  will-change: transform;
}

.t3d-toggle {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  z-index: 3;
  min-height: 30px;
  padding: 0.25rem 0.7rem;
  border: 1px solid rgba(147, 197, 253, 0.32);
  border-radius: 999px;
  background: rgba(8, 15, 30, 0.8);
  color: #e8f1ff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.t3d-toggle:hover {
  border-color: rgba(147, 197, 253, 0.7);
}

.t3d-toggle:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: 2px;
}

.t3d-toggle[hidden] {
  display: none;
}

@media (max-width: 599.98px) {
  .t3d {
    min-height: 270px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .t3d-canvas {
    transition: none;
  }
}

.t3d.is-narrow .t3d-labels {
  display: none;
}
