/*
  Prince Cleaning: button family (pearl, glow, quiet)
  Load after aard.css and aard.princecleaning.css. Unlayered, so it wins over Pico without !important.
  Usage guide: princecleaning-button-guide.md

  Licence notices. This family is derived from these MIT-licensed Uiverse.io components:
  - Pearl Button, copyright Marcelo Dolza: the glossy pill and gloss layers
  - Gradient border button, copyright Vishal S (Spacious74): the glowing gradient edge
  - Download button, copyright Sahil Khadka: the quiet translucent pill with an icon
  - Generate button, copyright Muhammad Hasan: the violet focus ring idea and the sparkle icon
  MIT licence: permission is granted to use, copy, modify and distribute, provided this notice is kept.
  Do not remove these credits.

  Theme: every colour uses light-dark(), so it follows the site's light and dark switch automatically.
  Calm mode: the site's Calm toggle sets the data-calm attribute on the html element. All movement is
  switched off when that attribute is present, and also under prefers-reduced-motion.
*/

:root,
::backdrop {
  /* Pearl: the one main action on a screen */
  --pc-pearl: light-dark(#2a1266, #4b25c4);
  --pc-pearl-ink: #fff;
  --pc-pearl-lift: light-dark(rgba(60, 20, 160, 0.4), rgba(60, 20, 160, 0.45));
  --pc-pearl-lift-hover: light-dark(rgba(90, 40, 200, 0.5), rgba(90, 40, 200, 0.55));

  /* Glow: the second choice (gradient edge) */
  --pc-glow-a: light-dark(#6d28d9, #8b5cf6);
  --pc-glow-b: light-dark(#c026d3, #f0abfc);
  --pc-glow-fill: light-dark(#ffffff, #1e1450);

  /* Quiet: small and tertiary actions */
  --pc-quiet: light-dark(rgba(28, 24, 56, 0.08), rgba(255, 255, 255, 0.1));
  --pc-quiet-hover: light-dark(rgba(28, 24, 56, 0.14), rgba(255, 255, 255, 0.17));

  /* Text on glow and quiet buttons follows the page ink */
  --pc-ink: var(--aard-color, light-dark(#1c1838, #f5f3ff));

  /* Keyboard focus ring */
  --pc-focus: light-dark(#4c1d95, #ffffff);
}

/* ---------- shared shape and gloss (this is what makes the three read as a family) ---------- */

.pc-btn {
  appearance: none;
  display: inline-block;
  position: relative;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 100px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.pc-btn__wrap {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 1em 1.8em;
  border-radius: inherit;
  position: relative;
  overflow: hidden;
}

.pc-btn__label {
  position: relative;
  z-index: 1;
}

.pc-btn svg {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: currentColor;
  position: relative;
  z-index: 1;
}

.pc-btn__wrap::before,
.pc-btn__wrap::after {
  content: "";
  position: absolute;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* soft dome of light */
.pc-btn__wrap::before {
  left: -15%;
  right: -15%;
  bottom: 25%;
  top: -100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

/* glossy highlight band; the inset values keep it close to the pill edge */
.pc-btn__wrap::after {
  left: 2.5%;
  right: 2.5%;
  top: 7%;
  bottom: 40%;
  border-radius: 1.5em 1.5em 0 0;
  box-shadow: inset 0 10px 8px -10px rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%);
}

.pc-btn:active {
  transform: translateY(3px);
}

.pc-btn:focus-visible {
  outline: 3px solid var(--pc-focus);
  outline-offset: 4px;
}

.pc-btn[disabled],
.pc-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 1. Pearl: primary ---------- */

.pc-btn-pearl,
.pc-btn-pearl:link,
.pc-btn-pearl:visited,
.pc-btn-pearl:hover,
.pc-btn-pearl:active,
.pc-btn-pearl:focus {
  color: var(--pc-pearl-ink);
}

.pc-btn-pearl {
  background: var(--pc-pearl);
  box-shadow:
    inset 0 0.3rem 0.9rem rgba(255, 255, 255, 0.3),
    inset 0 -0.1rem 0.3rem rgba(0, 0, 0, 0.6),
    inset 0 -0.4rem 0.9rem rgba(220, 200, 255, 0.45),
    0 1.1rem 1.6rem -0.3rem var(--pc-pearl-lift),
    0 0.5rem 0.6rem -0.4rem rgba(0, 0, 0, 0.75);
}

.pc-btn-pearl .pc-btn__label {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* ---------- 2. Glow: secondary ---------- */

.pc-btn-glow,
.pc-btn-glow:link,
.pc-btn-glow:visited,
.pc-btn-glow:hover,
.pc-btn-glow:active,
.pc-btn-glow:focus {
  color: var(--pc-ink);
}

.pc-btn-glow {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--pc-glow-fill), var(--pc-glow-fill)) padding-box,
    linear-gradient(90deg, var(--pc-glow-a), var(--pc-glow-b)) border-box;
  box-shadow:
    inset 0 0.25rem 0.7rem rgba(255, 255, 255, 0.12),
    0 0.5rem 0.8rem -0.5rem rgba(0, 0, 0, 0.5);
}

.pc-btn-glow::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pc-glow-a), var(--pc-glow-b));
  opacity: 0;
  filter: blur(0);
  transition: filter 0.4s ease, opacity 0.4s ease;
}

.pc-btn-glow .pc-btn__wrap::before {
  opacity: 0.5;
}

.pc-btn-glow .pc-btn__wrap::after {
  opacity: 0.55;
}

/* ---------- 3. Quiet: tertiary ---------- */

.pc-btn-quiet,
.pc-btn-quiet:link,
.pc-btn-quiet:visited,
.pc-btn-quiet:hover,
.pc-btn-quiet:active,
.pc-btn-quiet:focus {
  color: var(--pc-ink);
}

.pc-btn-quiet {
  background: var(--pc-quiet);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0.3rem 0.6rem -0.4rem rgba(0, 0, 0, 0.45);
}

.pc-btn-quiet .pc-btn__wrap::before,
.pc-btn-quiet .pc-btn__wrap::after {
  opacity: 0.35;
}

/* ---------- size ---------- */

.pc-btn-sm {
  font-size: 0.92rem;
}

.pc-btn-sm .pc-btn__wrap {
  padding: 0.65em 1.25em;
}

/* ---------- hover, only on devices that can hover ---------- */

@media (hover: hover) {
  .pc-btn-pearl:hover {
    box-shadow:
      inset 0 0.3rem 0.5rem rgba(255, 255, 255, 0.4),
      inset 0 -0.1rem 0.3rem rgba(0, 0, 0, 0.6),
      inset 0 -0.4rem 0.9rem rgba(230, 215, 255, 0.7),
      0 1.1rem 1.8rem -0.3rem var(--pc-pearl-lift-hover),
      0 0.5rem 0.6rem -0.4rem rgba(0, 0, 0, 0.75);
  }

  .pc-btn:hover .pc-btn__wrap::before {
    transform: translateY(-5%);
  }

  .pc-btn:hover .pc-btn__wrap::after {
    opacity: 0.4;
    transform: translateY(5%);
  }

  .pc-btn-glow:hover::before {
    opacity: 0.8;
    filter: blur(1.1em);
  }

  .pc-btn-quiet:hover {
    background: var(--pc-quiet-hover);
  }

  .pc-btn:hover svg {
    animation: pc-twinkle 1.4s ease-in-out infinite;
  }
}

@keyframes pc-twinkle {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.2) rotate(12deg); }
}

/* ---------- Calm mode and reduced motion: no movement at all ---------- */

:root[data-calm] .pc-btn,
:root[data-calm] .pc-btn *,
:root[data-calm] .pc-btn::before,
:root[data-calm] .pc-btn *::before,
:root[data-calm] .pc-btn *::after {
  animation: none !important;
  transition: none !important;
}

:root[data-calm] .pc-btn:active,
:root[data-calm] .pc-btn:hover .pc-btn__wrap::before,
:root[data-calm] .pc-btn:hover .pc-btn__wrap::after {
  transform: none !important;
}

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

  .pc-btn:active,
  .pc-btn:hover .pc-btn__wrap::before,
  .pc-btn:hover .pc-btn__wrap::after {
    transform: none !important;
  }
}
