/* The keys: every call to action on the website and in /app drawn as the phone's NightButton
 * (mobile/src/components/night/NightButton.tsx): a face on a darker lip, a gloss over its top, and pressed it
 * sinks onto the lip and springs back. The blue one (the primary) also glows, and the few that lead a screen carry
 * a slow sheen across them every ~4 s. Quiet buttons (secondary, ghost, the destructive one's neutral face) keep
 * their own face and words and get the lip and the press only. Disabled, a key is flat and sunk. Red stays only
 * the destructive words; Pro's gold only Pro's key.
 *
 * Loaded LAST on every page with buttons (tools/blog/lib/layout.mjs, the hand-written pages, /app and /app/sheet).
 * Each list is one :is(), whose specificity is its strongest member's, so a page's own :hover or :active rule never
 * wipes the gloss or the lip. A new button is a key by carrying a listed class (.btn-primary, .btn-ghost in /app;
 * .home .btn-primary, .btn-secondary on the site) or by joining a list here. The Practice view's buttons are keys too.
 * Reduced motion: no sheen and no spring; the press is a step. Also here: one tap feel for the whole site. */

/* ── Tokens: the phone's NightButton colours (Day = nightLight, Night = night) ── */
:root {
  --key-lip-h: 4px;
  --key-blue-face: #1d4ed8;   /* white on it 6.7:1 */
  --key-blue-lip: #1e3a8a;
  --key-blue-glow: rgba(47, 123, 255, .30);
  --key-gold-face: #f59e0b;   /* its ink on it 6:1 */
  --key-gold-lip: #b45309;
  --key-gold-ink: #3b2a00;
  --key-solid-face: #0f172a;  /* the phone's "white" key: navy in Day, white in Night */
  --key-solid-lip: #020617;
  --key-solid-ink: #ffffff;
}
:root[data-theme="dark"] {
  --key-blue-face: #1b5fe0;   /* white on it 5.6:1 */
  --key-blue-lip: #1538a0;
  --key-blue-glow: rgba(47, 123, 255, .55);
  --key-gold-face: #f5b544;
  --key-gold-lip: #a8700f;
  --key-gold-ink: #1f1600;
  --key-solid-face: #ffffff;
  --key-solid-lip: #aeb8cc;
  --key-solid-ink: #0a0d14;
}

