/* ==========================================================================
   my-design-kit · v1.0
   Plain-CSS versions of Tess's saved 21st.dev components, plus the
   coverflow phone frames designed to match them.

     1. Tokens (colours, shadow, radius, motion)
     2. Pill navigation bar ......... from 21st.dev "bottom-nav-bar"
     3. Infinite logo slider ........ from 21st.dev "infinite-slider"
     4. Coverflow phone frames ...... designed for this kit
     5. Reduced-motion overrides

   Pair with my-design-kit.js. All class names start with "kit-" so they
   never clash with a page's own styles.
   ========================================================================== */


/* ==========================================================================
   1. TOKENS
   Light values = shadcn/ui "neutral" theme defaults, which the original
   components use (bg-card, border-border, primary, muted...).
   Override any of these on :root or on a single component.
   ========================================================================== */
:root {
  /* Colours */
  --kit-card: #ffffff;                        /* bg-card            */
  --kit-border: #e5e5e5;                      /* border-border      */
  --kit-primary: #171717;                     /* text-primary       */
  --kit-primary-soft: rgb(23 23 23 / 0.10);   /* bg-primary/10      */
  --kit-muted: #f5f5f5;                       /* hover:bg-muted     */
  --kit-muted-fg: #737373;                    /* text-muted-foreground */
  --kit-focus: #171717;                       /* focus ring (added, see notes) */

  /* Surfaces */
  --kit-radius-full: 9999px;                  /* rounded-full       */
  --kit-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.10),
                   0 8px 10px -6px rgb(0 0 0 / 0.10);   /* shadow-xl */

  /* Motion: plain timings */
  --kit-dur-colors: 200ms;                            /* transition-colors duration-200 */
  --kit-ease-colors: cubic-bezier(0.4, 0, 0.2, 1);    /* Tailwind default easing        */
  --kit-dur-fade: 190ms;                              /* label opacity + margin (0.19s)  */
  --kit-ease-out: cubic-bezier(0, 0, 0.58, 1);        /* Framer Motion tween "easeOut"   */

  /* Motion: springs, converted from Framer Motion physics (mass 1).
     Each linear() curve traces the real spring; durations are the time
     it takes to settle within 0.1%. */

  /* "pop": stiffness 300, damping 26 (2.8% overshoot) - nav entrance */
  --kit-spring-pop: linear(0, 0.0285, 0.0999, 0.1968, 0.3059, 0.4175, 0.5249, 0.6236, 0.7111, 0.7863, 0.849, 0.8999, 0.9401, 0.9706, 0.9931, 1.0088, 1.019, 1.025, 1.0277, 1.0281, 1.0269, 1.0246, 1.0217, 1.0186, 1.0155, 1.0125, 1.0098, 1.0074, 1.0054, 1.0038, 1.0024, 1.0014, 1);
  --kit-spring-pop-dur: 470ms;

  /* "glide": stiffness 350, damping 32 (0.6% overshoot) - label width, sizes */
  --kit-spring-glide: linear(0, 0.0323, 0.1104, 0.2125, 0.3234, 0.4332, 0.5358, 0.6277, 0.7074, 0.7748, 0.8304, 0.8752, 0.9108, 0.9383, 0.9592, 0.9747, 0.9859, 0.9938, 0.9991, 1.0024, 1.0044, 1.0053, 1.0056, 1.0054, 1.005, 1.0044, 1.0038, 1.0032, 1.0026, 1.0021, 1.0017, 1.0013, 1);
  --kit-spring-glide-dur: 470ms;

  /* "press": stiffness 500, damping 25 (12% overshoot) - Framer's default
     spring for scale, used by whileTap={{ scale: 0.97 }} */
  --kit-spring-press: linear(0, 0.0679, 0.2291, 0.4298, 0.6304, 0.8057, 0.9425, 1.0374, 1.0934, 1.1176, 1.1182, 1.1036, 1.0812, 1.0566, 1.0337, 1.0147, 1.0007, 0.9917, 0.9869, 0.9855, 0.9865, 0.9888, 0.9917, 0.9946, 0.9971, 0.9991, 1.0005, 1.0013, 1.0017, 1.0017, 1.0015, 1.0012, 1);
  --kit-spring-press-dur: 570ms;
  --kit-press-scale: 0.97;
}

