/* ============================================================
   Edo Japan 49 – Ukiyo-e Room Widget Styles
   Version: 1.0.0
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --ej-indigo:   #1e3a8a;
  --ej-sakura:   #fda4af;
  --ej-bamboo:   #84cc16;
  --ej-wood:     #78350f;
  --ej-gold:     #d97706;
  --ej-paper:    #fef3c7;
  --ej-shadow:   rgba(0,0,0,.55);
  --ej-radius:   4px;
  --ej-ui-bg:    rgba(30,58,138,.72);
  --ej-ui-blur:  blur(8px);
  --ej-font-jp:  'Noto Serif JP', 'Hiragino Mincho ProN', serif;
  --ej-font-en:  'Palatino Linotype', 'Book Antiqua', Palatino, serif;
  --ej-trans:    .35s cubic-bezier(.4,0,.2,1);
}

/* ── Wrapper ────────────────────────────────────────────────── */
.edo-japan-49-wrapper {
  position: relative;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--ej-font-en);
}

.edo-japan-49-container {
  position: relative;
  width: 100%;
  height: 600px;
  overflow: hidden;
  background: #0a1628;
  border-radius: var(--ej-radius);
  cursor: grab;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,.4),
    0 0 0 1px rgba(120,53,15,.3),
    inset 0 0 80px rgba(30,58,138,.2);
}

.edo-japan-49-container:active { cursor: grabbing; }

/* ── Canvas ─────────────────────────────────────────────────── */
.edo-japan-49-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  touch-action: none;
}

/* ── UI Overlay ─────────────────────────────────────────────── */
.edo-japan-49-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* ── Nav Dots ───────────────────────────────────────────────── */
.ej49-nav-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: all;
}

.ej49-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ej-sakura);
  background: transparent;
  cursor: pointer;
  transition: background var(--ej-trans), transform var(--ej-trans);
  padding: 0;
}

.ej49-dot.active,
.ej49-dot:hover {
  background: var(--ej-sakura);
  transform: scale(1.4);
}

/* ── Toolbar Buttons ────────────────────────────────────────── */
.ej49-tea-btn,
.ej49-export-btn {
  position: absolute;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(253,164,175,.4);
  background: var(--ej-ui-bg);
  backdrop-filter: var(--ej-ui-blur);
  -webkit-backdrop-filter: var(--ej-ui-blur);
  color: var(--ej-sakura);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  transition: background var(--ej-trans), transform var(--ej-trans), border-color var(--ej-trans);
}

.ej49-tea-btn { right: 60px; }
.ej49-export-btn { right: 14px; }

.ej49-tea-btn:hover,
.ej49-export-btn:hover {
  background: rgba(30,58,138,.92);
  border-color: var(--ej-sakura);
  transform: scale(1.08);
}

.ej49-tea-btn svg,
.ej49-export-btn svg {
  width: 18px;
  height: 18px;
}

.ej49-tea-btn.active {
  background: rgba(120,53,15,.85);
  border-color: var(--ej-gold);
  color: var(--ej-gold);
}

/* ── Hints ──────────────────────────────────────────────────── */
.ej49-hints {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ej49-hint-item {
  font-size: 11px;
  color: rgba(253,164,175,.7);
  letter-spacing: .04em;
  background: var(--ej-ui-bg);
  backdrop-filter: var(--ej-ui-blur);
  -webkit-backdrop-filter: var(--ej-ui-blur);
  padding: 2px 8px;
  border-radius: 2px;
  border-left: 2px solid var(--ej-sakura);
}

/* ── Loading Screen ─────────────────────────────────────────── */
.ej49-loading {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a2f6b 0%, #0a1628 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity .8s ease, visibility .8s ease;
}

.ej49-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ej49-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Torii gate SVG animation */
.ej49-torii {
  width: 60px;
  height: 60px;
  background: var(--ej-sakura);
  clip-path: polygon(
    20% 100%, 20% 55%, 0% 55%, 10% 40%, 20% 44%,
    20% 30%, 80% 30%, 80% 44%, 90% 40%, 100% 55%,
    80% 55%, 80% 100%,
    70% 100%, 70% 55%, 30% 55%, 30% 100%
  );
  animation: ej49-torii-pulse 2s ease-in-out infinite;
}

@keyframes ej49-torii-pulse {
  0%, 100% { opacity: .6; transform: scale(1); }
  50%       { opacity: 1;  transform: scale(1.05); }
}

.ej49-loading-text {
  color: var(--ej-sakura);
  font-family: var(--ej-font-jp);
  font-size: 1rem;
  letter-spacing: .3em;
  animation: ej49-fade-pulse 2s ease-in-out infinite;
}

@keyframes ej49-fade-pulse {
  0%, 100% { opacity: .4; }
  50%       { opacity: 1; }
}

/* ── Lightbox ───────────────────────────────────────────────── */
.ej49-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .4s ease, visibility .4s ease;
}

.ej49-lightbox.open {
  opacity: 1;
  visibility: visible;
}

.ej49-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5,10,24,.88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}

.ej49-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 24px;
  max-width: 90vw;
  max-height: 90vh;
  background: #0f1f4a;
  border: 1px solid rgba(120,53,15,.5);
  border-radius: 6px;
  padding: 24px;
  overflow: auto;
  box-shadow:
    0 25px 60px rgba(0,0,0,.7),
    0 0 0 1px rgba(253,164,175,.1),
    inset 0 1px 0 rgba(253,164,175,.08);
  transform: scale(.92) translateY(10px);
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}

