/* ═══════════════════════════════════════
   DePrompter — Darkroom Aesthetic
   ═══════════════════════════════════════ */

:root {
  /* Core palette — dark mode (default) */
  --bg: #09090b;
  --bg-elevated: #111114;
  --surface: rgba(18, 18, 22, 0.82);
  --surface-solid: #111114;
  --text: #f0ece4;
  --text-secondary: #8a8580;
  --text-tertiary: #5c5854;
  --accent: #e85d26;
  --accent-glow: rgba(232, 93, 38, 0.15);
  --accent-subtle: rgba(232, 93, 38, 0.08);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-lg: 0 32px 64px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f7f4ef;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --text: #1a1816;
  --text-secondary: #6b6560;
  --text-tertiary: #9e9790;
  --accent: #d14a15;
  --accent-glow: rgba(209, 74, 21, 0.1);
  --accent-subtle: rgba(209, 74, 21, 0.05);
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 32px 64px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.06);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* ── Film Grain Overlay ── */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

[data-theme="light"] .grain-overlay {
  opacity: 0.025;
}

/* ── Ambient Glow ── */
.ambient-glow {
  position: fixed;
  top: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  max-width: 800px;
  max-height: 800px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    circle at 50% 50%,
    var(--accent-glow),
    transparent 70%
  );
  filter: blur(80px);
  animation: ambient-drift 20s ease-in-out infinite alternate;
}

@keyframes ambient-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-5%, 8%) scale(1.08); }
  100% { transform: translate(3%, -4%) scale(0.95); }
}

/* ── Page Layout ── */
.page-wrap {
  position: relative;
  z-index: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.logo {
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  position: relative;
}

.logo span {
  position: relative;
}

.logo span::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  opacity: 0.5;
  border-radius: 1px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease, background-color 0.2s ease;
  letter-spacing: 0.01em;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--accent-subtle);
}

/* ═══════════════════════════════════════
   DARK MODE TOGGLE — celestial eclipse
   ═══════════════════════════════════════ */

.toggle-wrap {
  margin-left: 12px;
  display: flex;
  align-items: center;
  position: relative;
  width: 120px;
  height: 32px;
  justify-content: center;
}

.theme-checkbox {
  width: 0;
  height: 0;
  visibility: hidden;
  position: absolute;
}

/* ── pill track (the groove) ── */
.theme-toggle-label {
  width: 56px;
  height: 32px;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  background: linear-gradient(180deg, #121216 0%, #0a0a0e 100%);
  border: 1px solid var(--border-strong);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.6),
    inset 0 -1px 3px rgba(255,255,255,0.04);
  transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  z-index: 2;
}

/* hover ring */
.theme-toggle-label::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  transition: border-color 0.3s ease;
  pointer-events: none;
}

.theme-toggle-label:hover::before {
  border-color: var(--accent-glow);
}

/* light mode track */
.theme-checkbox:checked + .theme-toggle-label {
  background: linear-gradient(180deg, #e8e2d8 0%, #d8d2c6 100%);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.1),
    inset 0 -1px 3px rgba(255,255,255,0.5);
}

.theme-checkbox:checked + .theme-toggle-label:hover::before {
  border-color: rgba(216, 134, 11, 0.3);
}

/* ── knob assembly ── */
.toggle-knob {
  width: 24px;
  height: 24px;
  position: absolute;
  left: 3px;
  border-radius: 50%;
  z-index: 3;
  transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.knob-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.12) 0%, transparent 50%),
    linear-gradient(145deg, #3a3a44 0%, #1e1e26 60%, #12121a 100%);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.06),
    inset 0 -2px 4px rgba(0,0,0,0.3),
    inset 0 1px 2px rgba(255,255,255,0.05);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.knob-halo {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid transparent;
  transition: border-color 0.4s ease, opacity 0.4s ease;
  opacity: 0;
}

.theme-toggle-label:hover .knob-halo {
  border-color: rgba(232, 93, 38, 0.25);
  opacity: 1;
}

/* light mode orb */
.theme-checkbox:checked + .theme-toggle-label .toggle-knob {
  left: calc(100% - 3px);
  transform: translateX(-100%);
}

.theme-checkbox:checked + .theme-toggle-label .knob-core {
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.35) 0%, transparent 50%),
    linear-gradient(145deg, #ffd08e 0%, #d8860b 60%, #b86a08 100%);
  box-shadow:
    0 2px 12px rgba(216, 134, 11, 0.35),
    0 0 0 1px rgba(255,204,137,0.2),
    inset 0 -2px 4px rgba(0,0,0,0.15),
    inset 0 1px 2px rgba(255,255,255,0.3);
}

