/* lens.css — Cobinar Lens overlay, panel and capture chrome.
   Host page requirement: wrap all page content in <div id="lens-stage">. */

:root {
  --lens-void: #0a0c0d;
  --lens-panel: #14181b;
  --lens-raise: #1b2024;
  --lens-rule: #272e33;
  --lens-ink: #e7ebed;
  --lens-mute: #8c979e;
  --lens-signal: #ff6a1a;
  --lens-signal-dim: rgba(255, 106, 26, 0.16);

  --lens-gap: 16px;
  --lens-width: 420px;
  --lens-scale: 1;
  --lens-radius: 22px;
  --lens-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --lens-dur: 560ms;

  --lens-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
    "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --lens-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
}

/* ---------------------------------------------------------------- stage */

html.lens-armed,
html.lens-open { overflow: hidden; }

html.lens-open body { background: var(--lens-void); }

#lens-stage {
  position: fixed;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: inherit;
  transform-origin: 0 50%;
  transition:
    transform var(--lens-dur) var(--lens-ease),
    border-radius var(--lens-dur) var(--lens-ease),
    box-shadow var(--lens-dur) var(--lens-ease),
    filter var(--lens-dur) var(--lens-ease);
  will-change: transform;
}

html.lens-open #lens-stage {
  transform: translateX(var(--lens-gap)) scale(var(--lens-scale));
  border-radius: var(--lens-radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

html.lens-open #lens-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 13, 0.24);
  pointer-events: none;
}

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

#lens-trigger {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--lens-signal);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(255, 106, 26, 0.38);
  transition: transform 180ms var(--lens-ease), box-shadow 180ms var(--lens-ease);
}
#lens-trigger:hover { transform: scale(1.06); }
#lens-trigger:active { transform: scale(0.94); }
#lens-trigger:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#lens-trigger[data-live="1"]::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--lens-signal);
  opacity: 0.55;
}

#lens-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  cursor: none;
  touch-action: none;
}
html.lens-armed #lens-overlay { display: block; }

#lens-overlay .rule {
  position: absolute;
  background: var(--lens-signal);
  opacity: 0.85;
  pointer-events: none;
}
#lens-overlay .rule.v { top: 0; bottom: 0; width: 1px; }
#lens-overlay .rule.h { left: 0; right: 0; height: 1px; }

#lens-marquee {
  position: absolute;
  border: 1px solid var(--lens-signal);
  box-shadow: 0 0 0 9999px rgba(8, 10, 11, 0.42);
  display: none;
}
#lens-marquee[data-on="1"] { display: block; }
#lens-marquee i {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--lens-signal);
}
#lens-marquee i:nth-child(1) { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
#lens-marquee i:nth-child(2) { top: -2px; right: -2px; border-left: 0; border-bottom: 0; }
#lens-marquee i:nth-child(3) { bottom: -2px; left: -2px; border-right: 0; border-top: 0; }
#lens-marquee i:nth-child(4) { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

#lens-readout {
  position: absolute;
  z-index: 61;
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(10, 12, 13, 0.92);
  color: var(--lens-ink);
  font: 500 11.5px/1.2 var(--lens-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}
#lens-readout b { color: var(--lens-signal); font-weight: 500; }

#lens-hint {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 61;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(10, 12, 13, 0.9);
  color: var(--lens-ink);
  font: 400 13px/1 var(--lens-sans);
  pointer-events: none;
}
#lens-hint kbd {
  font: 500 11px var(--lens-mono);
  padding: 2px 5px;
  margin: 0 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

/* --------------------------------------------------------------- panel */

#lens-panel {
  position: fixed;
  top: var(--lens-gap);
  right: var(--lens-gap);
  bottom: var(--lens-gap);
  z-index: 50;
  width: var(--lens-width);
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  border-radius: var(--lens-radius);
  background: var(--lens-panel);
  color: var(--lens-ink);
  font-family: var(--lens-sans);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform: translateX(calc(100% + var(--lens-gap)));
  opacity: 0;
  visibility: hidden;
  transition:
    transform var(--lens-dur) var(--lens-ease),
    opacity 260ms linear,
    visibility 0s linear var(--lens-dur);
}
html.lens-open #lens-panel {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s, 60ms, 0s;
}

