/* ==========================================================================
   Splash Screen Styles — 3가지 모드 지원
   Mode A: Center Focus (큐브 + 얇은 프로그레스 바)
   Mode B: SVG Wireframe (CAD 와이어프레임 드로잉)
   Mode C: Ring Progress (원형 프로그레스 링)
   ========================================================================== */

/* ==========================================================================
   공통 기반 스타일
   ========================================================================== */

.splash-screen-cad {
  /* 다크 테마 기본값 — 뷰포트 gray_radial 배경과 동일 (#3D4550 → #0E1218) */
  --splash-primary: #4DA3FF;
  --splash-primary-rgb: 77, 163, 255;
  --splash-bg: radial-gradient(ellipse at center, #3D4550 0%, #0E1218 100%);
  --splash-bg-surface: #232A31;
  --splash-border: #3A4552;
  --splash-text: #E6EDF3;
  --splash-text-muted: #AAB4BF;
  --splash-text-sub: #6B7785;
  --splash-success: #33D6A6;
  --splash-error: #f14c4c;

  position: fixed;
  inset: 0;
  background: var(--splash-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease;
  overflow: hidden;
  font-family: var(--font-family, 'Pretendard', 'Inter', 'Segoe UI', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif);
}

.splash-screen-cad:not(.splash-active) {
  display: none !important;
}

/* 라이트 테마 — 뷰포트 gray_radial 배경과 동일 (#FAFBFC → #D8DCE2) */
.splash-screen-cad.theme-light {
  --splash-primary: #2F80ED;
  --splash-primary-rgb: 47, 128, 237;
  --splash-bg: radial-gradient(ellipse at center, #FAFBFC 0%, #D8DCE2 100%);
  --splash-bg-surface: #FFFFFF;
  --splash-border: #D8DEE4;
  --splash-text: #1C1F23;
  --splash-text-muted: #5B6572;
  --splash-text-sub: #8A95A0;
  background: var(--splash-bg);
}

/* ==========================================================================
   Mode A — Center Focus
   ========================================================================== */

.splash-mode-a {
  flex-direction: column;
  gap: 0;
}

/* 배경 그리드 */
.splash-mode-a .splash-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(var(--splash-primary-rgb), 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--splash-primary-rgb), 0.04) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: grid-move 20s linear infinite paused;
  pointer-events: none;
}

.splash-active.splash-mode-a .splash-bg-grid {
  animation-play-state: running;
}

@keyframes grid-move {
  to { transform: translate3d(50px, 50px, 0); }
}

/* 콘텐츠 래퍼 */
.splash-mode-a .splash-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 360px;
  max-width: 90vw;
}

/* 큐브 */
.splash-mode-a .splash-cube-wrap {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 800px;
  margin-bottom: 28px;
}

.splash-mode-a .cad-cube {
  --cube-size: 72px;
  width: var(--cube-size);
  height: var(--cube-size);
  transform-style: preserve-3d;
  animation: cube-rotate 8s infinite linear paused;
}

.splash-active.splash-mode-a .cad-cube {
  animation-play-state: running;
}

@keyframes cube-rotate {
  from { transform: rotateX(-20deg) rotateY(30deg); }
  to   { transform: rotateX(340deg) rotateY(390deg); }
}

.splash-mode-a .cube-face {
  position: absolute;
  width: var(--cube-size);
  height: var(--cube-size);
  background: var(--splash-bg-surface);
  border: 1.5px solid var(--splash-primary);
  backface-visibility: hidden;
}

.splash-mode-a .cube-front  { transform: translateZ(calc(var(--cube-size) / 2)); }
.splash-mode-a .cube-back   { transform: translateZ(calc(var(--cube-size) / -2)) rotateY(180deg); }
.splash-mode-a .cube-left   { transform: rotateY(-90deg) translateZ(calc(var(--cube-size) / 2)); }
.splash-mode-a .cube-right  { transform: rotateY(90deg)  translateZ(calc(var(--cube-size) / 2)); }
.splash-mode-a .cube-top    { transform: rotateX(90deg)  translateZ(calc(var(--cube-size) / 2)); }
.splash-mode-a .cube-bottom { transform: rotateX(-90deg) translateZ(calc(var(--cube-size) / 2)); }

/* 타이틀 */
.splash-mode-a .splash-title {
  text-align: center;
  margin-bottom: 32px;
}

