/*
 * "Light or dark" tile in the "And so much more" bento grid.
 *
 * The tile carries a large switch (theme-tile.js toggles .is-dark on the
 * card). In light mode it looks like every other card; in dark mode the card
 * turns into a violet-to-midnight-blue night sky with twinkling stars and the
 * screenshot cross-fades from the light to the dark app view.
 */

.lp-theme-card {
  --theme-fade: 0.7s;
  transition:
    transform 0.5s var(--lp-ease),
    box-shadow 0.5s var(--lp-ease),
    color var(--theme-fade) var(--lp-ease);
  isolation: isolate;
}

/* ---------- Night sky (only visible in dark mode) ---------- */

/* Gradient layer: fades in instead of switching hard. */
.lp-theme-card::before,
.lp-theme-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--theme-fade) var(--lp-ease);
}
.lp-theme-card::before {
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(139, 92, 246, 0.55), transparent 60%),
    radial-gradient(90% 80% at 100% 100%, rgba(59, 130, 246, 0.28), transparent 65%),
    linear-gradient(140deg, #2a1658 0%, #15123a 45%, #070b1f 100%);
}

/* Stars: small radial dots in two tiling layers, slowly twinkling. */
.lp-theme-card::after {
  background-image:
    radial-gradient(1.4px 1.4px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 80px, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1.6px 1.6px at 150px 20px, #fff, transparent),
    radial-gradient(1px 1px at 210px 120px, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.2px 1.2px at 60px 160px, #fff, transparent),
    radial-gradient(1px 1px at 260px 60px, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1.8px 1.8px at 180px 190px, rgba(196, 181, 253, 0.95), transparent),
    radial-gradient(1px 1px at 120px 230px, #fff, transparent);
  background-size: 280px 250px;
}
.lp-theme-card.is-dark::before { opacity: 1; }
.lp-theme-card.is-dark::after {
  opacity: 0.9;
  animation: lp-theme-twinkle 4.5s ease-in-out infinite alternate;
}
@keyframes lp-theme-twinkle {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* ---------- Text colours ---------- */

.lp-theme-card h3,
.lp-theme-card p { transition: color var(--theme-fade) var(--lp-ease); }
.lp-theme-card.is-dark h3 { color: #f5f3ff; }
.lp-theme-card.is-dark p { color: rgba(226, 232, 255, 0.78); }
.lp-theme-card.is-dark:hover { box-shadow: 0 30px 60px -30px rgba(76, 29, 149, 0.6); }

/* ---------- The big switch ---------- */

.lp-theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.lp-theme-switch-track {
  position: relative;
  width: 104px;
  height: 56px;
  flex: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #bae6fd, #e0f2fe);
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.18);
  transition: background 0.5s var(--lp-ease);
}
.lp-theme-card.is-dark .lp-theme-switch-track {
  background: linear-gradient(135deg, #4c1d95, #1e1b4b);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(196, 181, 253, 0.25);
}
.lp-theme-switch-thumb {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #f59e0b;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
  transition: transform 0.5s var(--lp-ease), background 0.5s var(--lp-ease), color 0.5s var(--lp-ease);
}
.lp-theme-card.is-dark .lp-theme-switch-thumb {
  transform: translateX(48px);
  background: #ede9fe;
  color: #6d28d9;
}
.lp-theme-switch-thumb svg { width: 24px; height: 24px; grid-area: 1 / 1; transition: opacity 0.35s, transform 0.5s var(--lp-ease); }
.lp-theme-switch-thumb .is-moon { opacity: 0; transform: rotate(-60deg) scale(0.6); }
.lp-theme-card.is-dark .lp-theme-switch-thumb .is-sun { opacity: 0; transform: rotate(60deg) scale(0.6); }
.lp-theme-card.is-dark .lp-theme-switch-thumb .is-moon { opacity: 1; transform: none; }
.lp-theme-switch:focus-visible .lp-theme-switch-track { outline: 3px solid var(--lp-violet); outline-offset: 3px; }

.lp-theme-switch-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--lp-muted);
  transition: color var(--theme-fade) var(--lp-ease);
}
.lp-theme-card.is-dark .lp-theme-switch-label { color: #e9e5ff; }

/* ---------- Screenshot cross-fade ---------- */

.lp-theme-shots { position: relative; }
.lp-theme-shots img { transition: opacity var(--theme-fade) var(--lp-ease); }
.lp-theme-shots .is-dark-shot {
  position: absolute;
  inset: 0;
  opacity: 0;
  border-color: rgba(255, 255, 255, 0.12);
}
.lp-theme-card.is-dark .lp-theme-shots .is-dark-shot { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .lp-theme-card,
  .lp-theme-card *,
  .lp-theme-card::before,
  .lp-theme-card::after { transition: none !important; animation: none !important; }
}
