/* 
  Polaroid Photo Generator V24 CSS
  - 모바일 필터 터치 완전 수정
*/

@font-face { font-family: 'NeoDonggeunmo'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.3/NeoDunggeunmo.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'Jeongmeokbawi'; src: url('https://gcore.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/SangSangRockOTF.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'Independent'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_twelve@1.1/Dokrip.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'IncheonEducation'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2307-2@1.0/iceJaram-Rg.woff2') format('woff2'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'SandollSamlipHobbangOutline'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts-20-12@1.0/SDSamliphopangche_Outline.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'OgRenaissanceSecret'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2312-1@1.1/OG_Renaissance_Secret-Rg.woff2') format('woff2'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'SchoolSafetyColoredPencil'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/2511-1@1.0/HakgyoansimSaekyeonpilR.woff2') format('woff2'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'ThinRounded'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/2511-1@1.0/ThinDungGeunMo.woff2') format('woff2'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'DaeguDongseongRo'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/2511-1@1.0/DaeguDongseongro-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JoseonPalace'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@1.0/ChosunGs.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'IsYun'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2202-2@1.0/LeeSeoyun.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'Yeongwol'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/2507-2@1.0/YeongwolTTF-Regular.woff2') format('woff2'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'ShillaBold'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2206-02@1.0/Shilla_CultureB-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'SolmoeMedium'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts-20-12@1.0/kdg_Medium.woff') format('woff'); font-weight: 500; font-display: swap; }

.polaroid-studio-container {
  --bg-primary: #f5f5f0; --bg-secondary: #fff; --bg-section: #fff; --border-color: #222;
  --text-primary: #222; --text-secondary: #555;
  --color-accent: #3498db; --color-success: #27ae60; --color-warning: #f39c12; --color-danger: #e74c3c;
  --radius-container: 10px; --radius-section: 8px; --radius-button: 4px; --radius-input: 4px;
  --desk-bg: #e5e5e5; --desk-pattern: rgba(0,0,0,0.05);
  --shadow-sm: 2px 2px 0 rgba(0,0,0,0.1); --shadow-md: 4px 4px 0 rgba(0,0,0,0.15);
}

.polaroid-studio-container.dark {
  --bg-primary: #1a1a1a; --bg-secondary: #2d2d2d; --bg-section: #2d2d2d; --border-color: #bbb;
  --text-primary: #f0f0f0; --text-secondary: #aaa; --color-accent: #5dade2;
  --desk-bg: #111; --desk-pattern: rgba(255,255,255,0.05);
  --shadow-sm: 2px 2px 0 rgba(255,255,255,0.08); --shadow-md: 4px 4px 0 rgba(255,255,255,0.1);
}

.polaroid-studio-container {
  position: relative; max-width: 1180px; width: 100%; margin: 8px auto; padding: 8px;
  background: var(--bg-primary); border: 2px solid var(--border-color);
  border-radius: var(--radius-container); font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary); box-shadow: 8px 8px 0 rgba(0,0,0,0.15); box-sizing: border-box;
}
.polaroid-studio-container * { box-sizing: border-box; }

.header { margin-bottom: 16px; }
.main-title { font-size: 28px; font-weight: 800; margin: 0; color: var(--text-primary) !important; }
.subtitle { font-size: 16px; color: var(--text-secondary); margin-top: 4px; }
.dark-mode-toggle { position: absolute; top: 10px; right: 10px; padding: 8px 12px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; cursor: pointer; font-size: 18px; color: var(--text-primary); box-shadow: var(--shadow-sm); z-index: 20; }

.main-grid { display: grid; grid-template-columns: 420px 1fr; gap: 10px; align-items: start; }
@media (max-width: 900px) { .main-grid { grid-template-columns: 1fr; } .input-section { order: 2; } .result-section { order: 1; } }

.input-section, .result-section { background: var(--bg-section); padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-section); box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 14px; }
.section-header { font-size: 17px; font-weight: 700; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; color: var(--text-primary); display: flex; justify-content: space-between; align-items: center; }
.input-group { display: flex; flex-direction: column; gap: 10px; }

.upload-btn { width: 100%; padding: 12px; background: var(--bg-secondary); border: 2px dashed var(--border-color); border-radius: var(--radius-input); color: var(--text-secondary); font-weight: 600; font-size: 16px; cursor: pointer; transition: all 0.2s; }
.upload-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }

.color-palette { display: flex; gap: 8px; flex-wrap: wrap; }
.color-btn { 
  width: 30px; height: 30px; border-radius: 50%; 
  border: 1px solid #ccc; cursor: pointer; 
  background-image: none !important;
  touch-action: manipulation;
  user-select: none;
}
.color-btn.active { box-shadow: 0 0 0 2px var(--border-color), 0 0 0 4px var(--color-accent); border: none; }

/* 필터 컨테이너 - 스크롤 제거 */
.filter-container { 
  /* overflow 완전 제거 */
}
.filter-category { 
  font-size: 13px; 
  font-weight: 700; 
  color: var(--text-secondary); 
  margin-top: 8px;
  margin-bottom: 4px;
}
.filter-grid { 
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  gap: 6px;
  margin-bottom: 4px;
}
.filter-btn { 
  padding: 10px 4px; 
  font-size: 12px; 
  background: var(--bg-secondary); 
  border: 1px solid var(--border-color);
  border-radius: 8px; 
  color: var(--text-primary); 
  cursor: pointer; 
  font-weight: 600; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis;
  transition: all 0.1s;
  /* 모바일 최적화 */
  -webkit-user-select: none;
  user-select: none;
  min-height: 40px;
  /* 가장 중요 - 터치를 확실하게 */
  -webkit-tap-highlight-color: rgba(52, 152, 219, 0.4);
}
.filter-btn:active { 
  transform: scale(0.96); 
  background: var(--color-accent); 
  color: #fff; 
}
.filter-btn.active { 
  background: var(--color-accent); 
  color: #fff; 
  border-color: var(--color-accent);
  font-weight: 700;
}

