:root {
  --bg-color: #f7f4ef;
  --text-color: #1c1b18;
  --accent-color: #0b4a4d;
  --secondary-bg: #efe9e0;
  --card-bg: #ffffff;
  --font-main: "Space Grotesk", "Helvetica Neue", sans-serif;
  --font-heading: "Playfair Display", "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", monospace;
  --shadow: 0 20px 50px rgba(19, 12, 4, 0.12);
  --border-radius: 18px;
  --btn-bg: #1c1b18;
  --btn-text: #ffffff;
  --link-color: #0b4a4d;
  --viewer-bg: #e6dfd4;
}

[data-theme="midnight"] {
  --bg-color: #0a0a0a;
  --text-color: #e0e0e0;
  --accent-color: #00ffff;
  --secondary-bg: #111111;
  --card-bg: #161616;
  --font-main: "Roboto Mono", monospace;
  --font-heading: "Orbitron", sans-serif;
  --shadow: 0 4px 20px rgba(0, 255, 255, 0.15);
  --border-radius: 4px;
  --btn-bg: #00ffff;
  --btn-text: #000000;
  --link-color: #00ffff;
  --viewer-bg: #1a1a1a;
}

[data-theme="nature"] {
  --bg-color: #f7f3e8;
  --text-color: #4a4036;
  --accent-color: #5c7c55;
  --secondary-bg: #e8e4d9;
  --card-bg: #ffffff;
  --font-main: "Merriweather", serif;
  --font-heading: "Spectral", serif;
  --shadow: 0 4px 20px rgba(92, 124, 85, 0.1);
  --border-radius: 24px;
  --btn-bg: #5c7c55;
  --btn-text: #ffffff;
  --link-color: #3d5239;
  --viewer-bg: #e0dcd0;
}

* {
  box-sizing: border-box;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-radius 0.3s ease;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px 400px at 10% 5%, rgba(11, 74, 77, 0.08), transparent),
    radial-gradient(
      500px 300px at 90% 20%,
      rgba(28, 27, 24, 0.06),
      transparent
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  pointer-events: none;
  z-index: -1;
}

/* Header & Theme Switcher */
header {
  padding: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.theme-switcher {
  display: flex;
  gap: 0.5rem;
  background: var(--secondary-bg);
  padding: 0.5rem;
  border-radius: 50px;
}

.theme-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.6;
  transition: all 0.2s ease;
}

.theme-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.theme-btn.active {
  background: var(--btn-bg);
  color: var(--btn-text);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Download Buttons */
.download-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1rem;
}

.btn-download {
  display: block;
  background: var(--secondary-bg);
  color: var(--text-color);
  padding: 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.btn-download:hover {
  background: var(--accent-color);
  color: #fff;
  transform: translateY(-2px);
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 2.5rem 4rem;
  gap: 3rem;
}

main > section {
  width: min(1100px, 100%);
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: rgba(28, 27, 24, 0.7);
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.6rem, 4vw, 3.4rem);
  margin: 0;
}

.lede {
  font-size: 1.05rem;
  margin: 0;
  max-width: 32rem;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-tags span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(28, 27, 24, 0.2);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-bg);
  color: var(--btn-text);
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  width: fit-content;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(28, 27, 24, 0.18);
}

.cta:hover {
  transform: translateY(-2px);
}

.hero-collage {
  display: block;
  width: 100%;
  height: clamp(350px, 40vw, 450px);
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
  perspective: 2000px; /* Strong perspective for 3D effect */
}

.hero-collage::before {
  content: "Tap or hover to fan out";
  position: absolute;
  right: 0.8rem;
  bottom: -2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(28, 27, 24, 0.5);
}

.hero-collage:focus-visible {
  outline: 2px solid rgba(28, 27, 24, 0.5);
  outline-offset: 12px;
}

.hero-collage::after {
  display: none;
}

.tile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 180px; /* Fixed size for stack items */
  height: 240px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(28, 27, 24, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  filter: saturate(0.9) contrast(1.05);
  transition:
    transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.4s ease,
    filter 0.4s ease,
    opacity 0.4s ease;
  transform-style: preserve-3d;
  cursor: pointer;
  backface-visibility: hidden;
}

/* Stacked state (Default) */
/* Images are stacked with a slight rotation and offset */
.tile-a { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(0); z-index: 10; }
.tile-b { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(15px); z-index: 9; }
.tile-c { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(30px); z-index: 8; }
.tile-d { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(45px); z-index: 7; }
.tile-e { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(60px); z-index: 6; }
.tile-f { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(75px); z-index: 5; }
.tile-g { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(90px); z-index: 4; }
.tile-h { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(105px); z-index: 3; }
.tile-i { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(120px); z-index: 2; }
.tile-j { transform: translate(-50%, -50%) rotateX(45deg) rotateZ(-35deg) translateZ(135px); z-index: 1; }

/* Exploded state */
.hero-collage.is-exploded .tile-a { transform: translate(-140%, -120%) rotateX(10deg) rotateZ(-5deg) translateZ(50px); }
.hero-collage.is-exploded .tile-b { transform: translate(-10%, -150%) rotateX(15deg) rotateZ(10deg) translateZ(100px); }
.hero-collage.is-exploded .tile-c { transform: translate(110%, -100%) rotateX(10deg) rotateZ(-12deg) translateZ(30px); }
.hero-collage.is-exploded .tile-d { transform: translate(-160%, 10%) rotateX(12deg) rotateZ(8deg) translateZ(120px); }
.hero-collage.is-exploded .tile-e { transform: translate(-20%, -30%) rotateX(0deg) rotateZ(0deg) translateZ(200px); }
.hero-collage.is-exploded .tile-f { transform: translate(130%, 10%) rotateX(-10deg) rotateZ(5deg) translateZ(80px); }
.hero-collage.is-exploded .tile-g { transform: translate(-120%, 110%) rotateX(-15deg) rotateZ(-10deg) translateZ(40px); }
.hero-collage.is-exploded .tile-h { transform: translate(10%, 130%) rotateX(10deg) rotateZ(12deg) translateZ(110px); }
.hero-collage.is-exploded .tile-i { transform: translate(140%, 120%) rotateX(-12deg) rotateZ(-8deg) translateZ(60px); }
.hero-collage.is-exploded .tile-j { transform: translate(0%, 0%) rotateX(0deg) rotateZ(0deg) translateZ(300px); opacity: 0.9; }

