/**
 * The icon gallery: sidebar filters, icon grid and cards.
 */

/* ============ Layout ============ */
.layout {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: calc(100vh - var(--nav-h));
}

/* ============ Sidebar ============ */
.sidebar {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: var(--s-24) var(--s-16) var(--s-32) var(--s-24);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sidebar__head { display: none; }

.panel { padding-bottom: var(--s-24); margin-bottom: var(--s-24); border-bottom: 1px solid var(--line); }
.panel:last-child { border-bottom: 0; }
.panel__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-8);
  margin: 0 0 var(--s-12);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel__hint { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; opacity: 0.85; }

/* styles */
.styles { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-8); }
.styles__indicator {
  position: absolute;
  top: 0; left: 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
  transition: transform 0.5s var(--ease-out), width 0.5s var(--ease-out), height 0.5s var(--ease-out);
  pointer-events: none;
}
.style-tile {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: var(--s-8) var(--s-4);
  padding: var(--s-12);
  border-radius: 12px;
  border: 1px solid var(--line);
  text-align: left;
  color: var(--muted);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.style-tile:hover { color: var(--ink); border-color: var(--line-strong); }
.style-tile[aria-checked='true'] { color: var(--ink); border-color: transparent; }
.style-tile--all { grid-column: 1 / -1; grid-template-columns: auto 1fr auto; grid-template-rows: auto; align-items: center; gap: var(--s-8); }
.style-tile__glyph { width: 24px; height: 24px; color: var(--ink); }
.style-tile__glyph svg { width: 100%; height: 100%; overflow: visible; }
.style-tile[aria-checked='true'] .style-tile__glyph { color: var(--accent); }
.style-tile__count { font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; opacity: 0.8; justify-self: end; }
.style-tile__name { grid-column: 1 / -1; font-size: var(--fs-xs); line-height: 16px; letter-spacing: -0.01em; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.style-tile--all .style-tile__name { grid-column: auto; order: 1; }
.style-tile--all .style-tile__count { order: 2; }
.style-tile[data-empty] { opacity: 0.45; }

/* categories */
.cats { position: relative; display: flex; flex-direction: column; gap: 2px; }
.cats__indicator {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.5s var(--ease-out), height 0.5s var(--ease-out);
  pointer-events: none;
}
.cat {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 var(--s-12) 0 var(--s-8);
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  transition: color 0.25s;
}
.cat:hover { color: var(--ink); }
.cat[aria-checked='true'] { color: var(--ink); }
.cat__glyph {
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  transition: background 0.25s, color 0.25s;
}
.cat__glyph svg { width: 16px; height: 16px; }
.cat:hover .cat__glyph { background: var(--surface-3); }
.cat[aria-checked='true'] .cat__glyph { background: var(--accent); color: var(--on-accent); }
.cat__name { flex: 1; }
.cat__count {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: 0.8;
}

/* adjust */
.field { margin-bottom: var(--s-16); }
.field__row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s-8); font-size: var(--fs-xs); font-weight: 500; }
.field output { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }

