/* --- style.css ---
 * 역할: 메뉴·재생 화면 및 설정 창의 기본 스타일
 * 설명: 공통 변수 → 기본 요소 → 화면 구성 → 조건별 규칙의 흐름을 따르며 기존 캐스케이드 순서를 보존합니다.
*/

/* --- 테마 변수 (Theme Variables) --- */
:root { color-scheme: dark; --bg: #090c10; --line: #25313c; --text: #ecf1f6; --muted: #9baebb; --accent: #b5f588; --gap: 32px; --dim: .75; --fade: 250ms }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
[hidden] { display: none !important; }
* { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif }
button { font: inherit; cursor: pointer }
button:focus-visible { outline: 3px solid white; outline-offset: 5px }
button:disabled { cursor: not-allowed; opacity: .4 }
[hidden] { display: none !important }
/* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
#menu { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: radial-gradient(ellipse at 50% 35%, #18252c 0, transparent 65%), #090c10 }
.setup-inner { width: min(760px, 100%) }
.brand { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; letter-spacing: .16em; margin-bottom: 40px }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.mark { color: var(--accent); font-weight: 800; letter-spacing: .24em }
/* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
.edition { border: 1px solid var(--line); border-radius: 30px; padding: 7px 11px; letter-spacing: .08em }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 600; letter-spacing: -.055em; margin: 0 0 12px }
.subtitle { color: var(--muted); font-size: 15px; line-height: 1.7; margin: 0 0 28px }
/* --- 시작 전 점검·실행 (Startup Check) --- */
.console { border: 1px solid #31404b; background: #0b1116; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 80px #0005 }
.console-head { display: flex; align-items: center; gap: 8px; background: #131d25; border-bottom: 1px solid var(--line); padding: 15px 20px; font: 12px ui-monospace, Consolas, monospace; color: #b2c1cc }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4f6574 }
.dot:first-child { background: var(--accent) }
/* --- 시작 전 점검·실행 (Startup Check) --- */
.console-title { margin-left: 9px }
.status { margin-left: auto; color: var(--accent); font-size: 11px }
.logs { height: clamp(200px, 32vh, 310px); overflow: auto; padding: 18px 20px; font: 13px/1.85 ui-monospace, SFMono-Regular, Consolas, "Malgun Gothic", monospace; scrollbar-color: #3d5362 transparent }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.log { display: grid; grid-template-columns: 58px 1fr; gap: 8px; margin-bottom: 4px }
.log span:last-child { overflow-wrap: anywhere; color: #cfdae3 }
.log.ok span:first-child { color: var(--accent) }
.log.warn span:first-child { color: #ffd080 }
.log.error span:first-child { color: #ff9898 }
.log.info span:first-child { color: #94caff }
.log.dim span { color: #94a4b1 !important }
/* --- 시작 전 점검·실행 (Startup Check) --- */
.meter { height: 2px; background: #1e2b34 }
.meter i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .18s }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line) }
.stat { padding: 16px 20px; border-right: 1px solid var(--line) }
.stat:last-child { border: 0 }
.stat small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px }
.stat strong { font: 22px ui-monospace, Consolas, monospace }
.launch { margin-top: 20px; width: 100%; border: 0; border-radius: 10px; background: var(--accent); color: #172510; padding: 20px; font-size: 19px; font-weight: 750; display: flex; align-items: center; justify-content: center; gap: 14px; transition: background .2s }
.launch:hover:not(:disabled) { background: #cafba8 }
/* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
.footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 17px; color: var(--muted); font-size: 12px }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.text-button { background: none; border: 0; color: #c5d4df; padding: 8px 0; text-decoration: underline; text-underline-offset: 4px }
.note { margin: 22px 0 0; color: #8ea1ae; font-size: 12px; line-height: 1.7 }
/* --- 이미지 재생·조작 (Playback and Controls) --- */
#play { position: fixed; inset: 0; background: #000; overflow: hidden; isolation: isolate }
.wall { position: absolute; inset: -8% -2%; display: grid; gap: var(--gap); transform: scale(1.02) }
.wall-col { display: flex; flex-direction: column; gap: var(--gap) }
.wall-col:nth-child(even) { transform: translateY(-70px) }
.wall img { display: block; width: 100%; height: clamp(150px, 24vh, 350px); object-fit: cover }
.shade { position: absolute; inset: 0; background: rgba(0, 0, 0, var(--dim)) }
.stage { position: absolute; inset: clamp(24px, 6vh, 72px) clamp(12px, 3vw, 56px); display: grid; gap: clamp(10px, 2vw, var(--gap)) }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.slot { position: relative; overflow: hidden; min-width: 0; background: #080808; border-radius: 2px }
/* --- 이미지 재생·조작 (Playback and Controls) --- */
.frame { position: absolute; inset: 0; opacity: 0; transition: opacity var(--fade) ease; overflow: hidden }
.frame.active { opacity: 1 }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.blur { position: absolute; inset: -35px; background-position: center; background-size: cover; filter: blur(25px) brightness(.55); transform: scale(1.08) }
/* --- 이미지 재생·조작 (Playback and Controls) --- */
.photo { position: absolute; width: 100%; height: 100%; object-fit: contain; inset: 0 }
.controls { position: absolute; z-index: 20; top: 15px; left: 20px; right: 20px; display: flex; justify-content: space-between; gap: 10px; opacity: 0; transition: opacity .2s; pointer-events: none }
.controls.show, .controls:focus-within { opacity: 1; pointer-events: auto }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.control-group { display: flex; gap: 8px }
/* --- 이미지 재생·조작 (Playback and Controls) --- */
.controls button { background: #101820df; backdrop-filter: blur(12px); color: #edf4fa; border: 1px solid #43515d; border-radius: 7px; font-size: 12px; padding: 10px 14px }
.badge { position: absolute; z-index: 21; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 30px; background: #131d26ed; color: #dce9f2; font-size: 13px; pointer-events: none; white-space: nowrap }
.hint { position: absolute; bottom: 18px; width: 100%; text-align: center; color: #bac7d0; font-size: 12px; pointer-events: none; opacity: 0; transition: opacity .2s }
.hint.show { opacity: 1 }
/* --- 반응형·조건별 적용 (Conditional Rules) --- */
@media (max-width:600px) {
  /* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
  #menu { padding: 25px 16px }
  .brand { margin-bottom: 28px }
  /* --- 시작 전 점검·실행 (Startup Check) --- */
  .logs { padding: 14px 12px; font-size: 12px }
  .stat { padding: 12px }
  /* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
  .footer { align-items: flex-start }
  .edition { font-size: 10px }
  /* --- 이미지 재생·조작 (Playback and Controls) --- */
  .stage { inset: 62px 10px 40px; gap: 8px }
  .controls { left: 10px; right: 10px }
  .controls button { padding: 9px; font-size: 11px }
}
/* --- 이미지 재생·조작 (Playback and Controls) --- */
.wall { inset: -5% -3%; gap: clamp(20px, 5vw, 90px); transform: none; background: #000 }
.wall-col { gap: clamp(28px, 7vh, 100px) }
.wall-col:nth-child(even) { transform: translateY(-9vh) }
.wall img { height: clamp(120px, 29vh, 420px); object-fit: contain; background: #000 }
.shade { background: #000; opacity: 0 }
.stage { opacity: 0; pointer-events: none }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.slot { background: transparent; overflow: visible }
/* --- 이미지 재생·조작 (Playback and Controls) --- */
.frame { transition: none; transform-origin: 0 0; background: #080808 }
.wall { inset: 0; display: block; transform: none; will-change: transform; overflow: visible; background: transparent }
.wall img { position: absolute; display: block; object-fit: contain; background: #000; margin: 0; will-change: auto }
.controls { justify-content: flex-end }
.wall { backface-visibility: hidden; contain: layout style }
.frame { will-change: transform; contain: layout style }
/* --- 공통 요소·레이아웃 (Shared Elements) --- */
.blur { filter: blur(16px) brightness(.55) }
/* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
.setup-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin: 18px 0 26px; }
.setup-tool { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #141c24; color: var(--text); font-size: 13px; text-decoration: none; }
.setup-tool:hover { border-color: var(--accent); }
/* --- 이미지 편집·최근 기록 (Image Editor and History) --- */
a:focus-visible, .upload-label:focus-within { outline: 3px solid var(--accent); outline-offset: 4px; }
/* --- 설정 창·입력 항목 (Settings Dialog) --- */
#settingsDialog { width: min(760px, calc(100% - 24px)); max-height: 90dvh; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--text); background: #10171f; color-scheme: dark; }
#settingsForm { box-sizing: border-box; max-height: calc(90dvh - 2px); overflow: auto; padding: 26px; overscroll-behavior: contain; }
#settingsDialog::backdrop { background: rgba(0, 0, 0, .8); }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-heading h2 { margin: 0; font-size: 24px; }
/* --- 이미지 편집·최근 기록 (Image Editor and History) --- */
#settingsDialog button, .upload-label { padding: 10px 13px; border: 1px solid #40515f; border-radius: 8px; background: #202d38; color: var(--text); font: inherit; font-size: 14px; }
/* --- 설정 창·입력 항목 (Settings Dialog) --- */
.settings-help { color: var(--muted); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.settings-toggles { display: flex; flex-wrap: wrap; gap: 20px; margin: 22px 0; }
.settings-toggles label { display: flex; align-items: center; gap: 8px; }
.settings-toggles input { width: 18px; height: 18px; accent-color: var(--accent); }
.images-label, .settings-grid label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
#settingsDialog textarea, .settings-grid input { width: 100%; min-width: 0; border: 1px solid #40515f; border-radius: 8px; padding: 10px; background: #090f15; color: var(--text); font: inherit; }
#settingsDialog textarea { resize: vertical; font-family: ui-monospace, monospace; line-height: 1.6; }
#settingsDialog input:focus-visible, #settingsDialog textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
.settings-file-actions { display: flex; flex-wrap: wrap; gap: 10px; }
/* --- 이미지 편집·최근 기록 (Image Editor and History) --- */
.upload-label { cursor: pointer; position: relative; display: inline-flex; align-items: center; overflow: hidden; }
.upload-label input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
/* --- 설정 창·입력 항목 (Settings Dialog) --- */
#settingsMessage { min-height: 24px; color: var(--accent); line-height: 1.6; font-size: 14px; }
#settingsMessage.settings-error { color: #ffb3a6; }
.settings-bottom { display: flex; justify-content: flex-end; margin-top: 24px; }
#settingsDialog .apply-settings { background: var(--accent); color: #142012; font-weight: 700; }
/* --- 반응형·조건별 적용 (Conditional Rules) --- */
@media (max-width:520px) {
  /* --- 설정 창·입력 항목 (Settings Dialog) --- */
  .settings-grid { grid-template-columns: 1fr; }
  #settingsForm { padding: 18px; }
  /* --- 메뉴·브랜드·안내 (Menu and Branding) --- */
  .setup-actions { justify-content: flex-start; }
}
/* --- 설정 창·입력 항목 (Settings Dialog) --- */
.settings-grid input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.settings-grid textarea { min-height: 100px; }
/* --- 이미지 재생·조작 (Playback and Controls) --- */
.stage .slot { min-height: 0; }

/* --- 화면 크기에 맞춘 메뉴 콘텐츠 (Viewport-Fitted Menu) --- */
#menu { position: fixed; inset: 0; height: 100dvh; min-height: 0; overflow: hidden; padding: 16px; }
#menu .setup-inner { flex-shrink: 0; width: min(760px, 100%); transform: scale(var(--menu-scale, 1)); transform-origin: center; }

/* --- 데스크톱의 작은 창 크기(낮은 화면)에서 가독성 유지 (Desktop Minimum Fit Height) --- */
@media (hover: hover) and (pointer: fine) and (max-height: 750px) {
  #menu { position: relative; inset: auto; height: 750px; min-height: 750px; }
}

/* --- 데모 모드별 이미지 설정 접기·펼치기 (Demo Image Settings Panel) --- */
/* Demo 모드에서는 실제 이미지 설정을 접고, 이미지 모드에서는 부드럽게 펼칩니다. */
.image-settings-panel { grid-column: 1 / -1; min-width: 0; max-height: 3000px; opacity: 1; overflow: hidden; transition: max-height 320ms ease, opacity 220ms ease, margin 320ms ease; }
.image-settings-panel.is-collapsed { max-height: 0; opacity: 0; margin-top: 0; margin-bottom: 0; pointer-events: none; }
.image-settings-panel.no-transition { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .image-settings-panel { transition: none; }
}

/* --- 설정 창 너비에 따른 3열 배치 (Width-Based Settings Columns) --- */
#settingsDialog { container-type: inline-size; container-name: settings-dialog; }
@container settings-dialog (min-width: 700px) {
  .settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- 설정 적용 버튼 애니메이션 (Apply Button Animation) --- */
#settingsDialog .apply-settings { position: relative; overflow: hidden; isolation: isolate; }
/* --- 미적용 설정 애니메이션(빛 효과) (Pending Settings Shine Effect) --- */
#settingsDialog .apply-settings.has-pending-settings::after { animation: apply-button-shine 2300ms ease-in-out infinite; content: ""; position: absolute; top: -50%; left: -75%; width: 45%; height: 200%; background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.08) 20%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0.08) 80%, transparent 100%); transform: skewX(-20deg); pointer-events: none; }
/* --- 미적용 설정 애니메이션(빛 이동) (Pending Settings Shine Animation) --- */
@keyframes apply-button-shine {
  0%, 30% { left: -75%; opacity: 0; }
  35% { opacity: 1; }
  90% { left: 130%; opacity: 1; }
  95%, 100% { left: 130%; opacity: 0; }
}
/* --- 애니메이션 최소화 설정 (Reduced Motion) --- */
@media (prefers-reduced-motion: reduce) {
  #settingsDialog .apply-settings.has-pending-settings::after { animation: none; opacity: 0; }
}

/* 설정 적용 후 수동 재점검 */
.log-review { position:relative; }
.log-review.needs-recheck .logs { filter:blur(3px); opacity:.35; pointer-events:none; user-select:none; }
.recheck-overlay { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:16px; text-align:center; }
.recheck-overlay[hidden] { display:none; }
#recheckLarge { padding:18px 36px; border:1px solid var(--accent, #80bb70); border-radius:12px; background:var(--accent, #80bb70); color:#142019; font:700 clamp(20px,4vw,28px)/1.3 sans-serif; cursor:pointer; box-shadow:0 8px 28px #0003; }
#recheckLarge:focus-visible { outline:3px solid currentColor; outline-offset:5px; }
.recheck-overlay p { margin:0; font-size:13px; }
