* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #050607;
  --fg: #c8c8c8;
  --fg-dim: #555;
  --fg-bright: #f0f0f0;
  --accent: #888;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: "Rethink Sans", sans-serif;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* ── ASCII background ── */

#ascii-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── Canvas ── */

#canvas {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: visible;
  z-index: 1;
}

#world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#world.animating {
  transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ── Nodes ── */

.node {
  position: absolute;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.3s ease;
}

.node-symbol {
  position: relative;
  font-size: 20px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.node-label {
  position: relative;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--fg-dim);
  white-space: nowrap;
  transition: color 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.node:hover .node-symbol {
  opacity: 1;
  transform: scale(1.3);
}

.node:hover .node-label {
  color: var(--fg);
  opacity: 1;
}

/* Dot beneath each node — always visible anchor point */
.node-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--fg-dim);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.3s ease, box-shadow 0.3s ease;
  pointer-events: none;
}

.node:hover .node-dot {
  background: var(--fg);
  box-shadow: 0 0 8px rgba(200, 200, 200, 0.4);
}

/* ── Title (fixed top-left, clickable home) ── */

.site-title {
  position: fixed;
  top: 20px;
  left: 24px;
  font-family: "Ubuntu Condensed", sans-serif;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 50;
}

/* ── Stacked paper effect — shared by all interactive text ── */

.stacked-text {
  position: relative;
}

.stacked-text::before,
.stacked-text::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.3s ease;
}

.stacked-text::before {
  color: #7a5c3a;
}

.stacked-text::after {
  color: #3a5c6a;
}

/* Title hover */
.site-title:hover {
  color: var(--fg-bright);
}

.site-title:hover::before {
  opacity: 0.5;
  transform: translate(-2px, -3px);
}

.site-title:hover::after {
  opacity: 0.4;
  transform: translate(2px, 3px);
}

.site-title:active::before {
  opacity: 0.6;
  transform: translate(-4px, -5px);
}

.site-title:active::after {
  opacity: 0.5;
  transform: translate(4px, 5px);
}

/* Node label hover — triggered by parent .node:hover */
.node:hover .node-label::before {
  opacity: 0.5;
  transform: translate(-2px, -2px);
}

.node:hover .node-label::after {
  opacity: 0.4;
  transform: translate(2px, 2px);
}

.node:active .node-label::before {
  opacity: 0.6;
  transform: translate(-3px, -4px);
}

.node:active .node-label::after {
  opacity: 0.5;
  transform: translate(3px, 4px);
}

/* Node symbol hover — same effect on the symbol character */
.node:hover .node-symbol::before {
  opacity: 0.4;
  transform: translate(-2px, -2px);
}

.node:hover .node-symbol::after {
  opacity: 0.3;
  transform: translate(2px, 2px);
}

/* ── Preview node (live shader embed, transparent bg) ── */
/* The iframe renders at a high internal resolution (--preview-src)
   and is CSS-scaled down to the visual display size (--preview-display).
   This supersamples the shader so it looks crisp on the constellation. */

:root {
  --preview-display: 1199px;  /* visual size on the constellation */
  --preview-src: 1360px;      /* internal render resolution of the iframe */
  --preview-scale: 0.882;     /* preview-display / preview-src */
}

.node.has-preview {
  width: var(--preview-display);
  height: var(--preview-display);
  display: block;
  transform: translate(-50%, -50%);
  padding: 0;
  gap: 0;
  background: transparent;
}

.node-preview {
  width: var(--preview-src);
  height: var(--preview-src);
  border: none;
  display: block;
  pointer-events: none;
  mix-blend-mode: lighten;
  transform: scale(var(--preview-scale));
  transform-origin: 0 0;
}

/* ── Playable node (interactive game embed, scaled up) ── */
/* The iframe renders at native size (--playable-src) and is CSS-scaled
   up to the display size (--playable-display × --playable-scale). */

:root {
  --playable-src-w: 425px;
  --playable-src-h: 765px;
  --playable-scale: 1.2;
  --playable-display-w: 510px;  /* src-w × scale */
  --playable-display-h: 918px; /* src-h × scale */
}

