/* ============================================
   PERSONAL HOMEPAGE — Fantasy City Theme
   ============================================ */

:root {
  --text: rgba(255,255,255,0.93);
  --text-muted: rgba(255,255,255,0.62);
  --text-faint: rgba(255,255,255,0.28);
  --panel-bg: rgba(10,14,22,0.55);
  --panel-border: rgba(255,255,255,0.10);
  --panel-hover: rgba(255,255,255,0.14);
  --accent: #f0a860;
  --accent-glow: rgba(240,168,96,0.35);
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --app-height: 100vh;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #080b12;
  color: var(--text);
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Inter, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   BACKGROUND CANVAS
   ============================================ */
#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

/* ============================================
   SCROLL CONTAINER
   ============================================ */
.scroll-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.pages-wrapper {
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
  will-change: transform;
}
.pages-wrapper.is-fast {
  transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}
.scroll-container.is-transitioning {
  pointer-events: none;
}

/* ============================================
   PAGES
   ============================================ */
.page {
  width: 100%;
  height: 100vh;
  height: var(--app-height);
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.page-content {
  width: min(1100px, 90vw);
  padding: 40px 0;
  z-index: 2;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.section-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: 0.03em;
}

/* ============================================
   GLITCH TEXT
   ============================================ */
.glitch {
  color: #fff;
  font-size: clamp(3rem, 12vw, 10rem);
  white-space: nowrap;
  font-weight: 900;
  position: relative;
  margin: 0 auto;
  user-select: none;
  cursor: pointer;
  text-align: center;
}

.glitch::after,
.glitch::before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: #fff;
  background-color: transparent;
  overflow: hidden;
  clip-path: inset(0 0 0 0);
}

.glitch:not(.enable-on-hover)::after {
  left: 10px;
  text-shadow: var(--after-shadow, -10px 0 red);
  animation: animate-glitch var(--after-duration, 3s) infinite linear alternate-reverse;
}
.glitch:not(.enable-on-hover)::before {
  left: -10px;
  text-shadow: var(--before-shadow, 10px 0 cyan);
  animation: animate-glitch var(--before-duration, 2s) infinite linear alternate-reverse;
}

.glitch.enable-on-hover::after,
.glitch.enable-on-hover::before {
  content: '';
  opacity: 0;
  animation: none;
}

.glitch.enable-on-hover:hover::after {
  content: attr(data-text);
  opacity: 1;
  left: 10px;
  text-shadow: var(--after-shadow, -10px 0 red);
  animation: animate-glitch var(--after-duration, 3s) infinite linear alternate-reverse;
}
.glitch.enable-on-hover:hover::before {
  content: attr(data-text);
  opacity: 1;
  left: -10px;
  text-shadow: var(--before-shadow, 10px 0 cyan);
  animation: animate-glitch var(--before-duration, 2s) infinite linear alternate-reverse;
}

@keyframes animate-glitch {
  0%   { clip-path: inset(20% 0 50% 0); }
  5%   { clip-path: inset(10% 0 60% 0); }
  10%  { clip-path: inset(15% 0 55% 0); }
  15%  { clip-path: inset(25% 0 35% 0); }
  20%  { clip-path: inset(30% 0 40% 0); }
  25%  { clip-path: inset(40% 0 20% 0); }
  30%  { clip-path: inset(10% 0 60% 0); }
  35%  { clip-path: inset(15% 0 55% 0); }
  40%  { clip-path: inset(25% 0 35% 0); }
  45%  { clip-path: inset(30% 0 40% 0); }
  50%  { clip-path: inset(20% 0 50% 0); }
  55%  { clip-path: inset(10% 0 60% 0); }
  60%  { clip-path: inset(15% 0 55% 0); }
  65%  { clip-path: inset(25% 0 35% 0); }
  70%  { clip-path: inset(30% 0 40% 0); }
  75%  { clip-path: inset(40% 0 20% 0); }
  80%  { clip-path: inset(20% 0 50% 0); }
  85%  { clip-path: inset(10% 0 60% 0); }
  90%  { clip-path: inset(15% 0 55% 0); }
  95%  { clip-path: inset(25% 0 35% 0); }
  100% { clip-path: inset(30% 0 40% 0); }
}

/* ============================================
   HOME PAGE
   ============================================ */
.page-home .page-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
}

