/* Painting app: interface styles
   Principle: the chrome is true-neutral grayscale so it never biases color judgement.
   The only hue in the interface is the paint you are holding. */

@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: block;
}

:root {
  --surround: #2a2a2a;       /* the table the canvas sits on */
  --chrome: rgba(23, 23, 23, 0.94);
  --chrome-solid: #171717;
  --raised: #232323;
  --raised-2: #2f2f2f;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #f4f4f4;
  --ink-2: #a6a6a6;
  --ink-3: #6e6e6e;
  --on: #f4f4f4;             /* selected state: inverted */
  --on-ink: #171717;
  --paint: #23408e;          /* set by script: the active color */

  --bar-h: 48px;
  --btn: 40px;
  --gap: 10px;
  --r-panel: 18px;
  --r-row: 11px;

  --t-cap: 11px;
  --t-body: 13px;
  --t-title: 15px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surround);
  color: var(--ink);
  font-family: "Instrument Sans", -apple-system, system-ui, sans-serif;
  font-size: var(--t-body);
  font-weight: 450;
  letter-spacing: .005em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  font-variant-numeric: tabular-nums;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
svg .soft { opacity: .45; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

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

.stage {
  position: fixed;
  inset: 0;
  /* the free area between the bars and the sidebar */
  padding: 74px 24px 24px 80px;
  display: grid;
  place-items: center;
  touch-action: none;
}
.paper-wrap { position: relative; line-height: 0; }
.paper {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
  touch-action: none;
}

/* ---------- Floating bars ---------- */

.bar {
  position: fixed;
  top: calc(var(--gap) + env(safe-area-inset-top));
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: calc(var(--bar-h) / 2);
  z-index: 10;
}
.bar-left { left: calc(var(--gap) + env(safe-area-inset-left)); }
.bar-right { right: calc(var(--gap) + env(safe-area-inset-right)); }

.sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 6px; }

.btn {
  width: var(--btn);
  height: var(--btn);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--raised-2); }
.btn:active { background: var(--raised-2); transform: scale(.96); }
.btn.is-on { background: var(--on); color: var(--on-ink); }
.btn.is-open:not(.is-on) { background: var(--raised-2); }

.btn-text {
  height: var(--btn);
  padding: 0 14px 0 12px;
  border-radius: calc(var(--btn) / 2);
  font-weight: 550;
  letter-spacing: .01em;
}
.btn-text:hover { background: var(--raised-2); }

.btn-color .chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--paint);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 0 0 2px var(--chrome-solid), 0 0 0 3.5px rgba(255, 255, 255, .55);
}
.btn-color:hover .chip { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 0 0 2px var(--chrome-solid), 0 0 0 3.5px var(--ink); }

.btn-sm { width: 32px; height: 32px; }
.btn-sm svg { width: 18px; height: 18px; }
.btn-xs { width: 24px; height: 24px; }
.btn-xs svg { width: 16px; height: 16px; }

/* ---------- Sidebar ---------- */

.side {
  position: fixed;
  left: calc(var(--gap) + env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  width: var(--bar-h);
  padding: 12px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: calc(var(--bar-h) / 2);
  z-index: 10;
}
.side .btn { width: 38px; height: 38px; }
.side .btn svg { width: 20px; height: 20px; }
.side-gap { height: 8px; }

.slider {
  position: relative;
  width: 38px;
  height: 196px;
  cursor: ns-resize;
  touch-action: none;
}
.slider.short { height: 148px; }
.slider .track {
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  width: 4px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--raised-2);
  overflow: hidden;
}
.slider .fill-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ink-2);
  border-radius: 2px;
}
.slider .thumb {
  position: absolute;
  left: 50%;
  width: 26px;
  height: 14px;
  margin-left: -13px;
  margin-top: -7px;
  border-radius: 7px;
  background: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  transition: transform .12s var(--ease);
}
.slider.is-dragging .thumb { transform: scale(1.12); }
.slider .bubble {
  position: absolute;
  left: 52px;
  margin-top: -16px;
  height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  background: var(--chrome-solid);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: var(--t-title);
  font-weight: 550;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
  pointer-events: none;
}
.slider .bubble small { font-size: var(--t-cap); color: var(--ink-2); font-weight: 450; }
.slider.is-dragging .bubble { opacity: 1; transform: none; }

