/* Saltaire Image Generator — Editorial Warm Theme */

:root {
  /* Base palette — warm editorial */
  --bone: #f5efe4;
  --bone-2: #ece3d2;
  --bone-3: #e0d4bd;
  --ivory: #fbf7ef;
  --paper: #fffdf8;
  --terracotta: #b4613a;
  --terracotta-deep: #8a4529;
  --brass: #a88349;
  --brass-light: #c4a06a;
  --oxblood: #5c2e1f;
  --walnut: #3b2a1e;
  --ink: #221812;
  --ink-soft: #4a3b30;
  --ink-muted: #7a6a5a;
  --ink-faint: #a89a89;
  --rule: #d8cbb2;
  --rule-soft: #e7dcc7;

  /* Tweakable */
  --accent: var(--terracotta);
  --bg: var(--ivory);
  --surface: var(--paper);

  /* Type */
  --serif: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  --sans: 'Inter Tight', 'Söhne', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(59, 42, 30, 0.06), 0 1px 3px rgba(59, 42, 30, 0.04);
  --shadow-md: 0 4px 12px rgba(59, 42, 30, 0.08), 0 2px 4px rgba(59, 42, 30, 0.04);
  --shadow-lg: 0 16px 40px rgba(59, 42, 30, 0.12), 0 4px 12px rgba(59, 42, 30, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse 1200px 600px at 50% -100px, rgba(180, 97, 58, 0.06), transparent 60%),
    var(--bg);
}

/* Typography */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); }
.caps { text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; font-weight: 500; }
.hairline { letter-spacing: 0.22em; text-transform: uppercase; font-size: 10px; font-weight: 500; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.015em; line-height: 1.1; }

/* Layout */
.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 40px 80px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 36px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.brand-mark {
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  color: var(--walnut);
  letter-spacing: -0.02em;
}
.brand-divider {
  width: 1px; height: 20px; background: var(--rule);
}
.brand-tool {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.header-meta .status-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #7ba05b; margin-right: 6px; vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(123, 160, 91, 0.15);
}

/* Hero / title */
.page-title {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 40px;
  margin-bottom: 44px;
}
.page-title h1 {
  font-size: 52px;
  color: var(--walnut);
  max-width: 720px;
}
.page-title h1 em {
  font-style: italic;
  color: var(--terracotta);
}
.page-title .lede {
  font-size: 15px;
  color: var(--ink-muted);
  max-width: 360px;
  line-height: 1.55;
}

/* Stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-bottom: 40px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.step-indicator {
  position: relative;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
  transition: background 0.2s;
  border-right: 1px solid var(--rule);
}
.step-indicator:last-child { border-right: none; }
.step-indicator:hover:not(.disabled) { background: rgba(212, 186, 143, 0.08); }
.step-indicator.active {
  background: linear-gradient(to bottom, rgba(180, 97, 58, 0.04), transparent);
}
.step-indicator.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent);
}
.step-indicator.disabled { opacity: 0.4; cursor: not-allowed; }
.step-num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 36px;
  color: var(--ink-faint);
  line-height: 1;
  width: 44px;
}
.step-indicator.active .step-num { color: var(--accent); }
.step-indicator.complete .step-num { color: var(--walnut); }
.step-indicator.complete .step-num::after {
  content: '✓'; font-style: normal; font-size: 14px; margin-left: 4px; color: #7ba05b;
}
.step-label .caps { color: var(--ink-muted); }
.step-indicator.active .step-label .caps { color: var(--accent); }
.step-label .title {
  font-family: var(--serif); font-size: 20px; color: var(--walnut); margin-top: 2px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--walnut);
  color: var(--ivory);
  border-radius: 1px;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  color: var(--ivory);
}
.btn.primary:hover:not(:disabled) { background: var(--terracotta-deep); }
.btn.ghost {
  background: transparent;
  color: var(--walnut);
  border-color: var(--rule);
}
.btn.ghost:hover:not(:disabled) { background: var(--bone-2); border-color: var(--walnut); }
.btn.small { padding: 9px 16px; font-size: 11px; }

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  padding: 14px 18px;
  font-family: var(--sans);
  font-size: 15px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 1px;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 97, 58, 0.12);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a6a5a' stroke-width='1.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
label.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

/* Ornaments */
.ornament {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--brass);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.ornament::before, .ornament::after {
  content: ''; flex: 1; height: 1px; background: var(--rule);
}

