/* ──────────────────────────────────────────────────────────────
   PeriodicTan — cold lab aesthetic.
   Off-white surfaces, near-black ink, restrained radii, technical type.
   ────────────────────────────────────────────────────────────── */

:root {
  --bg:           #FAFBFC;
  --surface:      #FFFFFF;
  --surface-2:    #F4F5F7;

  --line:         #E1E4E8;
  --line-strong:  #C9CED4;

  --ink:          #0F1419;   /* near black */
  --ink-soft:     #57606A;
  --ink-faint:    #8C95A0;

  --accent:       #14151A;   /* button fill */
  --accent-hover: #2C3340;

  --tile-warm:    #FDFBF7;   /* very subtle warm tint for hover/elevation */

  --radius-lg:    8px;
  --radius-md:    6px;
  --radius-sm:    4px;

  --shadow-sm:    0 1px 2px rgba(15, 20, 25, 0.04);
  --shadow-md:    0 2px 16px rgba(15, 20, 25, 0.05);
  --shadow-lg:    0 4px 24px rgba(15, 20, 25, 0.07);

  /* Aptos first (locally installed on most Win/Mac machines via Office 365),
     IBM Plex Sans next (loaded reliably from Google Fonts), then system. */
  --font-sans:    'Aptos', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', 'Aptos Mono', 'SF Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  max-width: 760px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 30px; height: 30px;
  display: block;
}
.brand .wordmark {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font: 500 13px/1 var(--font-sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }

/* ── Layout ──────────────────────────────────────────────────── */
#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 80px;
}
.screen { animation: fadeIn 0.32s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Buttons ─────────────────────────────────────────────────── */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  padding: 15px 28px;
  border-radius: var(--radius-sm);
  font: 600 15px/1 var(--font-sans);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
  min-height: 50px;
  width: 100%;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled {
  background: var(--surface-2);
  color: var(--ink-faint);
  cursor: not-allowed;
}
.actions { margin-top: 22px; }
.actions.center { display: flex; justify-content: center; }
.actions.center .ghost-btn { width: auto; }

/* ── Cards ───────────────────────────────────────────────────── */
.welcome-card, .step-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

/* ── Welcome ─────────────────────────────────────────────────── */
.eyebrow {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin: 0 0 22px;
}
.eyebrow .num { color: var(--ink); margin-left: 6px; font-weight: 600; }

.welcome-card h1 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(28px, 6vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: var(--ink);
}
.welcome-card .lede {
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0 0 28px;
  max-width: 50ch;
}
.footnote {
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  text-align: center;
  text-transform: uppercase;
}

/* ── Step cards ──────────────────────────────────────────────── */
.step-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 14px;
}
.step-card h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.hint { color: var(--ink-soft); margin: 0 0 22px; font-size: 14px; }

/* ── Photo / sample step ─────────────────────────────────────── */
.dropzone {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: rgba(20, 21, 26, 0.08);
}
.dropzone:hover { background: var(--tile-warm); border-color: var(--ink-soft); }
.dropzone input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.dropzone-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--ink-soft);
  text-align: center;
  padding: 0 16px;
}
.dropzone-inner .dz-title {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 10px 0 0;
  color: var(--ink);
}
.dropzone-inner .dz-sub { font-size: 12px; color: var(--ink-faint); margin: 0; }
#preview { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Loading overlay */
.dz-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 20, 25, 0.72);
  color: white;
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Inline error / hint message */
.error-bar {
  margin-top: 16px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}

/* Skip link */
.skip-row { text-align: center; margin-top: 18px; }
.link-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font: 500 13px/1.4 var(--font-sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  cursor: pointer;
  padding: 8px 12px;
  letter-spacing: 0.01em;
}
.link-btn:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ── Analysis result panel ───────────────────────────────────── */
.analysis-result {
  margin-top: 22px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  animation: fadeIn 0.4s ease both;
}
.result-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.result-row {
  display: flex; justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
}
.result-row:last-of-type { border-bottom: none; }
.result-row strong {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.notes {
  margin: 12px 0 14px;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ── Quiz ─────────────────────────────────────────────────────── */
fieldset { border: none; padding: 0; margin: 0 0 26px; }
legend {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 12px;
  color: var(--ink-soft);
}
legend .opt { color: var(--ink-faint); font-weight: 400; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row label { position: relative; cursor: pointer; }
.chip-row input { position: absolute; opacity: 0; pointer-events: none; }
.chip-row span {
  display: inline-block;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  transition: all 0.12s;
}
.chip-row label:hover span { border-color: var(--line-strong); }
.chip-row input:checked + span {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.form-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 6px 0 20px;
  gap: 14px;
  flex-wrap: wrap;
}
.toggle {
  display: inline-flex; gap: 8px; align-items: center;
  font-weight: 500; font-size: 14px;
  cursor: pointer;
}
.toggle input { width: 16px; height: 16px; accent-color: var(--ink); }
.budget {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-flex; gap: 10px; align-items: center;
}
.budget input {
  width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

/* ── Results ─────────────────────────────────────────────────── */
.results-header {
  padding: 32px 6px 12px;
  text-align: center;
}
.results-header h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.profile-line {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 20px;
}
.results-list { display: flex; flex-direction: column; gap: 14px; }

.affiliate-note {
  margin: 22px 0 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  text-align: center;
}
.affiliate-note a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.foot-links {
  margin: 10px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.foot-links a {
  color: var(--ink-soft);
  text-decoration: none;
}
.foot-links a:hover { color: var(--ink); }
.foot-links span { opacity: 0.5; }

.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 22px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.product-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.product-card.first {
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}

/* Element-tile rank marker (top-left), restating the periodic motif */
.product-card .rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 14px;
}
.product-card.first .rank {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.product-card .brand-name {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  margin: 0 0 4px;
}
.product-card .name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -0.012em;
  color: var(--ink);
}

/* Match badge (atomic-tile feel, top-right) */
.match-badge {
  position: absolute;
  top: 22px; right: 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  color: var(--ink);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  letter-spacing: 0.02em;
}
.first .match-badge {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 16px;
}
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.meta .dot { width: 3px; height: 3px; background: var(--ink-faint); border-radius: 50%; }

.reasons {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 18px;
  padding: 0;
}
.reasons li {
  list-style: none;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  border: 1px solid var(--line);
}
.product-card .shop-btn {
  display: inline-block;
  background: var(--ink);
  color: white;
  text-decoration: none;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: background 0.12s;
}
.product-card .shop-btn:hover { background: var(--accent-hover); }

/* ── Footer ──────────────────────────────────────────────────── */
.foot {
  text-align: center;
  padding: 40px 24px 60px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  max-width: 760px;
  margin: 0 auto;
}

/* ── Small phones ────────────────────────────────────────────── */
@media (max-width: 380px) {
  .welcome-card, .step-card, .product-card { padding: 24px 18px; }
  .step-card h2, .results-header h2 { font-size: 22px; }
  .welcome-card h1 { font-size: 26px; }
}
