/* ============================================================
   PAINT RACK — "The Painter's Workbench"
   A hobby desk at night: matte charcoal surface, brass fittings,
   cards that pour their pigment over the edge.
   Display: Fraunces · UI: Figtree
   ============================================================ */

:root {
  --desk: #171310;          /* the desk mat */
  --desk-deep: #100d0b;
  --panel: #211c17;         /* raised wood/leather panel */
  --panel-2: #2a241d;
  --line: #372f26;          /* seams & stitching */
  --ink: #efe7da;           /* warm off-white text */
  --ink-dim: #a99e8d;
  --brass: #d9a441;         /* varnish amber / brass */
  --brass-deep: #a87a25;
  --danger: #c65b3f;
  --radius: 14px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(217, 164, 65, 0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(198, 91, 63, 0.05), transparent 55%),
    var(--desk);
  min-height: 100vh;
}
/* grain overlay — the tooth of the desk mat */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
header, main, dialog, .toast { position: relative; z-index: 2; }

/* ---------------- header ---------------- */
header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--desk-deep) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px 12px;
}
.brandline { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 640;
  font-size: 1.55rem;
  letter-spacing: 0.01em;
  font-variation-settings: "SOFT" 40, "WONK" 1;
}
h1 .drop { color: var(--brass); }
.stats {
  color: var(--ink-dim);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 4px;
}
.user-area { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--ink-dim); }
.user-area img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--brass-deep); }
.user-area button { background: none; border: none; color: var(--brass); cursor: pointer; font-size: 0.85rem; padding: 0; font-family: inherit; }
.user-area button:hover { text-decoration: underline; }

.toolbar { display: flex; gap: 10px; }
#search {
  flex: 1; padding: 12px 18px; font-size: 1rem;
  font-family: var(--font-body);
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search::placeholder { color: #7c7264; }
#search:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.18);
}
.btn {
  padding: 10px 18px; font-size: 0.92rem; cursor: pointer;
  font-family: var(--font-body); font-weight: 600;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--brass); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--brass), var(--brass-deep));
  border-color: var(--brass-deep);
  color: #241a08;
}
.btn.primary:hover { filter: brightness(1.08); }

/* chips: little hang-tags on a wire */
.filters { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; align-items: center; }
.chiprow { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  position: relative;
  padding: 4px 13px 4px 20px; font-size: 0.8rem; cursor: pointer; user-select: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px 999px 999px 4px;
  color: var(--ink-dim);
  transition: all 0.15s;
}
.chip::before {  /* the hole punch */
  content: ""; position: absolute; left: 7px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--desk); box-shadow: inset 0 0 0 1px var(--line);
}
.chip:hover { color: var(--ink); border-color: var(--brass-deep); }
.chip.active { background: var(--brass); border-color: var(--brass); color: #241a08; font-weight: 700; }
.chip.active::before { box-shadow: inset 0 0 0 1px var(--brass-deep); }
.owned-toggle { font-size: 0.85rem; color: var(--ink-dim); display: flex; gap: 7px; align-items: center; cursor: pointer; }
.owned-toggle input { accent-color: var(--brass); }

/* ---------------- main / grid ---------------- */
main { padding: 26px 22px 60px; max-width: 1440px; margin: 0 auto; }

.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brass);
  border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 22px;
  line-height: 1.5;
}
.notice b { color: var(--brass); }

.grid { display: flex; flex-direction: column; gap: 34px; }

/* search results the user doesn't own: present, but clearly set apart */
.catalog-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 6px 0 -16px;
  color: var(--ink-dim); font-size: 0.76rem; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; white-space: nowrap;
}
.catalog-divider::before, .catalog-divider::after {
  content: ""; height: 1px; flex: 1;
  background: linear-gradient(90deg, transparent, var(--brass-deep), transparent);
}
.card.not-owned { border-style: dashed; }
.card.not-owned .pour { filter: saturate(0.72) brightness(0.82); }
.card.not-owned:hover .pour { filter: none; transition: filter 0.2s; }
.card.not-owned h3 { color: var(--ink-dim); }
.card.not-owned:hover h3 { color: var(--ink); }