/* Utilities */
.flex { display: flex; }
.grid { display: grid; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.center { text-align: center; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Fade in */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease-out; }

/* STEP 1 — URL entry */
.step1-wrap {
  max-width: 780px;
  margin: 0 auto;
}
.step1-card {
  padding: 56px 56px 48px;
  text-align: center;
}
.step1-card .eyebrow { margin-bottom: 16px; color: var(--brass); }
.step1-card h2 { font-size: 40px; color: var(--walnut); margin-bottom: 14px; }
.step1-card .sub { color: var(--ink-muted); margin-bottom: 36px; font-size: 16px; }
.url-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 20px;
}
.url-input-row .input {
  padding: 18px 22px;
  font-size: 15px;
  font-family: var(--mono);
  font-size: 13px;
}
.url-input-row .btn {
  padding: 0 32px;
}
.examples {
  margin-top: 44px;
  padding-top: 32px;
  border-top: 1px solid var(--rule-soft);
  text-align: left;
}
.examples-heading {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.example-list {
  display: grid;
  gap: 2px;
}
.example-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 18px;
  padding: 14px 8px;
  align-items: center;
  cursor: pointer;
  border-radius: 1px;
  transition: background 0.15s;
  border-bottom: 1px solid var(--rule-soft);
}
.example-item:hover { background: var(--bone); }
.example-item:last-child { border-bottom: none; }
.example-thumb {
  width: 52px; height: 52px;
  background: var(--bone-2);
  border: 1px solid var(--rule);
  background-size: cover;
  background-position: center;
}
.example-name { font-family: var(--serif); font-size: 18px; color: var(--walnut); }
.example-meta { font-size: 11px; color: var(--ink-muted); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.example-go { font-size: 18px; color: var(--ink-faint); }
.example-item:hover .example-go { color: var(--accent); }

/* STEP 2 — Analysis + env picker */
.step2-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 40px;
  align-items: start;
}
.product-preview {
  position: sticky;
  top: 24px;
}
.product-image-wrap {
  aspect-ratio: 3/4;
  background: var(--bone-2);
  border: 1px solid var(--rule);
  overflow: hidden;
  position: relative;
}
.product-image-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.product-info { padding: 20px 4px; }
.product-info .pname {
  font-family: var(--serif); font-size: 24px; color: var(--walnut); margin-bottom: 6px;
  line-height: 1.15;
}
.product-info .pmeta { font-size: 12px; color: var(--ink-muted); letter-spacing: 0.08em; text-transform: uppercase; }
.product-info .price { font-family: var(--serif); font-size: 20px; color: var(--terracotta); margin-top: 12px; }
.product-info .source {
  font-size: 11px; color: var(--ink-faint); margin-top: 16px; font-family: var(--mono);
  word-break: break-all;
}

.analysis-card {
  padding: 32px;
}
.analysis-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--ink-muted);
}
.analysis-header::before {
  content: ''; width: 28px; height: 1px; background: var(--brass);
}
.analysis-title {
  font-family: var(--serif); font-size: 28px; color: var(--walnut); margin-bottom: 6px;
}
.analysis-sub { color: var(--ink-muted); margin-bottom: 28px; }

.attr-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule-soft);
  margin-bottom: 32px;
}
.attr {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
  padding-right: 20px;
}
.attr:nth-child(odd) { border-right: 1px solid var(--rule-soft); padding-left: 0; padding-right: 20px; }
.attr:nth-child(even) { padding-left: 20px; }
.attr-label { font-size: 10px; color: var(--ink-muted); letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 4px; font-weight: 500;}
.attr-value { font-family: var(--serif); font-size: 17px; color: var(--walnut); line-height: 1.3; }

.condition-block {
  background: var(--bone);
  border-left: 2px solid var(--brass);
  padding: 16px 20px;
  margin-bottom: 32px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-label h3 { font-size: 22px; color: var(--walnut); }
.section-label .hint { font-size: 12px; color: var(--ink-muted); }

/* Environment cards */
.env-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.env-card {
  border: 1px solid var(--rule);
  background: var(--paper);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.env-card:hover { border-color: var(--brass); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.env-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(180, 97, 58, 0.15); }
.env-card.selected::after {
  content: '✓'; position: absolute; top: 8px; right: 8px;
  background: var(--accent); color: var(--ivory);
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.env-thumb {
  aspect-ratio: 4/3;
  background-size: cover;
  background-position: center;
  background-color: var(--bone-2);
  position: relative;
}
.env-thumb.ai-generated::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, #c9a478 0%, #a6825a 40%, #8d6a48 100%);
}
.env-info { padding: 12px 14px; }
.env-name { font-family: var(--serif); font-size: 16px; color: var(--walnut); margin-bottom: 2px; }
.env-desc { font-size: 11px; color: var(--ink-muted); line-height: 1.4; }
.env-recommended {
  position: absolute; top: 8px; left: 8px;
  background: var(--walnut); color: var(--ivory);
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 4px 8px; font-weight: 500;
}

/* Sub-options row */
.suboptions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

/* Prompt preview toggle */
.prompt-preview-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.prompt-preview-toggle:hover { color: var(--accent); }
.prompt-preview-toggle svg { transition: transform 0.2s; }
.prompt-preview-toggle.open svg { transform: rotate(90deg); }

.prompt-block {
  background: #faf5ea;
  border: 1px solid var(--rule-soft);
  padding: 20px 22px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-height: 320px;
  overflow-y: auto;
  margin-top: 14px;
  white-space: pre-wrap;
}

/* Actions */
.step-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--rule);
}

