/* PickTint — warm paper, deep ink, coral/amber/teal accents. */

:root {
  --paper: #fdfaf4;
  --paper-sunk: #f3ecdf;
  --card: #ffffff;
  --ink: #12151a;
  --ink-soft: #3d444f;
  --ink-muted: #6b7280;
  --line: #e4dbcb;
  --coral: #e8596f;
  --amber: #f0a83c;
  --teal: #2fb3a4;
  --radius: 18px;
  --radius-small: 12px;
  --shadow: 0 18px 40px -28px rgba(18, 21, 26, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; }

a { color: var(--ink); text-decoration-color: var(--coral); text-underline-offset: 3px; }
a:hover { color: var(--coral); }

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 0; transform: translateY(-120%);
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  z-index: 20;
  border-radius: 0 0 10px 0;
}
.skip-link:focus { transform: none; }

/* Header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800; font-size: 21px; letter-spacing: -0.02em;
}

.brand-mark svg { display: block; width: 38px; height: 38px; border-radius: 10px; }
.brand-tint { color: var(--coral); }

.site-nav { display: flex; gap: 18px; font-size: 15px; font-weight: 600; }
.site-nav a { text-decoration: none; color: var(--ink-soft); }
.site-nav a:hover { color: var(--coral); }

main { display: block; }

/* Hero */

.hero {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 24px 4px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 12px; font-weight: 700; color: var(--teal);
}

.hero h1 { margin: 0 0 10px; font-size: clamp(28px, 3.6vw, 44px); }

.hero-lead {
  margin: 0 auto; max-width: 620px;
  font-size: clamp(16px, 1.8vw, 18px); color: var(--ink-soft);
}

.hero-points {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px 18px; list-style: none;
  margin: 14px 0 0; padding: 0;
  font-size: 13.5px; font-weight: 600; color: var(--ink-muted);
}

.hero-points li::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--amber);
  vertical-align: 1px;
}

.hero-points li:nth-child(2)::before { background: var(--coral); }
.hero-points li:nth-child(3)::before { background: var(--teal); }

/* Workbench */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
  max-width: 1180px;
  margin: 20px auto 0;
  padding: 0 24px;
}

.stage, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--ink-muted); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.button.primary:hover:not(:disabled) { border-color: var(--ink); background: #23272f; color: var(--paper); }
.button.ghost { background: transparent; }
.button.small { min-height: 40px; padding: 8px 14px; font-size: 14px; }

.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-small);
  background: var(--paper-sunk);
  overflow: hidden;
  transition: border-color 140ms ease, background 140ms ease;
}

