/* ─────────────────────────────────────────────
   rmbg.platform.ooo · styles.css
   Aesthetic: dark-ground, chartreuse accent,
   checkerboard as brand motif.
   Mobile-first (320px baseline).
───────────────────────────────────────────── */

/* ── TOKENS ── */
:root {
  /* Palette */
  --bg:        #0e0e0f;
  --bg-2:      #161618;
  --bg-3:      #1e1e21;
  --border:    rgba(255,255,255,0.08);
  --border-md: rgba(255,255,255,0.13);
  --ink:       #f0f0f0;
  --ink-2:     #a0a0a8;
  --ink-3:     #606068;
  --accent:    #e8ff47;
  --accent-dim:rgba(232,255,71,0.12);
  --accent-fg: #0e0e0f;
  --err:       #ff5c5c;
  --err-dim:   rgba(255,92,92,0.12);
  --ok:        #4dffb4;
  --ok-dim:    rgba(77,255,180,0.10);

  /* Checker pattern (light squares on dark) */
  --checker-light: rgba(255,255,255,0.07);
  --checker-dark:  transparent;
  --checker-size:  18px;

  /* Checker (white on white bg for result panes) */
  --checker-result-a: #f5f5f5;
  --checker-result-b: #e0e0e0;
  --checker-result-sz: 16px;

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow:    0 1px 3px rgba(0,0,0,0.5), 0 8px 32px rgba(0,0,0,0.4);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.6), 0 16px 48px rgba(0,0,0,0.5);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light mode: keep dark (results look best on dark) but adjust slightly */
@media (prefers-color-scheme: light) {
  :root {
    --bg:        #111113;
    --bg-2:      #18181b;
    --bg-3:      #222226;
    --border:    rgba(255,255,255,0.09);
    --border-md: rgba(255,255,255,0.15);
    --ink:       #f2f2f2;
    --ink-2:     #9898a4;
    --ink-3:     #5a5a64;
  }
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family:
    "Pretendard Variable", Pretendard,
    -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR",
    "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Subtle checker texture on body */
  background-image:
    linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%);
  background-size: var(--checker-size) var(--checker-size);
  background-position:
    0 0,
    0 calc(var(--checker-size) / 2),
    calc(var(--checker-size) / 2) calc(-1 * var(--checker-size) / 2),
    calc(-1 * var(--checker-size) / 2) 0;
}

body.is-loading {
  overflow: hidden;
}

/* ── UTILITY ── */
.hidden {
  display: none !important;
}

/* ── SITE WRAP ── */
.site-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14,14,15,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wordmark {
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.wordmark-rmbg {
  color: var(--accent);
}

.wordmark-dot {
  color: var(--ink-3);
}

.wordmark-platform {
  color: var(--ink-2);
  font-weight: 500;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ── HERO ── */
.hero {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 16px 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-title {
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin-bottom: 14px;
}

.hero-ko {
  display: block;
  color: var(--ink);
}

.hero-en {
  display: block;
  color: var(--accent);
  font-style: italic;
}

.hero-br {
  display: none;
}

.hero-sub {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.7;
}

.hero-sub-en {
  color: var(--ink-3);
  font-size: 12px;
}

/* Hero visual: animated checker tiles */
.hero-visual {
  flex-shrink: 0;
  display: none; /* mobile hidden, show md+ */
}

.checker-demo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  opacity: 0.6;
}

.checker-tile {
  border-radius: 2px;
  animation: tile-pulse 3s ease-in-out infinite;
}

.checker-tile--a { background: var(--accent); animation-delay: 0s; }
.checker-tile--b { background: var(--bg-3); animation-delay: 0.4s; }
.checker-tile--c { background: var(--bg-3); animation-delay: 0.8s; }
.checker-tile--d { background: var(--accent); animation-delay: 1.2s; }

@keyframes tile-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── MAIN ── */
.main-content {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 0 16px 100px; /* 100px bottom for sticky CTA room */
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 1.5px dashed var(--border-md);
  border-radius: var(--radius-lg);
  background: var(--bg-2);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 200ms var(--ease-out), background 200ms var(--ease-out);
  position: relative;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Hidden native input */
#file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.drop-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px 24px;
  cursor: pointer;
  text-align: center;
  pointer-events: none; /* input takes the clicks */
}

.drop-icon {
  color: var(--ink-3);
  transition: color 200ms, transform 200ms var(--ease-spring);
}

.upload-zone.drag-over .drop-icon {
  color: var(--accent);
  transform: translateY(-4px) scale(1.1);
}

.drop-primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drop-ko {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.drop-en {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}

.drop-hint {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* ── ALERT ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--err-dim);
  border: 1px solid rgba(255,92,92,0.25);
  color: #ff8888;
  font-size: 13px;
  line-height: 1.5;
  animation: alert-in 200ms var(--ease-out);
}

.alert svg {
  flex-shrink: 0;
  margin-top: 1px;
}

@keyframes alert-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SELECTION PREVIEW ── */
.selection {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fade-up 250ms var(--ease-out);
}

.selection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selection-label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.sel-en { margin-left: 4px; }

.selection-count {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Thumb grid */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-3);
  animation: thumb-in 250ms var(--ease-spring);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@keyframes thumb-in {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── SUBMIT BUTTON (sticky on mobile) ── */
#submit-button {
  /* Mobile: sticky bottom bar */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  border-radius: 0;
  border-top: 1px solid var(--border);
  margin: 0;
  width: 100%;
}

/* ── BTN-PRIMARY BASE ── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 17px 24px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition:
    background 160ms,
    transform 120ms var(--ease-spring),
    opacity 160ms;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
  background: #f5ff6e;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ko { font-weight: 700; }
.btn-divider { color: var(--accent-fg); opacity: 0.4; }
.btn-en { font-weight: 500; opacity: 0.75; }
.btn-arrow { flex-shrink: 0; }

/* ── SUMMARY ── */
.summary {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--ok-dim);
  border: 1px solid rgba(77,255,180,0.18);
  color: var(--ok);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  animation: fade-up 300ms var(--ease-out);
}

/* ── RESULTS ── */
.results {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fade-up 350ms var(--ease-out);
  box-shadow: var(--shadow-card);
}

.result-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.result-head h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0;
}

