/* Looper (i-244) — the tool card.
 *
 * Was a standalone page until 2026-09-06; the global `*` and `body`
 * reset it used to carry is gone, because this stylesheet now loads on
 * a full site page and would have restyled the header with it. Keep
 * every rule scoped to .pg-looper.
 *
 * 2026-09-19 facelift (Phil: "sparse and dated next to the rest of the
 * site"). Two things were wrong:
 *
 *   1. The CARD lived on `.pg-tool-hero .pg-looper`, so only /looper/
 *      got it. The member home's tools dock loads the same page with
 *      ?pgembed=1 and HOISTS `.pg-looper` out of the hero into
 *      `body > .pg-embed-root` (pg-member-home.php), which dropped
 *      every card rule — hence the bare, unstyled form in the dock.
 *      The card is now the BASE style, and the surfaces that already
 *      supply their own frame (the popover panel) undress it.
 *   2. The controls were browser defaults. They now borrow the shapes
 *      the site already uses — the band strip's tempo (label · slider ·
 *      number · BPM) and switch, the slowdowner's card and quiet
 *      secondary buttons. Nothing new was invented.
 *
 * Colors run through --lp-* tokens declared on the root, so night mode
 * (body.pg-app--dark, where the popover lives in /app/) is one block of
 * redefinitions at the bottom rather than a parallel set of rules.
 */

.pg-looper, .pg-looper * { box-sizing: border-box; }

/* Several blocks set their own display, which beats the UA's [hidden]
   rule — restore hidden's meaning everywhere inside the widget. */
.pg-looper [hidden] { display: none !important; }

.pg-looper {
    --lp-ink: #1f2937;
    --lp-ink-2: #374151;
    --lp-muted: #6b7280;
    --lp-faint: #9aa1ab;
    --lp-line: #e5e7eb;
    --lp-line-2: #eef0f2;
    --lp-soft: #f6f7f8;
    --lp-surface: #ffffff;
    --lp-green: #53a96b;
    --lp-green-d: #2c6b40;
    --lp-green-soft: #ecf6ef;
    --lp-green-line: #b3d4bd;
    --lp-blue: #1e4f75;
    --lp-red: #b3341f;
    --lp-red-hover: #9c2c1a;
    --lp-sw-off: #d7dce1;
    --lp-rec-on-bg: #1a1e23;
    --lp-rec-on-fg: #ffffff;

    position: relative;
    max-width: 940px;
    margin: 0 auto;
    padding: 0;
    background: var(--lp-surface);
    border: 1px solid var(--lp-line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(22, 58, 86, 0.05);
    font: 15px/1.45 var(--pg-font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    color: var(--lp-ink);
    text-align: left;
}

.pg-looper :where(button, input) { font-family: inherit; }
.pg-looper :where(button) { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pg-looper :focus-visible { outline: 2px solid rgba(30, 79, 117, 0.45); outline-offset: 2px; }

/* ---- header bar: name · tempo · count-in · ? --------------------- */
.pg-looper__row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0;
}
.pg-looper__row--tempo {
    padding: 10px 12px 10px 16px;
    border-bottom: 1px solid var(--lp-line);
}
.pg-looper__bar-title {
    flex: none;
    font: 700 15px/1 inherit;
    color: var(--lp-blue);
    margin-right: 2px;
}
.pg-looper__bar-help { display: inline-flex; align-items: center; flex: none; margin-left: auto; }

/* Tempo — the band strip's shape (.pg-band-tempo in assets/chart/band.css):
   a micro-label, a green-filled slider, then the number with its unit. */
.pg-looper__tempo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 250px;
    min-width: 200px;
    max-width: 360px;
}
.pg-looper__lbl {
    flex: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lp-faint);
}
.pg-looper__bpm-range {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-width: 80px;
    height: 20px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    --fill: 30%;   /* looper.js keeps this in step with the value */
}
.pg-looper__bpm-range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--lp-green) 0 var(--fill), var(--lp-line-2) var(--fill) 100%);
}
.pg-looper__bpm-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -5px;
    border: 2px solid var(--lp-green);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.pg-looper__bpm-range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--lp-line-2); }
.pg-looper__bpm-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--lp-green); }
.pg-looper__bpm-range::-moz-range-thumb {
    width: 14px; height: 14px;
    border: 2px solid var(--lp-green); border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.pg-looper__bpm-range:focus, .pg-looper__bpm-range:focus-visible { outline: none; }
.pg-looper__bpm-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(83, 169, 107, 0.25); }

