/**
 * Infiniview360 — Google Maps business panel mock + transition
 */

:root {
  /* Google Maps mock palette */
  --iv-blue: #1a73e8;
  --iv-blue-hover-bg: #e8f0fe;
  --iv-text: #202124;
  --iv-text-secondary: #70757a;
  --iv-border: #dadce0;
  --iv-surface: #ffffff;
  --iv-map-bg: #e8eaed;
  --iv-star: #f4b400;
  --iv-sidebar-width: 400px;
  --iv-font: "Roboto", Arial, sans-serif;

  /* Mobile Apps Labs palette — https://mobileappslabs.com/fr/ (banner & toast) */
  --mal-brand-dark: #1e293b;
  --mal-brand-light: #f1f5f9;
  --mal-logo: #ffae00;
  --mal-btn1: #00c6e0;
  --mal-btn1-hover: #22d3ee;
  --mal-font-body: "DM Sans", ui-sans-serif, sans-serif;
  --mal-banner-height: 3.5rem;
  --ease-exit: cubic-bezier(0.25, 1, 0.5, 1);
  --iv-door-x: 54%;
  --iv-door-y: 44%;
  --iv-door-shift-x: -30px;
  --iv-door-shift-y: 50px;
  --iv-portal-duration: 3.2s;
  --iv-portal-vignette-duration: 2.9s;
  --iv-portal-spin-duration: 6.4s;
  --iv-portal-origin-x: 50%;
  --iv-portal-origin-y: 50%;
  --iv-portal-start-scale: 0.1;
  /* svh = visible area with browser chrome; avoids 100vh spilling under tabs/taskbar */
  --iv-vh: 100vh;
}

@supports (height: 100svh) {
  :root {
    --iv-vh: 100svh;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: var(--iv-vh);
  max-height: 100%;
  overflow: hidden;
}

body.iv-maps {
  font-family: var(--iv-font);
  color: var(--iv-text);
  background: var(--iv-surface);
}

#app {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* —— Preloaded iframe —— */
#store-frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--iv-vh);
  border: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#store-frame.is-active {
  z-index: 10;
  opacity: 1;
  pointer-events: auto;
}

/* —— Shell (maps UI) —— */
#iv-shell {
  position: relative;
  z-index: 2;
  display: flex;
  height: 100%;
  min-height: 0;
  width: 100%;
  background: var(--iv-surface);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#iv-shell.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

#app[data-state="transition"] #iv-shell .iv-sidebar {
  transform: translateX(-100%);
}

#app[data-state="transition"] #iv-shell .iv-map-zoom {
  transform: scale(4);
  filter: blur(4px);
}

.iv-reduced-motion #app[data-state="transition"] #iv-shell .iv-map-zoom {
  transform: none;
  filter: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.iv-reduced-motion #app[data-state="transition"] #iv-shell .iv-sidebar {
  transition-duration: 0.35s;
}

/* Lang switch */
.iv-lang {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 20;
  font-size: 13px;
  font-weight: 500;
}

.iv-lang a {
  color: var(--iv-blue);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.iv-lang a:hover {
  background: var(--iv-blue-hover-bg);
}

/* —— Sidebar —— */
.iv-sidebar {
  position: relative;
  flex: 0 0 var(--iv-sidebar-width);
  width: var(--iv-sidebar-width);
  max-width: 100%;
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
  border-right: 1px solid var(--iv-border);
  background: var(--iv-surface);
  transition: transform 0.8s var(--ease-exit);
}

.iv-sidebar-content {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
}

.iv-hero-wrap {
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #e0e0e0;
}

.iv-hero {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  display: block;
}

.iv-sidebar-body {
  padding: 16px 20px 24px;
}

.iv-business-name {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0;
}

.iv-category {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--iv-text-secondary);
}

.iv-rating-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.iv-rating-value {
  font-weight: 500;
  color: var(--iv-text);
}

.iv-stars {
  display: inline-flex;
  gap: 1px;
  letter-spacing: -1px;
}