.dropzone.is-dragging { border-color: var(--teal); background: #e9f5f2; }
.dropzone:focus-visible { border-color: var(--teal); }

.stage-canvas {
  display: block;
  width: auto; height: auto;
  max-width: 100%; max-height: min(58vh, 560px);
  margin: 0 auto;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
  background: #fff;
}

.stage-empty { text-align: center; color: var(--ink-muted); padding: 30px 16px; }
.stage-empty-title { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: var(--ink); }
.stage-empty p { margin: 0; font-size: 14px; }

.image-meta { margin: 12px 2px 0; font-size: 13px; color: var(--ink-muted); }

/* Sampled color readout: sticky so the value stays visible while sampling.
   Rows are reserved so a sample never shifts the canvas below. */

.readout {
  position: sticky;
  top: 8px;
  z-index: 4;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-areas:
    "swatch values"
    "copies copies"
    "foot foot";
  gap: 8px 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: rgba(253, 250, 244, 0.97);
  box-shadow: 0 12px 26px -24px rgba(18, 21, 26, 0.6);
}

.readout-swatch {
  grid-area: swatch;
  width: 52px; height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(18, 21, 26, 0.15);
  background: var(--paper-sunk);
}

.readout-swatch.is-transparent {
  background-image:
    linear-gradient(45deg, #d8d2c6 25%, transparent 25%),
    linear-gradient(-45deg, #d8d2c6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8d2c6 75%),
    linear-gradient(-45deg, transparent 75%, #d8d2c6 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

/* Two fixed columns at desktop: every value stays on one line inside its reservation. */
.readout-values {
  grid-area: values;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(24px, auto);
  align-content: center;
  gap: 2px 12px;
  min-height: 52px;
}

.readout-cell { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.readout-key { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.readout-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; white-space: nowrap; }

/* Four slots stay in the grid even when RGBA is not applicable. */
.readout-copies {
  grid-area: copies;
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 140px));
  justify-content: flex-start;
  gap: 6px;
  min-height: 40px;
}

.readout-copies .button.is-hidden { visibility: hidden; }

.readout-foot {
  grid-area: foot;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  min-height: 20px;
  font-size: 12.5px;
  line-height: 20px;
  color: var(--ink-muted);
}

.readout-coords, .readout-note { min-height: 20px; }

.readout-coords { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.copy-fallback {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--coral);
  border-radius: 10px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #fff;
}

.status { min-height: 24px; margin: 12px 2px 0; font-size: 14px; color: var(--ink-soft); }
.status[data-tone="success"] { color: #1f7a5c; }
.status[data-tone="error"] { color: #b4354b; }

/* Palette panel */

.panel h2 { margin: 0 0 12px; font-size: 19px; }
.panel-controls { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
.count-field { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.count-field output { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); }
.count-range { width: 100%; accent-color: var(--coral); min-height: 28px; }

.palette-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }

.swatch {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  grid-template-areas:
    "chip field picker"
    "actions actions actions";
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--paper);
}

.swatch.is-selected { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(47, 179, 164, 0.22); }
.swatch-chip { grid-area: chip; width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(18, 21, 26, 0.14); }

.swatch-field { grid-area: field; min-width: 0; }
.swatch-hex {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  text-transform: uppercase;
}

.swatch-picker {
  grid-area: picker;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.swatch-actions { grid-area: actions; display: flex; gap: 4px; justify-content: flex-end; }

.icon-button {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--ink-muted); }
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-button[data-action="remove"]:hover:not(:disabled) { border-color: var(--coral); color: var(--coral); }

.palette-empty { margin: 0 0 12px; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius-small); font-size: 14px; color: var(--ink-muted); background: var(--paper-sunk); }

.panel-actions { display: grid; gap: 8px; }
.panel-hint { margin: 10px 0 0; font-size: 13px; color: var(--ink-muted); }

/* FAQ and legal */

.faq { max-width: 780px; margin: 56px auto 0; padding: 0 24px; }
.faq h2 { font-size: 26px; margin-bottom: 16px; }

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--card);
  padding: 14px 18px;
  margin-bottom: 10px;
}

.faq-item summary { cursor: pointer; font-weight: 700; font-size: 16px; }
.faq-item p { margin: 10px 0 0; color: var(--ink-soft); font-size: 15px; }

.legal { max-width: 720px; margin: 40px auto 0; padding: 0 24px; }
.legal h1 { font-size: clamp(30px, 4vw, 42px); margin-bottom: 8px; }
.legal-lead { font-size: 18px; color: var(--ink-soft); }
.legal-updated { font-size: 13px; color: var(--ink-muted); }
.legal h2 { margin: 32px 0 6px; font-size: 20px; }
.legal p { margin: 0 0 12px; color: var(--ink-soft); overflow-wrap: anywhere; }
.legal-back { margin-top: 36px; }

.missing { max-width: 640px; margin: 60px auto; padding: 0 24px; text-align: center; }
.missing h1 { font-size: clamp(30px, 4vw, 44px); }

/* Footer */

.site-footer {
  max-width: 1180px;
  margin: 64px auto 0;
  padding: 22px 24px 40px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: space-between;
  font-size: 14px;
  color: var(--ink-muted);
}

.site-footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* Narrow screens: image first, palette below */

@media (max-width: 960px) {
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 16px; }
  .hero { padding-top: 16px; }
  .readout { grid-template-columns: 44px minmax(0, 1fr); }
  .readout-swatch { width: 44px; height: 44px; }
  .stage, .panel { padding: 14px; }
  .dropzone { min-height: 180px; }
  .site-footer { margin-top: 44px; }
  .button.small, .icon-button, .swatch-hex, .swatch-picker { min-height: 44px; }
  .icon-button { width: 44px; }
}

@media (max-width: 640px) {
  /* One value per row keeps every value on a single line at 375px. */
  .readout-values {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(24px, auto);
    min-height: 96px;
  }
  .readout-copies { grid-template-columns: repeat(4, minmax(0, 1fr)); min-height: 44px; }
  /* Compact chips so the longest label (RGBA) stays inside its button even at 320. */
  .readout-copies .button { padding-left: 6px; padding-right: 6px; font-size: 13px; }
  /* Coordinates on one line, note on its own lines: 20 + 2 + 40 fits the reserve. */
  .readout-foot { min-height: 64px; }
  .readout-note { flex: 1 1 100%; }
  .swatch-picker { width: 44px; }
}

/* Very narrow phones: reclaim horizontal room so RGB/HSL never clip, and
   reserve a third note line for the semi-transparent message. */
@media (max-width: 480px) {
  /* Four nav links no longer fit one line: wrap the header instead of overflowing. */
  .site-header { flex-wrap: wrap; padding: 16px 12px 8px; row-gap: 4px; }
  .site-nav { gap: 14px; }
}

@media (max-width: 355px) {
  /* Very narrow phones: reclaim horizontal room so the readout never clips. */
  .workbench { padding: 0 12px; }
  .stage, .panel { padding: 10px; }
  .readout { padding: 10px; gap: 6px 10px; }
  .readout-swatch { width: 40px; height: 40px; }
  .readout-value { font-size: 14px; }
  .readout-foot { min-height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
