/* AI Skin Specialist — warm putty field, neutral grey examining plate, one cool lamp accent. */

:root {
  --paper: #e7e2db;
  --card: #f6f3ef;
  --plate: #6f6e6b;
  --ink: #1f1d1b;
  --ink-soft: #6c6359;
  --rule: #d2cbc2;
  --lamp: #4b3f97;
  --lamp-tint: #e9e5f7;
  --alert: #9d4634;
  --shadow: 0 1px 2px rgba(31, 29, 27, .05), 0 12px 32px -18px rgba(31, 29, 27, .35);

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step: 1.5rem;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141317;
    --card: #1c1b21;
    --plate: #3b3a3e;
    --ink: #efebe6;
    --ink-soft: #9a9189;
    --rule: #302e37;
    --lamp: #a99cf2;
    --lamp-tint: #241f37;
    --alert: #dd8a72;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -20px rgba(0, 0, 0, .8);
  }
}

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

/* display rules below would otherwise outrank the attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.readout {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .9rem;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  gap: .8rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.6rem 1.5rem 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.mark { color: var(--lamp); line-height: 0; }
.mark svg { width: 26px; height: 26px; stroke-width: 1.25; }

.wordmark {
  font-family: var(--display);
  font-variation-settings: "opsz" 40, "SOFT" 30, "WONK" 1;
  font-weight: 400;
  font-size: 1.4rem;
  letter-spacing: -.015em;
}

.caveat {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-soft);
}

/* ---------- layout ---------- */

.exam {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 1.5rem;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.plate-panel { position: sticky; top: 1.5rem; }

/* ---------- the plate ---------- */

.plate {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  background: var(--plate);
  overflow: hidden;
  display: grid;
  place-items: center;
  transition: box-shadow .25s ease;
}

/* the neutral grey ground is for judging skin tone against — it earns its weight
   only once there is a photo on it. Empty, the plate is just a quiet invitation. */
body[data-stage="empty"] .plate {
  background: var(--paper);
  outline: 1px dashed var(--rule);
  outline-offset: -10px;
  cursor: pointer;
}

body[data-stage="empty"] .plate:hover { outline-color: var(--lamp); }
body[data-stage="empty"] .plate-empty { color: var(--ink-soft); }
body[data-stage="empty"] .plate-hint { color: var(--ink); }

.plate.dragging { box-shadow: inset 0 0 0 2px var(--lamp); }

.specimen {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.plate-empty {
  padding: 1.5rem;
  text-align: center;
  color: #f2efeb;
}

.plate-hint {
  font-family: var(--display);
  font-variation-settings: "opsz" 30, "SOFT" 40, "WONK" 1;
  font-size: 1.15rem;
  font-weight: 300;
}

.plate-sub {
  margin-top: .35rem;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .05em;
  opacity: .7;
}

/* the loupe: a dermatoscope you drag across the photo */
.loupe {
  position: absolute;
  top: 0; left: 0;
  width: 150px; height: 150px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.9);
  transition: opacity .18s ease, transform .18s ease;
  background-repeat: no-repeat;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .55),
    0 0 0 7px rgba(75, 63, 151, .18),
    0 18px 40px -12px rgba(0, 0, 0, .55);
}

.loupe.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.plate-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .9rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .55rem 1.1rem;
  background: transparent;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.btn.ghost:hover { border-color: var(--lamp); color: var(--lamp); }

.btn.primary {
  width: 100%;
  margin-top: var(--step);
  padding: .8rem 1.1rem;
  border-color: transparent;
  background: var(--lamp);
  color: var(--card);
  letter-spacing: .01em;
}

.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.link {
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link:hover { color: var(--lamp); }

/* ---------- asking ---------- */

.mic-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.mic {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .55rem 1.05rem;
  background: transparent;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s ease, background .18s ease;
}

.mic:hover:not(:disabled) { border-color: var(--lamp); }
.mic:disabled { opacity: .4; cursor: not-allowed; }

.mic-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-soft);
  transition: background .18s ease;
}

body[data-status="listening"] .mic { border-color: var(--alert); }
body[data-status="listening"] .mic-dot {
  background: var(--alert);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: .3; } }

/* the mic level: one hairline that answers when you speak */
.level {
  position: relative;
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.level-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--lamp);
  transition: width .09s linear;
}

.clip {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .8rem;
}

.typed {
  width: 100%;
  margin-top: var(--step);
  padding: .8rem .9rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  resize: vertical;
  line-height: 1.45;
}

.typed:disabled { opacity: .4; }
.typed::placeholder { color: var(--ink-soft); }

.notice {
  margin-top: .9rem;
  padding-left: .8rem;
  border-left: 2px solid var(--alert);
  color: var(--alert);
  font-size: .875rem;
}

/* ---------- the reply ---------- */

.reply {
  margin-top: var(--step);
  padding-top: var(--step);
  border-top: 1px solid var(--rule);
}

.reply.arriving { animation: rise .5s cubic-bezier(.2, .7, .3, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

.heard {
  margin-bottom: .8rem;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  letter-spacing: .02em;
  color: var(--ink-soft);
}

.answer {
  font-family: var(--display);
  font-variation-settings: "opsz" 60, "SOFT" 40, "WONK" 1;
  font-weight: 300;
  font-size: 1.4rem;
  line-height: 1.42;
  letter-spacing: -.01em;
  text-wrap: pretty;
}

.player {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-top: 1.2rem;
}

.play {
  flex: none;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--lamp);
  border-radius: 50%;
  background: var(--lamp-tint);
  color: var(--lamp);
  cursor: pointer;
}

.play svg { width: 18px; height: 18px; fill: currentColor; }
.play .pause-icon { display: none; }
.player.playing .play-icon { display: none; }
.player.playing .pause-icon { display: block; }

.track {
  flex: 1;
  height: 2px;
  background: var(--rule);
  cursor: pointer;
}

.track-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--lamp);
}

/* ---------- foot ---------- */

.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.foot p {
  max-width: 56ch;
  color: var(--ink-soft);
  font-size: .8rem;
}

/* ---------- stages ---------- */

body[data-stage="empty"] .consult { opacity: .55; }

/* nothing to ask about yet — the button waits rather than shouts */
body[data-stage="empty"] .btn.primary {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-soft);
}

.consult { transition: opacity .3s ease; }

body[data-status="thinking"] .btn.primary { opacity: .75; cursor: progress; }

@media (max-width: 900px) {
  .exam { grid-template-columns: 1fr; }
  .plate-panel { position: static; }
  .plate { aspect-ratio: 1 / 1; }
  .caveat { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
