:root {
  /* Nuansa budaya Sunda: indigo langit malam, hijau bambu, emas tradisi */
  --bg: #0c1a2b;
  --bg-soft: #132946;
  --card: #f4ecd8;
  --card-soft: #efe2c3;
  --text: #1d2a3a;
  --muted: #445a72;
  --accent: #b08a42;
  --accent-hover: #9a7738;
  --secondary: #2e6b4e;
  --border: #d1bf95;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, #1e3b63 0%, var(--bg) 42%),
    linear-gradient(140deg, #0b1a2c 0%, #10233d 55%, #143054 100%);
  color: #f4f0e5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===== Landing page ===== */
header {
  text-align: center;
  padding: 48px 16px 24px;
}

header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.8vw, 2.5rem);
  color: #f2dfae;
  letter-spacing: 0.3px;
}

header p {
  margin-top: 10px;
  color: #d8e4f5;
}

.gallery-container {
  width: min(1100px, 92%);
  margin: 0 auto 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.product-card {
  background: linear-gradient(180deg, var(--card), var(--card-soft));
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(5, 12, 22, 0.34);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 38px rgba(5, 12, 22, 0.45);
}

.product-thumbnail {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e8d7af;
}

.product-thumbnail-fallback {
  display: grid;
  place-items: center;
  color: #f1e2be;
  font-weight: 600;
  letter-spacing: 0.4px;
  background: linear-gradient(145deg, #2e6b4e, #214d39);
}

.product-info {
  padding: 16px 16px 12px;
}

.product-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.product-description {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.view-button {
  display: block;
  margin: 0 16px 16px;
  text-align: center;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fffdf7;
  font-weight: 600;
}

.view-button:hover {
  background: var(--accent-hover);
}

footer {
  text-align: center;
  padding: 12px 16px 28px;
  color: #d8e4f5;
}

/* ===== Viewer page ===== */
.viewer-page {
  width: min(1100px, 94%);
  margin: 20px auto 32px;
}

.viewer-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.back-link {
  display: inline-block;
  padding: 8px 12px;
  min-height: 44px;
  border: 1px solid #cdb37b;
  border-radius: 10px;
  color: #f2dfae;
  background: rgba(14, 30, 50, 0.28);
}

.viewer-title {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  color: #f2dfae;
}

.viewer-canvas-wrap {
  position: relative;
  width: 100%;
  height: min(64vh, 680px);
  min-height: 380px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #3c5a7f;
  background: #10243d;
}

#viewer-canvas {
  width: 100%;
  height: 100%;
}

#viewer-canvas canvas {
  display: block;
  touch-action: none;
}

.viewer-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f2dfae;
  background: rgba(6, 16, 28, 0.62);
}

.viewer-status.hidden {
  display: none;
}

.desc-box {
  margin-top: 16px;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
}

.desc-box h2 {
  margin: 0 0 10px;
  color: var(--secondary);
}

.desc-box p,
.desc-box li {
  color: var(--muted);
  line-height: 1.6;
}

.desc-box ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

/* ===== Mobile-first responsiveness ===== */
@media (max-width: 768px) {
  header {
    padding: 28px 14px 18px;
  }

  header h1 {
    font-size: clamp(1.35rem, 6vw, 1.8rem);
    line-height: 1.25;
  }

  header p {
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .gallery-container {
    width: min(1100px, 94%);
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 28px;
  }

  .product-info {
    padding: 14px 14px 10px;
  }

  .product-title {
    font-size: 1.06rem;
  }

  .product-description {
    font-size: 0.95rem;
  }

  .view-button {
    margin: 0 14px 14px;
    padding: 12px 14px;
  }

  .viewer-page {
    width: min(1100px, 95%);
    margin: 12px auto 22px;
  }

  .viewer-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
  }

  .viewer-title {
    font-size: 1.45rem;
    line-height: 1.2;
  }

  .viewer-canvas-wrap {
    height: min(56vh, 480px);
    min-height: 300px;
    border-radius: 14px;
  }

  .desc-box {
    margin-top: 12px;
    padding: 14px;
    border-radius: 12px;
  }

  .desc-box h2 {
    font-size: 1.12rem;
  }

  .desc-box p {
    font-size: 0.96rem;
    line-height: 1.65;
  }

  footer {
    padding: 10px 14px 22px;
    font-size: 0.86rem;
  }
}

@media (max-width: 420px) {
  .viewer-title {
    font-size: 1.25rem;
  }

  .back-link {
    padding: 10px 12px;
    font-size: 0.95rem;
  }

  .viewer-canvas-wrap {
    min-height: 260px;
    height: min(50vh, 420px);
  }
}
