/* SupoRedo - Modern Styling */

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-tertiary: #1b2640;
  --bg-card: rgba(19, 27, 46, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: #3b82f6;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-yellow: #eab308;
  --accent-green: #10b981;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 50%, #c084fc 100%);
  --supo-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 50%, #c084fc 100%);
  --banana-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 50%, #c084fc 100%);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.35);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 0.9375rem; /* 15px accessible base */
  line-height: 1.5; /* WCAG 1.4.12 standard */
  letter-spacing: 0.01em;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* WCAG 2.0 Focus accessibility */
:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Background ambient glow */
.ambient-glow {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 400px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, rgba(234, 179, 8, 0.08) 50%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

/* Glass Card */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* Header */
.brand-badge {
  background: var(--banana-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

/* Drag and drop upload zone */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  transition: all 0.25s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.06);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

/* Aspect ratio selection tab */
.ratio-tab {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
}
.ratio-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}
.ratio-tab.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-blue);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.25);
}

/* Resolution chips */
.res-chip {
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}
.res-chip:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
}
.res-chip.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #60a5fa;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  color: #ffffff;
}

/* Ratio shape preview icons */
.ratio-icon {
  border: 1.5px solid currentColor;
  border-radius: 2px;
  display: inline-block;
  opacity: 0.8;
}

/* Before / After Split Slider (No zoom, perfectly aligned clip-path) */
.comparison-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: auto;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  border-radius: var(--radius-md);
  background-color: #05070d;
  cursor: ew-resize;
  touch-action: none;
}

#outputCanvas {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  display: block;
}

.comparison-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  transition: none !important;
  transform: none !important;
  animation: none !important;
}

.comparison-layer-after {
  clip-path: inset(0 calc(100% - var(--split-pos, 50%)) 0 0);
  will-change: clip-path;
}

#lbNineRowsInteractiveOverlay {
  pointer-events: none;
}

#lightboxComparisonBox .comparison-layer {
  object-fit: fill;
}

#lbNineRowsInteractiveOverlay .lb-nine-row-item {
  pointer-events: auto;
}

.comparison-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split-pos, 50%);
  width: 2px;
  background-color: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 4px #3b82f6;
  pointer-events: none;
  z-index: 25;
  transform: translateX(-50%);
}

.comparison-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: #0b0f19;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  font-weight: 800;
  font-size: 13px;
  border: 2px solid #2563eb;
}

/* Interactive Crop Box */
.crop-overlay-container {
  position: relative;
  display: inline-block;
}
.crop-box {
  position: absolute;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.72), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  cursor: move;
  box-sizing: border-box;
}
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: 2.5px solid #0284c7;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  z-index: 25;
  transition: transform 0.1s ease;
}
.crop-handle:hover {
  transform: scale(1.25);
  background: #e0f2fe;
}
.crop-handle.tl { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle.tr { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-handle.br { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-handle.edge-top { top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.edge-top:hover { transform: translateX(-50%) scale(1.25); }
.crop-handle.edge-bottom { bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.edge-bottom:hover { transform: translateX(-50%) scale(1.25); }
.crop-handle.edge-left { left: -7px; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle.edge-left:hover { transform: translateY(-50%) scale(1.25); }
.crop-handle.edge-right { right: -7px; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle.edge-right:hover { transform: translateY(-50%) scale(1.25); }

/* Modal Backdrop */
.modal-backdrop {
  background: rgba(5, 7, 13, 0.8);
  backdrop-filter: blur(8px);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Pulse animation */
@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.03); }
}
.pulsing-glow {
  animation: pulse-glow 3s infinite ease-in-out;
}

/* Lightbox Modal & Pixel Zoom Styles */
#lightboxModal {
  z-index: 100;
}

.lb-zoom-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}

#lightboxComparisonBox {
  margin: auto;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background-color: #05070d;
  cursor: ew-resize;
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
}

/* Spacebar + Mouse Drag Canvas Panning */
body.space-panning,
body.space-panning #mainViewportArea,
body.space-panning #mainViewportArea *,
body.space-panning #lightboxViewport,
body.space-panning #lightboxViewport * {
  cursor: grab !important;
  user-select: none !important;
}

body.space-panning.is-panning,
body.space-panning.is-panning #mainViewportArea,
body.space-panning.is-panning #mainViewportArea *,
body.space-panning.is-panning #lightboxViewport,
body.space-panning.is-panning #lightboxViewport * {
  cursor: grabbing !important;
}

/* Toast Notification System (Top Right Display & below Lightbox Navbar when Lightbox is active) */
#toastContainer {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  transition: top 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 當全螢幕 Lightbox 開啟時，系統訊息顯示在右上角，但在 lightbox nav bar 下方 */
#lightboxModal:not(.hidden) ~ #toastContainer,
body.lightbox-open #toastContainer {
  top: calc(var(--lb-navbar-height, 68px) + 12px) !important;
}

/* 首頁合併圖片與多圖批次輸出預覽圖置上對齊 (Lightbox 預覽圖維持置中對齊) */
#mainViewportArea.merge-top-align,
#mainViewportArea.batch-top-align {
  align-items: flex-start !important;
}
#mainViewportArea.merge-top-align #resultViewWrapper,
#mainViewportArea.merge-top-align #splitViewWrapper,
#mainViewportArea.merge-top-align #cropViewWrapper,
#mainViewportArea.batch-top-align #resultViewWrapper,
#mainViewportArea.batch-top-align #splitViewWrapper,
#mainViewportArea.batch-top-align #cropViewWrapper {
  align-items: flex-start !important;
}
#mainViewportArea.merge-top-align #resultCanvasContainer,
#mainViewportArea.merge-top-align #comparisonBox,
#mainViewportArea.merge-top-align #cropContainer,
#mainViewportArea.batch-top-align #resultCanvasContainer,
#mainViewportArea.batch-top-align #comparisonBox,
#mainViewportArea.batch-top-align #cropContainer {
  align-self: flex-start !important;
  margin-top: 0.5rem !important;
}
