/* =========================================================================
   gcolorpicker.com — "paint-chip studio" design system
   ========================================================================= */

/* ---------- tokens: light (default) ---------- */
:root {
  --bg: #f2eee3;
  --bg-soft: #ece6d7;
  --surface: #fffdf8;
  --surface-2: #faf5ea;
  --border: rgba(35, 28, 16, 0.14);
  --border-strong: rgba(35, 28, 16, 0.26);
  --text: #1e1a12;
  --text-dim: #6d6353;
  --text-faint: #948a78;
  --shadow-sm: 0 1px 2px rgba(30, 20, 8, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(30, 20, 8, 0.18), 0 2px 6px rgba(30,20,8,.06);
  --shadow-lg: 0 20px 50px -18px rgba(30, 20, 8, 0.28);
  --grain-opacity: 0.05;
  --checker-a: #e4ded0;
  --checker-b: #cfc7b4;
  --focus-ring: #1e1a12;

  --brand-a: #e0574a;
  --brand-b: #f2b545;
  --brand-c: #3c8f6b;

  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-body: "Manrope", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  color-scheme: light;
  --accent: #e0574a;
  --accent-ink: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171512;
    --bg-soft: #1d1a15;
    --surface: #211e18;
    --surface-2: #26221b;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f1ece0;
    --text-dim: #b3a996;
    --text-faint: #7d7666;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0,0,0,.3);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
    --grain-opacity: 0.07;
    --checker-a: #2a2620;
    --checker-b: #201d18;
    --focus-ring: #f1ece0;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #171512;
  --bg-soft: #1d1a15;
  --surface: #211e18;
  --surface-2: #26221b;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1ece0;
  --text-dim: #b3a996;
  --text-faint: #7d7666;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0,0,0,.3);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
  --grain-opacity: 0.07;
  --checker-a: #2a2620;
  --checker-b: #201d18;
  --focus-ring: #f1ece0;
  color-scheme: dark;
}

/* ---------- reset-ish ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
button, input { font-family: inherit; color: inherit; }
input:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
::selection { background: var(--accent); color: var(--accent-ink); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -3rem; background: var(--text); color: var(--bg);
  padding: .6rem 1rem; border-radius: .5rem; z-index: 100; transition: top .15s ease;
}
.skip-link:focus { top: 1rem; }

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

/* film-grain overlay for tactility */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999; mix-blend-mode: overlay;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 1.5rem; }