.iv-star {
  font-size: 14px;
  line-height: 1;
}

.iv-star--full,
.iv-star--half {
  color: var(--iv-star);
}

.iv-star--empty {
  color: #dadce0;
}

.iv-review-count {
  color: var(--iv-blue);
  cursor: default;
}

/* Action buttons */
.iv-actions {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--iv-border);
}

.iv-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: default;
}

.iv-action--website {
  cursor: default;
}

.iv-action--website .iv-action-label {
  color: var(--iv-blue);
}

.iv-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.15s ease;
}

.iv-action-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--iv-text-secondary);
  letter-spacing: 0.01em;
}

.iv-action--website:disabled {
  opacity: 1;
  cursor: default;
}

/* Info rows */
.iv-info-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.iv-info-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.45;
}

.iv-info-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--iv-text-secondary);
}

.iv-info-text {
  flex: 1;
  color: var(--iv-text);
}

.iv-hours-summary {
  font-weight: 500;
}

/* —— Map panel —— */
.iv-map-panel {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
  background: var(--iv-map-bg);
}

.iv-map-zoom {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: 55% 48%;
  transition: transform 1.2s ease-in, filter 1.2s ease-in;
}

.iv-map-media {
  position: relative;
  width: 100%;
  height: 100%;
}

.iv-door-enter {
  position: absolute;
  left: var(--iv-door-x);
  top: var(--iv-door-y);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--iv-blue);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: var(--iv-blue);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transform: translate(calc(-50% + var(--iv-door-shift-x)), calc(-50% + var(--iv-door-shift-y)));
  animation: iv-door-pulse 1.35s ease-in-out infinite;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.iv-door-enter::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--iv-blue);
  pointer-events: none;
  animation: iv-door-pulse-ring 1.35s ease-out infinite;
}

.iv-door-enter-icon {
  width: 28px;
  height: 28px;
}

.iv-door-enter:hover {
  background: var(--iv-blue);
  color: #fff;
  box-shadow: 0 4px 18px rgba(26, 115, 232, 0.45);
  transform: translate(calc(-50% + var(--iv-door-shift-x)), calc(-50% + var(--iv-door-shift-y))) scale(1.06);
}

.iv-door-enter:focus-visible {
  outline: 2px solid var(--iv-blue);
  outline-offset: 3px;
}

.iv-door-enter:disabled {
  opacity: 0.5;
  cursor: wait;
  animation: none;
}

.iv-door-enter:disabled::before {
  animation: none;
}

#app[data-state="transition"] .iv-door-enter {
  visibility: hidden;
  pointer-events: none;
  animation: none;
}

#app[data-state="transition"] .iv-door-enter::before {
  animation: none;
}

#app[data-state="store"] .iv-door-enter {
  display: none;
}

@keyframes iv-door-pulse {
  0%,
  100% {
    box-shadow:
      0 2px 14px rgba(0, 0, 0, 0.22),
      0 0 0 0 rgba(26, 115, 232, 0.55);
    transform: translate(calc(-50% + var(--iv-door-shift-x)), calc(-50% + var(--iv-door-shift-y))) scale(1);
  }
  50% {
    box-shadow:
      0 4px 22px rgba(26, 115, 232, 0.45),
      0 0 0 22px rgba(26, 115, 232, 0.28);
    transform: translate(calc(-50% + var(--iv-door-shift-x)), calc(-50% + var(--iv-door-shift-y))) scale(1.08);
  }
}

@keyframes iv-door-pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.85;
  }
  70%,
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

.iv-map-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
}

/* Copy overlay */
.iv-map-overlay {
  position: absolute;
  inset: 0;
  padding: 0;
  pointer-events: none;
  z-index: 5;
}