.range {
  --pct: 50%;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) var(--pct), var(--line) var(--pct));
}
.range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--line); }
.range::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: transform 0.3s var(--ease-spring);
}
.range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.range:hover::-webkit-slider-thumb { transform: scale(1.12); }
.range:active::-webkit-slider-thumb { transform: scale(1.25); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--accent-soft); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.35s var(--ease-spring);
}
.swatch::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.25s, transform 0.4s var(--ease-spring);
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-checked='true']::after { opacity: 1; transform: scale(1); }
.swatch--inherit {
  background: conic-gradient(var(--ink) 0 50%, var(--surface) 0 100%);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.swatch--custom {
  background: conic-gradient(#ff5d73, #ffb648, #3ddc97, #4fb3ff, #a78bfa, #ff5d73);
  overflow: visible;
}
.swatch--custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

.reset {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  padding: var(--s-8) 0;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: color 0.2s, background-size 0.35s var(--ease-out);
}
.reset:hover { color: var(--ink); background-size: 100% 1px; }

.scrim { display: none; }

/* ============ Main ============ */
.main {
  position: relative;
  padding: var(--s-32) var(--s-32) var(--s-80);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}
.toolbar {
  position: sticky;
  top: var(--nav-h);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-8);
  margin: calc(var(--s-32) * -1) calc(var(--s-32) * -1) var(--s-24);
  padding: var(--s-12) var(--s-32);
  background: var(--nav-bg);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
}
.toolbar .nav__count { margin-left: auto; }
.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-16);
  margin-bottom: var(--s-24);
}
.head__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.035em;
  line-height: 1.25;
}
.head__title.swap { animation: titleSwap 0.5s var(--ease-out); }
@keyframes titleSwap {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
}
.head__sub { margin: var(--s-8) 0 0; color: var(--muted); }
.head__sub b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.head__clear {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  height: 32px;
  padding: 0 var(--s-12);
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface);
  animation: pop 0.4s var(--ease-spring);
  transition: color 0.2s, border-color 0.2s;
}
.head__clear svg { width: 16px; height: 16px; transition: transform 0.4s var(--ease-spring); }
.head__clear:hover { color: var(--ink); border-color: var(--line-strong); }
.head__clear:hover svg { transform: rotate(90deg); }

/* ============ Grid + cards ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s-16);
}

.card {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--s-8);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  animation: rise 0.6s var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 18ms);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.25s;
}
.card:hover, .card:focus-within {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
}

.card__stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
}
.card__glyph {
  position: relative;
  width: var(--glyph);
  height: var(--glyph);
  color: var(--icon-color);
}
.card__glyph svg { width: 100%; height: 100%; overflow: visible; }
/* stroke slider applies to icons drawn with strokes */
.tuned .card[data-stroked] .card__glyph svg { stroke-width: var(--stroke); }

/* the whole card opens the detail dialog; this button makes that reachable by keyboard */
.card__open {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  cursor: pointer;
}
.card__open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card { cursor: pointer; }
.copy { z-index: 1; }

/* style label, shown when browsing all styles */
.card__style {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 1;
  display: none;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-8);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 16px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: color 0.3s, border-color 0.3s;
}
.grid[data-all-styles] .card__style { display: inline-flex; }
.card:hover .card__style { color: var(--ink); }
.card__style svg { width: 8px; height: 8px; }

/* lift-off ghost when copied */
.ghost {
  position: absolute;
  width: var(--glyph);
  height: var(--glyph);
  color: var(--accent);
  pointer-events: none;
  animation: ghost 0.75s var(--ease-out) forwards;
}
.ghost svg { width: 100%; height: 100%; }
@keyframes ghost {
  0% { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-32px) scale(1.5); filter: blur(2px); }
}

.card__name {
  margin: var(--s-8) var(--s-4);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  transition: color 0.3s;
}
.card:hover .card__name { color: var(--ink); }
.card__name mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 1px;
}

/* copy button */
.copy {
  position: relative;
  overflow: hidden;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-8);
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background 0.3s, color 0.3s, border-color 0.3s, transform 0.25s var(--ease-spring), box-shadow 0.3s;
}
.copy:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 18px -8px var(--accent-glow);
}
.copy:active { transform: scale(0.95); }
.copy__icon { position: relative; width: 16px; height: 16px; flex-shrink: 0; }
.copy__icon svg { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform 0.45s var(--ease-spring), opacity 0.25s; }
.copy__check { opacity: 0; }
.copy__check path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.copy:hover .copy__clip { transform: translateY(-1px) rotate(-6deg); }

.copy__label { position: relative; height: 18px; overflow: hidden; display: inline-grid; }
.copy__label span { grid-area: 1 / 1; line-height: 18px; transition: transform 0.45s var(--ease-out), opacity 0.3s; }
.copy__label span:last-child { transform: translateY(110%); opacity: 0; }

