/* ============================================================
   Pango Triage — production front-end styles
   Adapted from the approved design state-sheet (docs reference).
   Single full-screen phone app (no mockup chrome).
   ============================================================ */

:root {
  --buy:        oklch(0.72 0.17 155);
  --buy-dim:    oklch(0.32 0.07 155);
  --buy-bg:     oklch(0.23 0.05 155);
  --skip:       oklch(0.68 0.17 25);
  --skip-dim:   oklch(0.30 0.07 25);
  --skip-bg:    oklch(0.22 0.05 25);
  --nodata:     oklch(0.75 0.01 260);
  --nodata-dim: oklch(0.32 0.005 260);
  --nodata-bg:  oklch(0.24 0.005 260);
  --ink:        #fafafa;
  --ink-60:     rgba(255, 255, 255, 0.6);
  --ink-50:     rgba(255, 255, 255, 0.5);
  --ink-40:     rgba(255, 255, 255, 0.4);
  --sheet:      #18181b;
  --sheet-line: #27272a;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0c0c0e;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- camera feed (with gradient fallback behind the video) ---- */

.feed,
.feed-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.feed {
  object-fit: cover;
  background:
    repeating-linear-gradient(94deg, transparent 0 54px, rgba(255, 255, 255, 0.025) 54px 58px),
    radial-gradient(120% 90% at 50% 30%, #2a2622 0%, #1c1a17 45%, #0c0b0a 100%);
  z-index: 0;
}

.feed-overlay {
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  z-index: 1;
}

/* ---- session strip ---- */

.session {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(24, 24, 27, 0.72);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 7px 16px;
  white-space: nowrap;
}
.session .item { display: flex; align-items: baseline; gap: 5px; }
.session .v { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.session .v.green { color: var(--buy); }
.session .l { font-size: 10.5px; font-weight: 500; color: var(--ink-50); }

/* ---- reticle ---- */

.reticle {
  position: fixed;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 230px;
  height: 142px;
  z-index: 20;
  transition: opacity 0.25s ease;
}
.reticle .corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-top: 3px solid rgba(255, 255, 255, 0.85);
  border-left: 3px solid rgba(255, 255, 255, 0.85);
  border-top-left-radius: 8px;
  transition: border-color 0.2s ease;
}
.reticle .corner.tl { top: 0; left: 0; }
.reticle .corner.tr { top: 0; right: 0; transform: rotate(90deg); }
.reticle .corner.br { bottom: 0; right: 0; transform: rotate(180deg); }
.reticle .corner.bl { bottom: 0; left: 0; transform: rotate(270deg); }

.reticle .scanline {
  position: absolute;
  left: 24px; right: 24px;
  top: 50%; height: 2px; margin-top: -1px;
  background: var(--buy);
  border-radius: 2px;
  box-shadow: 0 0 12px var(--buy);
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* locked = barcode found */
.reticle.locked .corner { border-color: var(--buy); }
.reticle.locked .scanline { opacity: 1; }

/* dim the reticle while a verdict sheet is up */
body.has-result .reticle { opacity: 0.25; }

/* ---- hint pill ---- */

.hint {
  position: fixed;
  top: 47%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}
body.has-result .hint,
body.is-loading .hint { opacity: 0; }

/* ---- verdict sheet ---- */

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--sheet);
  border: 1px solid var(--sheet-line);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 26px);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet:not([hidden]) { transform: translateY(0); }

.sheet .top-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 13px;
}
.pill {
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
}
.pill.buy    { background: var(--buy-bg);    color: var(--buy);    border: 1px solid var(--buy-dim); }
.pill.skip   { background: var(--skip-bg);   color: var(--skip);   border: 1px solid var(--skip-dim); }
.pill.nodata { background: var(--nodata-bg); color: var(--nodata); border: 1px solid var(--nodata-dim); }

.sheet .isbn { font-size: 11px; color: var(--ink-40); font-variant-numeric: tabular-nums; }

