/* ============================================================
   Tuner — header trigger button + popover host + widget.
   ============================================================ */

/* ---- Header trigger button ----
   A solid charcoal circle that joins the header's icon family. A tuner
   is a physical device, so dark reads as "instrument" and sets it
   apart from the colored app icons. Turns green while the popover is
   open. background/border-radius are !important because the theme's
   button styling overrides a plain class selector at rest. */
.pg-tuner-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;        /* never let a tight header row squeeze it oval */
    padding: 0;
    border: none;
    border-radius: 50% !important;
    background: #2c333d !important;
    color: #f0f3f6;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.1s ease;
}
.pg-tuner-trigger svg { width: 20px; height: 20px; }
.pg-tuner-trigger svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.pg-tuner-trigger svg circle { fill: currentColor; }
.pg-tuner-trigger:hover {
    background: #3a4350 !important;
    transform: translateY(-1px);
}
.pg-tuner-trigger[aria-expanded="true"] {
    background: #2bb866 !important;
    color: #fff;
}

/* Mobile: a touch smaller so it sits in proportion with the roulette
   wheel in the cramped mobile header. Icon (svg) size is unchanged. */
@media (max-width: 600px) {
    .pg-tuner-trigger { width: 36px; height: 36px; }
}

/* ============================================================
   Popover host — desktop popover top-right under the header,
   mobile bottom sheet.
   ============================================================ */

.pg-tuner-pop {
    font-family: var(--pg-font-ui, inherit);
}

.pg-tuner-pop-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999999;
    background: transparent;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.pg-tuner-pop[data-pg-tuner-pop="open"] .pg-tuner-pop-backdrop { opacity: 1; }
.pg-tuner-pop[data-pg-tuner-pop="closed"] .pg-tuner-pop-backdrop { pointer-events: none; }