.node.has-playable {
  width: var(--playable-display-w);
  height: var(--playable-display-h);
  display: block;
  transform: translate(-50%, -50%) scale(var(--thumb-scale, 0.84));
  padding: 0;
  gap: 0;
  cursor: default;
  overflow: hidden;
  border-radius: 20px;
  transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none; /* prevent layout box from blocking other nodes */
}

/* Real DOM hit target — activates the node on hover so first interaction
   goes directly to the game, not to an "activate" click. Hidden when active. */
.playable-hitzone {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
  pointer-events: auto; /* override inherited none from parent */
}

.node.has-playable:hover {
  transform: translate(-50%, -50%) scale(1);
}

.node.has-playable.active {
  transform: translate(-50%, -50%) scale(var(--zoom-scale, 1));
  pointer-events: auto;
  cursor: default;
  z-index: 10;
  overflow: visible;
  transition: transform 0.15s ease-out;
}

.node.has-playable.active .playable-hitzone {
  display: none;
}

.node-playable {
  width: var(--playable-src-w);
  height: var(--playable-src-h);
  border: none;
  display: block;
  border-radius: 20px;
  background: transparent;
  transform: scale(var(--playable-scale));
  transform-origin: 0 0;
  pointer-events: none;
}

.node.has-playable.active .node-playable {
  pointer-events: auto;
}

/* ── Video card stack — 9:16 portrait (1080×1920) ── */

.video-stack {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 360px;
  height: 640px;
  z-index: 10;
}

/* Invisible hit-area: starts at the stacked size, expands to cover
   the full spread only once hovered (so nearby mousing doesn't trigger it) */
.video-stack::before {
  content: '';
  position: absolute;
  left: -16px;
  right: -16px;
  top: -16px;
  bottom: -16px;
  transition: left 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
              right 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.video-stack:hover::before {
  left: -425px;
  right: -425px;
}

.video-card {
  position: absolute;
  width: 360px;
  height: 640px;
  cursor: pointer;
  transition:
    transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity   0.25s ease;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Stack — default. Card 1 centered at stack origin so hover hitbox aligns. */
.video-card:nth-child(1) { transform: translate(  0px,  0px) rotate(-4deg); z-index: 3; }
.video-card:nth-child(2) { transform: translate( 30px,-20px) rotate( 1deg); z-index: 2; }
.video-card:nth-child(3) { transform: translate( 59px,-34px) rotate( 6deg); z-index: 1; }

/* Spread — hover. --video-offset shifts the whole fan if it would clip the screen edge */
.video-stack:hover .video-card:nth-child(1) { transform: translate(calc(var(--video-offset, 0px) + -400px), 0) rotate(-1deg); z-index: 1; }
.video-stack:hover .video-card:nth-child(2) { transform: translate(calc(var(--video-offset, 0px) +    0px), 0) rotate( 0deg); z-index: 2; }
.video-stack:hover .video-card:nth-child(3) { transform: translate(calc(var(--video-offset, 0px) +  400px), 0) rotate( 1deg); z-index: 3; }

/* Playing state — dim inactive cards */
.video-stack.has-playing .video-card:not(.playing) { opacity: 0.25; }
.video-stack.has-playing .video-card.playing       { z-index: 10; }

/* Mobile — always spread (no hover) */
@media (pointer: coarse) {
  .video-card:nth-child(1) { transform: translate(calc(var(--video-offset, 0px) + -400px), 0) rotate(0deg); z-index: 1; }
  .video-card:nth-child(2) { transform: translate(calc(var(--video-offset, 0px) +    0px), 0) rotate(0deg); z-index: 2; }
  .video-card:nth-child(3) { transform: translate(calc(var(--video-offset, 0px) +  400px), 0) rotate(0deg); z-index: 3; }
}

/* ── Fade-out overlay for dive animation ── */

#dive-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 100;
}

#dive-overlay.active {
  opacity: 1;
}

/* ── Mobile ── */