.home-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.hero-left {
  text-align: center;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-block {
  display: inline-block;
  margin: 0 auto;
  padding: 24px 48px;
  border-radius: 16px;
  background: rgba(10, 14, 22, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hero-right {
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .home-layout {
    flex-direction: column;
    gap: 20px;
  }
}

.hero-title {
  margin-bottom: 20px;
}

.title-line {
  display: block;
  font-size: clamp(42px, 8vw, 80px);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  background: linear-gradient(180deg, #fff 20%, rgba(240,168,96,0.7) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-sub {
  display: block;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 12px;
  letter-spacing: 0.08em;
}

.hero-desc {
  font-size: clamp(15px, 2.5vw, 18px);
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 36px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 40px;
  background: rgba(240,168,96,0.12);
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.06em;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.35s var(--ease-out);
}
.btn-primary:hover {
  border-color: var(--accent);
  background: rgba(240,168,96,0.22);
  box-shadow: 0 0 40px var(--accent-glow), inset 0 0 30px rgba(240,168,96,0.06);
  transform: translateY(-2px);
}
.btn-primary svg {
  transition: transform 0.35s var(--ease-out);
}
.btn-primary:hover svg {
  transform: translateY(3px);
}

/* ============================================
   BLUR TEXT (React Bits port)
   ============================================ */
.blur-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.blur-word {
  display: inline-block;
  will-change: transform, filter, opacity;
  filter: blur(10px);
  opacity: 0;
  transform: translateY(var(--blur-y-start, -50px));
  font-size: clamp(1.6rem, 3vw, 3.2rem);
  font-weight: 400;
  color: #e8c47c;
  letter-spacing: 0.04em;
}

.blur-text.is-visible .blur-word {
  animation: blurIn var(--blur-duration, 0.7s) ease forwards;
  animation-delay: var(--blur-delay, 0s);
}

@keyframes blurIn {
  0% {
    filter: blur(10px);
    opacity: 0;
    transform: translateY(var(--blur-y-start, -50px));
  }
  50% {
    filter: blur(5px);
    opacity: 0.5;
    transform: translateY(var(--blur-y-mid, 5px));
  }
  100% {
    filter: blur(0px);
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   TILTED CARDS (React Bits port)
   ============================================ */
.tilted-cards-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

.tilted-card-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

.tilted-card-figure {
  position: relative;
  perspective: 800px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tilted-card-inner {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: none;
}

.tilted-card-img {
  position: absolute;
  top: 0;
  left: 0;
  object-fit: cover;
  border-radius: 15px;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.tilted-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
  pointer-events: none;
  border-radius: 15px;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.15) 40%,
    transparent 100%
  );
}

.tilted-card-overlay-text {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  .tilted-card-row {
    gap: 12px;
  }
  .tilted-card-figure {
    width: 130px !important;
    height: 190px !important;
  }
  .tilted-card-inner,
  .tilted-card-img {
    width: 130px !important;
    height: 190px !important;
  }
  .tilted-card-overlay-text {
    font-size: 14px;
  }
  .glitch {
    font-size: clamp(2rem, 10vw, 3.5rem) !important;
  }
  .blur-word {
    font-size: clamp(1rem, 2.5vw, 1.6rem) !important;
  }
  .tilted-cards-container {
    margin-top: 28px !important;
  }
}

@media (max-width: 380px) {
  .tilted-card-figure,
  .tilted-card-inner,
  .tilted-card-img {
    width: 100px !important;
    height: 145px !important;
  }
  .tilted-card-overlay-text {
    font-size: 12px;
  }
  .glitch {
    font-size: clamp(1.6rem, 9vw, 2.8rem) !important;
  }
  #blurMotto {
    margin-top: 14px !important;
  }
  .tilted-cards-container {
    margin-top: 20px !important;
  }
  .volume-slider-pos {
    bottom: 14px;
    left: 8px;
  }
  .es-container {
    width: 9rem;
    padding: 8px 10px;
  }
}

/* ============================================
   ABOUT PAGE
   ============================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 48px;
  align-items: center;
}

.about-visual {
  display: flex;
  justify-content: center;
}

.avatar-frame {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.avatar-placeholder {
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.7;
}

.about-text p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-muted);
  margin: 16px 0 24px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}

.tag {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13px;
  color: var(--text);
  transition: all 0.3s var(--ease-out);
}
.tag:hover {
  border-color: var(--panel-hover);
  background: rgba(255,255,255,0.1);
  transform: translateY(-1px);
}

.stat-row {
  display: flex;
  gap: 40px;
}

.stat {
  text-align: center;
}
.stat-num {
  display: block;
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}
.stat-label {
  font-size: 13px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* ============================================
   PROJECTS PAGE
   ============================================ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 32px;
}

.project-card {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s var(--ease-out);
}
.project-card:hover {
  border-color: var(--panel-hover);
  transform: translateY(-4px);
  box-shadow: 0 24px 48px rgba(0,0,0,0.4);
}

.project-card-img {
  width: 100%;
  height: 160px;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.project-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-card-body {
  padding: 18px 20px 22px;
}

.project-card-body h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}
.project-card-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}
.project-tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

/* ============================================
   CONTACT PAGE
   ============================================ */
.contact-lead {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.6;
}

.contact-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 20px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  text-decoration: none;
  color: inherit;
  transition: all 0.35s var(--ease-out);
}
a.contact-card:hover {
  border-color: var(--accent);
  background: rgba(240,168,96,0.08);
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}

.contact-icon {
  font-size: 32px;
}
.contact-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.contact-value {
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  word-break: break-all;
}

/* ============================================
   NAV DOTS
   ============================================ */
.nav-dots {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: transparent;
  cursor: pointer;
  transition: all 0.4s var(--ease-out);
  padding: 0;
}
.nav-dot:hover {
  border-color: rgba(255,255,255,0.7);
  transform: scale(1.3);
}
.nav-dot.is-active {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ============================================
   ELASTIC SLIDER (volume)
   ============================================ */
.volume-slider-pos {
  position: fixed;
  bottom: 32px;
  left: 32px;
  z-index: 10;
}

.es-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 11rem;
  padding: 10px 16px;
  border-radius: 28px;
  background: rgba(10,14,22,0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
}

.es-wrapper {
  display: flex;
  width: 100%;
  touch-action: none;
  user-select: none;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.es-icon-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.es-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.6);
}

.es-root {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 150px;
  flex-grow: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
  align-items: center;
  padding: 0.75rem 0;
}

.es-root:active {
  cursor: grabbing;
}

.es-track-wrap {
  display: flex;
  flex-grow: 1;
  height: 5px;
}

.es-track {
  position: relative;
  height: 100%;
  flex-grow: 1;
  overflow: hidden;
  border-radius: 9999px;
  background-color: rgba(255,255,255,0.12);
}

.es-range {
  position: absolute;
  height: 100%;
  background-color: var(--accent, #f0a860);
  border-radius: 9999px;
}

.es-value {
  color: rgba(255,255,255,0.45);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* ============================================
   SCENE INDICATOR
   ============================================ */
.scene-indicator {
  position: fixed;
  bottom: 32px;
  left: 32px;
  z-index: 10;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  pointer-events: none;
}

/* ============================================
   REVEAL ANIMATIONS
   ============================================ */
.reveal-el {
  opacity: 0;
  transform: translateY(30px);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .volume-slider-pos {
    bottom: 20px;
    left: 20px;
  }
}

@media (max-width: 480px) {
  .page-content {
    width: 92vw;
    padding: 24px 0;
  }
  .masonry-overlay-header {
    padding: 14px 18px;
  }
  .masonry-overlay-title {
    font-size: 18px;
  }
}

/* ============================================
   MASONRY GALLERY OVERLAY
   ============================================ */
.masonry-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 11, 18, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.masonry-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.masonry-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  flex-shrink: 0;
  z-index: 2;
}

.masonry-overlay-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.06em;
}

.masonry-overlay-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.masonry-overlay-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}

.masonry-overlay-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 40px;
  -webkit-overflow-scrolling: touch;
}

/* ── Circular Gallery ── */
.circular-gallery {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  outline: none;
}

.circular-gallery:active {
  cursor: grabbing;
}

.circular-gallery:focus-visible {
  outline: 2px solid rgba(255,255,255,0.5);
  outline-offset: 4px;
}

/* ── Masonry List ── */
.masonry-list {
  position: relative;
  width: 100%;
}

/* ── Masonry Item ── */
.masonry-item-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform, width, height, opacity, filter;
  padding: 6px;
  cursor: pointer;
}