.copy.is-copied { background: var(--success); border-color: var(--success); color: #fff; box-shadow: 0 8px 18px -8px var(--success); }
[data-theme='dark'] .copy.is-copied { color: #0a0a0a; }
.copy.is-copied .copy__clip { opacity: 0; transform: scale(0.4) rotate(-45deg); }
.copy.is-copied .copy__check { opacity: 1; }
.copy.is-copied .copy__check path { animation: draw 0.45s 0.08s var(--ease-out) forwards; }
.copy.is-copied .copy__label span:first-child { transform: translateY(-110%); opacity: 0; }
.copy.is-copied .copy__label span:last-child { transform: none; opacity: 1; }

.ripple {
  position: absolute;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  pointer-events: none;
  animation: ripple 0.6s var(--ease-out) forwards;
}
@keyframes ripple { to { transform: scale(26); opacity: 0; } }

/* ============ Empty state ============ */
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: var(--s-80) var(--s-24);
  animation: pop 0.5s var(--ease-out);
}
.empty__art {
  width: 96px; height: 96px;
  padding: var(--s-16);
  margin-bottom: var(--s-24);
  border-radius: 24px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
}
.empty__art svg { width: 100%; height: 100%; }
.empty__art svg { color: var(--accent); animation: breathe 3.2s var(--ease-glide) infinite alternate; }
.empty__title { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.empty__text { margin: var(--s-8) 0 var(--s-24); color: var(--muted); }
.empty__btn {
  height: 40px;
  padding: 0 var(--s-16);
  border-radius: 10px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 10px 24px -10px var(--accent-glow);
  transition: transform 0.3s var(--ease-spring);
}
.empty__btn:hover { transform: translateY(-2px); }
.empty__btn:active { transform: scale(0.96); }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  :root { --side-w: 256px; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 55;
    top: 0; left: 0; bottom: 0;
    width: min(320px, 86vw);
    height: 100%;
    padding-top: var(--s-16);
    background: var(--bg);
    border-right: 1px solid var(--line);
    box-shadow: 30px 0 60px -30px rgba(0, 0, 0, 0.4);
    transform: translateX(-104%);
    transition: transform 0.5s var(--ease-out);
  }
  .sidebar.open { transform: none; }
  .sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-16);
    font-family: var(--font-display);
    font-weight: 600;
  }
  .sidebar__close { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); }
  .sidebar__close svg { width: 16px; height: 16px; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    animation: fade 0.35s var(--ease-out);
  }
  @keyframes fade { from { opacity: 0; } }

  .main { padding: var(--s-24) var(--s-16) var(--s-80); }
  .toolbar { margin: calc(var(--s-24) * -1) calc(var(--s-16) * -1) var(--s-24); padding: var(--s-12) var(--s-16); }
  .toolbar .nav__count { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: var(--s-12); }
  :root { --glyph: 32px; }
}

@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--line); }
  .copy:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); box-shadow: none; }
}

/* ============ Plans: Pro styles show a lock until the visitor has Pro ============ */
.card__pro, .style-tile__pro { display: none; }
.copy__lock { opacity: 0; }
:root:not([data-pro]) .card[data-tier='pro'] .copy__clip { opacity: 0; }
:root:not([data-pro]) .card[data-tier='pro'] .copy__lock { opacity: 1; }
:root:not([data-pro]) .card[data-tier='pro'] .card__pro {
  display: inline;
  margin-left: 2px;
  padding-left: var(--s-4);
  border-left: 1px solid var(--line);
  font-weight: 500;
  color: var(--ink-2);
}
:root:not([data-pro]) .style-tile__pro {
  display: block;
  position: absolute;
  top: 16px;
  left: 44px; /* beside the sample icon, so it never squeezes the name */
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 14px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* signed-out visitors: today's free copies */
.head__quota {
  display: flex;
  align-items: center;
  gap: var(--s-8);
  margin: var(--s-8) 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.head__quota[hidden] { display: none; }
.head__quota b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.head__quota a { color: var(--ink); font-weight: 500; text-underline-offset: 3px; }
.head__meter {
  position: relative;
  flex-shrink: 0;
  width: 40px; height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}
.head__meter::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--ink);
  transform: scaleX(calc(1 - var(--used, 0)));
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}

/* "Pro" next to a control that comes with Pro (color) */
.plan-chip { display: none; }
:root:not([data-pro]) .plan-chip--pro {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 14px;
  font-weight: 500;
  vertical-align: 1px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  border: 1px solid var(--line);
}
