/**
 * Copyright (c) 2026 KDTech
 * Author: david@KDTech
 * All rights reserved.
 *
 * Tilefold website — tiles and themes
 *
 * The extension story: a board of tile slots that lights up in a ripple when
 * a sample tile is installed, the sample-tile catalog, the two-file code card,
 * and the theme switcher whose new palette is revealed in a growing circle
 * from the swatch that was clicked.
 */

/* ---------- Tile kinds ---------- */

.kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.kinds li {
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.03);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Board ---------- */

.tiles-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
  margin-block-start: 56px;
}

.board {
  --cols: 8;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg), var(--highlight);
}

.slot {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  background: rgb(255 255 255 / 0.025);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
}

/* A ripple pass: each slot lights after a delay proportional to its distance. */
.slot.is-lit {
  animation: slot-light 700ms var(--ease-out);
  animation-delay: var(--delay, 0ms);
}

@keyframes slot-light {
  30% {
    background: rgb(124 92 255 / 0.35);
    box-shadow:
      inset 0 0 0 1px rgb(34 211 238 / 0.7),
      0 0 24px rgb(124 92 255 / 0.45);
    transform: scale(1.06);
  }
}

.slot.is-filled {
  display: grid;
  place-items: center;
  background: var(--slot-bg, var(--aurora));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.3),
    0 10px 24px -8px rgb(0 0 0 / 0.6);
  animation: slot-drop 650ms var(--ease-spring);
}

.slot.is-filled svg {
  width: 52%;
  height: 52%;
  color: #0a0b10;
}

@keyframes slot-drop {
  from {
    transform: translateY(-18px) rotate(-12deg) scale(0.6);
    opacity: 0;
  }
}

/* ---------- Catalog ---------- */

.catalog {
  display: grid;
  gap: 10px;
  align-content: start;
}

.tile-item {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.02);
  text-align: start;
  cursor: pointer;
  transition:
    border-color 200ms,
    background 200ms,
    transform 200ms var(--ease-out);
}

.tile-item:hover {
  border-color: var(--line-strong);
  background: rgb(255 255 255 / 0.045);
  transform: translateY(-1px);
}

.tile-item .ti-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--slot-bg);
  color: #0a0b10;
}

.tile-item .ti-icon svg {
  width: 22px;
  height: 22px;
}

.tile-item b {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.tile-item small {
  display: block;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.ti-state {
  padding: 6px 12px;
  border-radius: 9px;
  background: var(--text-1);
  color: var(--ink-1);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tile-item[aria-pressed="true"] .ti-state {
  background: rgb(61 220 151 / 0.14);
  color: var(--ok);
}

/* ---------- Code card ---------- */

.code-card {
  grid-column: 1 / -1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  background: #090a0f;
  box-shadow: var(--shadow-lg), var(--highlight);
}

.code-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-block-end: 1px solid var(--line);
}

.code-tabs button {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  cursor: pointer;
}

.code-tabs button[aria-selected="true"] {
  background: rgb(255 255 255 / 0.06);
  color: var(--text-1);
}

.code-tabs .hint {
  margin-inline-start: auto;
  align-self: center;
  color: var(--text-3);
  font-size: 12px;
}

.code-card pre {
  margin: 0;
  padding: 22px 24px;
  overflow-x: auto;
  color: #d5d8e6;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
}

.code-card pre[hidden] {
  display: none;
}

.tok-k {
  color: #c4a7ff;
}

.tok-s {
  color: #7ee0c3;
}

.tok-f {
  color: #7cc7ff;
}

.tok-c {
  color: #5d637a;
  font-style: italic;
}

.tok-n {
  color: var(--amber);
}

/* ---------- Build your own (Tile Tools) ---------- */

.build-card {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px 40px;
  padding: 28px 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  background: var(--aurora-soft);
  box-shadow: var(--highlight);
}

.build-copy {
  flex: 1 1 420px;
}

.build-copy h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.build-copy p {
  margin: 8px 0 0;
  color: var(--text-2);
  line-height: 1.6;
}

.build-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.build-examples a {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgb(10 11 16 / 0.5);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12.5px;
  transition:
    color 150ms,
    border-color 150ms;
}

.build-examples a:hover {
  border-color: rgb(255 255 255 / 0.3);
  color: var(--text-1);
}

.build-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Themes ---------- */

.theme-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
}

.theme-view {
  --t-bg: #0c0d13;
  --t-panel: #11131b;
  --t-fg: #e8eaf4;
  --t-dim: #6e7590;
  --t-accent: #7c5cff;
  --t-accent-2: #22d3ee;
  --t-ok: #3ddc97;
  padding: 22px;
  background: var(--t-bg);
  color: var(--t-fg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
}

/* The incoming theme, clipped to a circle that grows from the swatch. */
.theme-view.is-incoming {
  position: absolute;
  inset: 0;
  clip-path: circle(0 at var(--rx, 50%) var(--ry, 50%));
}

.theme-view.is-incoming.is-revealing {
  clip-path: circle(var(--rr, 150%) at var(--rx, 50%) var(--ry, 50%));
  transition: clip-path 720ms var(--ease-emph);
}

.tv-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-end: 18px;
  color: var(--t-dim);
  font-size: 12px;
}

.tv-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--t-dim);
  opacity: 0.6;
}

.tv-bar b {
  margin-inline-start: 10px;
  color: var(--t-fg);
  font-weight: 500;
}

.tv-block {
  margin-block-end: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border-inline-start: 3px solid var(--t-ok);
  background: var(--t-panel);
}

.tv-block.run {
  border-inline-start-color: var(--t-accent-2);
}

.tv-prompt {
  color: var(--t-accent);
}

.tv-dim {
  color: var(--t-dim);
}

.tv-ok {
  color: var(--t-ok);
}

.tv-acc {
  color: var(--t-accent-2);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-block-start: 28px;
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.03);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 200ms,
    color 200ms,
    transform 200ms var(--ease-out);
}

[dir="rtl"] .swatch {
  padding: 8px 8px 8px 14px;
}

.swatch:hover {
  transform: translateY(-1px);
  color: var(--text-1);
}

.swatch[aria-pressed="true"] {
  border-color: rgb(255 255 255 / 0.35);
  color: var(--text-1);
}

.swatch i {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2);
}

.theme-wrap {
  max-width: 860px;
  margin-inline: auto;
}

@media (max-width: 900px) {
  .tiles-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .board {
    --cols: 6;
  }
}
