/* ── AR Loader overlay ───────────────────────────────────────
   Shown while the AR scene + museum model finish loading after
   the user taps "Enter the AR art gallery". Progress is driven
   from real readiness signals in ar-loader.js, not simulated.
   ────────────────────────────────────────────────────────────── */

.ar-loader {
  position: fixed;
  inset: 0;
  z-index: 1100;                                 /* above HUD buttons (1000) and settings modal (1001) — covers them entirely while loading */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Generous top/bottom breathing room that honours device safe-areas
     (notch / home indicator). The clamp grows from ~24px on tiny phones
     to ~60px on tablets/desktop. */
  padding:
    max(env(safe-area-inset-top,    0px), clamp(24px, 5vh, 60px))
    clamp(16px, 5vw, 40px)
    max(env(safe-area-inset-bottom, 0px), clamp(24px, 5vh, 60px));
  background: linear-gradient(135deg, #0f2c4a 0%, #1a3a52 50%, #0d1f35 100%);
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #ffffff;
  opacity: 0;
  visibility: hidden;
  /* no transition by default → showing is instant, so the AR canvas is
     never glimpsed during the landing-screen fade-out */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.ar-loader::-webkit-scrollbar { display: none; }

.ar-loader--visible {
  opacity: 1;
  visibility: visible;
}

/* --hiding overrides --visible (later in source order) and is the only
   state where opacity is animated. Applied during dismissal so the
   loader fades smoothly into the AR view. */
.ar-loader--hiding {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.ar-loader__container {
  text-align: center;
  width: 100%;
  max-width: 400px;
  /* When viewport is shorter than content (small phones, landscape) the
     overlay scrolls instead of cropping. */
  margin: auto;
}

/* ── Circular progress ─────────────────────────────────────── */

.ar-loader__progress-circle {
  position: relative;
  /* Scales with viewport but capped: 200px on tiny phones, up to 280px
     on big screens. Square — width == height. */
  width: clamp(200px, 55vmin, 280px);
  height: clamp(200px, 55vmin, 280px);
  margin: 0 auto clamp(20px, 4vh, 40px);
}

.ar-loader__progress-bg {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(95, 191, 219, 0.08);
  border: 3px solid rgba(95, 191, 219, 0.20);
}

.ar-loader__progress-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);     /* start arc from 12 o'clock */
  border-radius: 50%;
}

.ar-loader__progress-ring svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ar-loader__progress-ring circle {
  fill: none;
  stroke: url(#ar-loader-gradient);
  stroke-width: 6;
  stroke-linecap: round;
  /* dasharray = 2π·65 ≈ 408 (matches circle r=65). dashoffset is
     written from JS each frame to reflect real progress. */
  stroke-dasharray: 408;
  stroke-dashoffset: 408;
  transition: stroke-dashoffset 0.18s ease-out;
}

.ar-loader__progress-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1vh, 8px);
  width: 80%;        /* keep wrapped status text from touching the ring */
  text-align: center;
}

/* Number + % share one row, with the % baseline-aligned to the digits. */
.ar-loader__progress-readout {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
}

.ar-loader__percentage {
  font-size: clamp(36px, 8vmin, 48px);
  font-weight: 700;
  color: #4dc3cf;
  line-height: 1;
}

.ar-loader__percentage-label {
  font-size: clamp(14px, 3vmin, 20px);
  font-weight: 700;
  color: #4dc3cf;
  line-height: 1;
}

/* ── Status text ──────────────────────────────────────────── */

.ar-loader__status-text {
  font-size: clamp(18px, 4.5vmin, 24px);
  font-weight: 600;
  margin-bottom: clamp(8px, 1.5vh, 12px);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.2;
}

/* Cycling status text now sits INSIDE the progress circle, directly
   beneath the percentage. Shrunk to fit inside the ring. */