@media (pointer: coarse) {
  /* Bigger touch targets on touch devices */
  .node:not(.has-preview):not(.has-playable) {
    padding: 16px;
    margin: -16px;
  }

  /* Labels always visible on mobile (no hover) */
  .node-label {
    opacity: 0.6;
  }

  .node-symbol {
    font-size: 24px;
  }

  .node-dot {
    width: 5px;
    height: 5px;
  }
}

@media (max-width: 480px) {
  .site-title {
    font-size: 13px;
    top: 16px;
    left: 16px;
  }
}

/* ── Mobile vertical scroll layout ── */

@media (max-width: 768px) {
  html, body {
    overflow: visible;
    overflow-x: hidden;
    touch-action: auto;
    cursor: auto;
    height: auto;
  }

  #canvas {
    position: relative;
    z-index: 1;
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 80px 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
  }

  #world {
    position: static;
    width: 100%;
    max-width: 400px;
    height: auto;
    transform: none !important;
    will-change: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
  }

  /* ── Nodes as vertical cards ── */

  .node {
    position: static;
    left: auto !important;
    top: auto !important;
    width: 100%;
    max-width: 400px;
  }

  /* Gloopy-booper preview card */
  .node.has-preview {
    width: 100%;
    max-width: 400px;
    height: 300px;
    transform: none;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
  }

  .node-preview {
    width: 100%;
    height: 100%;
    transform: none;
    mix-blend-mode: normal;
  }

  /* Playable game thumbnail cards */
  .node.has-playable {
    width: 100%;
    max-width: 400px;
    height: 280px;
    transform: none;
    pointer-events: auto;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
  }

  .node.has-playable .node-playable {
    width: 100%;
    height: 100%;
    transform: none;
    pointer-events: none;
    border-radius: 12px;
  }

  .node.has-playable .playable-hitzone {
    display: none;
  }

  .node.has-playable.active,
  .node.has-playable:hover {
    transform: none;
    overflow: hidden;
    z-index: auto;
  }

  /* ── Video carousel ── */

  .video-stack {
    position: static;
    transform: none;
    left: auto !important;
    top: auto !important;
    width: 100vw;
    height: auto;
    margin-left: -20px;
    margin-right: -20px;
    padding: 0 20px;
    display: flex;
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: auto;
  }

  .video-stack::-webkit-scrollbar {
    display: none;
  }

  .video-stack::before {
    display: none;
  }

  .video-card {
    position: static;
    flex: 0 0 75vw;
    max-width: 320px;
    height: auto;
    aspect-ratio: 9 / 16;
    scroll-snap-align: center;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  }

  .video-card:nth-child(1),
  .video-card:nth-child(2),
  .video-card:nth-child(3) {
    transform: none !important;
    z-index: auto;
  }

  /* ── Content ordering ── */

  .video-stack                     { order: 1; }
  .node[data-id="gloopy-booper"]  { order: 2; }
  .node[data-id="gem-crush"]      { order: 3; }
  .node[data-id="pottery-master"] { order: 4; }
}


/* ── Pigeon node ── */
.node.has-static {
  pointer-events: auto;
  background: transparent;
  transform: translate(-50%, -50%);
}

.pigeon-node {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.pigeon-text {
  font-family: Arial, Helvetica, sans-serif;
  color: #f5d623;
  font-size: 28px;
  font-weight: bold;
  line-height: 1.1;
  white-space: nowrap;
}

.pigeon-img {
  width: 320px;
  height: auto;
  user-select: none;
}

.pigeon-contact {
  font-family: Arial, Helvetica, sans-serif;
  color: #999;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
}

.pigeon-contact:hover {
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ── Pottery UI (parent-page overlay for pottery exhibit) ── */

#pottery-ui {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(20, 20, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: "Ubuntu Condensed", "Rethink Sans", sans-serif;
  font-size: 13px;
  color: var(--fg);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.pottery-ui-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#pottery-ui button {
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  transition: background 0.15s;
}

#pottery-ui button:hover {
  background: rgba(255, 255, 255, 0.14);
}

#pottery-ui select {
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
}

#pottery-ui input[type="color"] {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: transparent;
}

.pottery-ui-size {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-dim);
  cursor: default;
}

#pottery-ui input[type="range"] {
  width: 80px;
}