/* ---------- brand shelves ---------- */
.shelf-grid {
  display: grid; gap: 20px 16px;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.shelf-rail {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
  padding: 7px 10px;
  border-radius: 8px;
  /* walnut rail with a worn top edge */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 35%),
    linear-gradient(90deg, #34271b, #453626 35%, #34271b 90%);
  border: 1px solid #4a3a27;
  border-bottom-width: 3px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}
.shelf-plate {
  font-family: var(--font-display);
  font-weight: 640;
  font-size: 1.05rem;
  color: #241a08;
  background: linear-gradient(180deg, #e8bc63, var(--brass) 55%, var(--brass-deep));
  border: 1px solid var(--brass-deep);
  border-radius: 5px;
  padding: 2px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 3px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.01em;
}
.shelf-count {
  color: #8d7c62;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* ---------- the paint card: a pour of pigment ---------- */
.card {
  --paint: #888;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: visible;
  transition: transform 0.18s ease, border-color 0.18s, box-shadow 0.18s;
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--paint) 55%, var(--line));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.card.owned { border-color: color-mix(in srgb, var(--brass) 45%, var(--line)); }

.pour {
  position: relative;
  height: 84px;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 42%),
    var(--paint);
}
/* Translucent one-coat paints (contrast / speedpaint / wash / shade): the
   swatch sweeps the range one coat covers — thin highlight → pooled shade. */
.pour.range {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0) 42%),
    linear-gradient(105deg, var(--paint-hi) 0%, var(--paint-hi) 8%, var(--paint) 52%, var(--paint-lo) 96%);
}
/* Metallics: a specular sheen band. */
.pour.metal {
  background:
    linear-gradient(115deg, var(--paint-lo) 0%, var(--paint) 30%, var(--paint-hi) 47%, var(--paint) 60%, var(--paint-lo) 100%);
}
.range-marks {
  /* right inset clears the bottle artwork parked in the corner */
  position: absolute; left: 9px; right: 56px; bottom: 5px;
  display: flex; justify-content: space-between;
  font-size: 0.56rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}
.range-marks i { font-style: normal; }
/* the drips — kept short so they never reach the label text */
.pour::before, .pour::after {
  content: ""; position: absolute; top: 100%;
  width: 9px; background: var(--paint);
  border-radius: 0 0 99px 99px;
  filter: brightness(0.94);
}
.pour.range::before, .pour.range::after { background: var(--paint-lo); filter: none; }
.pour::before { left: 18%; height: 11px; }
.pour::after  { left: 32%; height: 6px; width: 6px; }
.card:nth-child(3n) .pour::before { left: 58%; height: 9px; }
.card:nth-child(4n) .pour::after  { left: 74%; height: 12px; }
.card:hover .pour::before { height: 14px; transition: height 0.35s ease; }

.pour .bottle {
  position: absolute; right: 10px; bottom: -8px;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
}
.pour img.bottle { object-fit: contain; }

