/* Styles specific to the Level 1 demos. Shared demo chrome is in ../demos.css */

/* ---------- 1. Motion graphics ---------- */
.mg { position: relative; width: 170px; height: 170px; }
.mg i {
  position: absolute; inset: 0; margin: auto;
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--accent); opacity: .85;
  animation: mg-orbit 4s cubic-bezier(.45,0,.55,1) infinite;
}
.mg i:nth-child(2) { animation-delay: -1.33s; opacity: .55; }
.mg i:nth-child(3) { animation-delay: -2.66s; opacity: .3; }

@keyframes mg-orbit {
  0%   { transform: rotate(0deg)   translateX(52px) rotate(0deg)   scale(1);   border-radius: 14px; }
  50%  { transform: rotate(180deg) translateX(52px) rotate(-180deg) scale(.55); border-radius: 50%; }
  100% { transform: rotate(360deg) translateX(52px) rotate(-360deg) scale(1);   border-radius: 14px; }
}

.mg b {
  position: absolute; inset: 0; margin: auto;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink);
  animation: mg-pulse 2s ease-in-out infinite;
}

@keyframes mg-pulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.5) } }

/* ---------- 2. Scroll reveal ---------- */
.scroller {
  width: 100%; max-width: 330px; height: 210px;
  overflow-y: auto; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg);
  padding: .8rem;
}
.reveal {
  padding: .9rem 1rem; margin-bottom: .7rem;
  background: var(--accent-soft); border-radius: 8px;
  font-size: .9rem; font-weight: 600; color: var(--accent);
  opacity: 0; transform: translateY(22px);
  transition: opacity .5s ease, transform .5s ease;
}
.reveal.in { opacity: 1; transform: none; }
.scroll-hint { font-size: .8rem; color: var(--muted); text-align: center; margin: .5rem 0 0; }

/* ---------- 3. Bar chart ---------- */
.chart { display: flex; align-items: flex-end; gap: .55rem; height: 150px; }
.bar-wrap { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.bar {
  width: 34px; border-radius: 6px 6px 0 0;
  background: var(--accent);
  height: 0; transition: height .9s cubic-bezier(.2,.8,.3,1), opacity .2s;
  cursor: pointer;
}
.bar:hover { opacity: .7; }
.bar-label { font-size: .72rem; color: var(--muted); }
.bar-val {
  font-size: .78rem; font-weight: 700; color: var(--accent);
  min-height: 1.1em;
}

/* ---------- 5. Tilt card ---------- */
.tilt-outer { perspective: 800px; }
.tilt {
  width: 210px; height: 135px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--ink));
  color: #fff; display: flex; align-items: center; justify-content: center;
  text-align: center; font-weight: 650; font-size: .92rem; padding: 1rem;
  transition: transform .12s ease-out, box-shadow .2s;
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
  will-change: transform; touch-action: none;
}

/* ---------- 6. Instant search ---------- */
.search-demo { width: 100%; max-width: 330px; }
.search-demo input {
  width: 100%; padding: .7rem .9rem; font-size: 16px;
  border: 2px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink);
}
.search-demo input:focus { outline: none; border-color: var(--accent); }
.results { list-style: none; padding: 0; margin: .7rem 0 0; max-height: 132px; overflow-y: auto; }
.results li {
  padding: .45rem .7rem; border-radius: 7px; font-size: .9rem;
  margin-bottom: .25rem; background: var(--accent-soft);
}
.no-hits { color: var(--muted); font-size: .88rem; padding: .45rem .7rem; }

/* ---------- 7. Before / after ---------- */
.ba {
  position: relative; width: 100%; max-width: 330px; height: 175px;
  border-radius: 12px; overflow: hidden; cursor: ew-resize;
  touch-action: none; user-select: none;
}
.ba-layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
            font-weight: 700; font-size: .95rem; letter-spacing: .05em; color: #fff; }
.ba-before { background: linear-gradient(135deg,#6b6357,#3a352d); }
.ba-after  { background: linear-gradient(135deg,#ffb865,#e0553f); clip-path: inset(0 50% 0 0); }
.ba-handle {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 3px;
  background: #fff; transform: translateX(-50%); pointer-events: none;
  box-shadow: 0 0 8px rgba(0,0,0,.4);
}
.ba-handle::after {
  content: '⇄'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff; color: #333; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 8. Drag to reorder ---------- */
.sortable { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 300px; }
.sortable li {
  padding: .75rem .9rem; margin-bottom: .5rem;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 9px; font-weight: 600; font-size: .92rem;
  cursor: grab; touch-action: none; user-select: none;
  display: flex; align-items: center; gap: .6rem;
  transition: transform .18s ease, box-shadow .18s ease;
}
.sortable li::before { content: '⠿'; opacity: .5; }
.sortable li.dragging {
  cursor: grabbing; box-shadow: 0 8px 20px rgba(0,0,0,.2);
  transform: scale(1.03); z-index: 2; position: relative;
}

/* ---------- 9. Confetti ---------- */
.confetti-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
.confetti-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.big-btn {
  position: relative; z-index: 1;
  padding: .85rem 1.6rem; font-size: 1rem; font-weight: 700;
  border: 0; border-radius: 99px; cursor: pointer;
  background: var(--accent); color: #fff;
  min-height: 44px;
}
@media (prefers-color-scheme: dark) { .big-btn { color: #14201a; } }
.big-btn:active { transform: translateY(1px); }

/* ---------- 10. Text scramble ---------- */
.scramble {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(1.1rem, 5vw, 1.7rem);
  font-weight: 700; color: var(--accent);
  min-height: 2.2em; display: flex; align-items: center;
  text-align: center; letter-spacing: .02em;
}

/* Respect people who get motion sick */
@media (prefers-reduced-motion: reduce) {
  .mg i, .mg b { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .bar { transition: none; }
}