.pg-looper__bpm-read { display: inline-flex; align-items: baseline; gap: 4px; flex: none; }
.pg-looper__bpm {
    font-family: inherit;
    width: 46px;
    height: 30px;
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    text-align: right;
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
    appearance: textfield;
}
.pg-looper__bpm::-webkit-outer-spin-button,
.pg-looper__bpm::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pg-looper__bpm:hover { background: var(--lp-surface); border-color: var(--lp-line); }
.pg-looper__bpm:focus { outline: none; background: var(--lp-surface); border-color: var(--lp-green-line); }
.pg-looper__bpm-unit { font-size: 12px; font-weight: 600; color: var(--lp-muted); }

/* Count-in — the site's switch, as the band strip draws it
   (.pg-band-switch). Repeated here rather than pulling all of band.css
   onto every page for one control; the checkbox inside is untouched, so
   looper.js still reads .checked. */
.pg-looper__countin-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--lp-ink-2);
}
.pg-looper__countin-label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pg-looper__sw {
    position: relative;
    flex: none;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: var(--lp-sw-off);
    transition: background 0.15s;
}
.pg-looper__sw::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s;
}
.pg-looper__countin-label input:checked + .pg-looper__sw { background: var(--lp-green); }
.pg-looper__countin-label input:checked + .pg-looper__sw::after { transform: translateX(14px); }
.pg-looper__countin-label input:focus-visible + .pg-looper__sw { box-shadow: 0 0 0 3px rgba(83, 169, 107, 0.3); }

/* ---- transport --------------------------------------------------- */
/* Record is the one thing you came to do, so it is the only filled
   button on the card. Play is a quiet secondary next to it, and stays
   quiet (not a grey slab) while it is disabled. Both keep plain text
   content — looper.js swaps it wholesale for "■ Stop" / "■ Stop loop",
   which would wipe any child markup. */
.pg-looper__row--transport { padding: 16px 16px 0; gap: 8px 10px; }

.pg-looper__record {
    font-family: inherit;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    background: var(--lp-red);
    color: #fff;
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(179, 52, 31, 0.35);
    transition: background 0.12s ease, transform 0.08s ease;
}
.pg-looper__record:hover { background: var(--lp-red-hover); }
.pg-looper__record:active { transform: scale(0.98); }
.pg-looper__record.is-recording {
    background: var(--lp-rec-on-bg);
    color: var(--lp-rec-on-fg);
    box-shadow: none;
    animation: pg-looper-pulse 1s ease-in-out infinite;
}
@keyframes pg-looper-pulse {
    50% { opacity: 0.72; }
}

.pg-looper__play {
    font-family: inherit;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--lp-line);
    border-radius: 9px;
    background: var(--lp-surface);
    color: var(--lp-ink-2);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.pg-looper__play:hover:not(:disabled) { border-color: #cdd4da; background: var(--lp-soft); }
.pg-looper__play.is-playing { background: var(--lp-green-soft); border-color: var(--lp-green-line); color: var(--lp-green-d); }
.pg-looper__play:disabled {
    background: var(--lp-surface);
    border-color: var(--lp-line-2);
    color: var(--lp-faint);
    cursor: default;
}

.pg-looper__beatadj { display: inline-flex; align-items: center; gap: 6px; }
.pg-looper__beat-minus,
.pg-looper__beat-plus {
    appearance: none;
    font-family: inherit;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--lp-line);
    border-radius: 8px;
    background: var(--lp-surface);
    color: var(--lp-muted);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
.pg-looper__beat-minus:hover:not(:disabled),
.pg-looper__beat-plus:hover:not(:disabled) { border-color: #cdd4da; color: var(--lp-ink); }
.pg-looper__beat-minus:disabled,
.pg-looper__beat-plus:disabled { opacity: 0.4; cursor: default; }
.pg-looper__beatcount {
    min-width: 58px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--lp-blue);
    font-variant-numeric: tabular-nums;
}

/* Throwing the take away is a quiet thing at the far edge of the row —
   it must not read as a control you reach for mid-practice. */
.pg-looper__clear {
    font-family: inherit;
    appearance: none;
    margin-left: auto;
    height: 30px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--lp-muted);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
}
.pg-looper__clear:hover { border-color: var(--lp-line); background: var(--lp-surface); color: var(--lp-red); }

