/* ======================================================
   RESET
====================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;

  width: 100%;
  height: 100%;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  background: #f3f3f3;
}

body {
  overflow: hidden;
}


/* ======================================================
   VIEWER GLOBAL
====================================================== */

.viewer-wrapper {
  position: relative;

  width: 100%;
  height: 100vh;
  height: 100dvh;

  min-height: 500px;

  overflow: hidden;

  background:
    radial-gradient(
      circle at center,
      #ffffff 0%,
      #eeeeee 68%,
      #e5e5e5 100%
    );
}


#viewer {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;
}


#viewer canvas {
  display: block;

  width: 100%;
  height: 100%;

  cursor: grab;

  touch-action: none;
}


#viewer canvas:active {
  cursor: grabbing;
}


/* ======================================================
   HEADER GLOBAL
====================================================== */

.site-header {
  position: absolute;

  top: 0;
  left: 0;

  z-index: 40;

  width: 100%;
  height: 92px;

  display: flex;
  align-items: center;
  justify-content: center;

  pointer-events: none;

  background:
    linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.96),
      rgba(255, 255, 255, 0.72),
      rgba(255, 255, 255, 0)
    );
}


.site-header img {
  display: block;

  width: 180px;
  max-width: 35vw;
  max-height: 56px;

  object-fit: contain;
}


/* ======================================================
   INFOS VIEWER
====================================================== */

.viewer-ui {
  position: absolute;

  left: 30px;
  bottom: 30px;

  z-index: 20;

  pointer-events: none;
}


.viewer-title {
  margin-bottom: 5px;

  font-size: 18px;
  font-weight: 700;

  color: #111;
}


.viewer-help {
  margin-bottom: 14px;

  font-size: 12px;

  color: #777;
}


/* ======================================================
   BOUTON RECENTRER DESKTOP
====================================================== */

#reset-view {
  pointer-events: auto;

  padding: 10px 16px;

  border: 1px solid #ccc;

  border-radius: 30px;

  background: rgba(255, 255, 255, 0.9);

  color: #111;

  font-size: 13px;

  cursor: pointer;

  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}


#reset-view:hover {
  background: #111;
  color: #fff;
  border-color: #111;
}


#reset-view:active {
  transform: scale(0.97);
}


/* ======================================================
   PANNEAU DESKTOP
====================================================== */

.desktop-panel {
  position: absolute;

  top: 105px;
  right: 30px;

  z-index: 25;

  width: 290px;

  max-height: calc(100vh - 135px);

  overflow-y: auto;

  padding: 22px;

  border: 1px solid rgba(0, 0, 0, 0.08);

  border-radius: 18px;

  background: rgba(255, 255, 255, 0.9);

  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.14);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  pointer-events: auto;
}


/* ======================================================
   CONTRÔLES
====================================================== */

.light-controls {
  display: flex;
  flex-direction: column;

  gap: 10px;
}


.light-controls label {
  margin-top: 6px;

  font-size: 11px;
  font-weight: 700;

  color: #555;

  text-transform: uppercase;

  letter-spacing: 0.5px;
}


.light-controls select {
  width: 100%;

  height: 44px;

  padding: 0 12px;

  border: 1px solid #d0d0d0;

  border-radius: 10px;

  background: #fff;

  color: #222;

  font-size: 14px;

  cursor: pointer;

  outline: none;
}


.light-controls select:focus {
  border-color: #999;
}


.light-controls select:disabled {
  opacity: 0.45;

  cursor: not-allowed;
}


/* ======================================================
   RANGE
====================================================== */

.light-controls input[type="range"] {
  width: 100%;

  margin: 2px 0 4px;

  cursor: pointer;
}


/* ======================================================
   SWITCH
====================================================== */

.light-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin-bottom: 4px;

  padding-bottom: 12px;

  border-bottom: 1px solid rgba(0, 0, 0, 0.08);

  font-size: 14px;
  font-weight: 700;

  color: #333;
}


.switch {
  position: relative;

  display: inline-block;

  width: 50px;
  height: 28px;

  flex: 0 0 auto;
}


.switch input {
  opacity: 0;

  width: 0;
  height: 0;
}


.slider {
  position: absolute;

  inset: 0;

  cursor: pointer;

  border-radius: 30px;

  background: #cfcfcf;

  transition: 0.2s ease;
}


.slider::before {
  content: "";

  position: absolute;

  left: 3px;
  top: 3px;

  width: 22px;
  height: 22px;

  border-radius: 50%;

  background: #fff;

  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.25);

  transition: 0.2s ease;
}


.switch input:checked + .slider {
  background: #111;
}


.switch input:checked + .slider::before {
  transform: translateX(22px);
}


/* ======================================================
   TOOLBAR MOBILE
====================================================== */

.mobile-toolbar {
  display: none;
}


/* ======================================================
   BOTTOM SHEET MOBILE
====================================================== */

.settings-sheet {
  display: none;
}


/* ======================================================
   BOUTON FERMER
====================================================== */