/* Older browsers without linear(): close cubic-bezier stand-ins */
@supports not (transition-timing-function: linear(0, 1)) {
  :root {
    --kit-spring-pop: cubic-bezier(0.34, 1.25, 0.64, 1);
    --kit-spring-glide: cubic-bezier(0.25, 1, 0.5, 1);
    --kit-spring-press: cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

/* Dark theme: opt in with class="kit-dark" (or data-kit-theme="dark") on
   <html> or on any one component. Values = shadcn neutral dark. */
.kit-dark,
[data-kit-theme="dark"] {
  --kit-card: #0a0a0a;
  --kit-border: #27272a;                      /* dark:border-sidebar-border */
  --kit-primary: #fafafa;
  --kit-primary-soft: rgb(250 250 250 / 0.15);/* dark:bg-primary/15 */
  --kit-muted: #262626;
  --kit-muted-fg: #a3a3a3;
  --kit-focus: #fafafa;
}


/* ==========================================================================
   2. PILL NAVIGATION BAR  (.kit-nav)
   Icon-only pills; the active pill tints and slides its label out.
   ========================================================================== */
.kit-nav {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 4px;                                   /* space-x-1 */
  height: 52px;                               /* h-[52px] */
  min-width: var(--kit-nav-min-width, 320px); /* min-w-[320px] */
  max-width: 95vw;                            /* max-w-[95vw] */
  padding: 8px;                               /* p-2 */
  background: var(--kit-card);
  border: 1px solid var(--kit-border);
  border-radius: var(--kit-radius-full);
  box-shadow: var(--kit-shadow-xl);
  /* entrance: scale 0.9 -> 1, fade in, "pop" spring */
  animation: kit-pop var(--kit-spring-pop-dur) var(--kit-spring-pop) both;
}

@keyframes kit-pop {
  from { scale: 0.9; opacity: 0; }
  to   { scale: 1;   opacity: 1; }
}

/* Fixed to the bottom of the screen, centred (stickyBottom) */
.kit-nav--bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;                               /* bottom-4 */
  width: fit-content;                         /* w-fit */
  margin-inline: auto;                        /* mx-auto */
  z-index: 20;                                /* z-20 */
}
/* Only from 1024px down (laptop keeps it wherever it sits in the page) */
@media (max-width: 1024px) {
  .kit-nav--bottom-md {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 16px;
    width: fit-content;
    margin-inline: auto;
    z-index: 20;
  }
}

.kit-nav__item {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;                                     /* gap-0 (gap-2 when active) */
  height: 40px;                               /* h-10 */
  min-width: 44px;                            /* min-w-[44px] tap target */
  padding: 8px 12px;                          /* px-3 py-2 */
  border: 0;
  border-radius: var(--kit-radius-full);
  background: transparent;
  color: var(--kit-muted-fg);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--kit-dur-colors) var(--kit-ease-colors),
    color var(--kit-dur-colors) var(--kit-ease-colors),
    scale var(--kit-spring-press-dur) var(--kit-spring-press);
}
.kit-nav__item:hover { background: var(--kit-muted); }
.kit-nav__item:active { scale: var(--kit-press-scale); }   /* whileTap */

/* The original removes focus rings entirely; the kit keeps a visible one
   for keyboard users only. */
.kit-nav__item:focus { outline: none; }
.kit-nav__item:focus-visible {
  outline: 2px solid var(--kit-focus);
  outline-offset: 2px;
}

.kit-nav__item.is-active {
  gap: 8px;                                   /* gap-2 */
  background: var(--kit-primary-soft);
  color: var(--kit-primary);
}

.kit-nav__icon {
  flex: none;
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color var(--kit-dur-colors) var(--kit-ease-colors);
}

/* Label wrapper: width springs 0 -> 72px, fades and nudges in */
.kit-nav__label {
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 0;
  max-width: 72px;
  margin-left: 0;
  opacity: 0;
  transition:
    width var(--kit-spring-glide-dur) var(--kit-spring-glide),
    opacity var(--kit-dur-fade) var(--kit-ease-out),
    margin-left var(--kit-dur-fade) var(--kit-ease-out);
}
.kit-nav__item.is-active .kit-nav__label {
  width: var(--kit-nav-label-width, 72px);
  margin-left: 8px;
  opacity: 1;
}