.hero-collage:not(.is-exploded) .tile:hover {
  filter: saturate(1.2) contrast(1.1);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
  z-index: 100 !important;
  transform: scale(1.1) !important;
}

.panel {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 2.2rem;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.6rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 2rem;
}

.panel-head p {
  margin: 0;
  color: rgba(28, 27, 24, 0.7);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.work-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.4rem;
  border-radius: 16px;
  background: var(--secondary-bg);
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(28, 27, 24, 0.08);
  min-height: 180px;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.work-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 30px rgba(28, 27, 24, 0.12);
}

.work-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.work-card p {
  margin: 0;
  color: rgba(28, 27, 24, 0.75);
  font-size: 0.95rem;
}

.work-card.flagship {
  background: linear-gradient(135deg, #ffffff 0%, #f1ebe2 100%);
  border: 1px solid rgba(11, 74, 77, 0.3);
}

.work-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.mono {
  font-family: var(--font-mono);
}

.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.2rem;
}

.now-card {
  padding: 1.4rem;
  border-radius: 14px;
  border: 1px solid rgba(28, 27, 24, 0.1);
  background: #faf7f2;
}

.now-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}

.now-card p {
  margin: 0;
  color: rgba(28, 27, 24, 0.7);
}

.archive details {
  border-radius: 16px;
  border: 1px solid rgba(28, 27, 24, 0.1);
  padding: 1rem 1.4rem;
  background: #f3eee6;
}

.archive summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
}

.archive-content {
  padding-top: 1.2rem;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.archive h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.archive ul {
  margin: 0;
  padding-left: 1.1rem;
}

.archive a {
  color: var(--link-color);
}

model-viewer {
  width: 100%;
  height: 500px;
  background-color: var(--viewer-bg);
  --poster-color: transparent;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem 2rem;
  font-size: 0.8rem;
  opacity: 0.7;
  max-width: 600px;
  margin: 0 auto;
}

footer a {
  color: var(--link-color);
}

/* Utilities */
.hidden {
  display: none !important;
}

.badge-new {
  display: inline-block;
  background-color: #ff4757;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.badge-rebooted {
  display: inline-block;
  background-color: #000;
  color: #00ffff;
  font-family: "Roboto Mono", monospace;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 8px;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid #00ffff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.badge-rebooted::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 255, 255, 0.2),
    transparent
  );
  animation: reboot-scan 2s infinite;
}

@keyframes reboot-scan {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

@media (max-width: 600px) {
  main {
    padding: 2.5rem 1.4rem 3.2rem;
    gap: 2rem;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero-collage {
    grid-template-rows: repeat(4, 70px);
  }

  /* Mobile-specific exploded coordinates (for Galaxy S25 / 360px width) */
  .hero-collage.is-exploded .tile-a { transform: translate(-80%, -90%) rotateX(10deg) rotateZ(-5deg) translateZ(30px); }
  .hero-collage.is-exploded .tile-b { transform: translate(-5%, -110%) rotateX(15deg) rotateZ(10deg) translateZ(60px); }
  .hero-collage.is-exploded .tile-c { transform: translate(65%, -70%) rotateX(10deg) rotateZ(-12deg) translateZ(20px); }
  .hero-collage.is-exploded .tile-d { transform: translate(-90%, 5%) rotateX(12deg) rotateZ(8deg) translateZ(70px); }
  .hero-collage.is-exploded .tile-e { transform: translate(-10%, -20%) rotateX(0deg) rotateZ(0deg) translateZ(120px); }
  .hero-collage.is-exploded .tile-f { transform: translate(50%, 5%) rotateX(-10deg) rotateZ(5deg) translateZ(50px); }
  .hero-collage.is-exploded .tile-g { transform: translate(-70%, 80%) rotateX(-15deg) rotateZ(-10deg) translateZ(25px); }
  .hero-collage.is-exploded .tile-h { transform: translate(5%, 90%) rotateX(10deg) rotateZ(12deg) translateZ(65px); }
  .hero-collage.is-exploded .tile-i { transform: translate(55%, 75%) rotateX(-12deg) rotateZ(-8deg) translateZ(35px); }
  .hero-collage.is-exploded .tile-j { transform: translate(0%, 0%) rotateX(0deg) rotateZ(0deg) translateZ(180px); opacity: 0.9; }

  .panel {
    padding: 1.6rem;
  }
}

/* Badge for Under Development */
.badge-dev {
  display: inline-block;
  background-color: transparent;
  color: #ffa502;
  /* Construction orange */
  font-family: "Roboto Mono", monospace;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 8px;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px dashed #ffa502;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% {
    border-color: rgba(255, 165, 2, 0.4);
    box-shadow: 0 0 0 rgba(255, 165, 2, 0);
  }

  50% {
    border-color: rgba(255, 165, 2, 1);
    box-shadow: 0 0 4px rgba(255, 165, 2, 0.2);
  }

  100% {
    border-color: rgba(255, 165, 2, 0.4);
    box-shadow: 0 0 0 rgba(255, 165, 2, 0);
  }
}