.pg-looper__status {
    min-height: 20px;
    padding: 10px 16px 0;
    font-size: 13px;
    color: var(--lp-muted);
}

.pg-looper__countin-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(42vw, 340px);
    font-weight: 800;
    color: rgba(30, 79, 117, 0.88);
    background: rgba(255, 255, 255, 0.72);
    pointer-events: none;
    z-index: 50;
}

/* ---- take view --------------------------------------------------- */
/* Empty is one muted line, not a framed void (Phil, 2026-09-19).
   looper.js carries .is-empty on the root while there is no take. */
.pg-looper__take { padding: 12px 16px 16px; }
.pg-looper__empty {
    margin: 0;
    padding: 18px 2px 20px;
    font-size: 13.5px;
    color: var(--lp-faint);
}
.pg-looper.is-empty .pg-looper__wave { display: none; }
.pg-looper:not(.is-empty) .pg-looper__empty { display: none; }
.pg-looper__wave {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--lp-line);
    border-radius: 10px;
    background: #f6f8fa;   /* matches the canvas fill looper.js paints */
}

/* ---- preview paywall (non-paid visitors) ------------------------- */
.pg-looper__paywall {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 14px;
    z-index: 5;
    padding: 16px;
}
.pg-looper__paywall-card {
    max-width: 460px;
    text-align: center;
}
.pg-looper__paywall-card h3 {
    margin: 0 0 8px;
    font-size: 20px;
}
.pg-looper__paywall-card p {
    margin: 0 0 16px;
    color: #4a545e;
}
.pg-looper__paywall-cta {
    display: inline-block;
    background: var(--lp-green);
    color: #fff;
    border: 0;
    border-radius: 9px;
    padding: 11px 20px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.pg-looper__paywall-cta:hover { background: #2E7D4F; text-decoration: none; }
.pg-looper__paywall-dismiss {
    display: block;
    margin: 12px auto 0;
    background: none;
    border: 0;
    color: #5A6672;
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
}

/* ============================================================
   Header popover (2026-09-11) — same shell as .pg-tempo-pop.
   ============================================================ */
.pg-looper-pop { font-family: var(--pg-font-ui, inherit); }
.pg-looper-pop-backdrop {
    position: fixed; inset: 0; z-index: 99999999;
    background: transparent; opacity: 0; transition: opacity 0.2s ease;
}
.pg-looper-pop[data-pg-looper-pop="open"] .pg-looper-pop-backdrop { opacity: 1; }
.pg-looper-pop[data-pg-looper-pop="closed"] .pg-looper-pop-backdrop { pointer-events: none; }
.pg-looper-pop-panel {
    position: fixed; z-index: 100000000; top: 66px; right: 14px;
    width: 440px; max-width: calc(100vw - 24px);
    background: var(--pg-surface, #fdfdfd); border: 1px solid var(--pg-border, #e5e7eb);
    border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    transform-origin: top right; transition: opacity 0.16s ease, transform 0.16s ease;
}
body.admin-bar .pg-looper-pop-panel { top: 98px; }
.pg-looper-pop[data-pg-looper-pop="closed"] .pg-looper-pop-panel { opacity: 0; transform: scale(0.96) translateY(-6px); pointer-events: none; }
.pg-looper-pop[data-pg-looper-pop="open"] .pg-looper-pop-panel { opacity: 1; transform: none; }
.pg-looper-pop-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px 0; }
.pg-looper-pop-title { font-size: 0.95rem; font-weight: 700; color: var(--pg-text, #1f2937); margin-right: auto; }
.pg-looper-pop-close {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0;
    padding: 0; border: none; border-radius: 50% !important; background: transparent !important; color: #6b7280; cursor: pointer;
}
.pg-looper-pop-close:hover { background: #eceef1 !important; color: #111827; }

/* The panel IS the card here, so the widget undresses: no second frame,
   no name (the title bar has it), one ? (the bar's). */
.pg-looper-pop .pg-looper {
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
.pg-looper-pop .pg-looper__bar-title,
.pg-looper-pop .pg-looper__bar-help,
.pg-looper-pop .pg-looper__row--tempo .pg-toolhelp { display: none !important; }
.pg-looper-pop .pg-looper__row--tempo { padding: 8px 16px 10px; }
.pg-looper-pop .pg-looper__row--transport { padding: 14px 16px 0; }
.pg-looper-pop .pg-looper__status { padding: 10px 16px 0; }
.pg-looper-pop .pg-looper__take { padding: 12px 16px 16px; }
.pg-looper-pop .pg-looper__paywall { border-radius: 14px; }

/* /looper/ page: the hero lifts the card off the tinted band. Everything
   else about it is the base card, so the tools dock — which hoists this
   widget out of the hero entirely — gets the same thing. */
.pg-tool-hero .pg-looper {
    margin-top: 30px;
    border-color: #dde5ea;
    box-shadow: 0 1px 2px rgba(22, 58, 86, 0.06), 0 18px 44px rgba(22, 58, 86, 0.14);
}

/* ---- night mode (the popover rides along in /app/) ---------------- */
body.pg-app--dark .pg-looper {
    --lp-ink: #e9e6e0;
    --lp-ink-2: #d4d8dd;
    --lp-muted: #99a2ac;
    --lp-faint: #7d8792;
    --lp-line: #2d343c;
    --lp-line-2: #262c33;
    --lp-soft: #232930;
    --lp-surface: #1e2328;
    --lp-green-d: #8fd0a4;
    --lp-green-soft: rgba(83, 169, 107, 0.18);
    --lp-green-line: #3b6b4c;
    --lp-blue: #8bb8dc;
    --lp-red: #c2452c;
    --lp-red-hover: #d0563f;
    --lp-sw-off: #3a424b;
    --lp-rec-on-bg: #e9e6e0;
    --lp-rec-on-fg: #15181c;
}
body.pg-app--dark .pg-looper__play:hover:not(:disabled),
body.pg-app--dark .pg-looper__beat-minus:hover:not(:disabled),
body.pg-app--dark .pg-looper__beat-plus:hover:not(:disabled) { border-color: #4a525c; }
body.pg-app--dark .pg-looper__countin-overlay { color: #cfe3f2; background: rgba(12, 15, 18, 0.78); }
body.pg-app--dark .pg-looper__paywall { background: rgba(21, 24, 28, 0.94); }
body.pg-app--dark .pg-looper__paywall-card p { color: #b6bec7; }
body.pg-app--dark .pg-looper-pop-close:hover { background: #2a3138 !important; color: #f2f0ec; }
/* The take view is a light drawing surface in both modes — looper.js
   paints the canvas with fixed light colors. Keep its frame from
   glowing against the dark card. */
body.pg-app--dark .pg-looper__wave { border-color: #2d343c; }

/* ---- narrow ------------------------------------------------------- */
@media (max-width: 560px) {
    /* The bar wraps to: [name … ?] / [tempo] / [count-in]. The ? is
       ordered up so it never lands alone on a line of its own. */
    .pg-looper__row--tempo { padding: 10px 12px; }
    .pg-looper__bar-help { order: 2; }
    .pg-looper__tempo { order: 3; flex: 1 1 100%; max-width: none; }
    .pg-looper__countin-label { order: 4; }
    .pg-looper__row--transport { padding: 14px 12px 0; }
    .pg-looper__status { padding: 10px 12px 0; }
    .pg-looper__take { padding: 12px 12px 14px; }
    .pg-looper__record { height: 38px; padding: 0 16px; }
    .pg-looper__beatcount { min-width: 52px; }
}

@media (max-width: 600px) {
    .pg-looper-pop[data-pg-looper-pop="open"] .pg-looper-pop-backdrop { background: rgba(0, 0, 0, 0.45); }
    .pg-looper-pop-panel {
        top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%;
        border-radius: 16px 16px 0 0; border-bottom: none; transition: transform 0.24s ease;
    }
    body.admin-bar .pg-looper-pop-panel { top: auto; }
    .pg-looper-pop[data-pg-looper-pop="closed"] .pg-looper-pop-panel { opacity: 1; transform: translateY(100%); }
    .pg-looper-pop[data-pg-looper-pop="open"] .pg-looper-pop-panel { transform: translateY(0); }
    .pg-looper-pop .pg-looper__row--tempo { padding: 8px 12px 10px; }
    .pg-looper-pop .pg-looper__row--transport { padding: 14px 12px 0; }
    .pg-looper-pop .pg-looper__status { padding: 10px 12px 0; }
    .pg-looper-pop .pg-looper__take { padding: 12px 12px 14px; }
}
