/* ============================================
   R. — Interactive Experiences
   Pure white background, dark black text
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: #ffffff;
  color: #0a0a0a;
  font-family: 'Inter', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ============================================
   Preloader
   ============================================ */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.preloader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.preloader-inner {
  text-align: center;
  width: 300px;
}
.preloader-title {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -3px;
  color: #0a0a0a;
  margin-bottom: 32px;
}
.preloader-bar-track {
  width: 100%;
  height: 3px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
}
.preloader-bar {
  height: 100%;
  width: 0%;
  background: #0a0a0a;
  border-radius: 2px;
  transition: width 0.15s ease;
}
.preloader-text {
  margin-top: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #aaa;
}

/* ============================================
   Image Expand Overlay
   ============================================ */
.image-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  background: rgba(255, 255, 255, 0);
  transition: background 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.image-overlay.active {
  pointer-events: all;
  background: rgba(255, 255, 255, 0.96);
}
.image-overlay.dark-mode.active {
  background: rgba(5, 5, 16, 0.96);
}
.overlay-img {
  position: absolute;
  border-radius: 50%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  will-change: transform, width, height, top, left, border-radius, opacity;
  transition:
    top 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    left 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    width 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    height 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-radius 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease,
    box-shadow 0.45s ease;
}
.overlay-img.expanding {
  opacity: 1;
  border-radius: 12px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.15), 0 10px 30px rgba(0, 0, 0, 0.1);
  pointer-events: all;
  cursor: zoom-out;
}
.overlay-img.collapsing {
  border-radius: 50%;
  box-shadow: none;
  pointer-events: none;
  transition:
    top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease 0.1s,
    box-shadow 0.3s ease;
}

/* Pages */
.page {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #ffffff;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.page.active {
  display: flex;
  opacity: 1;
}
.page.fade-out {
  opacity: 0;
}
#landing.page {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

#experience.page.active {
  overflow: hidden;
}

/* ============================================
   Landing Page
   ============================================ */
.landing-header {
  text-align: center;
  padding: 40px 20px 20px;
  flex-shrink: 0;
}
.landing-title {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  color: #0a0a0a;
}
.landing-title .dot {
  color: #0a0a0a;
}
.landing-subtitle {
  font-size: 16px;
  font-weight: 400;
  color: #666;
  margin-top: 12px;
  letter-spacing: 0.5px;
}

/* Shapes Grid */
.shapes-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
  padding: 30px 60px 60px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.shape-card {
  aspect-ratio: 1;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #e0e0e0;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  background: #ffffff;
  gap: 12px;
}
.shape-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #0a0a0a;
  opacity: 0;
  transition: opacity 0.35s ease;
  border-radius: 14px;
}
.shape-card:hover::before {
  opacity: 1;
}
.shape-card:hover {
  border-color: #0a0a0a;
  transform: scale(1.04);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.shape-card:hover .shape-label,
.shape-card:hover .shape-svg {
  color: #ffffff;
  fill: #ffffff;
  stroke: #ffffff;
}

.shape-svg {
  width: 64px;
  height: 64px;
  position: relative;
  z-index: 1;
  transition: all 0.35s ease;
  fill: none;
  stroke: #0a0a0a;
  stroke-width: 2;
}

.shape-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: #0a0a0a;
  position: relative;
  z-index: 1;
  transition: color 0.35s ease;
}

.shape-desc {
  font-size: 11px;
  font-weight: 400;
  color: #999;
  position: relative;
  z-index: 1;
  transition: color 0.35s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.shape-card:hover .shape-desc {
  color: #aaa;
}

/* ============================================
   Experience Page
   ============================================ */
.exp-nav {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  gap: 16px;
  flex-shrink: 0;
  border-bottom: 1px solid #eee;
  background: #ffffff;
  z-index: 10;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: #fff;
  color: #0a0a0a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.nav-btn:hover {
  background: #0a0a0a;
  color: #ffffff;
  border-color: #0a0a0a;
}

.exp-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: #0a0a0a;
}

.exp-hint {
  font-size: 13px;
  color: #999;
  margin-left: 8px;
  font-style: italic;
}

