/* ─── Design Tokens ─── */
:root {
  color-scheme: light;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;

  --ink: #1a1a1a;
  --ink-soft: #3d3d3d;
  --muted: #7a7a7a;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --paper: #ffffff;
  --surface: rgba(255, 255, 255, 0.72);
  --wash: #f5f3f0;
  --accent: #c44a2f;
  --accent-soft: rgba(196, 74, 47, 0.08);
  --accent-glow: rgba(196, 74, 47, 0.15);
  --sage: #4a6741;
  --blue: #2d5a7b;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 12px 40px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08), 0 24px 80px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 0 1px var(--accent-soft), 0 8px 40px var(--accent-glow);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 0.5s;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--wash);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* ─── Grain overlay ─── */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.028;
  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: 200px;
}

/* ─── Cursor glow ─── */
.cursor-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 74, 47, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.4s;
  opacity: 0;
}

/* ─── Shell & Layout ─── */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 16px;
}

.workspace {
  width: min(1120px, 100%);
  margin: 0 auto;
}

/* ─── Reveal animation ─── */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Topbar ─── */
.topbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
  padding: 20px 0;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--accent);
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 680px;
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 400;
  font-style: italic;
  line-height: 0.92;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2 {
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 400;
  font-style: italic;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

/* ─── Step pills ─── */
.steps {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: start;
}

.step {
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
  transition: all 0.4s var(--ease-out);
}

.step-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.82rem;
  margin-right: 4px;
}

.step.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-md);
}

/* ─── Cards / Panels ─── */
.panel,
.result-hero,
.palette-section,
.section-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
}

/* ─── Upload Panel ─── */
.upload-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
}

.upload-copy {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, #1a1a1a 0%, #2a2520 100%);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

.upload-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(196, 74, 47, 0.15), transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(74, 103, 65, 0.12), transparent 60%);
  pointer-events: none;
}

.upload-copy h2 {
  position: relative;
  color: var(--paper);
}

.upload-copy p {
  position: relative;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
  font-size: 0.88rem;
}

#summary,
.section-heading p,
.block-note {
  color: var(--muted);
  line-height: 1.65;
}

.block-note { margin-bottom: 14px; }

/* ─── File Input ─── */
.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ─── Dropzone ─── */
.dropzone {
  min-height: 260px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  color: var(--ink);
  transition:
    transform 0.4s var(--ease-spring),
    border-color 0.3s,
    box-shadow 0.4s var(--ease-out),
    background 0.3s;
}

.dropzone:hover,
.dropzone.is-dragging {
  transform: translateY(-4px) scale(1.005);
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: var(--shadow-glow);
}

.upload-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: all 0.4s var(--ease-spring);
}

.dropzone:hover .upload-icon {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1) rotate(90deg);
}

.upload-title {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.upload-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
}

/* ─── Preview Row ─── */
.preview-row {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: box-shadow 0.3s;
}

.preview-row:hover { box-shadow: var(--shadow-sm); }

.preview-row img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ─── Form elements ─── */
.notes-label {
  grid-column: 1 / -1;
  font-weight: 500;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

textarea {
  grid-column: 1 / -1;
  width: 100%;
  resize: vertical;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.88rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea::placeholder { color: var(--muted); }

/* ─── Buttons ─── */
.primary-button,
.ghost-button {
  position: relative;
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  min-height: 52px;
  padding: 0 28px;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 0.4s var(--ease-spring),
    box-shadow 0.4s var(--ease-out),
    background 0.3s,
    border-color 0.3s;
}

.primary-button {
  justify-self: stretch;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-md);
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--accent), #d4623e);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.primary-button:active { transform: translateY(0) scale(0.98); }

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  transform: none;
  background: var(--ink);
}

.ghost-button {
  border-color: var(--line-strong);
  background: var(--paper);
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.ghost-button:active { transform: translateY(0); }

/* ─── Status ─── */
.status {
  align-self: center;
  margin: 0;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

/* ─── Result Panel ─── */
.result-panel {
  display: grid;
  gap: 16px;
}

.result-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
}

.season-card {
  min-height: 280px;
  border-radius: var(--radius-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(160deg, #1a1a1a 0%, #2a2520 100%);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

.season-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 100%, rgba(196, 74, 47, 0.2), transparent 55%),
    radial-gradient(ellipse at 70% 0%, rgba(45, 90, 123, 0.15), transparent 55%);
  pointer-events: none;
}

.season-card > * { position: relative; }
.season-card .eyebrow { color: rgba(255,255,255,0.5); }
.season-card h2 { color: var(--paper); }

.season-card #summary {
  max-width: 740px;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.65;
}

.actions-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
}

