/*
 * DTA E-Scooter.css
 * Main stylesheet for the E-Scooter Digital Twin Application
 * __V3D_TEMPLATE__ - template-based file; delete this line to prevent this file from being updated
 */

/* ===== GLOBAL SETTINGS ===== */
:root {
  /* ----- Typography ----- */
  --font-family: 'Inter', sans-serif;

  /* Font Sizes */
  --font-size-small: 12px;
  --font-size-normal: 14px;
  --font-size-button: 12px;
  --font-size-title: 18px;

  /* Font Weights */
  --font-weight-regular: 300;
  --font-weight-medium: 300;
  --font-weight-semibold: 600;
  --font-weight-bold: 600;

  /* Line Heights */
  --line-height-normal: 1.4;
  --line-height-heading: 1.2;

  /* ----- Colors ----- */
  /* Text Colors */
  --text-color-primary: #ffffff;
  --text-color-secondary: #939498;
  --text-color-black: #000000;

  /* UI Element Colors */
  --bg-menu: #1e1f20;
  --bg-button: #333537;
  --bg-preloader: #181818;
  --bg-preloader-bar: #c8c8c8;
  --bg-preloader-background: #d9d9d9;
  --cta-color: #00EFE8;
  --cta-color-hover: #00948A;
  --cta-color-transparent: rgba(0, 239, 232, 0.3);
  --transparent-white-10: rgba(255, 255, 255, 0.1);
  --transparent-white-20: rgba(255, 255, 255, 0.2);
  --transparent-white-30: rgba(255, 255, 255, 0.3);
  --transparent-black-10: rgba(0, 0, 0, 0.1);
  --transparent-black-30: rgba(0, 0, 0, 0.3);
  --transparent-black-50: rgba(0, 0, 0, 0.5);

  /* Panel Colors */
  --bg-panel: #1e1f20;
  --bg-panel-item: #333537;

  /* ----- Filter Effects ----- */
  --icon-filter-gray: invert(60%) sepia(9%) saturate(119%) hue-rotate(202deg) brightness(89%) contrast(87%);
  --icon-filter-white: invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%);
  --icon-filter-cta: invert(67%) sepia(91%) saturate(380%) hue-rotate(131deg) brightness(101%) contrast(101%);

  /* ----- Sizing & Spacing ----- */
  /* Icon Sizes */
  --icon-size-menu: 28px;
  --icon-size-nav: 20px;

  /* Menu & Navigation */
  --menu-height: 64px;
  --menu-width: 412px;
  --menu-radius: 16px;
  --menu-padding: 60px;

  /* Buttons */
  --button-height: 40px;
  --button-padding: 8px;
  --button-gap: 20px;
  --button-border-radius: 24px;

  /* Panel Dimensions */
  --panel-border-radius: 16px;

  /* ----- Effects ----- */
  --shadow-glow: 0 0 8px 2px rgba(0, 239, 232, 0.4);
  --shadow-glow-hover: 0 0 12px 3px rgba(0, 239, 232, 0.5);
  --shadow-popup: 0 4px 20px rgba(0, 0, 0, 0.5);

  /* ----- Transitions ----- */
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* ----- Z-index Layers ----- */
  --z-index-base: 1;
  --z-index-menu: 10;
  --z-index-panel: 100;
  --z-index-tutorial: 1001;
}

/* Responsive Breakpoints */
:root {
  --breakpoint-sm: 480px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1200px;
}

/* ===== BASE ELEMENTS ===== */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-family);
}