/* ── One tap feel: no grey flash, no double-tap-zoom wait ── */
a, button, summary, label, select, [role="button"], input[type="checkbox"], input[type="radio"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Blue: the primary, with the glow ── */
:is(
  .home .btn-primary,
  .site-document .site-shell-cta,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .blog-page .play-btn,
  .identify-page .identify-record,
  .site-page-main .card button[type="submit"]:not(.btn-danger),
  .btn-primary,
  .btn.btn-light,
  .nav-new,
  .go-pro,
  .studio-rec
) {
  --key-face: var(--key-blue-face); --key-lip: var(--key-blue-lip); --key-glow: var(--key-glow-here, var(--key-blue-glow)); --key-gloss: .3; --key-ink: #fff;
}
/* Pro's gold (no glow: that is the blue's) and the solid alternative to the blue. */
.btn.btn-pro { --key-face: var(--key-gold-face); --key-lip: var(--key-gold-lip); --key-glow: transparent; --key-gloss: .4; --key-ink: var(--key-gold-ink); }
.btn.btn-white { --key-face: var(--key-solid-face); --key-lip: var(--key-solid-lip); --key-glow: transparent; --key-gloss: .22; --key-ink: var(--key-solid-ink); }
/* Small buttons carry a smaller lip; the header's key a smaller glow, so it does not haze the page under the bar. */
:is(.btn-sm, .home .btn-sm, .go-pro, .nav-new, .site-document .site-shell-actions > .site-shell-cta) { --key-lip-h: 3px; }
.site-document .site-shell-actions > .site-shell-cta { --key-glow-here: rgba(47, 123, 255, .22); }

/* ── The faced keys: face, words, gloss, lip and glow ── */
:is(
  .home .btn-primary,
  .site-document .site-shell-cta,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .blog-page .play-btn,
  .identify-page .identify-record,
  .site-page-main .card button[type="submit"]:not(.btn-danger),
  .btn-primary,
  .btn.btn-light,
  .nav-new,
  .go-pro,
  .studio-rec,
  .btn.btn-pro,
  .btn.btn-white
) {
  border-color: transparent;
  background-color: var(--key-face);
  background-image: linear-gradient(180deg, rgb(255 255 255 / var(--key-gloss)) 0%, rgb(255 255 255 / 0) 50%);
  color: var(--key-ink);
  box-shadow: 0 var(--key-lip-h) 0 var(--key-lip), 0 calc(var(--key-lip-h) + 6px) 22px -6px var(--key-glow);
}

/* ── Quiet: their own face and words; a lip of their own edge a shade down; no glow ── */
:is(
  .home .btn-secondary,
  .home .btn-ghost,
  .site-page-main button.btn-danger,
  .site-shell-panel .site-shell-signin,
  .blog-page .pdf-button,
  .btn-ghost:not(.btn-icon):not(.on),
  .btn-secondary:not(.btn-icon):not(.on)
) {
  --key-edge: var(--page-line-strong, var(--color-border-strong, #cbd5e1));
  --key-lip: #b8c0cc;
  --key-lip: color-mix(in srgb, var(--key-edge) 72%, #000);
  --key-glow: transparent;
  border-color: var(--key-edge);
  box-shadow: 0 var(--key-lip-h) 0 var(--key-lip);
}

/* ── Every key: the press. Down in 70 ms, back with a small overshoot (the phone's spring). ── */
:is(
  .home .btn-primary,
  .site-document .site-shell-cta,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .blog-page .play-btn,
  .identify-page .identify-record,
  .site-page-main .card button[type="submit"]:not(.btn-danger),
  .btn-primary,
  .btn.btn-light,
  .nav-new,
  .go-pro,
  .studio-rec,
  .btn.btn-pro,
  .btn.btn-white,
  .home .btn-secondary,
  .home .btn-ghost,
  .site-page-main button.btn-danger,
  .site-shell-panel .site-shell-signin,
  .blog-page .pdf-button,
  .btn-ghost:not(.btn-icon):not(.on),
  .btn-secondary:not(.btn-icon):not(.on)
) {
  transform: translateY(0);
  transition: transform 260ms cubic-bezier(.3, 1.7, .5, 1), box-shadow 260ms cubic-bezier(.3, 1.7, .5, 1),
    background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, filter 150ms ease-out, opacity 150ms ease-out;
  -webkit-user-select: none; user-select: none;
}
:is(
  .home .btn-primary,
  .site-document .site-shell-cta,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .blog-page .play-btn,
  .identify-page .identify-record,
  .site-page-main .card button[type="submit"]:not(.btn-danger),
  .btn-primary,
  .btn.btn-light,
  .nav-new,
  .go-pro,
  .studio-rec,
  .btn.btn-pro,
  .btn.btn-white,
  .home .btn-secondary,
  .home .btn-ghost,
  .site-page-main button.btn-danger,
  .site-shell-panel .site-shell-signin,
  .blog-page .pdf-button,
  .btn-ghost:not(.btn-icon):not(.on),
  .btn-secondary:not(.btn-icon):not(.on)
):active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(calc(var(--key-lip-h) - 1px));
  box-shadow: 0 1px 0 var(--key-lip), 0 2px 10px -6px var(--key-glow);
  transition-duration: 70ms;
  transition-timing-function: ease-out;
}
:is(
  .home .btn-primary,
  .site-document .site-shell-cta,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .blog-page .play-btn,
  .identify-page .identify-record,
  .site-page-main .card button[type="submit"]:not(.btn-danger),
  .btn-primary,
  .btn.btn-light,
  .nav-new,
  .go-pro,
  .studio-rec,
  .btn.btn-pro,
  .btn.btn-white,
  .home .btn-secondary,
  .home .btn-ghost,
  .site-page-main button.btn-danger,
  .site-shell-panel .site-shell-signin,
  .blog-page .pdf-button,
  .btn-ghost:not(.btn-icon):not(.on),
  .btn-secondary:not(.btn-icon):not(.on)
):focus-visible { outline: 2px solid var(--page-blue, var(--blue, #2563eb)); outline-offset: 3px; }
/* A mouse finds a faced key by a lift of light, never by a hop. */
@media (hover: hover) {
  :is(
    .home .btn-primary,
    .site-document .site-shell-cta,
    .blog-page .cta-button,
    .blog-page .parts-bar-go,
    .blog-page .play-btn,
    .identify-page .identify-record,
    .site-page-main .card button[type="submit"]:not(.btn-danger),
    .btn-primary,
    .btn.btn-light,
    .nav-new,
    .go-pro,
    .studio-rec,
    .btn.btn-pro,
    .btn.btn-white
  ):hover:not(:disabled) { filter: brightness(1.07); }
}
/* Disabled: flat and sunk, no gloss and no glow (the page's own rule fades it). */
:is(
  .home .btn-primary,
  .site-document .site-shell-cta,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .blog-page .play-btn,
  .identify-page .identify-record,
  .site-page-main .card button[type="submit"]:not(.btn-danger),
  .btn-primary,
  .btn.btn-light,
  .nav-new,
  .go-pro,
  .studio-rec,
  .btn.btn-pro,
  .btn.btn-white,
  .home .btn-secondary,
  .home .btn-ghost,
  .site-page-main button.btn-danger,
  .site-shell-panel .site-shell-signin,
  .blog-page .pdf-button,
  .btn-ghost:not(.btn-icon):not(.on),
  .btn-secondary:not(.btn-icon):not(.on)
):is(:disabled, [aria-disabled="true"]) {
  transform: translateY(calc(var(--key-lip-h) - 1px));
  background-image: none;
  box-shadow: 0 1px 0 var(--key-lip);
  filter: none;
}

/* ── The sheen: only on the keys that lead a screen ── */
:is(
  .home .try-main .btn-primary,
  .home .btn-primary.btn-lg,
  .blog-page .cta-button,
  .blog-page .parts-bar-go,
  .identify-page .identify-record,
  .btn-primary.btn-block,
  .btn-primary.btn-pay,
  .btn-primary.studio-go,
  .btn-primary.btn-pill
) { position: relative; isolation: isolate; overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
  :is(
    .home .try-main .btn-primary,
    .home .btn-primary.btn-lg,
    .blog-page .cta-button,
    .blog-page .parts-bar-go,
    .identify-page .identify-record,
    .btn-primary.btn-block,
    .btn-primary.btn-pay,
    .btn-primary.studio-go,
    .btn-primary.btn-pill
  ):not(:disabled)::after {
    content: ""; position: absolute; z-index: -1; top: -50%; bottom: -50%; left: 0; width: 56px; pointer-events: none;
    background: linear-gradient(90deg, rgb(255 255 255 / 0), rgb(255 255 255 / .32), rgb(255 255 255 / 0));
    transform: translateX(-140px) rotate(20deg);
    animation: key-sheen 4s ease-in-out 1.2s infinite;
  }
}
/* 0.9 s across, then ~3 s at rest; the sweep runs past the widest key on the site. */
@keyframes key-sheen {
  0% { transform: translateX(-140px) rotate(20deg); }
  22%, 100% { transform: translateX(680px) rotate(20deg); }
}
@media (prefers-reduced-motion: reduce) {
  :is(
    .home .btn-primary,
    .site-document .site-shell-cta,
    .blog-page .cta-button,
    .blog-page .parts-bar-go,
    .blog-page .play-btn,
    .identify-page .identify-record,
    .site-page-main .card button[type="submit"]:not(.btn-danger),
    .btn-primary,
    .btn.btn-light,
    .nav-new,
    .go-pro,
    .studio-rec,
    .btn.btn-pro,
    .btn.btn-white,
    .home .btn-secondary,
    .home .btn-ghost,
    .site-page-main button.btn-danger,
    .site-shell-panel .site-shell-signin,
    .blog-page .pdf-button,
    .btn-ghost:not(.btn-icon):not(.on),
    .btn-secondary:not(.btn-icon):not(.on)
  ) { transition: none; }
}