.lens-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--lens-rule);
}
.lens-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.lens-head .src {
  margin-left: auto;
  font: 400 11px/1 var(--lens-mono);
  color: var(--lens-mute);
}
.lens-close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--lens-rule);
  border-radius: 9px;
  background: transparent;
  color: var(--lens-mute);
  cursor: pointer;
  transition: color 140ms, border-color 140ms;
}
.lens-close:hover { color: var(--lens-ink); border-color: #3a444b; }

.lens-plate {
  margin: 14px 16px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--lens-raise);
  border: 1px solid var(--lens-rule);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
}
.lens-plate img { width: 100%; height: 100%; object-fit: contain; display: block; }

.lens-switch {
  display: flex;
  gap: 4px;
  margin: 14px 16px 0;
  padding: 3px;
  border-radius: 10px;
  background: var(--lens-raise);
}
.lens-switch button {
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--lens-mute);
  font: 500 13px var(--lens-sans);
  cursor: pointer;
  transition: background 180ms var(--lens-ease), color 180ms;
}
.lens-switch button[aria-selected="true"] { background: #2a3238; color: var(--lens-ink); }

.lens-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lens-body::-webkit-scrollbar { width: 8px; }
.lens-body::-webkit-scrollbar-thumb { background: #2b3338; border-radius: 4px; }

.lens-read { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--lens-ink); }
.lens-note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--lens-mute); }

.lens-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lens-chip {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--lens-rule);
  font-size: 12px;
  color: var(--lens-mute);
}
.lens-chip[data-key="1"] {
  border-color: transparent;
  background: var(--lens-signal-dim);
  color: var(--lens-signal);
}

.lens-swatches { display: flex; gap: 6px; }
.lens-swatches span {
  flex: 1;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lens-item {
  display: block;
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--lens-raise);
  border: 1px solid transparent;
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms, transform 160ms var(--lens-ease);
}
.lens-item:hover { border-color: #333d43; }
.lens-item:active { transform: scale(0.99); }
.lens-item h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.lens-item p { margin: 0; font-size: 12px; line-height: 1.45; color: var(--lens-mute); }
.lens-item .meta { margin-top: 6px; font: 400 11px var(--lens-mono); color: #6f7a81; }

.lens-empty {
  margin: auto 0;
  text-align: center;
  color: var(--lens-mute);
  font-size: 13px;
  line-height: 1.6;
}

/* ------------------------------------------------------------ skeleton */

.sk {
  border-radius: 8px;
  background: linear-gradient(100deg, #1e2428 22%, #2a3238 40%, #1e2428 58%);
  background-size: 300% 100%;
  animation: lens-shimmer 1.35s ease-in-out infinite;
}
.sk-line { height: 11px; }
.sk-line + .sk-line { margin-top: 8px; }
.sk-card { height: 74px; border-radius: 11px; }
.sk-plate { width: 100%; height: 100%; border-radius: 0; }
.sk-w90 { width: 90%; } .sk-w70 { width: 70%; } .sk-w45 { width: 45%; }

@keyframes lens-shimmer {
  from { background-position: 180% 0; }
  to { background-position: -80% 0; }
}

.lens-enter { animation: lens-rise 420ms var(--lens-ease) both; }
@keyframes lens-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* -------------------------------------------------------- small screens */

@media (max-width: 720px) {
  :root { --lens-gap: 0px; --lens-radius: 20px; }
  html.lens-open #lens-stage {
    transform: translateY(-38vh) scale(0.9);
    transform-origin: 50% 0;
  }
  #lens-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 68vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  #lens-trigger { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  #lens-stage, #lens-panel { transition-duration: 1ms; }
  .sk { animation: none; }
  .lens-enter { animation: none; }
}
