/* UI fonts, self-hosted (OFL, see fonts/OFL-*.txt). Inter Tight is a variable font. */
@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/inter-tight-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/inter-tight-latin.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: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/instrument-serif-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/instrument-serif-italic-latin.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;
}

:root {
  --filament: #8ec9e8;
  --paper: #f6f5f2;
  --ink: #141416;
  --muted: rgba(20, 20, 22, 0.46);
  --quiet: rgba(20, 20, 22, 0.66); /* muted, but readable at small sizes (≥ 4.5:1) */
  --hair: rgba(20, 20, 22, 0.08);
  --glass: rgba(255, 255, 255, 0.7);
  --lift: 0 1px 1px rgba(0, 0, 0, 0.03), 0 18px 50px -20px rgba(30, 25, 15, 0.28);
  --tint: color-mix(in oklab, var(--filament) 22%, var(--paper));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101012;
    --ink: #f3f2ef;
    --muted: rgba(243, 242, 239, 0.45);
    --quiet: rgba(243, 242, 239, 0.62);
    --hair: rgba(255, 255, 255, 0.08);
    --glass: rgba(28, 28, 31, 0.72);
    --lift: 0 1px 1px rgba(0, 0, 0, 0.2), 0 18px 50px -20px rgba(0, 0, 0, 0.7);
    --tint: color-mix(in oklab, var(--filament) 16%, var(--paper));
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  background:
    radial-gradient(60% 55% at 50% 40%, color-mix(in oklab, var(--filament) 30%, transparent), transparent 70%),
    linear-gradient(180deg, var(--tint), var(--paper) 120%);
  background-color: var(--paper);
  color: var(--ink);
  font: 500 15px/1.4 'Inter Tight', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.6s;
}

button { font: inherit; color: inherit; }

/* ---------- Header ---------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 36px 0;
  font-size: 13px;
}
.wordmark {
  margin: 0;
  font: italic 400 28px/1 'Instrument Serif', Georgia, serif;
  letter-spacing: -0.01em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  min-height: 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.stage.ready { opacity: 1; transform: none; }
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.stage canvas:active { cursor: grabbing; }

/* ---------- Dock ---------- */

.dock {
  width: min(1000px, calc(100% - 48px));
  margin: 0 auto 30px;
}

.bar {
  display: flex;
  align-items: stretch;
  padding: 8px;
  border-radius: 24px;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: var(--lift), inset 0 0 0 1px var(--hair);
}

.field {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 11px 18px 10px;
  border-radius: 16px;
  cursor: text;
  transition: background 0.2s;
}
.field + .field::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: var(--hair);
}
.field:hover { background: color-mix(in oklab, var(--ink) 3%, transparent); }
.field:focus-within { background: color-mix(in oklab, var(--ink) 5%, transparent); }
.field:hover::before, .field:focus-within::before,
.field:hover + .field::before, .field:focus-within + .field::before { opacity: 0; }
.field.code { flex: 0.7 1 0; }

.field span {
  display: block;
  margin-bottom: 3px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
.field input {
  width: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  text-overflow: ellipsis;
}
.field input::placeholder { color: var(--muted); opacity: 0.6; }

.end {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
}

/* ---------- Color ---------- */

.picker { position: relative; }

.dot {
  display: block;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--filament);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), inset 0 -6px 12px rgba(0, 0, 0, 0.08), 0 4px 12px -4px color-mix(in oklab, var(--filament) 70%, black);
  transition: transform 0.2s, background 0.4s;
}
.dot:hover, .dot[aria-expanded=true] { transform: scale(1.06); }

.palette {
  position: absolute;
  right: -6px;
  bottom: calc(100% + 18px);
  z-index: 2;
  width: 300px;
  padding: 14px;
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: var(--lift), inset 0 0 0 1px var(--hair);
  transform-origin: calc(100% - 28px) 100%;
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.palette[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(0.92) translateY(6px); } }

