/* JD's Color Converter — styles */

:root {
  color-scheme: light dark;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface2: #f0f0f0;
  --border: rgba(0,0,0,0.12);
  --text: #18181b;
  --text-muted: #71717a;
  --accent: #3b82f6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111112;
    --surface: #1c1c1e;
    --surface2: #2a2a2e;
    --border: rgba(255,255,255,0.1);
    --text: #e4e4e7;
    --text-muted: #a1a1aa;
    --shadow: 0 1px 3px rgba(0,0,0,0.5);
  }
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  padding: 10px 16px;
  text-align: center;
}
header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.04em;
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  text-align: center;
}

/* ── 2D picker ─────────────────────────────────────────────────────────────── */
#picker {
  position: relative;
  width: 100%;
  height: 200px;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

#pickerCursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(0,0,0,0.2);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ── Sliders ───────────────────────────────────────────────────────────────── */
.sliders {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 2px;
  text-align: center;
}

.slider-row {
  display: grid;
  grid-template-columns: 48px 1fr 60px;
  align-items: center;
  gap: 8px;
}

.slider-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.slider-value {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.slider-track {
  position: relative;
  height: 12px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

/* checkered bg for alpha track */
#alphaTrack {
  background-image:
    linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0)),
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: auto, 8px 8px, 8px 8px, 8px 8px, 8px 8px;
  background-position: 0 0, 0 0, 0 4px, 4px -4px, -4px 0;
}

.slider-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,0.25);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transform: translateY(-50%);
  pointer-events: none;
}

/* ── Input ─────────────────────────────────────────────────────────────────── */
.input-row {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#colorInput {
  flex: 1;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-family: ui-monospace, monospace;
  transition: border-color 0.15s;
}

#colorInput:focus {
  outline: none;
  border-color: var(--accent);
}

#colorInput.invalid {
  border-color: #ef4444;
}

/* ── Swatches ──────────────────────────────────────────────────────────────── */
.swatch-row {
  display: flex;
  gap: 0;
  height: 64px;
}

.swatch-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

.swatch-wrap:first-child { border-radius: 0 0 0 var(--radius); }
.swatch-wrap:last-child  { border-radius: 0 0 var(--radius) 0; }

.swatch-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swatch-bg.white  { background: #fff; }
.swatch-bg.black  { background: #000; }
.swatch-bg.check  {
  background-color: #ccc;
  background-image:
    linear-gradient(45deg, #888 25%, transparent 25%),
    linear-gradient(-45deg, #888 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #888 75%),
    linear-gradient(-45deg, transparent 75%, #888 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
}

.swatch {
  width: 100%;
  height: 100%;
}

.swatch-label {
  font-size: 0.6rem;
  text-align: center;
  padding: 2px 0;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ── Values table ──────────────────────────────────────────────────────────── */
.values-table {
  width: 100%;
  border-collapse: collapse;
}

.values-table tr + tr td,
.values-table tr + tr th {
  border-top: 1px solid var(--border);
}

.values-table th {
  width: 80px;
  padding: 6px 10px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface2);
  white-space: nowrap;
}

.values-table td {
  padding: 6px 10px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.values-table td[data-copy]:hover {
  background: var(--surface2);
}

.values-table td[data-copy]:hover::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 14px;
  background-color: var(--text-muted);
  opacity: 0.6;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath fill='currentColor' d='M248 80L136 80c-13.3 0-24-10.7-24-24s10.7-24 24-24l112 0c13.3 0 24 10.7 24 24s-10.7 24-24 24zm0 32c28.2 0 51.6-20.9 55.4-48L320 64c17.7 0 32 14.3 32 32l0 352c0 17.7-14.3 32-32 32L64 480c-17.7 0-32-14.3-32-32L32 96c0-17.7 14.3-32 32-32l16.6 0c3.9 27.1 27.2 48 55.4 48l112 0zm50.6-80c-9-18.9-28.3-32-50.6-32L136 0C113.7 0 94.4 13.1 85.4 32L64 32C28.7 32 0 60.7 0 96L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-352c0-35.3-28.7-64-64-64l-21.4 0z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath fill='currentColor' d='M248 80L136 80c-13.3 0-24-10.7-24-24s10.7-24 24-24l112 0c13.3 0 24 10.7 24 24s-10.7 24-24 24zm0 32c28.2 0 51.6-20.9 55.4-48L320 64c17.7 0 32 14.3 32 32l0 352c0 17.7-14.3 32-32 32L64 480c-17.7 0-32-14.3-32-32L32 96c0-17.7 14.3-32 32-32l16.6 0c3.9 27.1 27.2 48 55.4 48l112 0zm50.6-80c-9-18.9-28.3-32-50.6-32L136 0C113.7 0 94.4 13.1 85.4 32L64 32C28.7 32 0 60.7 0 96L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-352c0-35.3-28.7-64-64-64l-21.4 0z'/%3E%3C/svg%3E") no-repeat center / contain;
}

.values-table td.copied {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
}

.section-divider th {
  background: var(--bg);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  padding: 4px 10px;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 20px 0 30px;
}

footer a { color: var(--text-muted); }
footer a:hover { color: var(--text); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (min-width: 600px) {
  #picker { height: 240px; }
}