/* favourite star, floating on the swatch */
.fav-star {
  position: absolute; right: 8px; top: 8px;
  width: 27px; height: 27px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 13, 7, 0.55); backdrop-filter: blur(2px);
  border: 1px solid rgba(0, 0, 0, 0.4);
  color: rgba(243, 234, 215, 0.9);
  font-size: 0.95rem; line-height: 1; padding: 0; cursor: pointer;
  opacity: 0; transition: opacity 0.15s, color 0.15s, transform 0.15s;
}
.card:hover .fav-star { opacity: 1; }
.fav-star:hover { transform: scale(1.15); color: #ffd76a; }
.fav-star.on {
  opacity: 1; color: #ffd76a; border-color: var(--brass-deep);
  text-shadow: 0 0 7px rgba(255, 200, 80, 0.55);
}
.fav-star.static { cursor: default; }
@media (hover: none) { .fav-star { opacity: 0.85; } }

.owned-tag {
  position: absolute; left: 10px; top: 10px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em;
  background: var(--desk-deep); color: var(--brass);
  border: 1px solid var(--brass-deep);
  padding: 2px 9px; border-radius: 999px;
}

.card-body { padding: 18px 14px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.06rem;
  line-height: 1.22;
  letter-spacing: 0.005em;
}
.card .meta {
  color: var(--ink-dim); font-size: 0.76rem;
  display: flex; gap: 7px; flex-wrap: wrap; align-items: center;
}
.badge {
  font-size: 0.64rem; font-weight: 700; padding: 2px 8px; border-radius: 3px;
  background: var(--panel-2); border: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-dim);
}
/* one-coat types carry a sliver of their own range */
.badge-range {
  background:
    linear-gradient(105deg, var(--paint-hi), var(--paint), var(--paint-lo)) bottom / 100% 2px no-repeat,
    var(--panel-2);
  padding-bottom: 3px;
}
.card-actions { display: flex; gap: 6px; margin-top: auto; align-items: center; padding-top: 6px; position: relative; }
.card-menu {
  position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 20;
  display: flex; flex-direction: column; min-width: 172px;
  background: var(--desk-deep); border: 1px solid var(--brass-deep); border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.card-menu button {
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 9px 14px; color: var(--ink); font-family: var(--font-body); font-size: 0.85rem;
}
.card-menu[hidden] { display: none; }
.card-menu button:hover { background: var(--panel-2); color: var(--brass); }
.card-menu button + button { border-top: 1px solid var(--line); }
.mini.shop.on { color: var(--brass); border-color: var(--brass-deep); }
.shop-count {
  display: inline-block; margin-left: 5px;
  min-width: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--brass); color: #241a08;
  font-size: 0.68rem; font-weight: 800; line-height: 17px; text-align: center;
}
.qty { font-weight: 700; min-width: 3em; text-align: center; font-size: 0.9rem; color: var(--ink-dim); }
.qty .owned-label { color: var(--brass); }
.mini {
  padding: 4px 11px; font-size: 0.85rem; cursor: pointer;
  font-family: var(--font-body); font-weight: 600;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  transition: border-color 0.15s;
}
.mini:hover { border-color: var(--brass); }
.mini.alt { margin-left: auto; color: var(--ink-dim); }
.mini.alt:hover { color: var(--brass); }

/* ---------------- dialogs ---------------- */
dialog {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  max-width: 580px; width: calc(100vw - 40px); padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(10, 8, 6, 0.72); backdrop-filter: blur(3px); }
dialog h2 {
  margin: 0 0 12px;
  font-family: var(--font-display); font-weight: 640; font-size: 1.45rem;
}
dialog input, dialog select {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  font-family: var(--font-body); font-size: 0.95rem;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
}
dialog input:focus, dialog select:focus { outline: none; border-color: var(--brass); }
dialog form label { display: block; margin-bottom: 12px; font-size: 0.85rem; color: var(--ink-dim); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.hint { color: var(--ink-dim); font-size: 0.87rem; line-height: 1.5; }
code { color: var(--brass); font-size: 0.95em; }

#camera-video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 4/3; object-fit: cover; }

.match-results, .alt-list { display: flex; flex-direction: column; gap: 7px; max-height: 330px; overflow-y: auto; margin-top: 12px; }
.match-row, .alt-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.match-row { cursor: pointer; transition: border-color 0.12s, transform 0.12s; }
.match-row:hover { border-color: var(--brass); transform: translateX(3px); }
.dot { width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.45); box-shadow: inset 0 6px 8px -4px rgba(255,255,255,0.25); }
.match-row .info, .alt-row .info { flex: 1; min-width: 0; }
.match-row .info b, .alt-row .info b { display: block; font-size: 0.92rem; font-family: var(--font-display); font-weight: 560; }
.match-row .info span, .alt-row .info span { color: var(--ink-dim); font-size: 0.77rem; }
.alt-row .dist { font-size: 0.78rem; color: var(--ink-dim); white-space: nowrap; text-align: right; }
.alt-row .dist b { color: var(--brass); font-size: 0.95rem; }
#alt-target .alt-row { border-color: var(--brass-deep); margin-bottom: 10px; }
.alt-head {
  margin: 10px 0 2px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--ink-dim);
  display: flex; justify-content: space-between; align-items: baseline;
}
.alt-head span { font-weight: 400; letter-spacing: 0.03em; text-transform: none; font-size: 0.7rem; }
.dot.split { width: 46px; border-radius: 8px; }
.alt-row .info i { font-style: normal; }
.alt-row .info i.type-match { color: var(--brass); font-weight: 600; }

