/*
 * Plate Labs — shared interface
 *
 * One small design system for both studies: Inter, Plate orange, restrained
 * icon+label controls, visible focus, and a dark/light theme switch so the
 * atmosphere study and the still-life study can share every component.
 */

@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --lab-orange: #ff6a1a;
  --lab-orange-ink: #1b0c04;
  --lab-radius: 14px;
  --lab-sans: "Inter", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  --lab-shadow: 0 18px 48px rgba(0, 0, 0, .45);
}

[data-theme="dark"] {
  color-scheme: dark;
  --lab-bg: #08090b;
  --lab-ink: #ffffff;
  --lab-body: #d6d8dd;
  --lab-muted: #9aa0aa;
  --lab-panel: rgba(16, 18, 22, .82);
  --lab-panel-solid: #101216;
  --lab-line: rgba(255, 255, 255, .14);
  --lab-line-strong: rgba(255, 255, 255, .28);
  --lab-hover: rgba(255, 255, 255, .09);
}

[data-theme="light"] {
  color-scheme: light;
  --lab-bg: #efe7dc;
  --lab-ink: #201b16;
  --lab-body: #3b332b;
  --lab-muted: #6d6156;
  --lab-panel: rgba(255, 252, 247, .86);
  --lab-panel-solid: #fffcf7;
  --lab-line: rgba(45, 35, 25, .16);
  --lab-line-strong: rgba(45, 35, 25, .34);
  --lab-hover: rgba(45, 35, 25, .07);
  --lab-shadow: 0 18px 48px rgba(80, 60, 40, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--lab-bg);
  color: var(--lab-ink);
  font: 16px/1.5 var(--lab-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.028em; line-height: 1.06; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--lab-orange);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ stage */

.lab-root {
  position: fixed;
  inset: 0;
  display: block;
}

.lab-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.lab-canvas:focus-visible { outline: 2px solid var(--lab-orange); outline-offset: -4px; }

/* ------------------------------------------------------------------ chrome */

.lab-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  pointer-events: none;
}

.lab-topbar > * { pointer-events: auto; }

.lab-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  border-radius: 999px;
  background: var(--lab-panel);
  border: 1px solid var(--lab-line);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--lab-body);
  transition: border-color .18s ease, color .18s ease;
}

.lab-brand:hover { color: var(--lab-ink); border-color: var(--lab-line-strong); }
.lab-brand svg { width: 16px; height: 16px; flex: none; }
.lab-brand b { color: var(--lab-ink); font-weight: 600; }

.lab-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--lab-muted);
  padding-top: 12px;
  pointer-events: none;
}

.lab-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(620px, 68vw);
}

/* ----------------------------------------------------------------- buttons */

.lab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--lab-line);
  background: var(--lab-panel);
  backdrop-filter: blur(12px);
  color: var(--lab-body);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.lab-btn:hover { background: var(--lab-hover); color: var(--lab-ink); border-color: var(--lab-line-strong); }
.lab-btn:active { transform: translateY(1px); }
.lab-btn svg { width: 16px; height: 16px; flex: none; }

.lab-btn[aria-pressed="true"] {
  background: var(--lab-orange);
  border-color: var(--lab-orange);
  color: var(--lab-orange-ink);
}

.lab-btn-primary {
  background: var(--lab-orange);
  border-color: var(--lab-orange);
  color: var(--lab-orange-ink);
  font-weight: 600;
}

.lab-btn-primary:hover { background: #ff7f3b; border-color: #ff7f3b; color: var(--lab-orange-ink); }

.lab-btn-lg { min-height: 52px; padding: 14px 26px; font-size: 16px; }

.lab-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--lab-line);
  background: var(--lab-panel);
  font-size: 12.5px;
  color: var(--lab-muted);
}

/* ---------------------------------------------------------------- overlays */

.lab-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(0, 0, 0, .18), rgba(0, 0, 0, .74)),
    color-mix(in srgb, var(--lab-bg) 72%, transparent);
  backdrop-filter: blur(3px);
}

[data-theme="light"] .lab-overlay {
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(255, 250, 243, .35), rgba(70, 55, 40, .42)),
    color-mix(in srgb, var(--lab-bg) 55%, transparent);
}

.lab-card {
  width: min(560px, 100%);
  padding: 34px 34px 30px;
  border-radius: 22px;
  border: 1px solid var(--lab-line);
  background: var(--lab-panel-solid);
  box-shadow: var(--lab-shadow);
}

.lab-kicker {
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--lab-orange);
  font-weight: 600;
}