.kit-nav__text {
  overflow: hidden;
  font-weight: 500;                           /* font-medium */
  font-size: clamp(0.625rem, 0.5263rem + 0.5263vw, 1rem);  /* 10px -> 16px */
  line-height: 1.9;
  white-space: nowrap;
  text-overflow: ellipsis;
  user-select: none;
  opacity: 0;
  transition: opacity var(--kit-dur-colors) var(--kit-ease-colors);
}
.kit-nav__item.is-active .kit-nav__text {
  color: var(--kit-primary);
  opacity: 1;
}


/* ==========================================================================
   3. INFINITE LOGO SLIDER  (.kit-marquee)
   A row that scrolls forever at a steady speed; slows down on hover.
   The JS repeats the items so the loop never shows a gap.
   ========================================================================== */
.kit-marquee {
  overflow: hidden;
  --kit-marquee-gap: 16px;                    /* default gap (demo uses 24) */
}

.kit-marquee__track {
  display: flex;
  width: max-content;
  gap: var(--kit-marquee-gap);
  will-change: transform;
}
.kit-marquee[data-direction="vertical"] .kit-marquee__track {
  flex-direction: column;
  width: auto;
}

.kit-marquee__track > * { flex: none; }

/* Logos: same height, natural width (demo: h-[120px] w-auto) */
.kit-marquee img {
  display: block;
  height: var(--kit-marquee-logo-h, 120px);
  width: auto;
}

/* Optional extra (not in the original): soft fade at both edges */
.kit-marquee--fade {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
}


/* ==========================================================================
   4. COVERFLOW PHONE FRAMES  (.kit-coverflow + .kit-phone)
   Designed for this kit in the same language: full-round pills,
   shadow-xl, neutral tokens, the same springs and 0.97 press.
   Swipe, drag, arrow keys or the buttons; the centre phone faces you,
   the others turn away, shrink and dim.
   ========================================================================== */
.kit-coverflow {
  --kit-phone-w: 240px;                       /* phone width (laptop) */
  --kit-cf-gap: 8px;                          /* space between phones */
  --kit-cf-rotate: 42deg;                     /* how far side phones turn */
  --kit-cf-scale-step: 0.14;                  /* shrink per step from centre */
  --kit-cf-dim-step: 0.35;                    /* dim per step from centre */
  --kit-cf-pull: 30%;                         /* how much side phones tuck in */
  position: relative;
}

@media (max-width: 1024px) { .kit-coverflow { --kit-phone-w: 210px; } }
@media (max-width: 699px)  { .kit-coverflow { --kit-phone-w: min(60vw, 240px); --kit-cf-rotate: 36deg; } }

/* The scroller */
.kit-coverflow__track {
  position: relative;                         /* JS measures phones against this */
  display: flex;
  align-items: center;
  gap: var(--kit-cf-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-inline: calc(50% - var(--kit-phone-w) / 2);  /* first & last can centre */
  padding-block: 28px 36px;                            /* room for shadow */
  scrollbar-width: none;
  cursor: grab;
  outline: none;
}
.kit-coverflow__track::-webkit-scrollbar { display: none; }
.kit-coverflow__track.is-dragging { cursor: grabbing; scroll-snap-type: none; }
.kit-coverflow__track:focus-visible { outline: 2px solid var(--kit-focus); outline-offset: 4px; border-radius: 24px; }

/* One slide. JS sets --cf-d (signed distance from centre, -2..2)
   and --cf-abs (0..2) on every scroll frame. */
.kit-coverflow__item {
  --cf-d: 0;
  --cf-abs: 0;
  flex: none;
  width: var(--kit-phone-w);
  margin: 0;
  scroll-snap-align: center;
  transform:
    perspective(1100px)
    translateX(calc(var(--cf-d) * var(--kit-cf-pull) * -1))
    rotateY(calc(clamp(-1, var(--cf-d), 1) * var(--kit-cf-rotate) * -1))
    scale(calc(1 - var(--cf-abs) * var(--kit-cf-scale-step)));
  opacity: calc(1 - var(--cf-abs) * var(--kit-cf-dim-step));
  /* z-index (centre on top) is set by the JS */
  transition: opacity var(--kit-dur-colors) var(--kit-ease-colors);
  will-change: transform;
  user-select: none;
}
.kit-coverflow__item:not(.is-centre):hover { opacity: calc(1 - var(--cf-abs) * var(--kit-cf-dim-step) * 0.5); }
.kit-coverflow__item figcaption {
  margin-top: 16px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--kit-muted-fg);
  opacity: 0;
  transition: opacity var(--kit-dur-fade) var(--kit-ease-out);
}
.kit-coverflow__item.is-centre figcaption { opacity: 1; color: var(--kit-primary); }