.nav-arrows {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.exp-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #ffffff;
}
.exp-container canvas,
.exp-container svg {
  display: block;
  touch-action: none;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1100px) {
  .shapes-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 20px 30px 40px;
    gap: 16px;
  }
}
@media (max-width: 600px) {
  .shapes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px 12px 80px;
  }
  .landing-title { font-size: 42px; }
  .landing-header { padding: 24px 16px 12px; }
  .landing-subtitle { font-size: 13px; margin-top: 8px; }
  .shape-svg { width: 36px; height: 36px; }
  .shape-label { font-size: 13px; }
  .shape-desc { font-size: 9px; }
  .shape-card { gap: 6px; border-radius: 12px; padding: 10px 4px; }

  /* Experience nav */
  .exp-nav { padding: 10px 12px; gap: 8px; }
  .nav-btn { width: 34px; height: 34px; border-radius: 8px; }
  .exp-label { font-size: 18px; }
  .exp-hint { display: none; }

  /* Upload panel */
  .upload-panel { width: 100%; right: -100%; }
  .upload-trigger { width: 46px; height: 46px; bottom: 16px; right: 16px; }

  /* Overlay — full screen on mobile */
  .overlay-img.expanding {
    border-radius: 6px !important;
  }

  /* Preloader */
  .preloader-title { font-size: 48px; }
  .preloader-inner { width: 240px; }
}

/* ============================================
   Loading indicator
   ============================================ */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: #ccc;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Entrance animation for shape cards */
.shape-card {
  animation: cardEnter 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  transform: translateY(30px);
}
@keyframes cardEnter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.shape-card:nth-child(1)  { animation-delay: 0.05s; }
.shape-card:nth-child(2)  { animation-delay: 0.10s; }
.shape-card:nth-child(3)  { animation-delay: 0.15s; }
.shape-card:nth-child(4)  { animation-delay: 0.20s; }
.shape-card:nth-child(5)  { animation-delay: 0.25s; }
.shape-card:nth-child(6)  { animation-delay: 0.30s; }
.shape-card:nth-child(7)  { animation-delay: 0.35s; }
.shape-card:nth-child(8)  { animation-delay: 0.40s; }
.shape-card:nth-child(9)  { animation-delay: 0.45s; }
.shape-card:nth-child(10) { animation-delay: 0.50s; }
.shape-card:nth-child(11) { animation-delay: 0.55s; }
.shape-card:nth-child(12) { animation-delay: 0.60s; }
.shape-card:nth-child(13) { animation-delay: 0.65s; }
.shape-card:nth-child(14) { animation-delay: 0.70s; }
.shape-card:nth-child(15) { animation-delay: 0.75s; }

/* Title animation */
.landing-title {
  animation: titleIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  transform: translateY(-20px);
}
@keyframes titleIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.landing-subtitle {
  animation: titleIn 0.8s 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  transform: translateY(-10px);
}

/* ============================================
   Experience-specific overrides
   ============================================ */
#exp-container .r10-text {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  color: #0a0a0a;
  position: absolute;
  cursor: default;
  user-select: none;
}

/* D3 force graph */
#exp-container svg.d3-graph {
  width: 100%;
  height: 100%;
}
#exp-container svg.d3-graph .node {
  fill: #0a0a0a;
  cursor: grab;
}
#exp-container svg.d3-graph .link {
  stroke: #ddd;
  stroke-width: 1.5;
}

/* Chart.js container */
.chart-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ============================================
   Upload Panel
   ============================================ */
.upload-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 100;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0a0a0a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.upload-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(0,0,0,0.35);
}
.upload-trigger.hidden { display: none; }

.upload-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  height: 100%;
  background: #fff;
  z-index: 500;
  box-shadow: -4px 0 40px rgba(0,0,0,0.12);
  padding: 40px 28px;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.upload-panel.open { right: 0; }

.upload-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.upload-close:hover {
  color: #0a0a0a;
  background: #f0f0f0;
}

.upload-title {
  font-size: 22px;
  font-weight: 700;
  color: #0a0a0a;
  margin-bottom: 4px;
}
.upload-desc {
  font-size: 13px;
  color: #999;
  margin-bottom: 28px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.upload-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #666;
}
.upload-select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: #0a0a0a;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.upload-select:focus {
  outline: none;
  border-color: #0a0a0a;
}
.upload-file {
  padding: 10px;
  border: 2px dashed #e0e0e0;
  border-radius: 10px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-file:hover { border-color: #aaa; }

.upload-btn {
  padding: 12px;
  background: #0a0a0a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  margin-top: 4px;
}
.upload-btn:hover { background: #222; }
.upload-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.upload-progress { margin-top: 8px; }
.upload-progress-track {
  width: 100%;
  height: 4px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: #0a0a0a;
  border-radius: 2px;
  transition: width 0.2s ease;
}
.upload-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #aaa;
  margin-top: 6px;
  display: block;
}
.upload-msg {
  font-size: 13px;
  color: #4caf50;
  margin-top: 4px;
  min-height: 18px;
}
.upload-msg.error { color: #e53935; }

@media (max-width: 600px) {
  .upload-panel { width: 100%; right: -100%; }
  .upload-trigger { bottom: 16px; right: 16px; width: 48px; height: 48px; }
}