.splash-mode-a .title-main {
  display: block;
  font-size: 26px;
  font-weight: 600;
  color: var(--splash-text);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.splash-mode-a .title-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--splash-primary);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* 프로그레스 바 */
.splash-mode-a .splash-progress-wrap {
  width: 100%;
  margin-bottom: 16px;
}

.splash-mode-a .progress-track {
  width: 100%;
  height: 2px;
  background: rgba(var(--splash-primary-rgb), 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.splash-mode-a .progress-fill {
  height: 100%;
  width: 0%;
  background: var(--splash-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.splash-mode-a .progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.splash-mode-a .progress-status {
  font-size: 12px;
  color: var(--splash-text-muted);
}

.splash-mode-a .progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--splash-primary);
  font-family: 'Courier New', monospace;
}

/* ==========================================================================
   Mode B — SVG Wireframe
   ========================================================================== */

.splash-mode-b {
  flex-direction: column;
}

.splash-mode-b .splash-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 360px;
  max-width: 90vw;
}

/* SVG 와이어프레임 */
.splash-mode-b .splash-wireframe {
  width: 160px;
  height: 160px;
  margin-bottom: 28px;
}

.splash-mode-b .wf-line {
  fill: none;
  stroke: var(--splash-primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 뒷면 실선 부분 (위쪽 가로 + 오른쪽 세로) — 진하게 */
.splash-mode-b .wf-box-back-solid {
  opacity: 1;
}

/* 뒷면 점선 부분 (아래쪽 가로 + 왼쪽 세로 — 숨겨진 모서리) */
.splash-mode-b .wf-box-back-hidden {
  stroke-dasharray: 6 5;
  opacity: 0.5;
}

/* 연결 모서리 — 숨겨진 왼쪽 아래만 점선 */
.splash-mode-b .wf-edges-back {
  stroke-dasharray: 6 5;
  opacity: 0.5;
}

/* 드로잉 애니메이션 */
.splash-mode-b .wf-box-front {
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: draw-loop-front 3.5s ease-in-out infinite paused;
}
.splash-mode-b .wf-box-back-solid {
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: draw-loop-back-solid 3.5s ease-in-out infinite paused;
}
.splash-mode-b .wf-box-back-hidden {
  animation: fade-loop-back 3.5s ease-in-out infinite paused;
}
.splash-mode-b .wf-edges-front {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: draw-loop-edges 3.5s ease-in-out infinite paused;
}
.splash-mode-b .wf-edges-back {
  animation: fade-loop-back 3.5s ease-in-out infinite paused;
}

/* 드로잉 완료 후 회전 없이 반복 재드로잉 */
.splash-mode-b .splash-wireframe svg {
  display: block;
}

.splash-active.splash-mode-b .wf-box-front,
.splash-active.splash-mode-b .wf-box-back-solid,
.splash-active.splash-mode-b .wf-box-back-hidden,
.splash-active.splash-mode-b .wf-edges-front,
.splash-active.splash-mode-b .wf-edges-back {
  animation-play-state: running;
}

/* 앞면 드로잉 루프 */
@keyframes draw-loop-front {
  0%   { stroke-dashoffset: 320; opacity: 1; }
  34%  { stroke-dashoffset: 0;   opacity: 1; }
  71%  { stroke-dashoffset: 0;   opacity: 1; }
  86%  { stroke-dashoffset: 0;   opacity: 0; }
  100% { stroke-dashoffset: 320; opacity: 0; }
}

/* 뒷면 실선 드로잉 루프 */
@keyframes draw-loop-back-solid {
  0%   { stroke-dashoffset: 240; opacity: 1; }
  34%  { stroke-dashoffset: 0;   opacity: 1; }
  71%  { stroke-dashoffset: 0;   opacity: 1; }
  86%  { stroke-dashoffset: 0;   opacity: 0; }
  100% { stroke-dashoffset: 240; opacity: 0; }
}

/* 뒷면/뒤쪽 모서리 — 페이드 인/아웃 */
@keyframes fade-loop-back {
  0%   { opacity: 0; }
  11%  { opacity: 0.5; }
  71%  { opacity: 0.5; }
  86%  { opacity: 0; }
  100% { opacity: 0; }
}

/* 앞쪽 모서리 드로잉 루프 */
@keyframes draw-loop-edges {
  0%   { stroke-dashoffset: 120; opacity: 0; }
  23%  { stroke-dashoffset: 120; opacity: 1; }
  51%  { stroke-dashoffset: 0;   opacity: 1; }
  71%  { stroke-dashoffset: 0;   opacity: 1; }
  86%  { stroke-dashoffset: 0;   opacity: 0; }
  100% { stroke-dashoffset: 120; opacity: 0; }
}

/* 타이틀 */
.splash-mode-b .splash-title {
  text-align: center;
  margin-bottom: 28px;
}

.splash-mode-b .title-main {
  display: block;
  font-size: 26px;
  font-weight: 600;
  color: var(--splash-text);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.splash-mode-b .title-sub {
  display: block;
  font-size: 11px;
  color: var(--splash-primary);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* 프로그레스 */
.splash-mode-b .splash-progress-wrap {
  width: 100%;
  margin-bottom: 16px;
}

.splash-mode-b .progress-track {
  width: 100%;
  height: 2px;
  background: rgba(var(--splash-primary-rgb), 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.splash-mode-b .progress-fill {
  height: 100%;
  width: 0%;
  background: var(--splash-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.splash-mode-b .progress-info {
  display: flex;
  justify-content: space-between;
}

.splash-mode-b .progress-status {
  font-size: 12px;
  color: var(--splash-text-muted);
}

.splash-mode-b .progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--splash-primary);
  font-family: 'Courier New', monospace;
}

/* ==========================================================================
   Mode C — Ring Progress
   ========================================================================== */

.splash-mode-c {
  flex-direction: column;
}

.splash-mode-c .splash-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 320px;
  max-width: 90vw;
}

/* 링 */
.splash-mode-c .splash-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 28px;
}

.splash-mode-c .ring-svg {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}

.splash-mode-c .ring-track {
  fill: none;
  stroke: rgba(var(--splash-primary-rgb), 0.12);
  stroke-width: 6;
}

.splash-mode-c .ring-fill {
  fill: none;
  stroke: var(--splash-primary);
  stroke-width: 6;
  stroke-linecap: round;
  /* circumference = 2π × 71 ≈ 446 */
  stroke-dasharray: 446;
  stroke-dashoffset: 446;
  transition: stroke-dashoffset 0.4s ease;
}

/* 링 중앙 퍼센트 */
.splash-mode-c .ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.splash-mode-c .ring-pct {
  font-size: 32px;
  font-weight: 700;
  color: var(--splash-text);
  font-family: 'Courier New', monospace;
  line-height: 1;
}

.splash-mode-c .ring-label {
  font-size: 10px;
  color: var(--splash-text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* 타이틀 */
.splash-mode-c .splash-title {
  text-align: center;
  margin-bottom: 20px;
}

.splash-mode-c .title-main {
  display: block;
  font-size: 22px;
  font-weight: 600;
  color: var(--splash-text);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.splash-mode-c .title-sub {
  display: block;
  font-size: 10px;
  color: var(--splash-primary);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* 상태 텍스트 */
.splash-mode-c .progress-status {
  font-size: 12px;
  color: var(--splash-text-muted);
  text-align: center;
}

/* ==========================================================================
   에러 오버레이 (공통)
   ========================================================================== */

.splash-error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(var(--splash-primary-rgb), 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ==========================================================================
   접근성 & 모바일
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .splash-mode-a .cad-cube,
  .splash-mode-a .splash-bg-grid,
  .splash-mode-b .wf-box-front,
  .splash-mode-b .wf-box-back-solid,
  .splash-mode-b .wf-box-back-hidden,
  .splash-mode-b .wf-edges-front,
  .splash-mode-b .wf-edges-back {
    animation: none !important;
  }
  .splash-mode-b .wf-box-front,
  .splash-mode-b .wf-edges-front {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  .splash-mode-b .wf-box-back-solid,
  .splash-mode-b .wf-box-back-hidden,
  .splash-mode-b .wf-edges-back {
    opacity: 0.5;
  }
}

@media (max-width: 480px) {
  .splash-mode-a .title-main,
  .splash-mode-b .title-main { font-size: 20px; }
  .splash-mode-c .title-main { font-size: 18px; }
  .splash-mode-a .cad-cube { --cube-size: 56px; }
}