/* Panel — slim + tall. */
.pg-tuner-pop-panel {
    position: fixed;
    z-index: 100000000;
    top: 66px;
    right: 14px;
    width: 280px;
    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-tuner-pop-panel { top: 98px; }
.pg-tuner-pop[data-pg-tuner-pop="closed"] .pg-tuner-pop-panel {
    opacity: 0;
    transform: scale(0.96) translateY(-6px);
    pointer-events: none;
}
.pg-tuner-pop[data-pg-tuner-pop="open"] .pg-tuner-pop-panel {
    opacity: 1;
    transform: none;
}

/* Mobile: panel becomes a bottom sheet, backdrop dims. */
@media (max-width: 600px) {
    .pg-tuner-pop[data-pg-tuner-pop="open"] .pg-tuner-pop-backdrop {
        background: rgba(0, 0, 0, 0.45);
    }
    .pg-tuner-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-tuner-pop-panel { top: auto; }
    .pg-tuner-pop[data-pg-tuner-pop="closed"] .pg-tuner-pop-panel {
        opacity: 1;
        transform: translateY(100%);
    }
    .pg-tuner-pop[data-pg-tuner-pop="open"] .pg-tuner-pop-panel {
        transform: translateY(0);
    }
}

/* ============================================================
   Tuner widget
   ============================================================ */

.pg-tuner {
    display: flex;
    flex-direction: column;
}

/* ---- Top bar: power · instrument dropdown · close ---- */
.pg-tuner-bar {
    position: relative; /* lifts the dropdown menu above the screen */
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 8px 12px;
    border-bottom: 1px solid var(--pg-border, #e5e7eb);
}

.pg-tuner-power {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    border: 1.5px solid #c2c9d1;
    background: #fff;
    color: #8b97a3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.pg-tuner-power svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.pg-tuner-power:hover { color: #5a6570; border-color: #9aa4ae; }
.pg-tuner[data-pg-tuner-state="listening"] .pg-tuner-power,
.pg-tuner[data-pg-tuner-state="active"] .pg-tuner-power {
    color: #2bb866;
    border-color: #36d576;
    box-shadow: 0 0 0 3px rgba(54, 213, 118, 0.16);
}

/* Instrument dropdown — clean and light; the current instrument name
   doubles as the popover's title. */
.pg-tuner-select { position: relative; }
.pg-tuner-select-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 6px 5px 8px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--pg-blue, #1E4F75);
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s;
}
.pg-tuner-select-trigger:hover { background: rgba(30, 79, 117, 0.07); }
.pg-tuner-select-caret {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: #9aa4ae;
    transition: transform 0.15s;
}
.pg-tuner-select[data-pg-open="true"] .pg-tuner-select-caret { transform: rotate(180deg); }
.pg-tuner-select-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    min-width: 150px;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--pg-border, #e5e7eb);
    border-radius: 9px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
    z-index: 5;
    display: none;
}
.pg-tuner-select[data-pg-open="true"] .pg-tuner-select-menu { display: block; }
.pg-tuner-select-option {
    padding: 8px 11px;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.pg-tuner-select-option:hover { background: #f3f4f6; color: #1a1a1a; }
.pg-tuner-select-option[aria-selected="true"] { color: var(--pg-blue, #1E4F75); }

.pg-tuner-pop-close {
    flex-shrink: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #6b7d8a;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.pg-tuner-pop-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--pg-blue, #1E4F75);
}

/* ---- Body ---- */
.pg-tuner-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Display screen */
.pg-tuner-screen {
    background: #232a33;
    border-radius: 12px;
    padding: 18px 14px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Meter — note dead-center, segment bars flanking it */
.pg-tuner-meter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.pg-tuner-bars {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 0;
}
.pg-tuner-bars--flat { flex-direction: row-reverse; }
.pg-tuner-bars span {
    flex: 1 1 0;
    border-radius: 2px;
    background: #2b333d;
    transition: background 0.1s;
}
/* Graduated heights — short near the note, taller outward (a wedge). */
.pg-tuner-bars span:nth-child(1) { height: 12px; }
.pg-tuner-bars span:nth-child(2) { height: 16px; }
.pg-tuner-bars span:nth-child(3) { height: 20px; }
.pg-tuner-bars span:nth-child(4) { height: 24px; }
.pg-tuner-bars span:nth-child(5) { height: 28px; }
.pg-tuner-bars span.is-lit { background: #e8b04b; }

.pg-tuner-note {
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 1px;
    line-height: 1;
}
.pg-tuner-note-name {
    font-size: 46px;
    font-weight: 700;
    color: #e8edf2;
    transition: color 0.1s;
}
.pg-tuner-note-octave {
    font-size: 16px;
    font-weight: 600;
    color: #5f6b78;
}
.pg-tuner[data-pg-intune="true"] .pg-tuner-note-name { color: #36d576; }
.pg-tuner[data-pg-tuner-state="off"] .pg-tuner-note-name,
.pg-tuner[data-pg-tuner-state="error"] .pg-tuner-note-name { color: #3a4452; }

/* Cents value + tuning caption */
.pg-tuner-cents {
    font-size: 12px;
    font-weight: 600;
    color: #8b97a3;
    min-height: 15px;
    letter-spacing: 0.02em;
}
.pg-tuner-readout-caption {
    font-size: 12px;
    font-weight: 600;
    color: #6b7682;
    text-align: center;
}
.pg-tuner[data-pg-intune="true"] .pg-tuner-readout-caption { color: #36d576; }

/* ---- String chips — all on one line, no wrap ---- */
.pg-tuner-strings {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    width: 100%;
}
.pg-tuner-string {
    flex: 1 1 0;
    min-width: 0;
    padding: 5px 2px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    background: #f3f4f6;
    border-radius: 5px;
}
.pg-tuner-string sub {
    font-size: 8px;
    color: #9ca3af;
}
.pg-tuner-string.is-active {
    color: #fff;
    background: #232a33;
}
.pg-tuner-string.is-active sub { color: #8b97a3; }
.pg-tuner[data-pg-intune="true"] .pg-tuner-string.is-active { background: #36d576; }
.pg-tuner[data-pg-intune="true"] .pg-tuner-string.is-active sub { color: rgba(255, 255, 255, 0.8); }