.iv-overlay-inner {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 32px;
  background: var(--iv-surface);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.iv-map-overlay .iv-overlay-inner {
  position: absolute;
  left: var(--iv-door-x);
  top: 50%;
  max-width: min(520px, calc(100% - 48px));
  transform: translate(calc(-50% + var(--iv-door-shift-x)), calc(-50% - 250px));
}

/* Sidebar demo disclaimer overlay */
.iv-sidebar-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  pointer-events: none;
}

.iv-sidebar-overlay-inner {
  max-width: 100%;
  gap: 10px;
  padding: 20px 18px;
  transform: none;
}

.iv-sidebar-overlay-badge {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--iv-blue);
  opacity: 0;
  animation: iv-fade-in 0.8s ease 0.4s forwards;
}

.iv-sidebar-overlay-line1 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--iv-text);
  opacity: 0;
  animation: iv-fade-in 0.8s ease 1s forwards;
}

.iv-sidebar-overlay-line2 {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--iv-text-secondary);
  opacity: 0;
  animation: iv-fade-in 0.8s ease 1.6s forwards;
}

.iv-overlay-line1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--iv-text);
  opacity: 0;
  animation: iv-fade-in 0.8s ease 1s forwards;
}

.iv-overlay-line2-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.iv-overlay-arrow-wrap {
  flex-shrink: 0;
  display: flex;
  opacity: 0;
  animation: iv-arrow-fade 0.8s ease 2.5s forwards;
}

.iv-overlay-arrow {
  width: 32px;
  height: 32px;
  color: var(--iv-blue);
  display: block;
  animation: iv-bounce-down 1.2s ease 3.3s infinite;
}

.iv-overlay-line2 {
  margin: 0;
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 400;
  color: var(--iv-text-secondary);
  opacity: 0;
  animation: iv-fade-in 0.8s ease 2.5s forwards;
}

@keyframes iv-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes iv-arrow-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes iv-bounce-down {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(8px);
  }
}

/* Transition mask */
#transition-mask {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#transition-mask.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* —— Portal transition (Street View → 3D store) —— */
.portal-transition {
  position: fixed;
  inset: 0;
  z-index: 15;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  perspective: 1100px;
}

.portal-transition.is-active {
  visibility: visible;
}

.portal-transition__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 72% 62% at var(--iv-portal-origin-x) var(--iv-portal-origin-y),
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.35) 48%,
    rgba(0, 0, 0, 0.8) 100%
  );
  opacity: 0;
  transition: opacity 0.45s ease;
}

.portal-transition.phase-active .portal-transition__vignette,
.portal-transition.phase-done .portal-transition__vignette {
  opacity: 1;
  transition: opacity var(--iv-portal-vignette-duration) ease-in;
}

.portal-transition__stage {
  position: absolute;
  top: var(--iv-portal-origin-y);
  left: var(--iv-portal-origin-x);
  width: min(92vw, 960px);
  transform: translate(-50%, -50%) scale(var(--iv-portal-start-scale));
  transform-origin: 50% 50%;
  opacity: 0;
  will-change: transform, opacity;
}

.portal-transition__img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 12px 40px rgba(0, 198, 224, 0.35));
}

.portal-transition.phase-active .portal-transition__stage {
  animation: iv-portal-journey var(--iv-portal-duration) cubic-bezier(0.33, 0, 0.2, 1) forwards;
}

.portal-transition.phase-active .portal-transition__img {
  animation:
    iv-portal-glow var(--iv-portal-duration) ease-in-out forwards,
    iv-portal-spin var(--iv-portal-spin-duration) linear forwards;
}

.portal-transition.phase-done .portal-transition__stage {
  opacity: 0;
  transition: opacity 0.28s ease-out;
}

@keyframes iv-portal-journey {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(var(--iv-portal-start-scale)) translateZ(0);
  }
  14% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(13) translateZ(120px);
  }
}

@keyframes iv-portal-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes iv-portal-glow {
  to {
    filter: drop-shadow(0 0 48px rgba(0, 198, 224, 0.55)) brightness(1.08);
  }
}