.readout {
  font-size: var(--t-cap);
  color: var(--ink-3);
  line-height: 1;
  margin: 6px 0 10px;
}

.btn-modify {
  border-radius: 12px !important;
  background: var(--raised);
  margin: 0 0 12px;
}

/* ---------- Panels ---------- */

.panel {
  position: fixed;
  top: calc(var(--gap) + var(--bar-h) + 8px + env(safe-area-inset-top));
  right: calc(var(--gap) + env(safe-area-inset-right));
  max-height: calc(100% - var(--bar-h) - var(--gap) * 2 - 8px);
  display: flex;
  flex-direction: column;
  background: var(--chrome-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  z-index: 20;
  transform-origin: top right;
  animation: panel-in .18s var(--ease);
}
.panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } }

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px 18px;
}
.panel-title {
  margin: 0;
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: .005em;
  margin-right: auto;
}

/* ---------- Brush library ---------- */

.panel-brushes { width: 468px; height: 640px; }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  width: 196px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--raised);
  color: var(--ink-3);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  border: 0;
  outline: 0;
  background: none;
  width: 100%;
  font-size: var(--t-body);
  color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }
.search:focus-within { box-shadow: 0 0 0 1px var(--line-strong); }

.brush-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 150px 1fr;
  border-top: 1px solid var(--line);
}
.sets {
  overflow-y: auto;
  padding: 8px 6px 12px 8px;
  border-right: 1px solid var(--line);
}
.set {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--ink-2);
  text-align: left;
}
.set:hover { color: var(--ink); background: var(--raised); }
.set.is-on { color: var(--ink); background: var(--raised-2); font-weight: 550; }
.set .count { font-size: var(--t-cap); color: var(--ink-3); font-weight: 450; }
.sets .rule { height: 1px; background: var(--line); margin: 6px 6px; }

.brush-list { overflow-y: auto; padding: 8px 10px 12px; }
.brush {
  position: relative;
  width: 100%;
  display: block;
  padding: 10px 12px 6px;
  margin-bottom: 4px;
  border-radius: var(--r-row);
  text-align: left;
  color: var(--ink);
}
.brush:hover { background: var(--raised); }
.brush.is-on { background: var(--raised-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.brush-name { display: block; font-weight: 500; }
.brush canvas { display: block; width: 100%; height: 46px; margin-top: 2px; }
.empty-note { color: var(--ink-2); padding: 14px 12px; margin: 0; }

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

.panel-color { width: 340px; }
.swap {
  width: 52px;
  height: 28px;
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  cursor: pointer;
}
.swap span { flex: 1; }
.swap-cur { background: var(--paint); }

.color-mode { padding: 2px 18px 6px; }
.disc-wrap { position: relative; width: 280px; height: 280px; margin: 0 auto; touch-action: none; }
.disc { width: 280px; height: 280px; display: block; }
.ring-knob, .sb-knob {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .4);
  pointer-events: none;
}
.sb-knob { width: 26px; height: 26px; margin: -13px 0 0 -13px; }

.values {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.6fr;
  gap: 6px;
  margin-top: 14px;
}
.val {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--raised);
}
.val em { font-style: normal; color: var(--ink-3); font-size: var(--t-cap); }
.val b { font-weight: 500; }

.swatch-block { padding: 12px 18px 0; }
.swatch-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  font-size: var(--t-cap);
  color: var(--ink-2);
  margin-bottom: 6px;
}
.swatches {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}
.sw {
  aspect-ratio: 1;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.sw:hover { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); }
.sw.is-on { box-shadow: 0 0 0 2px var(--chrome-solid), 0 0 0 3.5px var(--ink); }
.sw.empty { background: transparent; box-shadow: none; border: 1px dashed rgba(255, 255, 255, .13); }