.actions-card .primary-button,
.actions-card .ghost-button {
  width: 100%;
}

/* ─── Metrics ─── */
.metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.metrics div {
  min-height: 96px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  transition: transform 0.4s var(--ease-spring), box-shadow 0.3s;
}

.metrics div:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.metrics span,
.confidence span,
.swatch small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.metrics strong {
  display: block;
  margin-top: 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 400;
  text-transform: capitalize;
}

/* ─── Confidence Meter ─── */
.confidence {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

.confidence span { color: rgba(255,255,255,0.5); }

.meter {
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #e8724e);
  border-radius: var(--radius-pill);
  transition: width 1.2s var(--ease-out);
}

.confidence strong { color: var(--paper); }

/* ─── Palette Section ─── */
.palette-section,
.section-block {
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
  flex-direction: column;
}

/* ─── Swatches ─── */
.swatches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.swatch {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--paper);
  transition: transform 0.4s var(--ease-spring), box-shadow 0.3s;
}

.swatch:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.swatch span {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 12px;
  transition: transform 0.3s var(--ease-spring);
}

.swatch:hover span { transform: scale(1.03); }

.swatch strong {
  display: block;
  text-transform: capitalize;
  font-size: 0.88rem;
}

.swatch em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
  line-height: 1.4;
}

/* ─── Insight & Style grids ─── */
.insight-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.style-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  color: var(--ink-soft);
  line-height: 1.65;
}

li {
  position: relative;
  padding-left: 18px;
}

li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

li + li { margin-top: 10px; }

/* ─── Chips ─── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  padding: 8px 16px;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--ink-soft);
  transition: all 0.3s var(--ease-out);
}

.chips span:hover {
  border-color: var(--ink);
  color: var(--ink);
  transform: translateY(-1px);
}

/* ─── Products ─── */
.products {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  min-height: 200px;
  transition: transform 0.4s var(--ease-spring), box-shadow 0.3s;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.product-card strong,
.product-card span {
  display: block;
}

.product-card strong { font-weight: 500; }

.product-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.product-card p {
  margin: 10px 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
  font-size: 0.88rem;
}

.product-card a {
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius-pill);
  padding: 12px 16px;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.3s var(--ease-out);
}

.product-card a:hover {
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ─── Hidden ─── */
[hidden] { display: none !important; }

/* ─── Stagger children animation ─── */
.result-panel .reveal {
  transition-delay: calc(var(--i, 0) * 0.08s);
}

/* ─── Responsive ─── */
@media (min-width: 621px) {
  .shell { padding: 24px; }

  .upload-panel,
  .result-hero {
    padding: 14px;
    gap: 14px;
  }

  .palette-section,
  .section-block {
    padding: 28px;
  }

  .upload-copy,
  .dropzone {
    min-height: 310px;
  }

  .metrics,
  .products,
  .swatches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-heading {
    align-items: baseline;
    flex-direction: row;
  }

  .confidence {
    grid-template-columns: auto 1fr auto;
  }
}

@media (min-width: 981px) {
  .shell { padding: 32px; }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: end;
    margin-bottom: 32px;
  }

  .steps { justify-content: end; }

  .upload-panel {
    grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
    gap: 14px;
    padding: 14px;
  }

  .upload-copy,
  .dropzone {
    min-height: 380px;
  }

  .upload-copy { padding: 36px; }

  .primary-button { justify-self: start; }

  .palette-section,
  .section-block {
    padding: 32px;
  }

  .preview-row { grid-column: 2; }

  .result-hero {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 14px;
    padding: 14px;
  }

  .season-card {
    min-height: 320px;
    padding: 48px;
  }

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

  .metrics div { min-height: 120px; }

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

  .insight-grid {
    grid-template-columns: 1fr 1fr 0.85fr;
  }

  .style-board {
    grid-template-columns: 1fr 1fr;
  }

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

@media (min-width: 621px) and (max-width: 980px) {
  .swatches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .insight-grid,
  .style-board {
    grid-template-columns: 1fr;
  }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .cursor-glow { display: none; }
}