/* ===== FONT IMPORTS ===== */
@font-face {
  font-family: 'Inter';
  font-weight: 400;
  font-style: normal;
  src: url('./fonts/Inter_18pt-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-weight: 500;
  font-style: normal;
  src: url('./fonts/Inter_18pt-Medium.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-weight: 600;
  font-style: normal;
  src: url('./fonts/Inter_18pt-SemiBold.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-weight: 700;
  font-style: normal;
  src: url('./fonts/Inter_18pt-Bold.ttf') format('truetype');
}

/* ===== 3D VIEWER COMPONENTS ===== */
.v3d-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Custom Preloader Screen Styles */
.custom-preloader-screen {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-preloader-background);
  transition: opacity 0.5s ease-in-out;
}

.preloader-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preloader-logo {
  width: 150px;
  height: 150px;
  margin-bottom: 30px;
  filter: brightness(0);
  animation: pulse 2s infinite alternate;
}

.preloader-progress-container {
  width: 100%;
  height: 10px;
  background-color: var(--bg-panel-item);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 0 10px var(--shadow-glow);
  border: 1px solid var(--text-color-black);
}

.preloader-progress-bar {
  height: 100%;
  width: 0%;
  background-color: var(--cta-color);
  border-radius: 5px;
  transition: width 0.3s ease-in-out;
}

.preloader-percentage {
  font-family: var(--font-family);
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-bold);
  color: var(--text-color-black);
  text-align: center;
}

/* Hide original Verge3D preloader */
#v3d_preloader_container {
  display: none !important;
}

/* ===== NAVIGATION SYSTEM ===== */
/* Common menu properties */
#navigation-menu,
#function-menu {
  position: fixed;
  background-color: var(--bg-menu);
  display: flex;
  align-items: center;
  z-index: var(--z-index-menu);
  box-sizing: border-box;
}

/* Navigation menu (top bar) */
#navigation-menu {
  top: 0;
  left: 0;
  width: 100%;
  height: var(--menu-height);
  justify-content: space-between;
  padding: 0;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
}

.nav-left {
  margin-left: var(--menu-padding);
}

.nav-right {
  gap: var(--button-gap);
  margin-right: var(--menu-padding);
}

#app-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-color-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-medium);
}

/* Function menu (bottom bar) - Desktop */
@media screen and (min-width: 1025px) {
  #function-menu {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content !important;
    min-width: auto !important;
    max-width: none !important;
    height: var(--menu-height);
    border-radius: var(--menu-radius);
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
  }
}

/* Ensure function menu has rounded corners in fullscreen mode when viewport is desktop-sized */
:fullscreen #function-menu,
:-webkit-full-screen #function-menu,
:-moz-full-screen #function-menu,
:-ms-fullscreen #function-menu {
  border-radius: var(--menu-radius) !important;
}

/* When in fullscreen mode, ensure desktop layout is maintained if viewport allows */
@media screen and (min-width: 1025px) {
  :fullscreen #function-menu,
  :-webkit-full-screen #function-menu,
  :-moz-full-screen #function-menu,
  :-ms-fullscreen #function-menu {
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: fit-content !important;
    min-width: auto !important;
    max-width: none !important;
    height: var(--menu-height) !important;
    border-radius: var(--menu-radius) !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 0 6px !important;
  }
  
  :fullscreen #function-menu .menu-item,
  :-webkit-full-screen #function-menu .menu-item,
  :-moz-full-screen #function-menu .menu-item,
  :-ms-fullscreen #function-menu .menu-item {
    flex-direction: column !important;
    padding: 2px 4px !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: auto !important;
    width: auto !important;
    flex: 0 0 auto !important;
    border-radius: var(--menu-radius) !important;
  }
}

/* Desktop: Menu items with centered icons and text below */
@media screen and (min-width: 1025px) {
  #function-menu .menu-item {
    flex-direction: column;
    padding: 2px 4px;
    align-items: center;
    justify-content: center;
    min-width: auto;
    width: auto;
    flex: 0 0 auto;
  }

  /* Desktop: Hide button-text span, use ::after pseudo-element instead */
  #function-menu .menu-item .button-text {
    display: none;
  }

  /* Desktop: Show text below icon using ::after */
  #function-menu .menu-item::after {
    content: attr(data-function);
    font-size: var(--font-size-button);
    margin-top: 2px;
    text-transform: capitalize;
    color: var(--text-color-primary);
    white-space: nowrap;
  }

  /* Desktop: AR button shows uppercase */
  #ar_button::after {
    content: "AR";
    text-transform: uppercase !important;
  }

  /* Desktop: AR-ready/edit hidden (mobile-only feature) */
  #ar_ready,
  #ar_edit {
    display: none !important;
  }

  /* Desktop: Hover state for text */
  #function-menu .menu-item:hover::after {
    color: var(--cta-color);
  }
}

/* Base menu-item styles (applies to all) */
.menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* AR buttons: defaults for puzzle-controlled visibility */
#ar_button {
  display: flex;
  order: 1;
}