.result-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.result-name {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

/* Original pane */
.pane {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pane--original {
  border-right: 1px solid var(--border);
}

figcaption {
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.pane-ko { color: var(--ink-3); }
.pane-en { color: var(--ink-3); opacity: 0.6; }

.pane img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.pane--original img {
  background: var(--bg-3);
}

/* Result pane: checkerboard background to show transparency */
.pane-checker {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background-color: var(--checker-result-a);
  background-image:
    linear-gradient(45deg, var(--checker-result-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-result-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-result-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-result-b) 75%);
  background-size: var(--checker-result-sz) var(--checker-result-sz);
  background-position:
    0 0,
    0 calc(var(--checker-result-sz) / 2),
    calc(var(--checker-result-sz) / 2) calc(-1 * var(--checker-result-sz) / 2),
    calc(-1 * var(--checker-result-sz) / 2) 0;
}

.pane-checker img {
  width: 100%;
  display: block;
  border: none;
  border-radius: 0;
}

/* Download button */
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(232,255,71,0.2);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.04em;
  align-self: flex-start;
  transition: background 140ms, border-color 140ms, transform 100ms;
  -webkit-tap-highlight-color: transparent;
}

.download-btn:hover {
  background: rgba(232,255,71,0.2);
  border-color: rgba(232,255,71,0.35);
}

.download-btn:active {
  transform: scale(0.96);
}

.download-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Placeholder */
.placeholder {
  min-height: 100px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

.ph-ko { font-weight: 600; }
.ph-en { opacity: 0.6; font-size: 11px; }

/* Result meta */
.result-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.result-meta span::before {
  content: "";
}

.result-card .alert {
  margin: 0 16px 12px;
}

/* ── LOADING OVERLAY ── */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(14,14,15,0.8);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.loading.hidden {
  display: none;
}

.loading-card {
  background: var(--bg-2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: min(340px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card);
  animation: scale-in 250ms var(--ease-spring);
}

/* Animated checker spinner */
.loading-checker {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.lc-inner {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
  background-image:
    linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  animation: checker-scroll 1.2s linear infinite;
}

@keyframes checker-scroll {
  from { background-position: 0 0, 0 6px, 6px -6px, -6px 0; }
  to   { background-position: 12px 12px, 12px 18px, 18px 6px, 6px 12px; }
}

.loading-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  gap: 6px;
  align-items: center;
}

.loading-ko { color: var(--ink); }
.loading-en {
  color: var(--ink-3);
  font-weight: 400;
  font-size: 13px;
}

.loading-meta {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.loading-pct {
  color: var(--accent);
  font-weight: 700;
}

.progress {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--bg-3);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 250ms var(--ease-out);
  border-radius: 999px;
}

.loading-hint {
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.5;
}

/* ── FOOTER ── */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px 28px;
  font-size: 11px;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-gpu {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.footer-sep { opacity: 0.4; }

.footer-brand {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.footer-brand:hover {
  text-decoration: underline;
}

/* ── ANIMATIONS ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── BREAKPOINT: MD (≥ 520px) ── */
@media (min-width: 520px) {
  .hero-br { display: block; }

  .thumb-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .drop-label {
    padding: 36px 24px 30px;
  }
}

/* ── BREAKPOINT: LG (≥ 720px) ── */
@media (min-width: 720px) {
  .hero {
    padding: 56px 16px 28px;
  }

  .hero-visual {
    display: block;
  }

  .hero-title {
    font-size: clamp(40px, 6vw, 64px);
  }

  /* Unstick submit button on desktop — embed it in the form */
  #submit-button {
    position: static;
    border-radius: var(--radius-md);
    border: none;
    width: auto;
    align-self: flex-start;
    padding: 14px 28px;
  }

  .upload-zone {
    padding: 24px;
  }

  .drop-label {
    padding: 44px 32px 36px;
  }

  .thumb-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── BREAKPOINT: XL (≥ 1024px) ── */
@media (min-width: 1024px) {
  .main-content {
    padding-bottom: 48px;
  }

  .hero-sub {
    font-size: 15px;
  }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .checker-tile,
  .lc-inner {
    animation: none !important;
  }
}

/* ── FOCUS VISIBLE ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
