/* ===== Page ===== */
body {
  margin: 0;
  background: #0000FF;
  font-family: "Work Sans", system-ui, sans-serif;
  overflow: hidden;
}

.site-title {
  position: fixed;
  top: 50%;
  left: 0;
  width: 100%;
  transform: translateY(-50%);
  z-index: 1; /* behind icons */

  text-align: center;
  white-space: nowrap;

  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: clamp(64px, 14vw, 220px);
  letter-spacing: 0.03em;      /* tighter so it fills width */
  text-transform: uppercase;

  color: rgba(255,255,255,0.45); /* brighter */
  pointer-events: none;
  user-select: none;
}




/* The drifting field fills the viewport */
#library {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

/* ===== Icon physics body ===== */
.item {
  position: absolute;
  width: 90px;
  height: 90px;
  perspective: 1000px;
  z-index: 10;
}

/* ===== Bobbing layer (separate from flip transforms) ===== */
.floater {
  width: 100%;
  height: 100%;
  animation: bob var(--bob-speed, 4s) ease-in-out infinite;
}

@keyframes bob {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(8px, -10px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* ===== Flip card ===== */
.card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform-origin: center center;
  transition: transform 0.6s ease, width 0.25s ease, height 0.25s ease;
}

/* Front and back faces */
.front,
.back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  background: white;
  box-shadow: 0 14px 36px rgba(0,0,0,0.22);
}

/* Front: full-bleed image */
.front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Back: text */
.back {
  transform: rotateY(180deg);
  padding: 18px;
  box-sizing: border-box;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.back h3 {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.back p {
  font-family: "Work Sans", system-ui, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.9;
  margin: 0;
}

/* ===== Hover: bring to top and expand+flip ===== */
.item:hover {
  z-index: 20;
}

/* ===== Hover: expand+flip but NEVER exceed viewport ===== */
.item:hover {
  z-index: 30;
}

/* Expanded size clamped to viewport */
.item:hover .card {
  width: min(520px, calc(100vw - (var(--edge-gap) * 2)));
  height: min(520px, calc(100vh - (var(--edge-gap) * 2)));
  transform: rotateY(180deg);
}


/* Shift expanded card so it stays on-screen (JS sets these vars) */
.item:hover .floater {
  animation: none; /* IMPORTANT: stop bob transform completely */
  transform: translate(var(--hover-shift-x, 0px), var(--hover-shift-y, 0px));
}


/* ===== Filter bubble UI ===== */
#filter-bubble {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  font-size: 14px;
}

#filter-toggle {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  background: white;
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
  cursor: pointer;
}

#filter-panel {
  margin-top: 10px;
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
  min-width: 260px;
}

.hidden {
  display: none;
}

.section-toggle {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 8px;
  cursor: pointer;
  font-weight: 600;
}

.section {
  padding: 6px 8px 10px 8px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.section label {
  display: block;
  padding: 6px 0;
  cursor: pointer;
}

/* ===== Filter emphasis on icons ===== */
.item.filtered-out {
  opacity: 0.30;
  transition: opacity 0.25s ease;
}

.item.filtered-in {
  opacity: 1;
  transition: opacity 0.25s ease;
}

.item.filtered-in {
  transform: scale(1.06);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* ===== Centered focus view ===== */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.18);
  z-index: 500;
  display: none;
}

#overlay.show {
  display: block;
}

.item.focused {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 520px;
  transform: translate(-50%, -50%);
  z-index: 600;
}

.item.focused .floater {
  animation-play-state: paused;
}

.item.focused .card {
  width: 100%;
  height: 100%;
  transform: rotateY(180deg); /* show text */
}
.open-link {
  margin-top: 8px;
  display: inline-block;
  padding: 10px 12px;
  border-radius: 999px;
  background: #111;
  color: white;
  text-decoration: none;
  font-size: 13px;
  width: fit-content;
}

/* ===== Centred hover preview ===== */
#preview.hidden { display: none; }

#preview {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 520px;
  transform: translate(-50%, -50%);
  z-index: 800;
  border-radius: 16px;
  background: white;
  box-shadow: 0 18px 60px rgba(0,0,0,0.28);
  padding: 18px;
  box-sizing: border-box;
  overflow: auto;
}

/* Make the preview feel like the "flipped side" */
#preview h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
}

#preview p {
  margin: 0 0 14px 0;
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.9;
}

#preview .meta {
  font-size: 12px;
  opacity: 0.65;
  margin-bottom: 14px;
}

#preview .open-link {
  display: inline-block;
  padding: 10px 12px;
  border-radius: 999px;
  background: #111;
  color: white;
  text-decoration: none;
  font-size: 13px;
}

:root {
  --icon-size: 90px;
  --edge-gap: 20px; /* minimum gap from viewport edges */
}