.ar-loader__status-subtext {
  font-size: clamp(9px, 2vmin, 12px);
  color: rgba(95, 191, 219, 0.9);
  letter-spacing: 0.5px;
  /* Lock height so the typing effect (empty → typed → empty) can't push
     the surrounding layout around. line-height and min-height must match. */
  line-height: 1.3;
  min-height: 1.3em;
  text-transform: uppercase;   /* Latin → caps; Arabic/Chinese → unchanged */
  max-width: 100%;
  overflow-wrap: break-word;
  text-align: center;
}

.ar-loader__dot {
  display: inline-block;
  animation: ar-loader-blink 1.5s ease-in-out infinite;
}

.ar-loader__dot:nth-child(2) { animation-delay: 0.2s; }
.ar-loader__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ar-loader-blink {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

/* ── Navigation guide card ─────────────────────────────────── */

.ar-loader__instructions {
  margin: clamp(18px, 3.5vh, 25px) auto 0;
  padding: clamp(12px, 2.5vh, 16px) clamp(14px, 4vw, 20px);
  background: rgba(77, 195, 207, 0.08);
  border-radius: 14px;
  border: 1.5px solid rgba(77, 195, 207, 0.25);
  max-width: 280px;
  text-align: center;
  animation: ar-loader-fade-in 0.8s ease-out;
}

@keyframes ar-loader-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ar-loader__instruction-title {
  font-size: 12px;
  color: #4dc3cf;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.ar-loader__instruction-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ar-loader__instruction-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.ar-loader__instruction-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.ar-loader__instruction-detail {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
}

.ar-loader__instruction-tip {
  font-size: 11px;
  color: #4dc3cf;
  margin-top: 8px;
  padding: 8px;
  background: rgba(77, 195, 207, 0.15);
  border-radius: 6px;
  font-weight: 500;
}

/* ── Responsive overrides ─────────────────────────────────── */

/* Very narrow phones (≤ 360 px) — pull the instruction card in a bit
   so it doesn't hug the device bezels. */
@media (max-width: 360px) {
  .ar-loader__instructions { max-width: 92%; }
}

/* Short portrait phones (iPhone SE, iPhone 12 mini, etc.) — compress
   the vertical rhythm so the full overlay fits without scrolling. */
@media (orientation: portrait) and (max-height: 640px) {
  .ar-loader {
    padding-top:    max(env(safe-area-inset-top,    0px), 16px);
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 16px);
  }
  .ar-loader__progress-circle {
    width: clamp(170px, 38vh, 220px);
    height: clamp(170px, 38vh, 220px);
    margin: 0 auto 16px;
  }
  .ar-loader__instructions  { margin-top: 14px; padding: 12px 16px; }
  .ar-loader__instruction-item { padding: 4px 0; }
  .ar-loader__instruction-content { gap: 8px; }
}

/* Landscape phones — circle goes alongside the text instead of above. */
@media (orientation: landscape) and (max-height: 500px) {
  .ar-loader__container {
    max-width: 720px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(20px, 4vw, 40px);
    text-align: left;
  }
  .ar-loader__progress-circle {
    width: clamp(150px, 70vh, 200px);
    height: clamp(150px, 70vh, 200px);
    margin: 0;
    flex: 0 0 auto;
  }
  .ar-loader__status-text   { font-size: clamp(16px, 3.6vh, 20px); }
  .ar-loader__instructions  { margin: 0; max-width: 100%; }
}

/* Tablets (≥ 768 px) — let the loader breathe a little more. */
@media (min-width: 768px) {
  .ar-loader__container       { max-width: 440px; }
  .ar-loader__instructions    { max-width: 320px; }
  .ar-loader__progress-circle { margin-bottom: 44px; }
}

/* Desktop (≥ 1200 px). */
@media (min-width: 1200px) {
  .ar-loader__container       { max-width: 480px; }
  .ar-loader__instructions    { max-width: 360px; padding: 20px 24px; }
  .ar-loader__progress-circle { margin-bottom: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .ar-loader__dot { animation: none; opacity: 0.8; }
  .ar-loader__progress-ring circle { transition: none; }
  .ar-loader__instructions { animation: none; }
}