.close-settings {
  width: 100%;

  margin-top: 12px;

  padding: 14px 18px;

  border: none;

  border-radius: 14px;

  background: #111;

  color: #fff;

  font-size: 14px;
  font-weight: 700;

  letter-spacing: 0.2px;

  cursor: pointer;

  transition:
    transform 0.15s ease,
    background 0.2s ease,
    opacity 0.2s ease;

  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.16);
}


.close-settings:hover {
  background: #222;
}


.close-settings:active {
  transform: scale(0.98);
}


/* ======================================================
   MOBILE
====================================================== */

@media (max-width: 768px) {

  body {
    overflow: hidden;
  }


  .viewer-wrapper {
    height: 100dvh;
    min-height: 0;
  }


  /* --------------------------------------------------
     HEADER
  -------------------------------------------------- */

  .site-header {
    height: 72px;

    padding-top: env(safe-area-inset-top);
  }


  .site-header img {
    width: 132px;
    max-width: 45vw;
    max-height: 38px;
  }


  /* --------------------------------------------------
     INFOS VIEWER
  -------------------------------------------------- */

  .viewer-ui {
    top: calc(82px + env(safe-area-inset-top));
    left: 18px;
    bottom: auto;

    z-index: 15;

    pointer-events: none;
  }


  .viewer-title {
    margin-bottom: 4px;

    font-size: 16px;
    font-weight: 700;

    color: #111;
  }


  .viewer-help {
    margin-bottom: 0;

    max-width: 250px;

    font-size: 11px;
    line-height: 1.35;

    color: rgba(0, 0, 0, 0.55);
  }


  #reset-view {
    display: none;
  }


  /* --------------------------------------------------
     MASQUER PANEL DESKTOP
  -------------------------------------------------- */

  .desktop-panel {
    display: none;
  }


  /* --------------------------------------------------
     TOOLBAR BASSE
  -------------------------------------------------- */

  .mobile-toolbar {
    position: absolute;

    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));

    z-index: 50;

    display: flex;
    align-items: center;
    justify-content: space-around;

    height: 68px;

    padding: 7px 10px;

    border: 1px solid rgba(0, 0, 0, 0.07);

    border-radius: 22px;

    background: rgba(255, 255, 255, 0.9);

    box-shadow:
      0 10px 35px rgba(0, 0, 0, 0.15);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }


  .mobile-toolbar button {
    min-width: 72px;

    padding: 5px;

    border: none;

    background: transparent;

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 3px;

    color: #111;

    font-size: 10px;
    font-weight: 600;

    cursor: pointer;
  }


  .mobile-toolbar button .icon {
    font-size: 21px;
    line-height: 1;
  }


  /* --------------------------------------------------
     BOTTOM SHEET
  -------------------------------------------------- */

  .settings-sheet {
    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    z-index: 80;

    display: block;

    max-height: 78dvh;

    padding:
      12px
      20px
      calc(24px + env(safe-area-inset-bottom));

    overflow-y: auto;

    border-radius: 24px 24px 0 0;

    background: rgba(248, 248, 248, 0.97);

    box-shadow:
      0 -12px 35px rgba(0, 0, 0, 0.18);

    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);

    transform: translateY(105%);

    transition:
      transform 0.28s ease;
  }


  .settings-sheet.open {
    transform: translateY(0);
  }


  .settings-handle {
    width: 42px;
    height: 5px;

    margin: 0 auto 18px;

    border-radius: 10px;

    background: #c7c7c7;
  }


  /* --------------------------------------------------
     CONTRÔLES MOBILE
  -------------------------------------------------- */

  .settings-sheet .light-controls {
    width: 100%;

    gap: 11px;
  }


  .settings-sheet .light-toggle {
    margin-bottom: 6px;

    padding-bottom: 12px;
  }


  .settings-sheet .light-controls label {
    margin-top: 4px;

    font-size: 12px;
  }


  .settings-sheet .light-controls select {
    height: 48px;

    border-radius: 12px;

    font-size: 15px;
  }


  .settings-sheet .light-controls input[type="range"] {
    height: 28px;
  }


  .close-settings {
    margin-top: 14px;
  }

}


/* ======================================================
   PETITS ÉCRANS
====================================================== */

@media (max-width: 430px) {

  .site-header {
    height: 68px;
  }


  .site-header img {
    width: 118px;
    max-height: 34px;
  }


  .mobile-toolbar {
    left: 8px;
    right: 8px;

    height: 64px;

    border-radius: 20px;
  }


  .mobile-toolbar button {
    min-width: 64px;

    font-size: 9px;
  }


  .mobile-toolbar button .icon {
    font-size: 19px;
  }


  .viewer-help {
    max-width: 210px;
  }


  .settings-sheet {
    padding-left: 16px;
    padding-right: 16px;
  }

}

/* ======================================================
   ETAT BOUTON LUMIERE MOBILE
====================================================== */

#mobile-light {
  border-radius: 14px;

  transition:
    background 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}


/* ON */

#mobile-light.is-on {
  background: #111;

  color: #fff;
}


#mobile-light.is-on .icon {
  opacity: 1;
}


/* OFF */

#mobile-light.is-off {
  background: rgba(0, 0, 0, 0.06);

  color: #777;
}


#mobile-light.is-off .icon {
  opacity: 0.45;
}