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

:root {
  /* Palette */
  --color-brand:        #2563eb;
  --color-brand-dark:   #1d4ed8;
  --color-brand-light:  #dbeafe;
  --color-success:      #16a34a;
  --color-success-bg:   #dcfce7;
  --color-error:        #dc2626;
  --color-error-bg:     #fee2e2;
  --color-outline:      #6b7280;

  /* Neutrals */
  --color-bg:           #f8fafc;
  --color-surface:      #ffffff;
  --color-border:       #e2e8f0;
  --color-text:         #1e293b;
  --color-text-muted:   #64748b;

  /* Typography */
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', monospace;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;

  /* Radii */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 12px 0 rgb(0 0 0 / 0.1);
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

/* ── Screen-reader-only utility ─────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

.hidden { display: none !important; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-xl) 0;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.site-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.site-title .icon { font-size: 1.6em; line-height: 1; }

.site-subtitle {
  margin-top: var(--space-xs);
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* ── Main layout ────────────────────────────────────────────────────────────── */
main.container {
  flex: 1;
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--color-text);
}

/* ── Drop zone ──────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--color-brand);
  background-color: var(--color-brand-light);
}

.drop-zone.drop-zone--active {
  border-color: var(--color-brand);
  background-color: var(--color-brand-light);
  transform: scale(1.01);
}

.drop-zone__icon { font-size: 3rem; margin-bottom: var(--space-md); }

.drop-zone__text {
  font-size: 1rem;
  color: var(--color-text-muted);
  line-height: 1.8;
}

.drop-zone__sub { color: var(--color-brand); }

.drop-zone__hint {
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ── File preview ───────────────────────────────────────────────────────────── */
.file-preview {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.file-preview__icon { font-size: 1.2rem; }
.file-preview__name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview__size { color: var(--color-text-muted); white-space: nowrap; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 3px; }

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

.btn--success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}
.btn--success:hover { filter: brightness(0.9); }

.btn--outline {
  background: transparent;
  color: var(--color-brand);
  border-color: var(--color-brand);
}
.btn--outline:hover { background: var(--color-brand-light); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--color-bg); color: var(--color-error); }

.btn--lg { padding: 0.75rem 2rem; font-size: 1rem; width: 100%; margin-top: var(--space-lg); }
.btn--sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Progress ───────────────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.progress-bar__fill {
  height: 100%;
  background: var(--color-brand);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
  /* Indeterminate animation when width is set to 100% artificially */
}

.progress-bar__fill--indeterminate {
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); width: 60%; }
  100% { transform: translateX(200%);  width: 60%; }
}

.progress-status {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── Result ─────────────────────────────────────────────────────────────────── */
.result {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.result__icon { font-size: 2.5rem; flex-shrink: 0; }

.result__body { flex: 1; min-width: 0; }

.result__message {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: var(--space-xs);
}

.result-card.result-card--success { border-color: #86efac; background: var(--color-success-bg); }
.result-card.result-card--error   { border-color: #fca5a5; background: var(--color-error-bg);   }

/* ── How it works ───────────────────────────────────────────────────────────── */
.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  font-size: 0.95rem;
}

.step__number {
  flex-shrink: 0;
  width: 1.8rem; height: 1.8rem;
  background: var(--color-brand);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.1rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-brand-light);
  color: var(--color-brand-dark);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-lg) 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.site-footer a {
  color: var(--color-brand);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .result { flex-direction: column; text-align: center; }
  .btn--success, .btn--outline { width: 100%; }
}