.sheet .title {
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet .author { font-size: 12.5px; color: var(--ink-50); margin-top: 2px; }

.stats {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 14px; align-items: end; margin-top: 15px;
}
.stats[hidden] { display: none; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat.hero .v { font-size: 27px; }
.stat.hero.buy .v  { color: var(--buy); }
.stat.hero.skip .v { color: var(--skip); }
.stat .l {
  font-size: 10px; font-weight: 500; color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* the Sales stat is a button that expands the recent-sales list */
.stat-tap {
  background: none; border: none; margin: 0; padding: 0;
  font: inherit; color: inherit; cursor: pointer;
  text-align: left; align-items: flex-start;
}
.stat-tap .l { display: inline-flex; align-items: center; gap: 3px; }
.chev {
  font-weight: 700; color: var(--ink-40);
  transition: transform 0.2s ease;
}
.stat-tap.expanded .chev { transform: rotate(90deg); }
.stat-tap.no-comps .chev { display: none; }
.stat-tap:disabled { cursor: default; }

/* recent sales (sold comps) — collapsed by default, animates open */
.comps {
  max-height: 0; overflow: hidden;
  transition: max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.comps.open { max-height: 46vh; margin-top: 16px; }
.comps-head {
  position: sticky; top: 0; z-index: 1;
  background: var(--sheet);
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-40);
  padding-bottom: 8px;
}
.comps-list {
  max-height: 40vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.comp-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline; gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--sheet-line);
}
.comp-row:first-child { border-top: none; }
.comp-price {
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.comp-cond { font-size: 12.5px; color: var(--ink-60); }
.comp-date {
  font-size: 11.5px; color: var(--ink-40);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

.sheet .note {
  font-size: 12.5px; color: var(--ink-50); margin-top: 12px;
  line-height: 1.45; text-wrap: pretty;
}
.sheet .note[hidden] { display: none; }

.sheet .dismiss-hint {
  font-size: 11.5px; color: var(--ink-40); text-align: center; margin-top: 14px;
}

/* ---- full-screen tap layer ---- */

.tap-layer {
  position: fixed;
  inset: 0;
  z-index: 25;          /* above feed/reticle, below the sheet */
  background: transparent;
  border: none;
  cursor: pointer;
}

/* ---- settings button (top-right, glass circle to match session strip) ---- */

.settings-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  z-index: 31;                 /* above tap-layer (25) so it stays tappable */
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(24, 24, 27, 0.72);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.settings-btn:active { transform: scale(0.92); }

/* ---- settings sheet + backdrop ---- */

.settings-backdrop {
  position: fixed; inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.settings-backdrop.open { opacity: 1; visibility: visible; }

.settings-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 46;
  background: var(--sheet);
  border: 1px solid var(--sheet-line);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 8px 22px calc(env(safe-area-inset-bottom, 0px) + 30px);
  transform: translateY(101%);
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.settings-sheet.open { transform: translateY(0); }

.settings-sheet .grabber {
  width: 36px; height: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 auto 4px;
}

.set-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.set-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.done-btn {
  background: none; border: none; cursor: pointer;
  color: var(--buy);
  font-size: 16px; font-weight: 600;
  font-family: inherit;
  padding: 4px 2px;
}
.done-btn:active { opacity: 0.6; }

.set-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.set-label { font-size: 15px; font-weight: 500; color: var(--ink); }
.set-value {
  font-size: 30px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--buy);
  font-variant-numeric: tabular-nums;
}

/* iOS-style slider with a green filled track (fill % set inline from JS) */
.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  border-radius: 999px;
  background: var(--sheet-line);
  outline: none;
  margin: 4px 0 2px;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 28px; height: 28px; border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.set-scale {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink-40);
  font-variant-numeric: tabular-nums;
}

.set-help {
  font-size: 13px; color: var(--ink-60);
  line-height: 1.5; text-wrap: pretty;
  margin-top: 16px;
}
.set-help b { color: var(--ink); font-weight: 600; }
.set-subhelp {
  font-size: 12px; color: var(--ink-40);
  line-height: 1.45; margin-top: 6px;
}

/* ---- loading spinner ---- */

@keyframes pango-spin { to { transform: rotate(360deg); } }
.spinner {
  position: fixed;
  top: 47%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 22;
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  animation: pango-spin 0.7s linear infinite;
  display: none;
}
body.is-loading .spinner { display: block; }
