/* =========================================================
   Pixel Verifier — design system
   ========================================================= */

:root{
  color-scheme: light;

  /* ---- palette: light (default) ---- */
  --bg: #f0f2ec;
  --bg-image: radial-gradient(circle at 14% -10%, #e4ebd8 0%, transparent 45%),
              radial-gradient(circle at 100% 0%, #dce9ee 0%, transparent 40%);
  --surface: #ffffff;
  --surface-2: #e7eae0;
  --border: #d3d7c8;
  --border-strong: #b7bda6;
  --text: #14170f;
  --text-dim: #565b49;
  --text-faint: #8b917c;
  --accent: #4a6300;
  --accent-strong: #3a4e00;
  --accent-contrast: #f6ffe0;
  --accent-2: #0d6d92;
  --accent-2-strong: #095674;
  --danger: #ab2a20;
  --checker-a: #e6e8de;
  --checker-b: #f6f7f1;
  --shadow-lg: 0 24px 60px -24px rgba(20, 23, 15, 0.28);
  --shadow-sm: 0 2px 10px -4px rgba(20, 23, 15, 0.22);
  --focus-ring: 0 0 0 3px rgba(74, 99, 0, 0.35);

  --font-display: "Unbounded", "Arial Black", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
}

@media (prefers-color-scheme: dark){
  :root{
    color-scheme: dark;
    --bg: #0b0d0a;
    --bg-image: radial-gradient(circle at 12% -10%, #151a0e 0%, transparent 45%),
                radial-gradient(circle at 105% 5%, #0c1a20 0%, transparent 42%);
    --surface: #14170f;
    --surface-2: #1b1f16;
    --border: #262b1e;
    --border-strong: #3a4130;
    --text: #eef1e6;
    --text-dim: #9aa08c;
    --text-faint: #656b56;
    --accent: #c8ff3d;
    --accent-strong: #b3e62c;
    --accent-contrast: #10130a;
    --accent-2: #5ec8ff;
    --accent-2-strong: #8adbff;
    --danger: #ff6b5e;
    --checker-a: #191d13;
    --checker-b: #21261a;
    --shadow-lg: 0 24px 70px -20px rgba(0, 0, 0, 0.7);
    --shadow-sm: 0 2px 14px -4px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(200, 255, 61, 0.35);
  }
}

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

html{ -webkit-text-size-adjust: 100%; }

body{
  margin: 0;
  min-height: 100vh;
  background: var(--bg) var(--bg-image);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.5;
  padding: clamp(16px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 32px);
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

::selection{ background: var(--accent); color: var(--accent-contrast); }

button{ font-family: inherit; }

a, button{ -webkit-tap-highlight-color: transparent; }

:focus{ outline: none; }
:focus-visible{ box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

.skip-link{
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--accent-contrast);
  padding: 10px 16px; border-radius: var(--radius-sm); z-index: 200;
  font-weight: 600;
}
.skip-link:focus{ left: 16px; top: 16px; }

/* faint CRT-style scanline overlay for texture, purely decorative */
.scanlines{
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background-image: repeating-linear-gradient(to bottom, rgba(127,127,127,0.035) 0px, rgba(127,127,127,0.035) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* =========================================================
   Header
   ========================================================= */
.site-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}

.wordmark{
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(18px, 2.4vw, 22px);
  letter-spacing: 0.01em;
  color: var(--text);
}
.wordmark-icon{ color: var(--accent); display: inline-flex; }
.wordmark-text em{ font-style: normal; color: var(--accent); }

.privacy-pill{
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.pulse-dot{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(94,200,255,0.6);
  animation: pulse 2.4s ease-out infinite;
  flex: none;
}
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(94,200,255,0.55); }
  70%{ box-shadow: 0 0 0 7px rgba(94,200,255,0); }
  100%{ box-shadow: 0 0 0 0 rgba(94,200,255,0); }
}

/* =========================================================
   Intro / dropzone
   ========================================================= */
main{ flex: 1; display: flex; flex-direction: column; gap: 22px; max-width: 1280px; width: 100%; margin: 0 auto; }

.intro{
  text-align: center;
  padding: clamp(28px, 6vw, 64px) 16px clamp(8px, 3vw, 20px);
  animation: rise 0.7s 0.05s cubic-bezier(.2,.8,.2,1) both;
}
.intro h1{
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(32px, 6vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.intro-lede{
  color: var(--text-dim);
  max-width: 46ch;
  margin: 0 auto 32px;
  font-size: clamp(14px, 1.6vw, 16px);
  line-height: 1.65;
}

.dropzone{
  max-width: 620px;
  margin: 0 auto;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: clamp(28px, 5vw, 44px) 24px;
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease, box-shadow .18s ease;
  color: var(--text-dim);
}
.dropzone:hover{ border-color: var(--accent-2); box-shadow: var(--shadow-sm); }
.dropzone:active{ transform: scale(0.995); }
.dropzone.is-dragover{
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  box-shadow: var(--shadow-lg);
}
.dz-icon{ color: var(--text-faint); margin-bottom: 12px; }
.dz-primary{ margin: 0 0 6px; font-size: 15px; color: var(--text); }
.dz-primary strong{ color: var(--accent-2); }
.dz-secondary{ margin: 0; font-size: 12px; letter-spacing: 0.02em; color: var(--text-faint); }

/* =========================================================
   App / workspace
   ========================================================= */
.app{
  display: none;
  flex-direction: column;
  gap: 14px;
  animation: rise 0.5s cubic-bezier(.2,.8,.2,1) both;
}
.app.is-active{ display: flex; }
.intro.is-collapsed{ display: none; }

.toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}
.tool-group{
  display: flex;
  align-items: center;
  gap: 6px;
  padding-inline-end: 10px;
  border-right: 1px solid var(--border);
}
.tool-group:last-child{ border-right: none; padding-inline-end: 0; }

.btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .08s ease, color .15s ease;
  white-space: nowrap;
}
.btn:hover{ border-color: var(--border-strong); }
.btn:active{ transform: translateY(1px) scale(0.98); }
.icon-btn{ padding: 7px 11px; font-size: 15px; line-height: 1; font-weight: 700; }
.zoom-readout{ min-width: 64px; justify-content: center; font-variant-numeric: tabular-nums; }

.toggle-btn[aria-pressed="true"]{
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  border-color: var(--accent);
  color: var(--accent-strong);
}
@media (prefers-color-scheme: dark){
  .toggle-btn[aria-pressed="true"]{ color: var(--accent); }
}

.segmented{ background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg-btn{
  font-family: var(--font-mono);
  font-size: 12.5px; font-weight: 600;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.seg-btn.is-active{
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-block{ width: 100%; justify-content: center; margin-top: 12px; }

/* =========================================================
   Stage
   ========================================================= */
.stage-wrap{
  position: relative;
  flex: 1;
  min-height: 360px;
  height: min(62vh, 640px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  touch-action: none;
}
#stage{
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.app.mode-measure #stage{ cursor: cell; }

.stage-hint{
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.app.mode-measure .stage-hint{ opacity: 1; }

.shortcuts-hint{
  position: absolute;
  bottom: 10px; left: 50%; transform: translateX(-50%);
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.01em;
  color: var(--text-faint);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px){ .shortcuts-hint{ display: none; } }

.loupe{
  position: fixed;
  width: 168px; height: 168px;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  z-index: 60;
  box-shadow: 0 12px 34px -8px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
  background: var(--surface);
  transform: translate(-50%, -130%);
}
.loupe canvas{ display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.loupe-ring{
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.loupe-ring::before, .loupe-ring::after{
  content: "";
  position: absolute;
  background: var(--accent-2);
  opacity: 0.85;
}
.loupe-ring::before{ left: 50%; top: 8px; bottom: 8px; width: 1px; transform: translateX(-50%); }
.loupe-ring::after{ top: 50%; left: 8px; right: 8px; height: 1px; transform: translateY(-50%); }

/* =========================================================
   Panels
   ========================================================= */
.panels{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 860px){
  .panels{ grid-template-columns: 1fr; }
}

.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.panel h2{
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.panel-sub{
  font-size: 12px; letter-spacing: 0; text-transform: none;
  color: var(--accent-2); font-weight: 600;
}

.kv{ margin: 0; display: flex; flex-direction: column; gap: 9px; }
.kv > div{ display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.kv dt{ font-size: 11.5px; color: var(--text-faint); }
.kv dd{ margin: 0; font-size: 13px; font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

.swatch-row{ display: flex; gap: 14px; align-items: flex-start; }
.swatch{
  position: relative;
  overflow: hidden;
  width: 56px; height: 56px; flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-image:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
  background-color: var(--checker-b);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease;
}
.swatch-fill{
  position: absolute;
  inset: 0;
  background: transparent;
}
.value-list{ flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.value-row{ display: flex; align-items: center; gap: 8px; }
.value-label{ font-size: 10.5px; color: var(--text-faint); width: 34px; flex: none; letter-spacing: 0.04em; }
.value-row code{
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 7px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn{
  flex: none;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  transition: color .15s ease, border-color .15s ease, transform .1s ease;
}
.copy-btn:hover{ color: var(--accent-2); border-color: var(--accent-2); }
.copy-btn.is-copied{ color: var(--accent); border-color: var(--accent); }
.copy-btn:active{ transform: scale(0.92); }

#measDist{ display: inline-flex; align-items: center; gap: 6px; }
#measDist .copy-btn{ width: 20px; height: 20px; font-size: 11px; }

/* =========================================================
   Footer / toast
   ========================================================= */
.site-footer{
  text-align: center;
  color: var(--text-faint);
  font-size: 11.5px;
  padding: 6px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.site-footer p{ margin: 0; }
.foot-meta{ letter-spacing: 0.03em; }
.v-badge{
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-dim);
  font-size: 10px;
  margin-left: 4px;
}

.toast{
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 500;
}
.toast.is-visible{ opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Motion
   ========================================================= */
@keyframes rise{
  from{ opacity: 0; transform: translateY(10px); }
  to{ opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Small screens
   ========================================================= */
@media (max-width: 560px){
  .site-header{ gap: 10px; }
  .privacy-pill{ font-size: 10.5px; padding: 6px 10px 6px 8px; }
  .toolbar{ gap: 6px 8px; }
  .tool-group{ padding-inline-end: 8px; }
  .stage-wrap{ height: min(58vh, 520px); }
}