/* STEP 3 — Generation + results */
.step3-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 40px;
}
.gen-summary {
  position: sticky; top: 24px;
}
.gen-summary-card {
  padding: 24px;
  margin-bottom: 16px;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-soft);
  gap: 16px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .lbl { font-size: 11px; color: var(--ink-muted); letter-spacing: 0.1em; text-transform: uppercase; }
.summary-row .val { font-family: var(--serif); font-size: 15px; color: var(--walnut); text-align: right; }

.results-stage {
  background: var(--paper);
  border: 1px solid var(--rule);
  min-height: 520px;
  padding: 32px;
  position: relative;
}
.results-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 520px;
  color: var(--ink-muted);
}
.results-empty .ornament { width: 200px; margin-bottom: 24px; }
.results-empty .big { font-family: var(--serif); font-size: 28px; color: var(--walnut); margin-bottom: 8px; }

/* Loading state */
.gen-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 520px;
  gap: 24px;
}
.gen-loading .big {
  font-family: var(--serif); font-size: 28px; color: var(--walnut); font-style: italic;
}
.gen-loading .sub { color: var(--ink-muted); font-size: 14px; text-align: center; max-width: 360px; }
.gen-progress {
  width: 280px; height: 2px; background: var(--rule); position: relative; overflow: hidden;
}
.gen-progress::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 40%; background: var(--accent);
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.gen-stages {
  display: flex; gap: 20px; font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.gen-stages .stg.active { color: var(--accent); }
.gen-stages .stg.done { color: var(--walnut); }

/* Result grid */
.results-grid {
  display: grid;
  gap: 12px;
}
.results-grid.cols-1 { grid-template-columns: 1fr; }
.results-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.results-grid.cols-4 { grid-template-columns: 1fr 1fr; }

.result-image {
  background: var(--bone-2);
  border: 1px solid var(--rule);
  aspect-ratio: 4/5;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.result-image img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s;
}
.result-image:hover img { transform: scale(1.02); }
.result-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(34, 24, 18, 0.65), transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 14px;
  gap: 6px;
}
.result-image:hover .result-overlay { opacity: 1; }
.result-btn {
  background: rgba(251, 247, 239, 0.95);
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--walnut);
  font-family: var(--sans);
  font-weight: 500;
}
.result-btn:hover { background: var(--ivory); }

/* History gallery */
.history {
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--rule);
}
.history-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 20px;
}
.history-header h3 { font-size: 24px; color: var(--walnut); }
.history-header h3 em { font-style: italic; color: var(--terracotta); }
.history-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.history-item {
  aspect-ratio: 4/5;
  background: var(--bone-2);
  border: 1px solid var(--rule);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.history-item img { width: 100%; height: 100%; object-fit: cover; }
.history-item .he-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  background: linear-gradient(to top, rgba(34, 24, 18, 0.8), transparent);
  color: var(--ivory);
}
.history-empty { color: var(--ink-faint); font-style: italic; padding: 24px 0; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed; right: 24px; bottom: 24px;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  font-family: var(--sans);
}
.tweaks-panel.open { display: block; }
.tweaks-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--walnut);
  display: flex; justify-content: space-between; align-items: center;
}
.tweaks-close {
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-muted);
  line-height: 1;
}
.tweaks-body { padding: 18px; }
.tweak-row { margin-bottom: 18px; }
.tweak-row:last-child { margin-bottom: 0; }
.tweak-row label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-muted); margin-bottom: 8px; display: block; }
.swatch-row { display: flex; gap: 8px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: border-color 0.15s;
}
.swatch.active { border-color: var(--walnut); }

/* Modal lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(34, 24, 18, 0.88);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 40px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  background: none; border: none; color: var(--ivory);
  font-size: 32px; cursor: pointer; font-family: var(--serif);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--brass); }
