/*
 * Styles for demo_jp.html (DeepAR v5 eyewear try-on).
 *
 * Reworked to match the visual identity of the legacy page
 * (https://ar.virtry.net/demo_jp.html): a white, vertically-stacked, centered
 * layout — logo top-left, a landscape preview box, a horizontal thumbnail strip
 * with arrows, then a large App Store badge + QR, then a privacy note.
 *
 * The mechanics stay on the v5 stack: a `#deepar-preview` previewElement (the
 * SDK appends its own <canvas>), the dependency-free src/carousel.js contract,
 * and the loading / permission-denied screens driven by src/demo_jp.js.
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: #fff;
  color: #222;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
    HelveticaNeue, "Segoe UI", "游ゴシック体", YuGothic, "Yu Gothic M",
    "游ゴシック Medium", "Yu Gothic Medium", "ヒラギノ角ゴ ProN W3",
    "Hiragino Kaku Gothic ProN W3", HiraKakuProN-W3, "ヒラギノ角ゴ ProN",
    "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro",
    "メイリオ", Meiryo, Osaka, "ＭＳ Ｐゴシック", "MS PGothic", sans-serif;
}

.fixed-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

/* ---------- AR screen: centered, stacked card on a white page ---------- */

#ar-screen {
  width: 90%;
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
}

.inner {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header band above the camera feed — recommended-browser note. */
#browser-note {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  text-align: center;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
}

@media only screen and (max-device-width: 500px) {
  #browser-note {
    min-height: 40px;
    font-size: 12px;
  }
}

/* ---------- Source selector: camera feed vs. uploaded photo ----------
   Segmented pill toggle directly above the preview. The selected source is
   lit with the same orange glow used for the active carousel thumbnail. */

#source-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 10px;
}

.source-btn {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: #222;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 100px;
  padding: 8px 22px;
  cursor: pointer;
  opacity: 0.8;
  transition: all 300ms ease;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.source-btn.active {
  opacity: 1;
  font-weight: bold;
  border-color: #ff6c00;
  box-shadow: 0 0 10px 0 rgb(255 108 0);
}

.source-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Shutter: captures the current try-on (legacy round camera button). */
#shutter-btn {
  width: 44px;
  height: 44px;
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.9;
  transition: all 300ms ease;
  border-radius: 50%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

#shutter-btn:hover {
  opacity: 1;
  box-shadow: 0 0 10px 0 rgb(255 108 0);
}

/* Nothing to capture yet (no face tracked): dimmed like a disabled button. */
#shutter-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

@media screen and (max-width: 595px) {
  .source-btn {
    font-size: 13px;
    padding: 6px 16px;
  }

  #shutter-btn {
    width: 38px;
    height: 38px;
  }
}

/* DeepAR previewElement — the SDK appends its own <canvas> child here.
   Landscape box, centered, capped like the legacy 60vh / 640px canvas. */
#deepar-preview {
  width: 100%;
  max-width: 640px;
  height: 60vh;
  max-height: 480px;
  margin: 0 auto;
  background-color: #000;
  position: relative;
}

#deepar-preview canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  transition: opacity 0.2s ease;
}

/* While a photo is being resized / processed, hide the stale frame
   (replaces the legacy canvas.style.opacity = 0 trick). */
#deepar-preview.processing canvas {
  opacity: 0;
}

/* Logo pinned to the top-left corner of the camera feed. */
#logo {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 20%;
  max-width: 50px;
  z-index: 20;
}

/* Face-visibility / camera hint text, overlaid on the preview box. */
.text {
  position: absolute;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  width: 80%;
  max-width: 460px;
  text-align: center;
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  z-index: 30;
  padding: 2%;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 6px;
}

#glass_text {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  /* Center within the feed both ways, and size to content so each line
     (split by <br>) never wraps onto an extra line. */
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  max-width: none;
  white-space: nowrap;
}

@media screen and (max-width: 595px) {
  /* Narrow feed: let each line wrap where it needs to rather than
     overflowing the box. */
  #glass_text {
    width: 90%;
    max-width: 460px;
    white-space: normal;
  }
}