.lab-card h1 {
  margin-top: 14px;
  font-size: clamp(30px, 5.2vw, 44px);
}

.lab-card p {
  margin-top: 14px;
  color: var(--lab-body);
  font-size: 15.5px;
  line-height: 1.62;
}

.lab-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.lab-meta {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--lab-line);
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--lab-muted);
}

.lab-meta b { color: var(--lab-body); font-weight: 600; }

/* ----------------------------------------------------------------- loading */

.lab-progress {
  margin-top: 22px;
  height: 4px;
  border-radius: 999px;
  background: var(--lab-hover);
  overflow: hidden;
}

.lab-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--lab-orange);
  transition: width .3s ease;
}

.lab-progress-label {
  margin-top: 10px;
  font-size: 13px;
  color: var(--lab-muted);
}

/* ----------------------------------------------------------------- failure */

.lab-failure {
  position: absolute;
  inset: 0;
  z-index: 20;
  margin: auto;
  align-content: center;
  display: grid;
  gap: 14px;
  max-width: 560px;
  padding: 32px;
  color: var(--lab-ink);
}

.lab-failure h2 { font-size: 26px; }
.lab-failure p { color: var(--lab-body); font-size: 15px; line-height: 1.6; }
.lab-failure-hint { color: var(--lab-muted); font-size: 13.5px; }
.lab-failure-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* -------------------------------------------------------------------- help */

.lab-help {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 6;
  width: min(320px, calc(100vw - 40px));
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--lab-line);
  background: var(--lab-panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--lab-shadow);
}

.lab-help h2 {
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--lab-muted);
}

.lab-help dl {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 14px;
  align-items: baseline;
  font-size: 13.5px;
}

.lab-help dt { margin: 0; }
.lab-help dd { margin: 0; color: var(--lab-body); }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--lab-line-strong);
  background: var(--lab-hover);
  font: 600 11.5px/1.2 var(--lab-sans);
  text-align: center;
  color: var(--lab-ink);
}

/* ------------------------------------------------------------------ prompt */

.lab-prompt {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%) translateY(8px);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--lab-line-strong);
  background: var(--lab-panel);
  backdrop-filter: blur(12px);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

.lab-prompt.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.lab-status {
  position: absolute;
  left: 50%;
  top: 74px;
  transform: translateX(-50%);
  z-index: 6;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--lab-panel);
  border: 1px solid var(--lab-line);
  backdrop-filter: blur(12px);
  font-size: 13.5px;
  color: var(--lab-body);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  text-align: center;
  max-width: min(520px, calc(100vw - 48px));
}

.lab-status.is-visible { opacity: 1; }

/* ------------------------------------------------------------------- touch */

.lab-touch {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 6;
  height: 190px;
  pointer-events: none;
}

.lab-stick {
  position: absolute;
  left: 26px;
  bottom: 26px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1px solid var(--lab-line-strong);
  background: color-mix(in srgb, var(--lab-panel-solid) 45%, transparent);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  touch-action: none;
}

.lab-stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--lab-ink) 22%, transparent);
  border: 1px solid var(--lab-line-strong);
}

.lab-action {
  position: absolute;
  right: 26px;
  bottom: 40px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  pointer-events: auto;
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--lab-orange);
  background: color-mix(in srgb, var(--lab-orange) 88%, transparent);
  color: var(--lab-orange-ink);
  box-shadow: var(--lab-shadow);
}

.lab-action[disabled] {
  opacity: .35;
  background: var(--lab-panel);
  color: var(--lab-muted);
  border-color: var(--lab-line);
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .lab-topbar { padding: 12px; gap: 10px; }
  .lab-title { display: none; }
  .lab-controls { max-width: 62vw; gap: 6px; }
  .lab-btn { min-height: 38px; padding: 8px 12px; font-size: 13px; }
  /* clipped rather than display:none, so the label still names the button
     for assistive technology when only the icon is visible */
  .lab-btn .lab-btn-text {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .lab-btn.lab-btn-keeptext .lab-btn-text { position: static; width: auto; height: auto; clip: auto; }
  .lab-help { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .lab-card { padding: 26px 22px 24px; }
  /* the toolbar wraps on narrow screens, so the status moves out from under it */
  .lab-status { top: auto; bottom: 22px; }
}

@media (max-height: 520px) {
  .lab-help { display: none; }
}

/* ---------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ------------------------------------------------------------ capture mode */

.capture-mode .lab-topbar,
.capture-mode .lab-overlay,
.capture-mode .lab-help,
.capture-mode .lab-prompt,
.capture-mode .lab-status,
.capture-mode .lab-touch { display: none !important; }
