/*
 * WANDER & BLOOM - MAIN STYLESHEET
 * This file controls both index.html and ar.html
 */

/* === 1. GLOBAL & FONT DEFINITIONS === */
:root {
  --bg-main: #f5ede5;
  --text-dark: #3b0d00;
  --text-light: #ffffff;
  --brand-green: #384d36;
  --brand-green-tint: rgba(56, 77, 54, 0.37); /* #384d36 at 37% */
  --btn-back: rgba(59, 13, 0, 0.54);      /* #3b0d00 at 54% */
  --btn-save: #22c55e;
  --btn-cancel: #333;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-dark: rgba(0, 0, 0, 0.2);

  --z-scene: 1;
  --z-ui: 10000;
  --z-preview: 20000;
  --z-preload: 30000;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text-dark);
  background-color: var(--bg-main);
}

/* FIX: Force MindAR default loading screen to stay hidden forever 
   so it doesn't interfere with our custom loader. */
.mindar-ui-loading {
  display: none !important;
}

.ar-button {
  cursor: pointer;
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-light);
  background-color: var(--text-dark);
  box-shadow: 0 4px 12px var(--shadow-light);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  text-decoration: none; 
  text-align: center;
  text-transform: uppercase; 
}
.ar-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px var(--shadow-dark);
}

.logo-top {
  width: 100px;
  height: auto;
  object-fit: contain;
  padding: 5px 0px;
}

.credit {
  text-align: center;
  margin-bottom: 24px;
}
.credit-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #000;
}
.credit-logo {
  height: 48px;
  object-fit: contain;
}

/* === 2. INDEX.HTML STYLES === */
#index-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 100dvh;
  padding: 16px;
}
#index-page .panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 400px;
  margin-top: -24px; 
}
#index-page .tagline {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0;
  color: var(--text-dark);
}
#index-page #hero-graphic {
  width: 100%;
  max-width: 220px;
  height: auto;
  border-radius: 16px;
  padding: 12px 0px;
}
#index-page .ar-button {
  width: 100%;
  max-width: 240px;
  padding: 16px;
  font-size: 18px;
}

/* === 3. AR.HTML - PRELOAD SCREEN === */
#preload {
  position: fixed;
  inset: 0;
  z-index: var(--z-preload);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  
  /* FIX: Added solid background color. 
     This blocks the "Blue Screen" (3D Canvas) from showing through 
     while the assets are warming up behind it. */
  background-color: var(--bg-main);
  
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-in-out;
}
#preload .panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  text-align: center;
}

.preload-main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#preload .logo-top{
  margin: 15px 0px 10px;
}

#preload h2 {
  margin: 16px 0 12px;
  font-size: 22px;
  font-weight: 700;
}
#preload p {
  margin: 6px 0 12px;
  opacity: 0.9;
}
#start-content {
  display: none; 
  width: 100%;
}

#start-content #ready-subline {
  font-weight: 700;
  margin-bottom: 24px;
}

.loader {
  margin: 10px auto 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(59, 13, 0, 0.2);
  border-top-color: var(--text-dark);
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  width: 100%;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}
.button-group .ar-button {
  flex: 1;
}
#backBtn {
  background-color: var(--btn-back);
}
.tip-box {
  margin-top: 24px;
  padding: 16px 20px;
  border: 1px solid var(--brand-green);
  background: var(--brand-green-tint);
  border-radius: 16px;
  text-align: center; 
}
.tip-box p {
  font-size: 15px;
  line-height: 1.5;
  margin: 8px 0;
  color: var(--text-dark);
}
.tip-box p:first-child { margin-top: 0; }
.tip-box p:last-child { margin-bottom: 0; }

/* === 4. AR.HTML - STATE MANAGEMENT === */
#ar-page.state-loading #preload { opacity: 1; pointer-events: auto; }

/* FIX: Instead of visibility:hidden, we use opacity:0.
   This keeps the scene 'active' so pre-warming works (no freeze),
   but 'invisible' so you don't see the camera zooming/glitching behind the loader. */
#ar-page.state-loading a-scene { 
  opacity: 0; 
  pointer-events: none; 
}

#ar-page.state-ar #ar-ui { opacity: 1; }
#ar-page.state-ar a-scene { 
  opacity: 1; 
  visibility: visible; 
  pointer-events: auto; 
}

#ar-page.state-preview #photoPreview { opacity: 1; pointer-events: auto; }
#ar-page.state-preview #ar-ui { opacity: 0; }
#ar-page.state-preview a-scene { visibility: visible; }

/* === 5. AR.HTML - CORE AR UI === */
a-scene {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  z-index: var(--z-scene);
}
.a-enter-vr-button {
  display: none !important;
}
#ar-ui {
  position: fixed;
  inset: 0;
  z-index: var(--z-ui);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease-in-out;
}
#ar-ui > * {
  pointer-events: auto;
}
#arBack {
  background: rgba(0,0,0,0.55);
  color: var(--text-light);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  line-height: 1;
  cursor: pointer;
  align-self: flex-start;
  text-transform: none; 
}
#ar-ui .spacer {
  flex-grow: 1;
}
#arToolbar {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#takePhotoBtn {
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(59, 13, 0, 0.3);
}
#soundToggleBtn {
  background-color: rgba(255, 255, 255, 0.65);
  color: var(--text-dark);
  font-weight: 500;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#soundIcon {
  height: 18px; 
  width: auto;
  display: block;
}

/* === 6. AR.HTML - PHOTO PREVIEW === */
#photoPreview {
  position: fixed;
  inset: 0;
  z-index: var(--z-preview);
  background: rgba(0,0,0,0.9);
  color: var(--text-light);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-in-out;
}
#photoPreview .img-container {
  position: absolute;
  inset: 64px 16px 96px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#photoPreviewImg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
}
#photoPreview .btn-container {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#photoCancelBtn, #photoSaveBtn {
  cursor: pointer;
  padding: 12px 18px;
  border-radius: 10px;
  border: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}
#photoCancelBtn {
  background: var(--btn-cancel);
  color: var(--text-light);
}
#photoSaveBtn {
  background: var(--btn-save);
  color: var(--text-light);
}