/* App-store badge + QR, centered and large, below the carousel. */
.info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6%;
  padding: 3%;
  width: 100%;
}

.info #app-store-badge {
  max-width: 260px;
  height: auto;
  filter: drop-shadow(10px 10px 10px rgba(0, 0, 0, 0.35));
}

.info .qr-code {
  width: auto;
  max-width: 120px;
  height: auto;
}

@media only screen and (max-device-width: 500px) {
  #ar-screen {
    width: 100%;
  }

  .info {
    flex-direction: column;
    gap: 12px;
  }

  .info .qr-code {
    display: none;
  }
}

#bottom_note {
  text-align: center;
  color: #444;
  font-size: 13px;
  line-height: 1.6;
  margin: 20px;
}

@media only screen and (max-device-width: 500px) {
  #bottom_note {
    font-size: 12px;
    text-align: left;
  }
}

/* ---------- Starter overlay (camera access + privacy, start button) ----------
 * Ported from the live SOLAIZ page (eyewear_embed_v2.css + solaiz.css), scoped
 * to cover #deepar-preview. `.on` = first view, `.paused` = idle-pause resume
 * overlay (icon and guide hidden). Toggled by src/demo_jp.js.
 */

#starter-wrapper {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  overflow-y: auto;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  transition: opacity 500ms;
}

#starter-wrapper.on,
#starter-wrapper.paused {
  display: flex;
}

/* Tall content (narrow screens): start at the top so nothing is clipped. */
#starter-wrapper.on {
  justify-content: safe center;
}

#starter-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6%;
  width: 100%;
}

#starter-row img {
  width: 75px;
  height: 75px;
}

#starter-wrapper.paused #starter-row img,
#starter-wrapper.paused #guideWrapper {
  display: none;
}

#starter {
  width: 20%;
  min-width: 200px;
  min-height: 65px;
  padding: 0;
  border: none;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  background: transparent linear-gradient(180deg, #ff0031 0%, #ff5c9b 100%) 0% 0%
    no-repeat padding-box;
  color: #fff;
  text-align: center;
  font-weight: 700;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

#starter:hover,
#starter:focus-visible {
  animation: heartbeat 1.5s ease-in-out infinite both;
}

#starter > span {
  font-size: 1.2rem;
  line-height: 1.4;
}

#guideWrapper {
  margin: 2% 5% 0;
  max-width: 720px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 13px;
}

#guide {
  margin: 10px 1%;
  text-align: left;
  line-height: 1.5;
}

.starter-note {
  text-align: left;
  margin: 12px 5px 0;
  line-height: 1.5;
}

/* Mock of the browser's camera-permission prompt (illustration only). */
.permission-popup {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  width: 380px;
  max-width: 100%;
  font-size: 14px;
  color: #202124;
  text-align: left;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}

.popup-title {
  margin: 0;
}

.close-btn {
  font-family: Arial, sans-serif;
  font-size: 24px;
  font-weight: 300;
  color: #5f6368;
  line-height: 1;
}

.popup-body {
  display: flex;
  align-items: center;
  padding: 16px;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}

.camera-icon {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  fill: #5f6368;
}

.popup-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px;
}

.popup-actions span {
  text-align: right;
  text-decoration: underline;
}

.permission-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dadce0;
  background-color: #f8f9fa;
  border-radius: 4px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-left: 8px;
  color: #3c4043;
}

.btn-primary {
  border: 2px solid #1a73e8;
  color: #1a73e8;
  padding: 6px 15px;
  background-color: #fff;
  box-shadow: 0 0 3px 3px #ff0;
}

@media only screen and (max-device-width: 500px) {
  #starter {
    animation: heartbeat 1.5s ease-in-out infinite both;
  }

  .permission-popup {
    width: auto;
  }

  .popup-actions span {
    font-size: 0.8em;
  }

  .starter-note {
    font-size: 12px;
  }
}