/* The phone itself */
.kit-phone {
  position: relative;
  box-sizing: border-box;
  padding: 8px;
  border-radius: calc(var(--kit-phone-w) * 0.16);
  background: #0a0a0a;
  border: 1px solid #27272a;
  box-shadow: var(--kit-shadow-xl), inset 0 0 0 1.5px rgb(255 255 255 / 0.06);
  cursor: pointer;
  transition: scale var(--kit-spring-press-dur) var(--kit-spring-press);
}
.kit-phone:active { scale: var(--kit-press-scale); }

.kit-phone__screen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 9 / 16;
  border-radius: calc(var(--kit-phone-w) * 0.16 - 8px);
  background: #000;
}
.kit-phone__screen > img,
.kit-phone__screen > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Dynamic-island style pill */
.kit-phone__screen::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 50%;
  translate: -50% 0;
  width: 30%;
  height: calc(var(--kit-phone-w) * 0.075);
  border-radius: var(--kit-radius-full);
  background: #000;
  pointer-events: none;
}

/* Play hint on the centre phone (hidden once a full video is playing) */
.kit-phone__play {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--kit-radius-full);
  background: rgb(255 255 255 / 0.9);
  color: #171717;
  box-shadow: var(--kit-shadow-xl);
  opacity: 0;
  scale: 0.9;
  pointer-events: none;
  transition:
    opacity var(--kit-dur-fade) var(--kit-ease-out),
    scale var(--kit-spring-pop-dur) var(--kit-spring-pop);
}
.kit-phone__play svg { width: 22px; height: 22px; margin-left: 3px; fill: currentColor; }
.kit-coverflow__item.is-centre .kit-phone__play { opacity: 1; scale: 1; }
.kit-coverflow__item.is-playing .kit-phone__play { opacity: 0; scale: 0.9; }

/* Controls: prev / dots / next, in the nav bar's pill language */
.kit-coverflow__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}
.kit-coverflow__btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--kit-border);
  border-radius: var(--kit-radius-full);
  background: var(--kit-card);
  color: var(--kit-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--kit-dur-colors) var(--kit-ease-colors),
    opacity var(--kit-dur-colors) var(--kit-ease-colors),
    scale var(--kit-spring-press-dur) var(--kit-spring-press);
}
.kit-coverflow__btn:hover { background: var(--kit-muted); }
.kit-coverflow__btn:active { scale: var(--kit-press-scale); }
.kit-coverflow__btn:focus { outline: none; }
.kit-coverflow__btn:focus-visible { outline: 2px solid var(--kit-focus); outline-offset: 2px; }
.kit-coverflow__btn:disabled { opacity: 0.35; cursor: default; }
.kit-coverflow__btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Dots: the active one stretches into a pill, like the nav label */
.kit-coverflow__dots { display: flex; align-items: center; gap: 6px; }
.kit-coverflow__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: var(--kit-radius-full);
  background: var(--kit-border);
  cursor: pointer;
  transition:
    width var(--kit-spring-glide-dur) var(--kit-spring-glide),
    background-color var(--kit-dur-colors) var(--kit-ease-colors);
}
.kit-coverflow__dot:hover { background: var(--kit-muted-fg); }
.kit-coverflow__dot.is-active { width: 24px; background: var(--kit-primary); }
.kit-coverflow__dot:focus-visible { outline: 2px solid var(--kit-focus); outline-offset: 2px; }


/* ==========================================================================
   COUNT-UP NUMBERS  ([data-kit-count])
   Behaviour is in the JS; this keeps digits steady while they count.
   ========================================================================== */
[data-kit-count] {
  display: inline-grid;
  justify-items: start;
  font-variant-numeric: tabular-nums;
}
/* the final value (invisible) and the counting value share one cell,
   so the number always takes the width of its final value */
.kit-count__ghost,
.kit-count__value { grid-area: 1 / 1; }
.kit-count__ghost { visibility: hidden; }

/* ==========================================================================
   FLIP TILES  (.kit-flip)
   A button with a front and back face that turns over on tap. The faces
   share one grid cell, so the tile is as tall as its taller face.
   ========================================================================== */