/* ---------- header ---------- */
.site-header {
  padding-block: 1.4rem;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark { display: inline-flex; filter: drop-shadow(0 2px 4px rgba(0,0,0,.15)); }
.brand-word {
  font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: -0.01em;
}
.brand-dot { color: var(--text-faint); font-weight: 500; }
.brand-tag {
  margin: 0; color: var(--text-dim); font-size: .84rem; flex: 1 1 auto;
  font-style: italic; font-family: var(--font-display);
}
.brand-tag em { color: var(--accent); font-style: italic; }

.theme-toggle {
  width: 2.3rem; height: 2.3rem; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: grid; place-items: center;
  color: var(--text-dim); transition: transform .2s ease, border-color .2s ease, color .2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-sun circle { fill: currentColor; stroke: none; }
.icon-moon path { fill: currentColor; stroke: none; }

/* sun icon shown in light mode (click to go dark), moon icon shown in dark mode */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: inline-block; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 1.5rem;
  padding-block: 1.75rem 3rem;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}
.picker-panel {
  padding: 1.4rem 1.4rem 1.6rem;
  position: sticky;
  top: 1.25rem;
}
@media (max-width: 900px) {
  .picker-panel { position: static; }
}

.tools-col { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.card { padding: 1.3rem 1.4rem 1.5rem; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.card-head h2 { font-size: 1.05rem; letter-spacing: -0.01em; }
.card-sub { margin: .2rem 0 0; font-size: .78rem; color: var(--text-faint); }

/* ---------- preview row ---------- */
.preview-row { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.2rem; }

.swatch-big {
  position: relative; width: 4.6rem; height: 4.6rem; border-radius: 16px; flex-shrink: 0;
  box-shadow: var(--shadow-md); overflow: hidden; border: 1px solid var(--border);
}
.swatch-big-checker, .swatch-big-fill { position: absolute; inset: 0; }
.swatch-big-checker {
  background-image: conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0);
  background-size: 12px 12px;
}
.swatch-big-fill { transition: background-color .05s linear; }

.headline-block { min-width: 0; }
.headline-hex {
  font-family: var(--font-display); font-weight: 600; font-size: 1.65rem; letter-spacing: -0.01em;
  line-height: 1.1;
}
.headline-name {
  font-size: .78rem; color: var(--text-dim); font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .06em; margin-top: .15rem;
}
.tool-row { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: .4rem .75rem; font-size: .76rem; font-weight: 600; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}
.btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.btn-ghost { background: transparent; }
.btn-tiny { padding: .25rem .6rem; font-size: .7rem; }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; }

/* ---------- SV square ---------- */
.sv-wrap { margin-bottom: 1rem; }
.sv-square {
  position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 18px;
  cursor: crosshair; touch-action: none; border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.02), var(--shadow-sm);
  background:
    linear-gradient(to top, #000 0%, transparent 100%),
    linear-gradient(to right, #fff 0%, rgba(255,255,255,0) 100%),
    hsl(var(--cur-hue, 4) 100% 50%);
}
.sv-thumb {
  position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.35);
  transform: translate(-50%, -50%); pointer-events: none;
}

/* ---------- sliders ---------- */
.slider-block { margin-bottom: .85rem; }
.slider-label {
  display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-faint); margin-bottom: .35rem;
}
.hue-slider, .alpha-slider {
  position: relative; height: 16px; border-radius: 999px; touch-action: none; cursor: pointer;
  border: 1px solid var(--border-strong);
}
.hue-slider {
  background: linear-gradient(to right,
    hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%),
    hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%));
}
.alpha-slider { overflow: hidden; }
.alpha-slider-checker, .alpha-slider-fill { position: absolute; inset: 0; border-radius: inherit; }
.alpha-slider-checker {
  background-image: conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0);
  background-size: 10px 10px;
}
.slider-thumb {
  position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.35);
  transform: translate(-50%, -50%); pointer-events: none;
}

/* ---------- value fields ---------- */
.value-grid { display: flex; flex-direction: column; gap: .55rem; margin-top: 1.3rem; }
.field-row { display: flex; align-items: center; gap: .7rem; }
.field-label {
  width: 2.6rem; flex-shrink: 0; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
}
.field-io {
  display: flex; align-items: center; gap: .3rem; flex: 1; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: .3rem .4rem .3rem .55rem;
}
.field-hash { color: var(--text-faint); font-family: var(--font-mono); font-size: .85rem; }
.field-input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: .88rem; padding: .15rem 0;
}
.field-input:focus { outline: none; }
.channels { gap: .25rem; }
.chan-input {
  width: 3.1rem; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: .85rem; text-align: center; padding: .15rem 0; border-radius: 6px;
  -moz-appearance: textfield;
}
.chan-input:focus { outline: none; background: var(--bg-soft); }
.chan-input::-webkit-outer-spin-button, .chan-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.chan-alpha { border-left: 1px solid var(--border); padding-left: .35rem; margin-left: .1rem; }
.chan-unit { font-size: .74rem; color: var(--text-faint); margin-right: .25rem; }
.mono { font-family: var(--font-mono); }

.copy-btn {
  flex-shrink: 0; width: 1.8rem; height: 1.8rem; border-radius: 7px; border: none;
  background: transparent; color: var(--text-faint); cursor: pointer; display: grid; place-items: center;
  transition: color .15s ease, background .15s ease;
}
.copy-btn:hover { color: var(--text); background: var(--bg-soft); }
.copy-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- chips (paint-deck swatches) ---------- */
.chip-row {
  display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .6rem;
}
.chip-row:last-child { margin-bottom: 0; }
.chip-row-recent { min-height: 2.6rem; align-items: center; }