#ar_ready,
#ar_edit {
  display: none;
}
#ar_ready {
  order: 2;
}
#ar_edit {
  order: 3;
}
#explode_button {
  order: 4;
}

/* ===== BUTTON DESIGN SYSTEM ===== */
/* Base button styles */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-button);
  font-family: var(--font-family);
  font-weight: var(--font-weight-regular);
  padding: var(--button-padding);
  transition: color var(--transition-fast), filter var(--transition-fast);
}

.btn img {
  transition: filter var(--transition-fast);
}

/* Button shapes */
.btn-circle {
  border-radius: 50%;
  width: var(--button-height);
  height: var(--button-height);
  padding: 0;
}

.btn-pill {
  border-radius: var(--button-border-radius);
  padding: 8px 16px;
  height: var(--button-height);
}

/* Function Menu Buttons (Gray with White hover) */
.btn-gray-to-white {
  color: var(--text-color-primary);
  background: transparent;
}

.btn-gray-to-white:hover,
.btn-gray-to-white.active {
  color: var(--cta-color);
}

.btn-gray-to-white img {
  filter: var(--icon-filter-white);
  width: var(--icon-size-menu);
  height: var(--icon-size-menu);
}

.btn-gray-to-white:hover img,
.btn-gray-to-white.active img {
  filter: var(--icon-filter-cta);
}

/* Navigation Buttons (White with Gray hover) */
.btn-white-to-gray {
  color: var(--text-color-primary);
  background-color: var(--bg-button);
}

.btn-white-to-gray:hover {
  color: var(--text-color-primary);
}

.btn-white-to-gray img {
  filter: var(--icon-filter-white) !important;
  width: var(--icon-size-nav);
  height: var(--icon-size-nav);
}

.btn-white-to-gray:hover img {
  filter: var(--icon-filter-cta) !important;
}

/* Reset button text */
#reset_button img,
#return_button img {
  margin-right: 10px;
}

#reset_button .button-text,
#return_button .button-text {
  color: var(--text-color-primary);
}

#reset_button:hover .button-text,
#return_button:hover .button-text {
  color: var(--cta-color);
}

/* Hide the default fullscreen button */
#fullscreen-button {
  display: none !important;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===== UNAVAILABLE POPUP ===== */
.unavailable-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--bg-panel);
  color: var(--text-color-primary);
  border-radius: var(--panel-border-radius);
  padding: 8px 12px;
  font-family: var(--font-family);
  font-weight: var(--font-weight-regular);
  text-align: center;
  z-index: var(--z-index-tutorial);
  box-shadow: var(--shadow-popup);
  display: none;
  min-width: 200px;
}

.unavailable-popup p {
  margin: 0;
  font-size: var(--font-size-normal);
}

/* ===== AR POPUPS ===== */
.ar-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--bg-panel);
  color: var(--text-color-primary);
  border-radius: var(--panel-border-radius);
  padding: 20px;
  width: calc(100% - 40px);
  max-width: 460px;
  box-shadow: var(--shadow-popup);
  z-index: var(--z-index-tutorial);
  display: none;
  box-sizing: border-box;
  border: 1px solid var(--transparent-white-20);
}

#ar_unavailable {
  display: none; /* enable for manual testing; set to none when wiring puzzles */
}

#ar_failure {
  display: none; /* enable for manual testing; set to none when wiring puzzles */
  top: calc(50% + 40px); /* slight offset so the two popups don’t overlap */
}

.ar-popup h2 {
  margin: 0 0 12px;
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
}

.ar-popup p {
  margin: 0 0 12px;
  font-size: var(--font-size-normal);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
}

.ar-popup .ar-popup-section {
  background: var(--transparent-white-10);
  border: 1px solid var(--transparent-white-20);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.ar-popup .ar-popup-subtitle {
  font-weight: var(--font-weight-semibold);
  margin-bottom: 8px;
  color: var(--text-color-primary);
}

.ar-browser-list,
.ar-checklist {
  margin: 0;
  padding-left: 16px;
  color: var(--text-color-primary);
  font-size: var(--font-size-normal);
  line-height: var(--line-height-normal);
}

.ar-browser-list {
  list-style: none;
  padding-left: 0;
}

.ar-browser-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--transparent-white-10);
}

