/* Ready-made components: gallery section, component pages, grid tiles, and the web ports. */

/* ---------- Gallery section ---------- */

.cp-grid { display: flex; align-items: flex-start; gap: 12px; }
/* Three columns need more than the text column: the grid breaks out of it, centered, up to 1240px. */
@media (min-width: 1400px) {
  .cp-grid { width: min(1240px, calc(100vw - var(--rail, 0px) - 48px)); position: relative; left: 50%; transform: translateX(-50%); }
}
/* Two columns filled left, right, left...: reading order stays row by row, heights stay natural. */
.cp-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.cp-panel {
  /* Masonry, Pinterest style: each card keeps its natural height, columns fill top to bottom. */
  position: relative; display: flex; flex-direction: column; min-width: 0;
  border-radius: 24px; background: var(--surface);
}
.cp-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 0 18px; border-radius: 24px 24px 0 0;
}
.cp-panel-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cp-name { font-size: 13px; line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; color: var(--muted); transition: color .2s; }
.cp-go {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  color: var(--faint); opacity: 0; transition: opacity .2s, color .2s, background .2s;
}
.cp-panel:hover .cp-go { opacity: 1; }
.cp-panel-head:hover .cp-go { color: var(--text); background: var(--wash); }
.cp-panel:hover .cp-name { color: var(--text); }
.cp-panel-body { flex: 1; min-height: 190px; padding: 24px 20px 32px; }

/* Every mounted demo body centers its component. A tile too small for one scales it down (fitTile). */
.cp-body { display: grid; place-items: center; }
.cp-fit { position: relative; flex: none; }
.cp-fit > * { position: absolute; left: 0; top: 0; }
.cp-mode-stage { width: 100%; max-width: 440px; }
.cp-stage { height: auto; min-height: 360px; }
.cp-stage .stage-slot { padding: 44px 24px 68px; }

/* ---------- Grid tiles ---------- */

.g-thumb-cp .stage-slot { padding: 16px; }

/* ---------- Toast ---------- */

.cp-toasts { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 2; max-width: none; margin: 0; --dissolve-muted: #8E8E93; }
.cp-toasts-fixed {
  position: fixed; top: calc(var(--top-h) + 10px); left: 50%; right: auto; z-index: 33;
  width: min(380px, calc(100vw - 24px)); transform: translateX(-50%);
}
:root:not([data-theme="light"]) .cp-toast { outline: 1px solid rgba(255, 255, 255, 0.09); outline-offset: -1px; }
.cp-btn {
  height: 44px; padding: 0 22px; border-radius: var(--pill);
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600;
  transition: transform .2s cubic-bezier(0.32, 0.72, 0, 1), opacity .2s;
}
.cp-btn:hover { opacity: .88; }
.cp-btn:active { transform: scale(0.97); opacity: .75; }
.cp-mode-tile.cp-is-toast { align-items: end; }
.cp-mode-tile.cp-is-toast .cp-btn { margin-bottom: 4px; }
.cp-mode-tile .cp-btn { height: 36px; padding: 0 18px; font-size: 13.5px; }

/* ---------- SwipeToDelete (the core brings the row, the action and the swipe) ---------- */

.cp-inbox { width: 100%; max-width: 440px; }
.cp-swipe { margin-bottom: 8px; }
.cp-swipe:last-child { margin-bottom: 0; }
.cp-swipe.grow {
  overflow: hidden;
  transition: height .28s cubic-bezier(0.32, 0.72, 0, 1), margin-bottom .28s cubic-bezier(0.32, 0.72, 0, 1);
}
.cp-swipe.gone { height: 0 !important; margin-bottom: 0; overflow: hidden; }
.cp-swipe-clip { border-radius: 18px; --dissolve-danger: #FF3B30; }
.cp-swipe-clip::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line); pointer-events: none; }
.cp-swipe-row { display: block; }
.cp-reset {
  display: block; margin: 12px auto 0; height: 32px; padding: 0 16px; border-radius: var(--pill);
  background: var(--wash); color: var(--text); font-size: 13px; font-weight: 600;
  transition: background .2s;
}
.cp-reset:hover { background: var(--wash-2); }
.cp-reset[hidden] { display: none; }

/* ---------- LikeButton (the core brings the heart, the sparks and the counter) ---------- */

.cp-like { padding: 4px; margin: -4px; border-radius: 10px; }
.cp-count { min-width: 3ch; text-align: left; }
.cp-like-lg { gap: 10px; }
.cp-like-lg .cp-count { font-size: 20px; }

/* ---------- MorphButton, GooeyMenu: the native #1C1C1E pill, inverted on the dark site so it still reads ---------- */

.cp-morph, .cp-goo-stage { --dissolve-primary: #F2F4F7; --dissolve-primary-foreground: #12151A; --dissolve-success: #34C759; }
[data-theme="light"] :is(.cp-morph, .cp-goo-stage) { --dissolve-primary: #1C1C1E; --dissolve-primary-foreground: #FFFFFF; }

.cp-morph { width: 100%; max-width: 320px; }
.cp-morph:focus-visible { border-radius: 26px; }
.cp-morph .dissolve-morph-done { color: #fff; }

/* ---------- SplitButton ---------- */

.cp-split {
  width: 100%; max-width: 340px;
  --dissolve-danger: #FF3B30; --dissolve-danger-foreground: #fff; --dissolve-surface-2: #2C2C2E; --dissolve-foreground: #F2F4F7;
}
[data-theme="light"] .cp-split { --dissolve-surface-2: #E9E9EB; --dissolve-foreground: #1C1C1E; }

/* ---------- GooeyMenu ---------- */

.cp-goo-stage { position: relative; display: grid; place-items: center; width: 100%; }
.cp-mode-tile .cp-goo { transform: scale(0.92); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .cp-grid { flex-direction: column; align-items: stretch; }
  .cp-col { display: contents; }
  .cp-go { opacity: 1; }
  .cp-stage { min-height: 320px; }
}

@media (max-width: 600px) {
  .cp-panel { border-radius: 20px; }
  .cp-panel-head { padding: 14px 12px 0 16px; }
  .cp-panel-body { padding: 18px 14px 18px; min-height: 160px; }
  .cp-stage .stage-slot { padding: 36px 16px 64px; }
}

/* Engine effects mixed into the gallery grid. */
.cp-fx-body { display: grid; place-items: center; min-height: 170px; }
.cp-fx-body .stage-slot { width: 100%; box-sizing: border-box; padding: 0; min-height: 0; display: grid; place-items: center; }
.cp-grid-home { margin-top: 72px; }

