/* Editorial aesthetic preset + dark mode overrides.
   Base design tokens come from the graffiti toolkit + .theme-editorial.
   The variables below are the project's editorial palette (provided preset). */

:root {
  --fg-light: #1a1814;
  --fg-dark: #ede6d6;
  --bg-light: #faf6ee;
  --bg-dark: #1a1814;
  --primary: #94352b;
  --primary-hover: #7a2a22;
  --muted: #8a8170;
  --border: #e3dccd;
  --surface: #ffffff;

  --font-sans: 'Fraunces', Charter, Georgia, serif;
  --font-size-min: 17px;
  --font-size-max: 20px;
  --font-ratio-min: 1.2;
  --font-ratio-max: 1.25;
  --font-width-min: 320;
  --font-width-max: 1500;
  --br-xs: 1px;
  --br-s: 2px;
  --br-m: 4px;
  --br-l: 6px;
  --br-xl: 8px;
  --br-xxl: 12px;

  /* Active theme values (light by default) */
  --fg: var(--fg-light);
  --bg: var(--bg-light);
}

[data-theme="dark"] {
  --fg-light: #ede6d6;
  --fg-dark: #1a1814;
  --bg-light: #1a1814;
  --bg-dark: #faf6ee;
  --border: #34302a;
  --surface: #221f1a;
  --muted: #9a917f;

  --fg: var(--fg-light);
  --bg: var(--bg-light);
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: clamp(var(--font-size-min), calc(var(--font-size-min) + (var(--font-size-max) - var(--font-size-min)) * (100vw - var(--font-width-min) * 1px) / (var(--font-width-max) - var(--font-width-min))), var(--font-size-max));
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  transition: background 0.2s, color 0.2s;
}

header {
  text-align: center;
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* Dark mode toggle pinned to the top-right corner (icon only) */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  line-height: 0;
}
#theme-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

h1 { margin: 0; font-size: 2rem; color: var(--fg); }
header p { color: var(--muted); margin: 0; }

.controls {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 2rem;
}

/* Buttons in the controls row span the full width */
.controls .btn { width: 100%; }

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--br-m);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

#fileCount {
  font-weight: 500;
  min-width: 120px;
  display: inline-block;
  text-align: center;
}

.results { margin-bottom: 2rem; }

#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem 0;
}

.thumb {
  position: relative;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--br-m);
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
  transition: border-color 0.2s;
}
.thumb:hover { border-color: var(--primary); }

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

.thumb-name {
  display: block;
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
  color: var(--fg);
  word-break: break-all;
}

.thumb-dl {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--br-s);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.thumb-dl:hover { border-color: var(--primary); color: var(--primary); }

.results h2 { margin-top: 0; }

#progressBar {
  height: 24px;
  background: var(--border);
  border-radius: var(--br-xl);
  overflow: hidden;
  margin: 1rem 0;
}
#progressFill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

#logList {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--br-m);
  background: var(--surface);
}
#logList li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
#logList li:last-child { border-bottom: none; }
.log-ok { color: var(--primary); }
.log-error { color: #c0392b; }

footer {
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 2rem;
}
footer a { color: var(--primary); }
