:root {
  --night: 0;
  --sky-day-1: #f4e7d7;
  --sky-day-2: #f8cfa9;
  --sky-night-1: #3e4470;
  --sky-night-2: #5a5f92;
  --ink: color-mix(in oklab, #4a3b32, #eceaf8 calc(var(--night) * 100%));
  --paper: color-mix(in oklab, #fffdf7, #4a4f7a calc(var(--night) * 100%));
  --coral: #e89a72;
  --glow: #ffd98a;
}

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

html, body { height: 100%; }

body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.sky {
  position: fixed;
  inset: 0;
  background: linear-gradient(
    to bottom,
    color-mix(in oklab, var(--sky-day-1), var(--sky-night-1) calc(var(--night) * 100%)),
    color-mix(in oklab, var(--sky-day-2), var(--sky-night-2) calc(var(--night) * 100%))
  );
  z-index: 0;
}

.sky-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.8s ease;
  filter: blur(13px) saturate(1.08);
  transform: scale(1.09);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.9s ease;
}

#scene.ready { opacity: 1; }
#scene.dragging { cursor: grabbing; }

.brand {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 24px;
  z-index: 10;
  pointer-events: none;
  user-select: none;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand p {
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.72;
}

#dayNight {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: 22px;
  z-index: 10;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(74, 59, 50, 0.18);
  transition: transform 0.25s ease, background 0.4s ease;
}

#dayNight:hover { transform: scale(1.08); }
#dayNight:active { transform: scale(0.94); }

#dayNight svg { grid-area: 1 / 1; transition: opacity 0.35s ease, transform 0.45s ease; }
#dayNight .icon-moon { opacity: 0; transform: rotate(-60deg) scale(0.5); }
#dayNight[aria-pressed="true"] .icon-sun { opacity: 0; transform: rotate(60deg) scale(0.5); }
#dayNight[aria-pressed="true"] .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

.hotspot {
  position: fixed;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 5;
  padding: 0;
}

.hotspot::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow:
    0 0 0 3px color-mix(in srgb, #fffdf7 85%, transparent),
    0 3px 10px rgba(74, 59, 50, 0.28);
  transition: inset 0.2s ease, background 0.4s ease;
}

.hotspot::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 2px solid var(--coral);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.55); opacity: 0.9; }
  70%, 100% { transform: scale(1.25); opacity: 0; }
}

.hotspot:hover::before,
.hotspot:focus-visible::before { inset: 9px; }

.hotspot.occluded { opacity: 0.16; pointer-events: none; }
.hotspot.occluded::after { animation: none; opacity: 0; }
.hotspot:disabled { cursor: default; }

#count {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 6;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 700;
  color: var(--coral);
  text-shadow:
    -2px -2px 0 #fffdf7, 2px -2px 0 #fffdf7,
    -2px 2px 0 #fffdf7, 2px 2px 0 #fffdf7,
    0 6px 18px rgba(74, 59, 50, 0.25);
  pointer-events: none;
  user-select: none;
  translate: -50% -50%;
}

.card {
  position: fixed;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(340px, calc(100vw - 40px));
  background: var(--paper);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  border-radius: 24px;
  padding: 26px 26px 24px;
  box-shadow: 0 24px 60px rgba(74, 59, 50, 0.22);
  opacity: 0;
  scale: 0.94;
  translate: -50% -46%;
  transition:
    opacity 0.28s ease,
    scale 0.28s cubic-bezier(0.34, 1.4, 0.64, 1),
    translate 0.28s cubic-bezier(0.34, 1.4, 0.64, 1),
    display 0.28s allow-discrete,
    overlay 0.28s allow-discrete;
}

.card:popover-open {
  opacity: 1;
  scale: 1;
  translate: -50% -50%;
}

@starting-style {
  .card:popover-open { opacity: 0; scale: 0.94; translate: -50% -46%; }
}

.card::backdrop {
  background: rgba(58, 48, 42, 0.16);
  backdrop-filter: blur(2px);
}

.card-icon { font-size: 1.7rem; line-height: 1; margin-bottom: 10px; }

.card h2 {
  font-size: 1.32rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.card p:not(.card-icon) {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.55;
  opacity: 0.88;
}

.card p + p { margin-top: 8px; }

.card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: inherit;
  font-size: 1.15rem;
  font-family: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.card-close:hover { background: color-mix(in srgb, currentColor 14%, transparent); transform: rotate(90deg); }

.contact-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 18px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--coral);
  color: #fffdf7;
  border: none;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--coral) 45%, transparent);
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1.5px solid color-mix(in srgb, currentColor 25%, transparent);
}

#hint {
  position: fixed;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  translate: -50%;
  z-index: 10;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.62;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.8s ease;
}

#hint.gone { opacity: 0; }

#toast {
  position: fixed;
  bottom: max(76px, calc(env(safe-area-inset-bottom) + 54px));
  left: 50%;
  translate: -50% 12px;
  z-index: 20;
  background: var(--ink);
  color: color-mix(in oklab, #fffdf7, #eceaf8 calc(var(--night) * 100%));
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, translate 0.3s ease;
}

#toast.show { opacity: 1; translate: -50% 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
}

.fallback img {
  width: min(420px, 86vw);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(74, 59, 50, 0.3);
}

.fallback a { color: var(--coral); }

.no3d .fallback { display: flex; }
.no3d #scene, .no3d .hotspot, .no3d #count, .no3d #hint { display: none; }

.noscript {
  position: fixed;
  inset: auto 0 40vh 0;
  text-align: center;
  z-index: 40;
  font-weight: 600;
}

.noscript a { color: var(--coral); }

button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
  border-radius: 8px;
}

@media (max-width: 720px) {
  .brand { left: 18px; }
  .brand h1 { font-size: 1.05rem; }
  #dayNight { right: 16px; width: 48px; height: 48px; }

  .card {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    border-radius: 26px 26px 0 0;
    padding: 28px 26px calc(30px + env(safe-area-inset-bottom));
    translate: 0 100%;
    scale: 1;
    opacity: 1;
  }

  .card:popover-open { translate: 0 0; scale: 1; opacity: 1; }

  @starting-style {
    .card:popover-open { translate: 0 100%; scale: 1; opacity: 1; }
  }

  .card::backdrop { background: rgba(58, 48, 42, 0.22); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