/* COMPACT TEXTURE LAYOUT */
.texture-compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-block { background: rgba(128,128,128,0.05); padding: 10px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.05); transition: opacity 0.2s; }
.control-block.compact { padding: 8px; }
.control-block.inactive .slider-wrapper { opacity: 0.4; pointer-events: none; }
.block-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.mt-2 { margin-top: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--text-primary); font-weight: 600; }
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--color-accent); margin: 0; }
.title-label { font-size: 13px; }
.title-label span { font-size: 12px; }

.slider-wrapper { display: flex; align-items: center; gap: 10px; }
.slider-wrapper.compact-slider { gap: 6px; margin-top: 4px; }
.slider-label { width: 70px; font-size: 13px; font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }
input[type="range"] { flex: 1; height: 6px; background: #ddd; border-radius: 3px; -webkit-appearance: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--color-accent); border: 1px solid var(--border-color); border-radius: 50%; cursor: pointer; }
.texture-controls { display: flex; flex-wrap: wrap; gap: 12px; }
.texture-controls.compact-checks { gap: 8px; }
.texture-controls.compact-checks .checkbox-label { font-size: 12px; }

.text-add-row { display: flex; gap: 6px; }
#new-text-input { flex: 1; padding: 8px; border: 1px solid var(--border-color); border-radius: var(--radius-input); background: var(--bg-secondary); color: var(--text-primary); font-size: 15px; }
.action-btn { padding: 0 14px; background: var(--color-accent); color: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-button); cursor: pointer; font-weight: 600; white-space: nowrap; }

.edit-panel { background: rgba(52, 152, 219, 0.08); border: 1px solid var(--border-color); padding: 10px; border-radius: var(--radius-button); display: none; flex-direction: column; gap: 8px; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.edit-panel.active { display: flex; }
.panel-title { font-size: 13px; font-weight: 700; color: var(--color-accent); }
#edit-text-input, #font-select { width: 100%; padding: 6px; border: 1px solid var(--border-color); border-radius: var(--radius-input); background: var(--bg-secondary); color: var(--text-primary); font-size: 14px; }
.text-actions { display: flex; justify-content: flex-end; }
.delete-btn { padding: 4px 10px; background: var(--color-danger); color: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-button); cursor: pointer; font-size: 12px; }

.date-control-box { background: rgba(128,128,128,0.05); border: 1px solid var(--border-color); padding: 8px; border-radius: var(--radius-button); }
.date-header { display: flex; justify-content: space-between; align-items: center; }
#date-picker { padding: 4px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--bg-secondary); color: var(--text-primary); font-size: 13px; }

.desk-wrapper { width: 100%; min-height: 600px; background-color: var(--desk-bg); background-image: linear-gradient(var(--desk-pattern) 1px, transparent 1px), linear-gradient(90deg, var(--desk-pattern) 1px, transparent 1px); background-size: 20px 20px; border: 2px solid var(--border-color); border-radius: var(--radius-section); overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; touch-action: none; }
.canvas-shadow-box { box-shadow: 0 30px 70px rgba(0,0,0,0.45); transition: transform 0.1s ease-out, opacity 0.3s; opacity: 0; transform: scale(0.9); max-width: 90%; max-height: 90%; }
.canvas-shadow-box.active { opacity: 1; transform: scale(1); }
canvas { display: block; max-width: 100%; height: auto; cursor: default; touch-action: none; }
canvas.can-drag { cursor: grab; }
canvas.is-dragging { cursor: grabbing; }
#empty-state { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--text-secondary); opacity: 0.6; pointer-events: none; }
#empty-state .icon { font-size: 48px; margin-bottom: 8px; }

.view-controls { display: flex; align-items: center; gap: 8px; }
.view-controls button { width: 26px; height: 26px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--bg-secondary); cursor: pointer; font-weight: 700; color: var(--text-primary); padding: 0; }
#zoom-level { font-size: 13px; font-weight: 600; min-width: 40px; text-align: center; }

.calculate-btn { width: 100%; padding: 14px; background: var(--color-accent); color: #fff; border: 1.5px solid var(--border-color); border-radius: var(--radius-button); font-size: 18px; font-weight: 700; cursor: pointer; box-shadow: 4px 4px 0 rgba(0,0,0,0.2); margin-top: auto; }
.calculate-btn:hover:not(:disabled) { transform: translate(1px, 1px); box-shadow: 3px 3px 0 rgba(0,0,0,0.2); }
.calculate-btn:disabled { background: #888; cursor: not-allowed; box-shadow: none; }
.reset-btn { width: 100%; padding: 10px; background: var(--color-warning); color: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-button); cursor: pointer; font-weight: 600; margin-top: 10px; }
.watermark { text-align: right; font-size: 13px; color: var(--text-light); margin-top: 8px; }
.toast { position: fixed; bottom: 30px; right: 30px; padding: 12px 20px; background: var(--text-primary); color: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 8px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.2); opacity: 0; visibility: hidden; transition: all 0.3s; z-index: 9999; }
.toast.show { opacity: 1; visibility: visible; transform: translateY(-10px); }

@media (max-width: 768px) { 
  .filter-grid { grid-template-columns: repeat(4, 1fr); } 
  .desk-wrapper { min-height: 400px; }
  .texture-compact-grid { grid-template-columns: 1fr; }
}