.masonry-item-img {
  position: relative;
  background-size: cover;
  background-position: center center;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  box-shadow: 0px 10px 50px -10px rgba(0, 0, 0, 0.2);
}

/* ── Lightbox ── */
.masonry-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.masonry-lightbox.is-open {
  opacity: 1;
}

.masonry-lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  z-index: 2;
}

.masonry-lightbox-close:hover {
  background: rgba(255,255,255,0.15);
}

.masonry-lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* ============================================
   DOME GALLERY (React Bits port)
   ============================================ */
.dg-root {
  position: relative;
  width: 100%;
  height: 100%;
  --radius: 520px;
  --viewer-pad: 72px;
  --circ: calc(var(--radius) * 3.14);
  --rot-y: calc((360deg / var(--segments-x)) / 2);
  --rot-x: calc((360deg / var(--segments-y)) / 2);
  --item-width: calc(var(--circ) / var(--segments-x));
  --item-height: calc(var(--circ) / var(--segments-y));
}

.dg-root * { box-sizing: border-box; }

.dg-sphere,
.dg-item,
.dg-item-img {
  transform-style: preserve-3d;
}

.dg-main {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
}

.dg-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  perspective: calc(var(--radius) * 2);
  perspective-origin: 50% 50%;
  contain: layout paint size;
}