@keyframes heartbeat {
  from {
    transform: scale(1);
    transform-origin: center center;
    animation-timing-function: ease-out;
  }
  10% {
    transform: scale(0.91);
    animation-timing-function: ease-in;
  }
  17% {
    transform: scale(0.98);
    animation-timing-function: ease-out;
  }
  33% {
    transform: scale(0.87);
    animation-timing-function: ease-in;
  }
  45% {
    transform: scale(1);
    animation-timing-function: ease-out;
  }
}

/* ---------- Loading screen ---------- */

#loading-screen {
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#loader-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.splashScreen {
  width: 100%;
  max-width: 120px;
}

.progress-track {
  width: 200px;
  max-width: 60vw;
  height: 8px;
  margin-top: 20px;
  background-color: rgb(55 65 81 / 1);
  border-radius: 100px;
  overflow: hidden;
}

#loading-progress-bar {
  width: 0%;
  background: rgb(0 98 209 / 1);
  height: 100%;
  transition: width 5s ease-out;
}

/* ---------- Thumbnail carousel (works with src/carousel.js) ----------
 * Restyled to read like the legacy horizontal thumbnail strip: rounded
 * thumbnails on a white strip, the selected one lit with an orange glow.
 * The center element (selection ring in the stock style) is made invisible
 * so selection is shown by the glow on the active thumbnail instead.
 */

.carousel {
  position: relative;
  margin: 8px auto 0;
  overflow: hidden;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 130px;
  width: 100%;
  max-width: 1000px;
  z-index: 40;
}

.carousel.active {
  cursor: grabbing;
}

.carousel-slider {
  position: absolute;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  top: 0;
  left: 0;
  width: fit-content;
  height: inherit;
  transition: left 0.3s ease;
  will-change: transform;
}

/* All thumbnails fit the visible width: show as a fixed, centered row
   instead of the draggable/transform-positioned track (Slick's default
   behavior when slidesToShow already covers every slide). */
.carousel.fits {
  cursor: default;
}

.carousel.fits .carousel-slider {
  position: static;
  transform: none !important;
  transition: none;
}

/* Selection ring from the stock carousel — hidden; the legacy look shows
   selection via the orange glow on the active thumbnail (below). Taken out
   of flex flow so it never competes with .carousel-slider for centering
   (it would otherwise be centered as a *group* with the slider, pushing the
   visible thumbnails off-center by roughly its own width). */
.carousel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  border: none;
  border-radius: 50%;
  z-index: 100;
  pointer-events: none;
  -webkit-user-select: none;
}

.carousel-slider .slide {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 100px;
  margin-left: 8px;
  margin-right: 8px;
  opacity: 0.8;
  transition: all 300ms ease;
}

.carousel-slider .slide.active {
  opacity: 1;
  box-shadow: 0 0 10px 0 rgb(255 108 0);
}

.slide {
  overflow: hidden;
  background-color: #fff;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media screen and (max-width: 595px) {
  .carousel {
    height: 100px;
  }

  .carousel-center,
  .carousel-slider .slide {
    width: 70px;
    height: 70px;
  }
}

/* Left / right arrows over the carousel. */
.carousel-arrows {
  position: absolute;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 95vw;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}

.carousel-arrows img {
  width: auto;
  max-height: 48px;
  cursor: pointer;
  pointer-events: all;
}

/* ---------- Loading spinner (carousel center) ---------- */

.lds-ring {
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  z-index: 110;
}
.lds-ring div {
  box-sizing: border-box;
  display: block;
  position: absolute;
  width: 64px;
  height: 64px;
  margin: 8px;
  border: 8px solid #ff6c00;
  border-radius: 50%;
  animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  border-color: #ff6c00 transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
  animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
  animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
  animation-delay: -0.15s;
}

@keyframes lds-ring {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ---------- Permission denied screen ---------- */

#permission-denied-screen {
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.permission-denied-text-container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.permission-denied-text {
  width: 400px;
  max-width: 95%;
  font-size: 16px;
  line-height: 1.4;
  color: #fff;
}

/* The English hint lines are far longer than the Japanese ones, so the
   nowrap/size-to-content treatment above would overflow the 640px preview.
   Let them wrap inside the box instead. */
html[lang="en"] #glass_text {
  width: 90%;
  max-width: 600px;
  white-space: normal;
}