.ar-browser-list li:last-child {
  border-bottom: none;
}

.ar-popup-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.ar-popup-button {
  background-color: var(--cta-color);
  color: var(--text-color-black);
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-family: var(--font-family);
  font-size: var(--font-size-button);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  box-sizing: border-box;
  width: 100%;
  max-width: 280px;
}

.ar-popup-button:hover {
  background-color: var(--cta-color-hover);
  color: var(--text-color-primary);
  transform: translateY(-1px);
}

.ar-popup-button:active {
  transform: translateY(0);
}

.ar-browser-list .ar-label {
  font-weight: var(--font-weight-semibold);
}

.ar-browser-list .ar-value {
  color: var(--cta-color);
  font-weight: var(--font-weight-semibold);
}

.ar-checklist {
  padding-left: 18px;
}

.ar-checklist li {
  margin-bottom: 8px;
}

.ar-checklist li:last-child {
  margin-bottom: 0;
}

.ar-note {
  margin: 0;
  font-size: var(--font-size-small);
  color: var(--text-color-secondary);
  line-height: var(--line-height-normal);
}

/* ===== RESPONSIVE DESIGN ===== */
/* Mobile and Tablet - under 1024px */
@media screen and (max-width: 1024px) {
  /* Navigation menus - Hidden by default on mobile */
  #navigation-menu {
    padding: 0 10px;
    background-color: transparent;
    display: none;
  }

  /* Function menu - Hidden by default on mobile */
  #function-menu {
    display: none;
  }

  .nav-left {
    margin-left: 10px;
  }

  .nav-right {
    margin-right: 10px;
  }

  /* Hide app title on mobile */
  #app-title {
    display: none;
  }

  /* Change reset, return, and fullscreen button colors */
  #reset_button.btn-white-to-gray,
  #return_button.btn-white-to-gray,
  #custom-fullscreen.btn-white-to-gray {
    background-color: var(--bg-menu);
  }

  /* Mobile: Function menu - transparent background, buttons on sides */
  #function-menu {
    width: 100%;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0;
    background-color: transparent;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 20px;
    padding: 0 20px;
  }

  /* Mobile: Function menu buttons - horizontal layout */
  #function-menu .menu-item {
    background-color: var(--bg-menu);
    border-radius: var(--menu-radius);
    padding: 12px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
  }

  /* Mobile: Show button-text span, hide ::after */
  #function-menu .menu-item .button-text {
    display: inline-flex;
    align-items: center;
    color: var(--text-color-primary);
    font-size: var(--font-size-button);
    font-family: var(--font-family);
    font-weight: var(--font-weight-regular);
    white-space: nowrap;
    margin: 0;
    padding: 0;
    line-height: 1;
  }

  #function-menu .menu-item:hover .button-text,
  #function-menu .menu-item.active .button-text {
    color: var(--cta-color);
  }

  /* Mobile: Space between icon and text */
  #function-menu .menu-item img {
    margin-right: 10px;
    margin-left: 0;
    margin-top: 0;
    margin-bottom: 0;
    flex-shrink: 0;
    vertical-align: middle;
  }

  /* Mobile: Vertically center icon + label */
  #function-menu .menu-item .button-text {
    vertical-align: middle;
  }

  /* Mobile: Hide ::after pseudo-element */
  #function-menu .menu-item::after {
    content: none;
    display: none;
  }
}

/* Landscape mode for mobile devices */
@media screen and (max-width: 1024px) and (orientation: landscape) {
  /* Navigation menu - Hidden by default on mobile landscape */
  #navigation-menu {
    display: none;
  }

  /* Function menu positioning - vertical column on the right side */
  /* Hidden by default, shown via JavaScript when UI is toggled */
  #function-menu {
    display: none;
    width: auto;
    height: calc(100% - var(--menu-height));
    bottom: 0;
    top: var(--menu-height);
    left: auto;
    right: 20px;
    transform: none;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 0;
    background-color: transparent;
  }

  /* Landscape: Function menu buttons */
  #function-menu .menu-item {
    background-color: var(--bg-menu);
    border-radius: var(--menu-radius);
    padding: 12px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
  }

  /* Landscape: Show button-text, hide ::after */
  #function-menu .menu-item .button-text {
    display: inline-block;
    color: var(--text-color-primary);
    font-size: var(--font-size-button);
    white-space: nowrap;
  }

  #function-menu .menu-item:hover .button-text,
  #function-menu .menu-item.active .button-text {
    color: var(--cta-color);
  }

  /* Landscape: Space between icon and text */
  #function-menu .menu-item img {
    margin-right: 10px;
    margin-left: 0;
    margin-top: 0;
    margin-bottom: 0;
  }

  /* Landscape: Hide ::after pseudo-element */
  #function-menu .menu-item::after {
    content: none;
    display: none;
  }
}