.dg-sphere {
  transform: translateZ(calc(var(--radius) * -1));
  will-change: transform;
}

.dg-overlay,
.dg-overlay-blur {
  position: absolute;
  inset: 0;
  margin: auto;
  z-index: 3;
  pointer-events: none;
}

.dg-overlay {
  background-image: radial-gradient(rgba(235,235,235,0) 65%, var(--overlay-blur-color, #120F17) 100%);
}

.dg-overlay-blur {
  -webkit-mask-image: radial-gradient(rgba(235,235,235,0) 70%, var(--overlay-blur-color, #120F17) 90%);
  mask-image: radial-gradient(rgba(235,235,235,0) 70%, var(--overlay-blur-color, #120F17) 90%);
  backdrop-filter: blur(3px);
}

.dg-item {
  width: calc(var(--item-width) * var(--item-size-x));
  height: calc(var(--item-height) * var(--item-size-y));
  position: absolute;
  top: -999px; bottom: -999px; left: -999px; right: -999px;
  margin: auto;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  transition: transform 300ms;
  transform:
    rotateY(calc(var(--rot-y) * (var(--offset-x) + ((var(--item-size-x) - 1) / 2)) + var(--rot-y-delta, 0deg)))
    rotateX(calc(var(--rot-x) * (var(--offset-y) - ((var(--item-size-y) - 1) / 2)) + var(--rot-x-delta, 0deg)))
    translateZ(var(--radius));
}

.dg-item-img {
  position: absolute;
  display: block;
  inset: 10px;
  border-radius: var(--tile-radius, 12px);
  background: transparent;
  overflow: hidden;
  backface-visibility: hidden;
  transition: transform 300ms;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  pointer-events: auto;
  transform: translateZ(0);
}

.dg-item-img:focus { outline: none; }

.dg-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  backface-visibility: hidden;
  filter: var(--image-filter, none);
}

.dg-viewer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--viewer-pad);
}

.dg-viewer .dg-frame {
  height: 100%;
  aspect-ratio: 1;
  border-radius: var(--enlarge-radius, 32px);
  display: flex;
}

@media (max-aspect-ratio: 1/1) {
  .dg-viewer .dg-frame { height: auto; width: 100%; }
}

.dg-viewer .dg-scrim {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0,0,0,0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 500ms ease;
  backdrop-filter: blur(3px);
}

.dg-root[data-enlarging='true'] .dg-viewer .dg-scrim {
  opacity: 1;
  pointer-events: all;
}

.dg-viewer .dg-enlarge {
  position: absolute;
  z-index: 30;
  border-radius: var(--enlarge-radius, 32px);
  overflow: hidden;
  transition: transform 500ms ease, opacity 500ms ease;
  transform-origin: top left;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.dg-viewer .dg-enlarge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: var(--image-filter, none);
}

.dg-edge-fade {
  position: absolute;
  left: 0; right: 0;
  height: 120px;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--overlay-blur-color, #120F17));
}

.dg-edge-fade--top { top: 0; transform: rotate(180deg); }
.dg-edge-fade--bottom { bottom: 0; }

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .scroll-container {
    scroll-behavior: auto;
  }
  .btn-primary, .project-card, .contact-card, .tag {
    transition: none;
  }
}