#iv-shell.is-portal-suck {
  transform-origin: var(--iv-portal-origin-x) var(--iv-portal-origin-y);
  animation: iv-maps-suck var(--iv-portal-duration) cubic-bezier(0.33, 0, 0.2, 1) forwards;
}

@keyframes iv-maps-suck {
  0% {
    transform: scale(1) translateY(0);
    opacity: 1;
    filter: blur(0);
  }
  100% {
    transform: scale(1.4) translateY(-14%);
    opacity: 0;
    filter: blur(8px);
  }
}

#store-frame.is-portal-reveal {
  transition: opacity 0.55s ease-in;
}

/* —— MAL banner & CTA toast (mobileappslabs.com) —— */
#mal-footer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: var(--mal-banner-height);
  padding: 10px 16px;
  font-family: var(--mal-font-body);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: rgba(30, 41, 59, 0.8);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(30, 41, 59, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#mal-footer a {
  font-weight: 600;
  color: var(--mal-btn1);
  text-decoration: none;
}

#mal-footer a:hover {
  color: var(--mal-btn1-hover);
  text-decoration: underline;
}

#mal-footer[hidden] {
  display: none !important;
}

#cta-toast {
  position: fixed;
  top: var(--mal-banner-height);
  left: 50%;
  z-index: 12;
  width: min(92vw, 420px);
  padding: 20px 24px;
  font-family: var(--mal-font-body);
  background: var(--iv-surface);
  border: 1px solid rgba(30, 41, 59, 0.25);
  border-radius: 12px;
  box-shadow:
    0 8px 30px rgba(30, 41, 59, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06);
  transform: translateX(-50%) translateY(calc(-100% - var(--mal-banner-height) - 16px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease,
    visibility 0s linear 0.4s;
}

#cta-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease,
    visibility 0s;
}

.mal-toast__text {
  margin: 0 0 16px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  color: rgba(30, 41, 59, 0.85);
}

.mal-toast__btn {
  display: block;
  margin: 0 auto;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--mal-brand-dark);
  background: var(--mal-btn1);
  border: none;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: default;
}

/* —— Mobile: minimal sidebar strip —— */
@media (max-width: 1023px) {
  .iv-sidebar {
    flex: 0 0 72px;
    width: 72px;
  }

  .iv-business-name,
  .iv-category,
  .iv-rating-row,
  .iv-info-rows,
  .iv-action:not(.iv-action--website) {
    display: none !important;
  }

  .iv-sidebar-body {
    padding: 12px 8px;
  }

  .iv-actions {
    flex-direction: column;
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    gap: 8px;
  }

  .iv-action--website {
    min-width: 0;
  }

  .iv-action-icon {
    width: 44px;
    height: 44px;
  }

  .iv-action-label {
    font-size: 10px;
    max-width: 64px;
    text-align: center;
    line-height: 1.2;
  }

  .iv-lang {
    bottom: 12px;
    left: 12px;
  }

  .iv-map-overlay .iv-overlay-inner {
    max-width: min(520px, calc(100% - 32px));
  }

  .iv-overlay-arrow-wrap {
    display: none;
  }

  .iv-sidebar-overlay {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .iv-overlay-line1,
  .iv-overlay-line2,
  .iv-overlay-arrow-wrap,
  .iv-sidebar-overlay-badge,
  .iv-sidebar-overlay-line1,
  .iv-sidebar-overlay-line2 {
    animation: none;
    opacity: 1;
  }

  .iv-overlay-arrow {
    animation: none;
  }

  .iv-door-enter,
  .iv-door-enter::before {
    animation: none;
  }

  #iv-shell .iv-sidebar,
  #iv-shell .iv-map-zoom,
  #store-frame,
  #transition-mask,
  #cta-toast {
    transition: none;
  }

  .portal-transition,
  .portal-transition__stage,
  .portal-transition__vignette,
  .portal-transition__img,
  #iv-shell.is-portal-suck {
    animation: none !important;
    transition: none !important;
  }

  #iv-shell.is-portal-suck {
    transform: none;
    filter: none;
  }
}