.chips {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.chip {
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s;
}
.chip:hover { transform: scale(1.12); }
.chip[aria-pressed=true] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }

.custom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
}
.rainbow {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(#f43f5e, #f59e0b, #eab308, #22c55e, #06b6d4, #6366f1, #d946ef, #f43f5e);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.rainbow input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.custom input[name=hex] {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  outline: none;
  background: color-mix(in oklab, var(--ink) 5%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Download ---------- */

.download {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 22px 0 26px;
  border: 0;
  border-radius: 17px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}
.download svg { width: 18px; height: 18px; transition: transform 0.2s; }
.download:hover svg { transform: translateY(2px); }
.download:active { transform: scale(0.98); }
.download:disabled { opacity: 0.35; cursor: default; }

/* ---------- Meta row ---------- */

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 24px;
  margin-top: 14px;
  padding: 0 14px;
  font-size: 13px;
}
.toggles { display: flex; gap: 28px; }
.toggle { display: flex; gap: 18px; }
.toggle button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}
.toggle button:hover { color: var(--ink); }
.toggle button[aria-pressed=true] { color: var(--ink); }
.toggle button[aria-pressed=true]::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 7px 1px 0;
  border-radius: 50%;
  background: currentColor;
}
.note { margin: 0 0 0 auto; color: var(--muted); text-align: right; }
.note:empty { display: none; }

/* Author credit: stays pinned right; the note grows to its left. */
.credit {
  flex: none;
  margin: 0 0 0 auto;
  color: var(--quiet);
  font-size: 12px;
  white-space: nowrap;
}
.note:not(:empty) + .credit { margin-left: 0; padding-left: 16px; border-left: 1px solid var(--hair); }
.credit a {
  color: inherit;
  text-decoration: none;
  border-radius: 3px;
  transition: color 0.2s;
}
.credit a:hover, .credit a:focus-visible {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.credit a:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 1px; }

/* ---------- Privacy page (privacy.html) ---------- */

body.page { display: block; height: auto; min-height: 100dvh; background-attachment: fixed; }
.page .top { padding: 0 0 44px; }
.page .wordmark { color: inherit; text-decoration: none; }
.page .wordmark:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 4px; }
.prose {
  max-width: 65ch;
  margin: 0 auto;
  padding: 28px 24px 64px;
  font-weight: 400;
  font-size: 15.5px;
  line-height: 1.6;
}
.prose h1 {
  margin: 0 0 6px;
  font: italic 400 44px/1.1 'Instrument Serif', Georgia, serif;
  letter-spacing: -0.01em;
}
.prose h2 { margin: 36px 0 8px; font-size: 16px; font-weight: 600; }
.prose p, .prose ul { margin: 0 0 12px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--muted); }
.prose a:hover { text-decoration-color: currentColor; }
.prose a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }
.prose .lede { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.prose strong { font-weight: 600; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .top { padding: 20px 20px 0; }
  .top .toggle { gap: 14px; }
  .wordmark { font-size: 24px; }
  .stage { min-height: 46vh; }
  .dock { width: calc(100% - 32px); margin-bottom: 16px; }
  .bar { flex-wrap: wrap; padding: 6px; border-radius: 22px; }
  .field { flex: 1 1 50%; }
  .field.code { flex: 1 1 50%; }
  .field + .field::before { display: none; }
  .end { flex: 1 1 100%; padding: 6px 4px 2px; }
  .download { flex: 1; justify-content: center; }
  .meta { flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 8px; }
  .toggles { gap: 22px; }
  .note { margin-left: 0; text-align: left; }
  .credit, .note:not(:empty) + .credit { margin-left: 0; padding-left: 0; border-left: 0; }
  .page .top { padding: 0 0 32px; }
  .prose { padding: 20px 20px 48px; }
  .prose h1 { font-size: 36px; }
  .palette { right: auto; left: -4px; transform-origin: 26px 100%; }
}