.chip {
  --chip-color: #cccccc;
  position: relative; width: 3.4rem; border: none; cursor: pointer; padding: 0;
  border-radius: 10px 10px 4px 4px; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-mask-image: radial-gradient(circle 5px at 50% 9px, transparent 98%, black 100%);
          mask-image: radial-gradient(circle 5px at 50% 9px, transparent 98%, black 100%);
}
.chip:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.chip:active { transform: translateY(-1px); }
.chip-current { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent), var(--shadow-sm); }
.chip-fill { display: block; height: 2.7rem; background: var(--chip-color); }
.chip-code {
  display: block; font-family: var(--font-mono); font-size: .58rem; text-align: center;
  padding: .3rem 0 .35rem; background: var(--surface-2); color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chip-recent {
  width: 2.2rem; border-radius: 50%;
  -webkit-mask-image: none; mask-image: none;
}
.chip-recent .chip-fill { height: 2.2rem; border-radius: 50%; border: 1px solid var(--border-strong); }
.chip-recent .chip-code { display: none; }

.empty-note { color: var(--text-faint); font-size: .8rem; font-style: italic; margin: 0; }

.harmony-group { margin-bottom: 1rem; }
.harmony-group:last-child { margin-bottom: 0; }
.harmony-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); margin: 0 0 .5rem;
}

/* ---------- contrast checker ---------- */
.contrast-body { display: flex; flex-direction: column; gap: 1rem; }
.contrast-sample {
  border-radius: 14px; padding: 1.3rem 1.2rem; display: flex; flex-direction: column; gap: .5rem;
  background: var(--sample-bg, #fff); color: var(--sample-fg, #000); border: 1px solid var(--border);
  transition: background-color .1s linear, color .1s linear;
}
.contrast-sample-big { font-family: var(--font-display); font-size: 2rem; font-weight: 600; line-height: 1; }
.contrast-sample-text { font-size: .88rem; max-width: 40ch; }

.contrast-controls {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: end;
}
@media (max-width: 480px) {
  .contrast-controls { grid-template-columns: 1fr; }
  .swap-btn { justify-self: start; }
}
.contrast-slot { display: flex; flex-direction: column; gap: .3rem; }
.chip-set-btn {
  flex-shrink: 0; border: none; background: transparent; color: var(--text-faint);
  font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; cursor: pointer;
  padding: .2rem .3rem; border-radius: 6px; font-weight: 700; white-space: nowrap;
}
.chip-set-btn:hover { color: var(--accent); background: var(--bg-soft); }
.swap-btn { width: 2.1rem; height: 2.1rem; border-radius: 50%; padding: 0; justify-self: center; align-self: center; }

.contrast-ratio-row { display: flex; align-items: baseline; gap: .15rem; }
.ratio-value { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; }
.ratio-suffix { font-family: var(--font-mono); color: var(--text-faint); font-size: 1rem; }

.wcag-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (max-width: 420px) { .wcag-grid { grid-template-columns: 1fr; } }
.wcag-cell {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .7rem;
}
.wcag-label { font-size: .76rem; color: var(--text-dim); }
.wcag-badge {
  font-family: var(--font-mono); font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .2rem .5rem; border-radius: 999px;
}
.wcag-badge.pass { background: rgba(60, 143, 107, 0.18); color: #2a7a54; }
.wcag-badge.fail { background: rgba(224, 87, 74, 0.18); color: #c04434; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wcag-badge.pass { color: #6fcf9e; }
  :root:not([data-theme="light"]) .wcag-badge.fail { color: #f0897b; }
}
:root[data-theme="dark"] .wcag-badge.pass { color: #6fcf9e; }
:root[data-theme="dark"] .wcag-badge.fail { color: #f0897b; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding-block: 1.4rem 2.2rem; }
.footer-inner p { margin: 0; font-size: .76rem; color: var(--text-faint); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 12px);
  background: var(--text); color: var(--bg); font-size: .8rem; font-weight: 600;
  padding: .6rem 1rem; border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  z-index: 1000; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .wrap { padding-inline: 1rem; }
  .headline-hex { font-size: 1.35rem; }
  .swatch-big { width: 3.8rem; height: 3.8rem; }
}