.auth-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color 0.15s, transform 0.1s;
}
.auth-btn:hover { border-color: var(--brass); transform: translateY(-1px); }

/* Official brand sign-in buttons */
.auth-btn.github { background: #24292f; color: #fff; border-color: #24292f; }
.auth-btn.github:hover { background: #2f363d; border-color: #444c56; }
.auth-btn.google { background: #fff; color: #3c4043; border-color: #dadce0; }
.auth-btn.google:hover { background: #f8f9fa; border-color: #d2e3fc; }
.auth-btn svg { flex-shrink: 0; }

/* ---------------- profile ---------------- */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: 3px 10px 3px 3px; cursor: pointer;
  color: var(--ink-dim); font-size: 0.85rem; font-family: inherit;
  transition: border-color 0.15s;
}
.user-chip:hover { border-color: var(--brass-deep); color: var(--ink); text-decoration: none; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--brass-deep); }
.profile-id {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  color: var(--ink-dim); font-size: 0.85rem;
}
.profile-id img { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--brass-deep); }
.profile-id b { color: var(--ink); }
.game-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 12px; }
.chip.game::before { display: none; }
.chip.game { padding-left: 12px; }
.game-other { display: flex; gap: 8px; margin-bottom: 6px; }
.game-other input { flex: 1; margin-top: 0; }
.game-other .btn { flex-shrink: 0; }
#profile-form label > .hint { display: block; margin-top: 4px; font-size: 0.78rem; }

/* ---------------- sharing ---------------- */
.share-row { display: flex; gap: 8px; margin: 6px 0 12px; }
.share-row input { flex: 1; margin-top: 0; font-size: 0.8rem; color: var(--ink-dim); }
.share-row .btn { flex-shrink: 0; }
.share-mode .user-area { font-size: 0.95rem; color: var(--ink); }
.share-mode .user-area img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--brass-deep); }
.share-mode .user-area b { color: var(--brass); }

/* ---------------- sets ---------------- */
.set-detail-head { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.set-detail-head b { flex: 1; font-family: var(--font-display); font-size: 1.02rem; }
.set-tools { display: flex; gap: 6px; }
.set-row { cursor: pointer; }
.set-row input { width: auto; margin: 0; accent-color: var(--brass); flex-shrink: 0; }
.set-paints { max-height: 380px; }

/* ---------------- scan flash ---------------- */
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 200; opacity: 0; }
.dialog-flash { position: absolute; inset: 0; pointer-events: none; z-index: 5; opacity: 0; border-radius: inherit; }
.dialog-flash.ok {
  background: radial-gradient(ellipse at center, rgba(72, 205, 110, 0.22), rgba(34, 160, 76, 0.5));
  animation: flash 0.55s ease-out;
}
.dialog-flash.warn {
  background: radial-gradient(ellipse at center, rgba(224, 141, 48, 0.2), rgba(197, 84, 32, 0.48));
  animation: flash 0.65s ease-out;
}
#flash.ok {
  background: radial-gradient(ellipse at center, rgba(72, 205, 110, 0.22), rgba(34, 160, 76, 0.5));
  animation: flash 0.55s ease-out;
}
#flash.warn {
  background: radial-gradient(ellipse at center, rgba(224, 141, 48, 0.2), rgba(197, 84, 32, 0.48));
  animation: flash 0.65s ease-out;
}
@keyframes flash {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--desk-deep); border: 1px solid var(--brass-deep);
  padding: 11px 22px; border-radius: 999px; z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  font-size: 0.92rem;
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.toast b { color: var(--brass); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 640px) {
  .toolbar { flex-wrap: wrap; }
  #search { min-width: 100%; }
  .brandline { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  * { transition: none !important; }
}
