/* ========================================
   Reset, Typography, Layout, Views
   ======================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse at 15% 0%, rgba(107,141,181,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 100%, rgba(184,115,51,0.04) 0%, transparent 50%);
}

/* ========================================
   View State Management
   ======================================== */
.view { display: none; }
body[data-state="upload"] #upload-view { display: flex; }
body[data-state="processing"] #processing-view { display: flex; }
body[data-state="results"] #results-view { display: block; }

/* ========================================
   Upload View
   ======================================== */
#upload-view {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.upload-content {
  text-align: center;
  max-width: 560px;
  padding: 2rem;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 4.5rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  color: var(--text-primary);
}
.hero-title .accent { color: var(--accent-bright); }
.hero-sub {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border-medium);
  border-radius: 14px;
  padding: 3rem 2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-raised);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 40px var(--accent-dim);
}
.drop-zone input { display: none; }
.drop-icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
  transition: color 0.3s, transform 0.3s;
}
.drop-zone:hover .drop-icon,
.drop-zone.dragover .drop-icon {
  color: var(--accent);
  transform: translateY(-3px);
}
.drop-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.drop-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Privacy badge */
.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.privacy-note svg { color: var(--green); flex-shrink: 0; }

/* Export help */
.export-help {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.export-help summary {
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.export-help summary:hover { color: var(--accent); }
.export-help ol {
  text-align: left;
  margin-top: 0.75rem;
  padding-left: 1.5rem;
  line-height: 1.8;
}
.export-help a {
  color: var(--denim);
  text-decoration: none;
}
.export-help a:hover { text-decoration: underline; }

/* ========================================
   Processing View
   ======================================== */
#processing-view {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.processing-content {
  text-align: center;
  width: 100%;
  max-width: 420px;
  padding: 2rem;
}
.processing-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
}
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ========================================
   Results View
   ======================================== */
.results-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 2rem;
  background: rgba(27,40,56,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}
.header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
}
.btn-reset {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#results-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* ========================================
   Sections
   ======================================== */
.section {
  padding: 3rem 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.section.visible {
  opacity: 1;
  transform: translateY(0);
}
.section + .section {
  border-top: 2px dashed var(--stitch);
  opacity: 1;
  border-image: none;
}
.section + .section::before {
  content: none;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.section-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 600px;
}
.subsection {
  margin-top: 2rem;
}

/* ========================================
   Footer
   ======================================== */
.results-footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 2px dashed var(--stitch);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.results-footer a {
  color: var(--accent);
  text-decoration: none;
}
.results-footer a:hover { text-decoration: underline; }

/* ========================================
   Toast (error)
   ======================================== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.88rem;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 90vw;
}
.toast[hidden] { display: none; }
.toast button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .results-header { padding: 0.75rem 1rem; }
  #results-container { padding: 0 1rem; }
  .section { padding: 2rem 0; }
  .data-table { font-size: 0.75rem; }
  .stats-row { gap: 1.2rem; }
  .bloat-legend { gap: 0.8rem; font-size: 0.72rem; }
  .tax-legend { gap: 0.8rem; font-size: 0.72rem; }
  .xray-legend { gap: 0.8rem; font-size: 0.72rem; }
  .xray-callout { padding: 1rem 1.5rem; }
  .xray-callout-value { font-size: 2rem; }
}
