/* Te Ara Tūhura — Prototype One (camera → open portal → 360). */

:root {
  --bg: #0a0c0b;
  --ink: #e8efe9;
  --moss: #7fd1a8;
  --dim: rgba(232, 239, 233, 0.55);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* camera passthrough (boot) */
#camera-feed {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #0a0c0b; z-index: 0; display: none;
}
body.mode-camera #camera-feed { display: block; }

/* 360 canvas (portal) */
#scene { position: fixed; inset: 0; z-index: 1; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }
#scene canvas { display: block; }
body.mode-camera #scene { display: none; }

/* prev/next film (portal only) */
.zone {
  position: fixed; top: 0; bottom: 0; width: 16vw; z-index: 5; cursor: pointer;
  display: flex; align-items: center;
}
#zone-left { left: 0; justify-content: flex-start; padding-left: max(8px, env(safe-area-inset-left)); }
#zone-right { right: 0; justify-content: flex-end; padding-right: max(8px, env(safe-area-inset-right)); }
body.mode-camera .zone { display: none; }

/* ‹ › cues on the tap zones; a tap flashes its arrow so you can see it registered */
.edge-arrow {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(10, 12, 11, 0.32); border: 1px solid rgba(232, 239, 233, 0.22);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0.6; pointer-events: none;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), background 0.6s var(--ease);
}
.edge-arrow svg { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.zone.flash .edge-arrow {
  opacity: 1; transform: scale(1.25); background: rgba(127, 209, 168, 0.6); border-color: var(--moss);
  transition: none;
}

/* hotspots: a pulsing moss dot pinned in the film (main.js places them each frame); 44px tap target */
#hotspots { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
body.mode-camera #hotspots { display: none; }
.hotspot {
  position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border: 0; background: none;
  padding: 0; cursor: pointer; display: none; pointer-events: auto;
}
.hotspot.on { display: block; }
.hotspot .dot {
  position: absolute; left: 13px; top: 13px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--moss); border: 2px solid var(--ink); box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}
.hotspot .pulse {
  position: absolute; left: 4px; top: 4px; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--moss); animation: hotspot-pulse 1.8s var(--ease) infinite;
}
@keyframes hotspot-pulse { from { transform: scale(0.5); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* info card: slides up from the bottom; any tap on it closes it, the film keeps playing */
#info-card {
  position: fixed; left: 50%; bottom: max(5vh, calc(env(safe-area-inset-bottom) + 12px)); z-index: 7;
  width: min(86vw, 420px); padding: 18px 20px 14px; border-radius: 18px;
  background: rgba(10, 12, 11, 0.72); border: 1px solid rgba(127, 209, 168, 0.45);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  text-align: center; cursor: pointer;
  opacity: 0; transform: translate(-50%, 16px); transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
#info-card[hidden] { display: none; }
#info-card.show { opacity: 1; transform: translate(-50%, 0); }
#info-card .card-title { font-size: 1.15rem; letter-spacing: 0.08em; color: var(--ink); }
#info-card .card-text { margin-top: 6px; font-size: 0.95rem; color: var(--moss); }
#info-card .card-close { margin-top: 10px; font-size: 0.66rem; letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; }

#scene-label {
  position: fixed; left: 50%; bottom: max(7vh, env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  font-size: 0.95rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink); opacity: 0; pointer-events: none; z-index: 6;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.7);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
#scene-label.show { opacity: 1; transform: translate(-50%, 0); }
#scene-label { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
#scene-label .title { white-space: nowrap; }
#scene-label .latlon {
  font-size: 0.66rem; letter-spacing: 0.12em; opacity: 0.8; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* loading ring: .loading eases the fill toward 90% (the browser can't say how long), .done completes it and fades */
#loading-ring {
  position: fixed; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  z-index: 6; pointer-events: none; opacity: 0; transition: opacity 0.4s var(--ease) 0.25s;
}
#loading-ring circle { fill: none; stroke-width: 3.5; }
#loading-ring .track { stroke: rgba(10, 12, 11, 0.35); }
#loading-ring .fill {
  stroke: var(--moss); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5));
}
body.mode-portal #loading-ring.loading { opacity: 1; transition: opacity 0.15s; }
#loading-ring.loading .fill { stroke-dashoffset: 10; transition: stroke-dashoffset 6s cubic-bezier(0.1, 0.7, 0.3, 1); }
#loading-ring.done .fill { stroke-dashoffset: 0; transition: stroke-dashoffset 0.25s ease-out; }

#back {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; z-index: 40;
  padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(232, 239, 233, 0.25);
  background: rgba(10, 12, 11, 0.5); backdrop-filter: blur(6px); color: var(--ink);
  font-size: 0.8rem; cursor: pointer;
}
#back[hidden] { display: none; }

/* scale-through warp: moss covers, then irises away to reveal the 360 */
#warp {
  position: fixed; inset: 0; z-index: 25; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, #a9e6c6 0%, #7fd1a8 46%, #5bbf93 100%);
  clip-path: circle(150% at 50% 50%);
  transition: opacity 0.32s var(--ease), clip-path 0.62s var(--ease);
}
#warp.on { opacity: 1; }
#warp.reveal { clip-path: circle(0% at 50% 50%); } /* iris away → step through into the world */
#warp.dark { background: radial-gradient(circle at 50% 50%, #16241d 0%, #0a0c0b 72%); } /* ?iris=dark variant */

/* launch over the camera */
#portal-launch {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem;
  background: radial-gradient(120% 120% at 50% 45%, transparent 30%, rgba(0, 0, 0, 0.55) 100%);
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
#portal-launch.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.portal-btn {
  position: relative; width: 150px; height: 150px; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer; display: grid; place-items: center;
  transition: transform 0.75s var(--ease), opacity 0.6s var(--ease);
}
.portal-btn .ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(127, 209, 168, 0.7);
  box-shadow: 0 0 44px rgba(127, 209, 168, 0.25), inset 0 0 26px rgba(127, 209, 168, 0.1);
  animation: pulse 3.2s var(--ease) infinite;
}
.portal-btn .core {
  width: 20px; height: 20px; border-radius: 50%; background: var(--moss);
  box-shadow: 0 0 26px rgba(127, 209, 168, 0.9);
  transition: transform 0.3s var(--ease);
}
.portal-btn:active .core { transform: scale(0.8); }
.portal-btn.warp { transform: scale(22); opacity: 0; } /* fly through it */

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 0.4; }
  100% { transform: scale(1); opacity: 0.9; }
}

.wordmark {
  font-size: 0.9rem; letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--ink); padding-left: 0.42em; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}
/* Toct12 (Jon, 12 Oct): one film, no clip title, no prev/next arrows */
#scene-label, .zone { display: none !important; }
.hint { font-size: 0.74rem; letter-spacing: 0.06em; color: var(--dim); }
/* iPhone only: Safari can't go full screen from a page, a Home Screen icon can (Jon, 2026-10-01) */
#a2hs { position: absolute; left: 1rem; right: 1rem; bottom: calc(1.2rem + env(safe-area-inset-bottom)); text-align: center; }
#a2hs[hidden] { display: none; }

/* words under the ring during the black-and-white loading stage (Jon, 2026-10-15) */
#loading-msg {
  position: fixed; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); margin: 0; z-index: 6; pointer-events: none;
  font-size: 0.78rem; letter-spacing: 0.08em; color: var(--ink); white-space: nowrap; text-align: center;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8); opacity: 0; transition: opacity 0.3s var(--ease);
}
body.mode-portal #loading-ring.loading ~ #loading-msg { opacity: 1; transition: opacity 0.15s; }