.segmented {
  display: flex;
  gap: 2px;
  margin: 16px 12px 12px;
  padding: 3px;
  border-radius: 11px;
  background: var(--raised);
}
.segmented button {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 12.5px;
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-on { background: var(--on); color: var(--on-ink); font-weight: 550; }

/* ---------- Layers ---------- */

.panel-layers { width: 320px; right: calc(var(--gap) + 48px + env(safe-area-inset-right)); }
.layers {
  list-style: none;
  margin: 0;
  padding: 0 8px 10px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.layer {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 10px 0 6px;
  border-radius: var(--r-row);
  cursor: pointer;
}
.layer:hover { background: var(--raised); }
.layer.is-on { background: var(--on); color: var(--on-ink); }
.thumb {
  width: 52px;
  height: 40px;
  border-radius: 5px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e6e6e6 25%, transparent 25%),
    linear-gradient(-45deg, #e6e6e6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e6e6 75%),
    linear-gradient(-45deg, transparent 75%, #e6e6e6 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.layer .thumb.solid { background-image: none; }
.layer-name { display: block; font-weight: 500; }
.layer-meta { display: block; font-size: var(--t-cap); color: var(--ink-2); margin-top: 2px; }
.layer.is-on .layer-meta { color: #5c5c5c; }
.layer.is-hidden .layer-name, .layer.is-hidden .layer-meta { color: var(--ink-3); }
.layer.is-hidden .thumb { opacity: .55; }
.vis {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1.5px var(--ink-3);
}
.vis svg { width: 16px; height: 16px; stroke-width: 2.2; opacity: 0; }
.vis.is-on { background: var(--ink); box-shadow: none; color: var(--on-ink); }
.vis.is-on svg { opacity: 1; }
.layer.is-on .vis.is-on { background: var(--on-ink); color: var(--on); }
.layer.is-on .vis { box-shadow: inset 0 0 0 1.5px #8a8a8a; }

/* ---------- Smoothing ---------- */

.side .btn-smooth { margin: 2px 0 0; }
.side .btn-smooth.is-off { color: var(--ink-3); }
.panel-smooth {
  width: 300px;
  left: calc(var(--gap) + var(--bar-h) + 12px + env(safe-area-inset-left));
  right: auto;
  transform-origin: left center;
}
.smooth-val { font-size: var(--t-title); font-weight: 550; }
.smooth-body { padding: 4px 18px 16px; }
.hslider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  touch-action: none;
}
.hslider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(var(--ink-2), var(--ink-2)) 0 / var(--fill, 25%) 100% no-repeat, var(--raised-2); }
.hslider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--raised-2); }
.hslider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ink-2); }
.hslider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.hslider::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--ink); }
.seg-sm { margin: 12px 0 0; }
.hint { margin: 12px 0 0; font-size: 12px; line-height: 1.45; color: var(--ink-2); }

/* ---------- Notice ---------- */

.notice {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--chrome-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  color: var(--ink);
  z-index: 30;
  line-height: 1.45;
}

/* ---------- Tooltip ---------- */

.tip {
  position: fixed;
  z-index: 40;
  height: 26px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .12s var(--ease), transform .12s var(--ease);
}
.tip.is-shown { opacity: 1; transform: none; }

/* ---------- Smaller tablets ---------- */

@media (max-height: 860px) {
  .slider { height: 168px; }
  .slider.short { height: 124px; }
  .panel-brushes { height: calc(100% - var(--bar-h) - var(--gap) * 2 - 8px); }
  .disc-wrap, .disc { width: 248px; height: 248px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Brand: nib mark in the top bar, launch splash ---------- */
.brand-mark { width: 30px; height: var(--btn); display: grid; place-items: center; color: var(--ink); margin: 0 2px 0 6px; flex: none; }
.brand-mark svg { width: 16px; height: 26px; display: block; stroke: none; }
.dc-splash { position: fixed; inset: 0; z-index: 1000; background: #000; display: grid; place-items: center; transition: opacity .6s var(--ease); }
.dc-splash img { width: min(62vw, 400px); height: auto; }
.dc-splash.out { opacity: 0; pointer-events: none; }