.ej49-lightbox.open .ej49-lightbox-content {
  transform: scale(1) translateY(0);
}

.ej49-lightbox-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--ej-sakura);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--ej-trans), transform var(--ej-trans);
  z-index: 2;
}

.ej49-lightbox-close:hover {
  color: #fff;
  transform: rotate(90deg) scale(1.2);
}

.ej49-lightbox-image-wrap {
  flex: 0 0 auto;
  width: min(400px, 50vw);
  position: relative;
}

.ej49-lightbox-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  border: 1px solid rgba(120,53,15,.4);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

.ej49-lightbox-canvas-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ej49-lightbox-canvas {
  width: 100%;
  height: 100%;
}

.ej49-lightbox-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
  color: var(--ej-paper);
  font-family: var(--ej-font-jp);
}

.ej49-lb-title {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--ej-sakura);
  margin: 0;
  letter-spacing: .05em;
  border-bottom: 1px solid rgba(120,53,15,.4);
  padding-bottom: 8px;
}

.ej49-lb-artist,
.ej49-lb-series,
.ej49-lb-year {
  margin: 0;
  font-size: .85rem;
  color: rgba(254,243,199,.75);
  letter-spacing: .04em;
}

.ej49-lb-artist::before { content: '絵師: '; color: var(--ej-gold); }
.ej49-lb-series::before { content: '揃物: '; color: var(--ej-gold); }
.ej49-lb-year::before   { content: '年代: '; color: var(--ej-gold); }

.ej49-lb-description {
  margin: 0;
  font-size: .875rem;
  line-height: 1.65;
  color: rgba(254,243,199,.88);
  flex: 1;
}

.ej49-lb-context-details {
  border-top: 1px solid rgba(120,53,15,.3);
  padding-top: 8px;
}

.ej49-lb-context-details summary {
  cursor: pointer;
  font-size: .8rem;
  color: var(--ej-gold);
  letter-spacing: .08em;
  list-style: none;
  user-select: none;
}

.ej49-lb-context-details summary::-webkit-details-marker { display: none; }
.ej49-lb-context-details summary::before { content: '► '; font-size: .7rem; }
.ej49-lb-context-details[open] summary::before { content: '▼ '; }

.ej49-lb-context {
  margin: 8px 0 0;
  font-size: .8rem;
  line-height: 1.7;
  color: rgba(254,243,199,.7);
}

.ej49-lb-lang-switcher {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.ej49-lb-lang-switcher button {
  padding: 3px 10px;
  background: transparent;
  border: 1px solid rgba(253,164,175,.3);
  color: rgba(253,164,175,.7);
  font-size: .75rem;
  cursor: pointer;
  border-radius: 2px;
  transition: background var(--ej-trans), color var(--ej-trans), border-color var(--ej-trans);
  letter-spacing: .06em;
}

.ej49-lb-lang-switcher button:hover,
.ej49-lb-lang-switcher button.active {
  background: var(--ej-sakura);
  color: #0a1628;
  border-color: var(--ej-sakura);
}

/* ── Tea Ceremony Mode ──────────────────────────────────────── */
.edo-japan-49-wrapper.tea-ceremony .edo-japan-49-container {
  filter: saturate(.85) brightness(.92);
}

.edo-japan-49-wrapper.tea-ceremony .ej49-hint-item {
  opacity: .5;
}

/* ── Export Toast ───────────────────────────────────────────── */
.ej49-toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #0f1f4a;
  border: 1px solid var(--ej-gold);
  color: var(--ej-paper);
  padding: 12px 20px;
  border-radius: 4px;
  font-size: .875rem;
  font-family: var(--ej-font-jp);
  z-index: 999999;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: ej49-toast-in .35s cubic-bezier(.34,1.56,.64,1);
}

.ej49-toast.hide {
  animation: ej49-toast-out .35s ease forwards;
}

@keyframes ej49-toast-in {
  from { opacity: 0; transform: translateY(20px) scale(.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ej49-toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(10px); }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ej49-lightbox-content {
    flex-direction: column;
    max-width: 95vw;
    max-height: 92vh;
    padding: 16px;
  }

  .ej49-lightbox-image-wrap {
    width: 100%;
  }

  .ej49-hints {
    display: none;
  }

  .ej49-hint-item { font-size: 10px; }
}

@media (max-width: 480px) {
  .edo-japan-49-container {
    height: 380px;
  }
}

/* ── Accessibility ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ej49-torii,
  .ej49-loading-text {
    animation: none;
    opacity: 1;
  }
  .ej49-lightbox,
  .ej49-lightbox-content {
    transition: none;
  }
}

@media (prefers-color-scheme: light) {
  .ej49-lightbox-content {
    background: #fef3c7;
    color: #1e3a8a;
    border-color: rgba(120,53,15,.4);
  }
  .ej49-lb-title    { color: var(--ej-indigo); }
  .ej49-lb-artist,
  .ej49-lb-series,
  .ej49-lb-year,
  .ej49-lb-description,
  .ej49-lb-context  { color: #1e3a8a; }
}
