/* ============================================================
   Skin Condition Classifier - design system
   Palette: warm cream + ink + a single sage accent.
   ============================================================ */

:root {
  /* Color - warm cream background, Tailwind-gray text for premium clinical-but-inviting feel */
  --cream:        #FAF7F2;   /* warm off-white background */
  --cream-deep:   #F3EEE4;   /* slightly deeper cream for hover / disabled */
  --paper:        #FFFFFF;   /* cards */
  --ink:          #111827;   /* gray-900, primary text */
  --ink-soft:     #374151;   /* gray-700, body text */
  --ink-mute:     #6B7280;   /* gray-500, disclaimers and muted */
  --ink-fade:     #9CA3AF;   /* gray-400 */
  --line:         #E5E7EB;   /* gray-200, borders */
  --line-soft:    #F3F4F6;   /* gray-100, subtle dividers */
  --sage:         #6f8a6a;   /* accent */
  --sage-deep:    #557255;   /* accent hover */
  --sage-tint:    rgba(111, 138, 106, 0.10);
  --rust:         #b85c4a;   /* danger / malignant warnings */
  --rust-tint:    rgba(184, 92, 74, 0.08);

  /* Type - DM Sans for display (modern geometric, Lululemon-style confidence), Inter for body */
  --font-display: "DM Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Layout */
  --col:          760px;
  --col-wide:     980px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 2px rgba(26, 20, 16, 0.04), 0 8px 24px rgba(26, 20, 16, 0.06);
  --shadow-hover: 0 2px 4px rgba(26, 20, 16, 0.06), 0 12px 32px rgba(26, 20, 16, 0.10);

  color-scheme: light only;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); transition: border-color 0.2s; }
a:hover { border-color: var(--ink); }

button { font-family: inherit; }

/* ============================================================
   Header / footer
   ============================================================ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px max(28px, 5vw);
  border-bottom: 1px solid var(--line);
  background: var(--cream);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--sage);
}
.brand-wordmark { display: flex; align-items: baseline; gap: 8px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;    /* slight tracking outward, brand-style */
  color: var(--ink);
}
.brand-product {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.site-link {
  font-size: 13px;
  color: var(--ink-mute);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.site-link:hover { color: var(--ink); border-color: var(--ink); }

.site-footer {
  padding: 36px 24px;
  text-align: center;
  border-top: 1px solid var(--line);
  margin-top: 80px;
  color: var(--ink-mute);
  font-size: 13px;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--ink-mute); border-color: transparent; }
.site-footer a:hover { color: var(--ink); border-color: var(--ink); }

/* ============================================================
   Layout
   ============================================================ */

.container {
  max-width: var(--col);
  margin: 0 auto;
  padding: 64px 24px 0;
}

/* ============================================================
   Screen transitions
   ============================================================ */

.screen { display: none; }
.screen.active {
  display: block;
  animation: screen-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Hero (capture screen)
   ============================================================ */

.hero { margin-bottom: 48px; }

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(44px, 6vw, 72px);
  line-height: 1.0;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
  color: var(--ink);
}

.hero-sub {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 540px;
  margin: 0 0 12px;
}

.hero-disclaimer {
  font-size: 14px;
  color: var(--ink-mute);
  margin: 0;
  max-width: 540px;
}
.hero-disclaimer em { font-style: italic; }

/* ============================================================
   Capture card
   ============================================================ */

.capture-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.capture-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #14110e;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, transform 0.18s ease;
}
/* When there's no image / no camera, the whole stage is a tappable target. */
.capture-stage.is-tappable { cursor: pointer; }
.capture-stage.is-tappable:hover,
.capture-stage.is-tappable:focus-visible {
  background: #1e1a15;
  outline: none;
}
.capture-stage.is-tappable:hover .capture-placeholder,
.capture-stage.is-tappable:focus-visible .capture-placeholder { opacity: 0.85; }
.capture-stage.is-tappable:active { transform: scale(0.995); }

#camera-video,
#preview-image {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
#camera-video.visible,
#preview-image.visible { display: block; }

.capture-placeholder {
  color: var(--cream);
  text-align: center;
  opacity: 0.65;
  padding: 24px;
  transition: opacity 0.18s ease;
  user-select: none;
}
.capture-placeholder svg { display: block; margin: 0 auto 12px; opacity: 0.9; }
.capture-placeholder p { margin: 0; font-size: 15px; letter-spacing: 0.02em; font-weight: 600; }
.capture-placeholder p.capture-sub {
  margin-top: 6px; font-size: 12px; font-weight: 400; opacity: 0.7;
  letter-spacing: 0.04em;
}

/* Swap-camera pill in the corner of the video preview */
.camera-switch-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 40px; height: 40px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.camera-switch-btn:hover { background: rgba(0, 0, 0, 0.75); }
.camera-switch-btn:active { transform: scale(0.94); }
.camera-switch-btn:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

.capture-controls {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.capture-controls .btn { flex: 1; }

.capture-actions {
  margin-top: 16px;
}
.capture-actions .btn-primary {
  width: 100%;
  padding: 16px 28px;
  font-size: 15px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  background: transparent;
  color: var(--ink);
}

.btn:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}
.btn-primary:hover {
  background: #2c2218;
  border-color: #2c2218;
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}

.btn:disabled {
  background: var(--cream-deep);
  color: var(--ink-mute);
  border-color: var(--cream-deep);
  cursor: not-allowed;
  transform: none;
}
.btn:disabled:hover { background: var(--cream-deep); color: var(--ink-mute); }