.kit-flip {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
  perspective: 1400px;
  -webkit-tap-highlight-color: transparent;
  transition: scale var(--kit-spring-press-dur) var(--kit-spring-press);
}
.kit-flip:active { scale: var(--kit-press-scale); }
.kit-flip:focus { outline: none; }
.kit-flip:focus-visible { outline: 2px solid var(--kit-focus); outline-offset: 3px; border-radius: 12px; }
.kit-flip__inner {
  display: grid;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--kit-spring-glide-dur) var(--kit-spring-glide);
}
.kit-flip__face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.kit-flip__back { transform: rotateY(180deg); }
.kit-flip.is-flipped .kit-flip__inner { transform: rotateY(180deg); }

/* ==========================================================================
   MESSAGES  ([data-kit-messages]): texts arriving in a phone
   Put it inside .kit-phone > .kit-phone__screen. Messages stack from the
   bottom; older ones scroll up and out of the top, like a real thread.
   ========================================================================== */
.kit-messages { --kit-phone-w: 280px; width: var(--kit-phone-w); margin-inline: auto; }
.kit-messages .kit-phone { cursor: default; }
.kit-messages .kit-phone:active { scale: 1; }
.kit-messages .kit-phone__screen {
  display: flex;
  flex-direction: column;
  background: #fff;
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
}
.kit-messages__head {
  flex: none;
  padding: calc(var(--kit-phone-w) * 0.13) 12px 10px;
  border-bottom: 1px solid #ececec;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.3;
  color: #8e8e93;
  background: #f9f9f9;
}
.kit-messages__head b { display: block; font-size: 0.82rem; color: #1c1c1e; font-weight: 600; }
.kit-messages__list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;   /* newest at the bottom */
  gap: 8px;
  margin: 0;
  padding: 12px 10px 16px;
  list-style: none;
  overflow: hidden;
}
.kit-msg {
  flex: none;
  align-self: flex-start;
  max-width: 82%;
  padding: 8px 11px;
  border-radius: 18px 18px 18px 6px;
  background: #e9e9eb;
  color: #1c1c1e;
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: pre-line;
  overflow-wrap: anywhere;
  transform-origin: 0 100%;
  opacity: 0;
  scale: 0.85;
  transition:
    opacity var(--kit-dur-fade) var(--kit-ease-out),
    scale var(--kit-spring-pop-dur) var(--kit-spring-pop);
}
.kit-msg.is-in { opacity: 1; scale: 1; }
.kit-msg .link { color: #0a64d6; text-decoration: underline; }
/* typing indicator: three dots bouncing */
.kit-msg--typing { display: flex; gap: 4px; padding: 11px 12px; opacity: 1; scale: 1; }
.kit-msg--typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #9a9aa0;
  animation: kit-typing 1s infinite ease-in-out;
}
.kit-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.kit-msg--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes kit-typing { 0%, 60%, 100% { translate: 0 0; opacity: 0.5; } 30% { translate: 0 -4px; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .kit-msg { opacity: 1; scale: 1; transition: none; }
  .kit-msg--typing span { animation: none; }
}

/* Text for screen readers only (used by count-up for the final value) */
.kit-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}


/* ==========================================================================
   5. REDUCED MOTION
   Visitors who ask their device for less motion get still versions.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .kit-nav { animation: none; }
  .kit-nav__item,
  .kit-nav__label,
  .kit-nav__text,
  .kit-phone,
  .kit-coverflow__btn,
  .kit-coverflow__dot { transition-duration: 0s; }
  .kit-nav__item:active,
  .kit-phone:active,
  .kit-coverflow__btn:active { scale: 1; }

  /* Logos sit still and wrap instead of scrolling */
  .kit-marquee__track { flex-wrap: wrap; justify-content: center; width: auto; transform: none !important; }
  .kit-marquee [data-kit-clone] { display: none; }

  /* Flip tiles swap faces instantly instead of turning */
  .kit-flip:active { scale: 1; }
  .kit-flip__inner { transition: none; transform: none !important; }
  .kit-flip__back { transform: none; visibility: hidden; }
  .kit-flip.is-flipped .kit-flip__front { visibility: hidden; }
  .kit-flip.is-flipped .kit-flip__back { visibility: visible; }

  /* Phones lie flat */
  .kit-coverflow__item { transform: scale(calc(1 - var(--cf-abs) * 0.08)); }
}