/* iPhone SE and very small devices */
@media screen and (max-width: 375px) and (max-height: 667px) {
  /* Tighter spacing in header */
  .nav-left {
    margin-left: 5px;
  }

  .nav-right {
    margin-right: 5px;
    gap: 10px;
  }

  /* Very small devices: Function menu */
  #function-menu {
    padding: 0 10px;
    gap: 15px;
  }

  /* Very small devices: Function menu buttons */
  #function-menu .menu-item {
    padding: 10px 14px;
  }

  /* Very small devices: Space between icon and text */
  #function-menu .menu-item img {
    margin-right: 8px;
  }

  /* Smaller buttons */
  .btn-circle {
    width: 36px;
    height: 36px;
  }

  /* Landscape mode for very small devices */
  @media (orientation: landscape) {
    #function-menu {
      padding: 15px 0;
      gap: 15px;
      right: 10px;
    }

    #function-menu .menu-item {
      padding: 10px 14px;
    }

    #function-menu .menu-item img {
      margin-right: 8px;
      width: 24px;
      height: 24px;
    }
  }
}

/* Large desktops - optimize for larger screens */
@media screen and (min-width: var(--breakpoint-xl)) {
  :root {
    --font-size-normal: 16px;
    --font-size-title: 20px;
  }

  .btn-circle {
    width: 44px;
    height: 44px;
  }
}

/* ===== CONTROLS TOGGLE BUTTON ===== */
/* Hide controls toggle button on desktop */
.controls-toggle-btn {
  display: none;
}

/* Show controls toggle button only on mobile */
@media screen and (max-width: 1024px) {
  .controls-toggle-btn {
    display: flex;
    position: fixed;
    top: calc((var(--menu-height) - var(--button-height)) / 2);
    left: 50%;
    transform: translateX(-50%);
    z-index: calc(var(--z-index-menu) + 10);
    align-items: center;
    justify-content: center;
  }
  
  /* Match the mobile navigation button background color */
  .controls-toggle-btn.btn-white-to-gray {
    background-color: var(--bg-menu);
  }

  /* Prevent active state color change */
  .controls-toggle-btn.btn-white-to-gray.active,
  .controls-toggle-btn.btn-white-to-gray.active .button-text,
  .controls-toggle-btn.btn-white-to-gray.active img {
    color: var(--text-color-primary) !important;
    filter: var(--icon-filter-white) !important;
  }

  .controls-toggle-btn img {
    margin: 0;
    width: var(--icon-size-nav);
    height: var(--icon-size-nav);
    filter: var(--icon-filter-white) !important;
  }

  /* Prevent icon color change on hover */
  .controls-toggle-btn:hover img,
  .controls-toggle-btn.btn-white-to-gray:hover img {
    filter: var(--icon-filter-white) !important;
  }

  .controls-toggle-btn .button-text {
    color: var(--text-color-primary);
  }

  /* Prevent text color change on hover */
  .controls-toggle-btn:hover .button-text,
  .controls-toggle-btn.btn-white-to-gray:hover .button-text {
    color: var(--text-color-primary) !important;
  }

  /* Center horizontally at top in landscape mode */
  @media (orientation: landscape) {
    .controls-toggle-btn {
      top: calc((var(--menu-height) - var(--button-height)) / 2);
      left: 50%;
      transform: translateX(-50%);
    }
  }

  /* Center horizontally at top for very small devices */
  @media screen and (max-width: 375px) {
    .controls-toggle-btn {
      top: calc((var(--menu-height) - var(--button-height)) / 2);
      left: 50%;
      transform: translateX(-50%);
      padding: 6px 12px;
    }
  }
}