/* ============================================================
   Results screen
   ============================================================ */

.results-photo { margin: 0 0 40px; }
.photo-pair {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.photo-frame { margin: 0; }
.photo-frame img {
  width: 220px; height: 220px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.photo-frame figcaption {
  margin-top: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  text-align: center;
  font-weight: 600;
}
.heatmap-frame img {
  /* tasteful indicator that this is an interpretation, not the raw photo */
  outline: 1px solid var(--sage);
  outline-offset: 2px;
}
@media (max-width: 520px) {
  .photo-frame img { width: 160px; height: 160px; }
}

.top-guess {
  text-align: center;
  margin-bottom: 40px;
}
.top-guess .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin-bottom: 12px;
}
.top-guess .name {
  font-family: var(--font-display);
  font-size: clamp(34px, 4.5vw, 48px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.top-guess .meta {
  font-size: 14px;
  color: var(--ink-mute);
}
.top-guess .meta .tag {
  display: inline-block;
  padding: 4px 10px;
  margin-right: 8px;
  background: var(--sage-tint);
  color: var(--sage-deep);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.top-guess .meta .tag.cancerous,
.top-guess .meta .tag.pre-cancerous { background: var(--rust-tint); color: var(--rust); }

.results-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 32px;
}
.guess-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.guess-row .info {
  flex: 1;
  min-width: 0;
}
.guess-row .name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.guess-row .name {
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guess-row .code {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
}
.guess-row .bar-track {
  height: 4px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
}
.guess-row .bar-fill {
  height: 100%;
  background: var(--sage);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.guess-row .pct {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink);
  min-width: 48px;
  text-align: right;
}

.warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: var(--rust-tint);
  border-left: 3px solid var(--rust);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 32px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
.warning strong { color: var(--rust); }

/* Photo tips card (shown on low-confidence "couldn't identify" results) */
.tips {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}
.tips h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--sage-deep);
  margin: 0 0 18px;
}
.tips ul { margin: 0; padding-left: 22px; }
.tips li {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 12px 0;
}
.tips li strong {
  color: var(--ink);
  font-weight: 600;
}

.action-row {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  margin-bottom: 24px;
}
.action-row .btn { flex: 1; }

/* ============================================================
   Info screen
   ============================================================ */

.info-article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 48px;
  box-shadow: var(--shadow);
}
.info-article h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 4.5vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  color: var(--ink);
}
.info-article .tagline {
  color: var(--ink-mute);
  font-size: 15px;
  margin: 0 0 36px;
  font-style: italic;
}
.info-article h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--sage-deep);
  margin: 36px 0 16px;
}
.info-article h2:first-of-type { margin-top: 0; }
.info-article p, .info-article li {
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-soft);
}
.info-article ul { padding-left: 22px; margin: 12px 0; }
.info-article li { margin: 8px 0; }
.info-article .disclaimer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
}

/* ============================================================
   Preflight alert (Claude vision rejecting the photo before classify)
   ============================================================ */

.preflight-alert {
  background: var(--rust-tint);
  border: 1px solid rgba(184, 92, 74, 0.4);
  border-left: 3px solid var(--rust);
  border-radius: var(--radius-sm);
  padding: 20px 22px;
  margin-top: 20px;
}
.preflight-alert h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--rust);
}
.preflight-alert p {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.preflight-alert .btn {
  font-size: 13px;
  padding: 10px 18px;
}

/* ============================================================
   Chat panel (Claude follow-up Q&A on the results screen)
   ============================================================ */

.chat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin: 36px 0 0;
  box-shadow: var(--shadow);
}
.chat-card h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.chat-card .chat-help {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--ink-mute);
  line-height: 1.5;
}
.chat-card .chat-help em {
  display: inline-block;
  margin: 2px 4px 2px 0;
  background: var(--line-soft);
  padding: 3px 10px;
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  color: var(--ink-soft);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  min-height: 0;
}
.chat-message { display: flex; max-width: 85%; }
.chat-message.user { align-self: flex-end; justify-content: flex-end; }
.chat-message.assistant { align-self: flex-start; }
.chat-message.system { align-self: center; max-width: 100%; }
.chat-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-message.user .chat-bubble {
  background: var(--ink);
  color: var(--cream);
  border-bottom-right-radius: 4px;
}
.chat-message.assistant .chat-bubble {
  background: var(--line-soft);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.chat-message.system .chat-bubble {
  background: var(--rust-tint);
  color: var(--rust);
  font-size: 13px;
  text-align: center;
}

.typing-indicator {
  display: inline-flex; gap: 4px;
  padding: 14px 16px;
  background: var(--line-soft);
  border-radius: 14px; border-bottom-left-radius: 4px;
}
.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--ink-mute);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.30s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-input-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.chat-input-form input {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--cream);
  color: var(--ink);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.chat-input-form input:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-tint);
}
.chat-input-form button {
  padding: 12px 22px;
  font-size: 14px;
}

.chat-disclaimer {
  margin: 14px 0 0;
  font-size: 11px;
  color: var(--ink-mute);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============================================================
   Loading state
   ============================================================ */

.loading {
  position: fixed;
  inset: 0;
  background: rgba(247, 242, 233, 0.92);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading.active { display: flex; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Small-screen responsive
   ============================================================ */

@media (max-width: 600px) {
  .container { padding: 32px 16px 0; }
  .site-header { padding: 20px 16px; }
  .info-article { padding: 28px 20px; }
  .capture-controls { flex-direction: column; }
  .action-row { flex-direction: column; }
  .hero-title { font-size: 36px; }
}