.theme-checkbox:checked + .theme-toggle-label .knob-halo {
  border-color: rgba(216, 134, 11, 0.2);
}

/* active press — elastic squash */
.theme-toggle-label:active .toggle-knob {
  transform: scaleY(0.82);
}

.theme-checkbox:checked + .theme-toggle-label:active .toggle-knob {
  left: calc(100% - 3px);
  transform: translateX(-100%) scaleY(0.82);
}

/* ── text labels — outside the pill, opposite side of knob ── */
.toggle-label-text {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.35s ease, transform 0.35s ease;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

/* dark mode: knob on left → "Dark" appears on the right */
.dark-label {
  left: calc(50% + 40px);
  color: rgba(212, 208, 232, 0.9);
  opacity: 1;
}

/* light mode: knob on right → "Light" appears on the left */
.light-label {
  right: calc(50% + 40px);
  left: auto;
  color: rgba(184, 106, 8, 0.85);
  opacity: 0;
  transform: translateY(-50%) translateX(-3px);
}

/* swap when checked */
.theme-checkbox:checked ~ .dark-label {
  opacity: 0;
  transform: translateY(-50%) translateX(3px);
}

.theme-checkbox:checked ~ .light-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ═══════════════════════════════════════
   HERO
   ═══════════════════════════════════════ */

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.hero-content {
  padding: 8px 0 16px;
}

/* ── Typography ── */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
  display: inline-block;
  position: relative;
  padding-left: 22px;
}

.eyebrow::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 1.5px;
  background: var(--accent);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--text);
  max-width: 14ch;
  margin-bottom: 20px;
}

h1 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 300;
}

.subtitle {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-secondary);
  max-width: 48ch;
  line-height: 1.65;
  margin-bottom: 36px;
}

/* ═══════════════════════════════════════
   UPLOAD CARD
   ═══════════════════════════════════════ */

.upload-card {
  display: grid;
  gap: 16px;
}

.upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  backdrop-filter: blur(12px);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.upload-dropzone::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-subtle);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.upload-dropzone:hover::before,
.upload-dropzone.is-drag-over::before {
  opacity: 1;
}

.upload-dropzone:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.upload-dropzone.is-drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.upload-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.upload-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--border-strong);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.upload-dropzone:hover .upload-icon {
  transform: scale(1.08);
  box-shadow: 0 0 24px var(--accent-glow);
}

.upload-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.upload-hint {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

.upload-preview-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  border-radius: var(--radius-md);
}

.upload-dropzone.has-preview .upload-empty-state {
  display: none;
}

.upload-dropzone.has-preview .upload-preview-image {
  display: block;
}

.upload-dropzone.has-preview {
  border-style: solid;
  border-color: var(--border);
  min-height: 200px;
  max-height: 340px;
}

.upload-dropzone.has-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0, 0, 0, 0.4));
  border-radius: var(--radius-md);
  pointer-events: none;
}

.file-input {
  width: 100%;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
}

.file-input::file-selector-button {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  margin-right: 14px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  background: var(--bg-elevated);
  transition: all 0.2s ease;
}

.file-input::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.01em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(232, 93, 38, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(232, 93, 38, 0.35);
  filter: brightness(1.08);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  font-size: 0.8rem;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-subtle);
}

/* ═══════════════════════════════════════
   OUTPUT CARD
   ═══════════════════════════════════════ */

.output-card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-lg);
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.output-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
}

.output-box {
  min-height: 280px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 20px;
  font-family: "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
  position: relative;
  overflow: hidden;
}

.output-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.3;
}

.output-box p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ═══════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════ */

.site-footer {
  text-align: center;
  padding: 24px 0 8px;
  border-top: 1px solid var(--border);
}

.site-footer p {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (min-width: 860px) {
  .page-wrap {
    padding: 28px 40px 60px;
    gap: 36px;
  }

  .hero {
    grid-template-columns: 1.2fr 1fr;
    gap: 36px;
    align-items: start;
  }

  .output-box {
    min-height: 100%;
  }
}

@media (max-width: 680px) {
  .page-wrap {
    padding: 16px 18px 32px;
  }

  .site-header {
    flex-direction: column;
    gap: 14px;
    align-items: flex-start;
  }

  .site-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .toggle-wrap {
    margin-left: auto;
  }

  .output-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-secondary {
    width: 100%;
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ambient-glow { animation: none; }
  .upload-dropzone { transition: none; }
  .btn { transition: none; }
  .theme-toggle-label,
  .toggle-knob,
  .toggle-text,
  .knob-core,
  .knob-halo { transition: none; }
}
