/* Hex From Image: styles
   Neutral UI on purpose: the user's image supplies the color. One accent (vermilion) for marks + focus. */

/* Self-hosted fonts (latin subset) */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 600 800;
  font-stretch: 100%;
  font-display: swap;
  src: url(/assets/fonts/bricolage-grotesque-600-800.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/jetbrains-mono-500.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/assets/fonts/jetbrains-mono-600.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #f3f1ec;
  --surface: #fffefb;
  --ink: #17161a;
  --muted: #615e58;
  --line: #dcd8cf;
  --soft: #ebe8e1;
  --accent: #f0461a;
  --danger: #b42318;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111110;
  --surface: #1a1a18;
  --ink: #f2efe8;
  --muted: #a39f96;
  --line: #2f2e2b;
  --soft: #222220;
  --accent: #ff5a2b;
  --danger: #ff8a7a;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--soft); padding: 1px 6px; border-radius: 5px; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand {
  display: inline-flex; align-items: baseline; gap: 1px; margin: 0;
  font: 800 23px/1 var(--font-display); letter-spacing: -.03em; text-decoration: none;
}
.brand-hash { font-family: var(--font-mono); font-weight: 600; color: var(--accent); margin-right: 1px; }
.brand-sm { font-size: 18px; }
.brand-from { color: var(--muted); font-weight: 700; }
.nav { display: flex; align-items: center; gap: 22px; font-size: 15px; }
.nav a { color: var(--ink); opacity: .78; text-decoration: none; font-weight: 500; }
.nav a:hover { opacity: 1; }
.nav a:hover { color: var(--ink); }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--ink); }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; }
[data-theme="dark"] .i-moon { display: none; }
@media (max-width: 520px) { .nav a { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  font: 600 15px/1 var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); opacity: 1; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.link-btn {
  border: 0; padding: 0; background: none; color: var(--ink); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; font-weight: 600;
}

/* ---------- Ad slots ----------
   Fixed min-heights reserve space so ads never push content around (good for Core Web Vitals / SEO). */
.ad-slot {
  position: relative; display: grid; place-items: start center; padding-top: 10px; border-radius: 6px;
  background: var(--soft); color: color-mix(in oklab, var(--muted) 70%, transparent);
  font: 500 10.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
}
.ad-incontent { min-height: 280px; margin: 48px 0 0; }
.ad-mid { min-height: 250px; margin: 40px 0; }
.ad-end { min-height: 250px; margin: 0 0 56px; }
.ad-rail { width: 300px; min-height: 600px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 56px; }
.rail { display: none; }
@media (min-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .rail { display: block; padding-top: 40px; }
  .rail .ad-slot { position: sticky; top: 24px; }
}

/* ---------- Tool ---------- */
.tool { padding: 40px 0 0; }
.intro { max-width: 820px; margin-bottom: 24px; }
h1 {
  margin: 0 0 12px; font: 800 clamp(36px, 5.4vw, 60px)/1 var(--font-display);
  letter-spacing: -.032em; text-wrap: balance;
}
.lede { margin: 0; max-width: 56ch; text-wrap: balance; font-size: 18px; color: var(--muted); text-wrap: pretty; }

.dropzone {
  display: grid; justify-items: center; align-content: center; gap: 14px; text-align: center;
  min-height: 260px; padding: 40px 24px; border: 1.5px solid var(--line); border-radius: 18px;
  background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s;
  box-shadow: 0 1px 0 rgb(0 0 0 / .03), 0 12px 32px -18px rgb(0 0 0 / .25);
}
.dropzone:hover, .is-dragging .dropzone {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 16%, transparent), 0 12px 32px -18px rgb(0 0 0 / .25);
}
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.dz-swatches { display: flex; }
.dz-swatches { margin-bottom: 4px; }
.dz-swatches i { width: 30px; height: 30px; border-radius: 50%; margin-left: -8px; box-shadow: 0 0 0 3px var(--surface), inset 0 0 0 1px rgb(255 255 255 / .14); }
.dz-swatches i:nth-child(1) { background: #1f1a33; margin-left: 0; }
.dz-swatches i:nth-child(2) { background: #6b3a6e; }
.dz-swatches i:nth-child(3) { background: #d9577a; }
.dz-swatches i:nth-child(4) { background: #f28a5b; }
.dz-swatches i:nth-child(5) { background: #ffd07a; }
.dz-title { font: 700 clamp(24px, 3vw, 32px)/1.1 var(--font-display); letter-spacing: -.025em; }
.dz-meta { font-size: 14px; color: var(--muted); text-wrap: balance; }
.coarse-ptr { display: none; }
@media (pointer: coarse) { .fine-ptr { display: none; } .coarse-ptr { display: inline; } }
.below-dz { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; margin: 14px 4px 0; font-size: 14.5px; color: var(--muted); }
.below-dz p { margin: 0; display: inline-flex; align-items: center; gap: 7px; }
.privacy { color: var(--ink); font-weight: 600; }
.privacy svg { color: var(--accent); }
.error {
  margin: 12px 0 0; padding: 11px 14px; border-radius: 10px; font-size: 15px;
  color: var(--danger); background: color-mix(in oklab, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--danger) 30%, transparent);
}

/* Workspace (after an image is loaded) */
.workspace { display: grid; gap: 20px; }
@media (min-width: 920px) {
  .workspace { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); align-items: start; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }

.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.file-name { margin: 0; min-width: 0; font: 600 13.5px/1.3 var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-dims { color: var(--muted); font-weight: 500; }
.stage {
  display: grid; place-items: center; min-height: 240px; padding: 12px; border-radius: 12px;
  background-color: var(--soft);
}
.stage.has-alpha {
  background-image: conic-gradient(var(--line) 25%, transparent 0 50%, var(--line) 0 75%, transparent 0);
  background-size: 18px 18px;
}
.frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; cursor: crosshair; touch-action: manipulation; }
.frame img { display: block; max-width: 100%; max-height: min(62vh, 560px); width: auto; height: auto; border-radius: 4px; user-select: none; -webkit-user-drag: none; }
.markers { position: absolute; inset: 0; pointer-events: none; }
.marker {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%;
  display: grid; place-items: center; font: 700 11px/1 var(--font-mono); color: #fff;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .45), 0 2px 8px rgb(0 0 0 / .35);
}
.chip {
  --tx: 16px; --ty: 16px;
  position: absolute; z-index: 2; pointer-events: none; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font: 600 13px/1 var(--font-mono); white-space: nowrap; transform: translate(var(--tx), var(--ty));
  box-shadow: 0 8px 24px rgb(0 0 0 / .28);
}
.chip.flip-x { --tx: calc(-100% - 16px); }
.chip.flip-y { --ty: calc(-100% - 16px); }
.chip-sw { width: 20px; height: 20px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); }
.hint { margin: 10px 2px 0; font-size: 14px; color: var(--muted); }

.picked { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.h-small { margin: 0 0 10px; font: 700 16px/1.2 var(--font-display); letter-spacing: -.01em; }
.picked ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pk { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.pk:hover { border-color: var(--ink); }
.pk-main {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 4px 4px 5px;
  border: 0; background: none; color: var(--ink); font: 600 13px/1 var(--font-mono); cursor: pointer;
}
.pk-chip { position: relative; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(128 128 128 / .3); display: grid; place-items: center; font-size: 10px; color: #fff; text-shadow: 0 0 3px rgb(0 0 0 / .8); }
.pk-x { width: 34px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 0 999px 999px 0; }
.pk-x:hover { color: var(--ink); }

/* Results */
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.results h2 { margin: 0; font: 700 22px/1.2 var(--font-display); letter-spacing: -.02em; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.seg button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 600 12.5px/1 var(--font-mono); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.count { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.count input { width: 110px; accent-color: var(--ink); }
.count output { min-width: 2ch; font: 600 14px var(--font-mono); color: var(--ink); }

.strip { display: flex; gap: 2px; height: 64px; margin-bottom: 10px; }
.strip-seg:first-child { border-radius: 10px 0 0 10px; }
.strip-seg:last-child { border-radius: 0 10px 10px 0; }
.strip-seg { flex-basis: 0; min-width: 14px; padding: 0; border: 0; cursor: pointer; transition: flex-grow .25s ease; }
.strip-seg:hover { filter: brightness(1.1); }
.summary { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }

.swatches { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sw {
  width: 100%; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 7px 14px 7px 7px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); text-align: left; cursor: pointer;
}
.sw:hover { border-color: var(--ink); }
.sw-chip { width: 48px; height: 48px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgb(128 128 128 / .28); }
.sw-body { display: grid; gap: 3px; min-width: 0; }
.sw-code { font: 600 17px/1.2 var(--font-mono); letter-spacing: .01em; }
.sw-meta { font-size: 13px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-side { display: grid; justify-items: end; gap: 3px; }
.sw-pct { font: 600 14px/1.2 var(--font-mono); }
.sw-copy { font-size: 12.5px; font-weight: 600; line-height: 1.2; color: var(--ink); opacity: .7; }
.sw:hover .sw-copy { opacity: 1; text-decoration: underline; }
.export { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- SEO content ---------- */
.content { max-width: 760px; padding-bottom: 56px; }
.content h2 { margin: 52px 0 14px; font: 700 clamp(25px, 3vw, 34px)/1.12 var(--font-display); letter-spacing: -.03em; text-wrap: balance; }
.content p, .content li { color: color-mix(in oklab, var(--ink) 86%, var(--bg)); text-wrap: pretty; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 16px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 14px; }
.steps li::before {
  content: counter(step); width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; font: 600 14px/1 var(--font-mono); color: var(--ink);
}
.table-wrap { overflow-x: auto; }
.compare { width: 100%; border-collapse: collapse; font-size: 15px; }
.compare th, .compare td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.compare th { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.compare td:first-child { font-weight: 600; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  display: flex; justify-content: space-between; gap: 16px; padding: 15px 0; cursor: pointer;
  list-style: none; font-weight: 600; font-size: 17px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font: 600 18px/1.4 var(--font-mono); color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 16px; }

/* Content pages */
.doc { padding: 48px 0 72px; }
.doc h1 { margin-bottom: 14px; }
.doc .lede { margin-bottom: 28px; }
.doc h2 { margin-top: 40px; font-size: clamp(22px, 2.4vw, 28px); }
.doc ul { padding-left: 22px; }
.doc li + li { margin-top: 8px; }
.updated { font: 500 13px/1 var(--font-mono); color: var(--muted); margin: 0 0 24px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 36px; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.site-footer nav { display: flex; gap: 20px; font-size: 14px; }
.site-footer nav a { color: var(--muted); text-decoration: none; }
.site-footer nav a:hover { color: var(--ink); }
.fine { width: 100%; margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Feedback ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40; pointer-events: none;
  padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font: 600 14px/1 var(--font-mono); box-shadow: 0 10px 30px rgb(0 0 0 / .25);
  opacity: 0; transform: translate(-50%, 16px); transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.is-dragging::after {
  content: "Drop your image to find its colors";
  position: fixed; inset: 12px; z-index: 45; pointer-events: none;
  display: grid; place-items: center; border: 3px dashed var(--accent); border-radius: 22px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  font: 700 clamp(22px, 3vw, 32px)/1.1 var(--font-display); letter-spacing: -.02em;
}
.is-busy .dropzone { opacity: .6; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
