/* css/perilGuardSettings.css
 *
 * PerilGuard Settings panel (#peril-menu / #perilMob-menu with .pgs-panel, rows
 * built by includes/layers/perilGuard.js). Same look as the gear Settings window
 * (css/settings.css): glass panel, title bar, banded sections, orange switches.
 * Loaded at every width, so it carries its own copies of those values (the
 * --hts-* tokens are only loaded on desktop).
 */

.pgs-panel {
    --pgs-font: 'Segoe UI', 'Open Sans', 'Roboto', Arial, sans-serif;
    --pgs-panel-bg: rgba(44, 66, 94, 0.82);
    --pgs-bar-bg: rgba(29, 52, 76, 0.95);
    --pgs-border: rgba(255, 255, 255, 0.14);
    --pgs-divider: rgba(255, 255, 255, 0.10);
    --pgs-section-light: rgba(72, 102, 138, 0.38);
    --pgs-section-dark: rgba(16, 32, 54, 0.42);
    --pgs-field-bg: rgba(29, 52, 76, 0.55);
    --pgs-field-border: rgba(255, 255, 255, 0.18);
    --pgs-hover: rgba(41, 87, 123, 0.60);
    --pgs-accent: rgb(229, 132, 17);
}

/* Shown with display:flex by openPerilGuardOptions */
#peril-menu.pgs-panel,
#perilMob-menu.pgs-panel {
    position: fixed;
    top: 110px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 140px);
    margin: 0;
    padding: 0;
    z-index: 30;
    /* The old grid panel rules (indexDesktop/indexMobile.css) centre and space
       the children; the title bar and body need the full width */
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow: hidden;
    background: var(--pgs-panel-bg);
    backdrop-filter: blur(6.6px);
    -webkit-backdrop-filter: blur(6.6px);
    border: 1px solid var(--pgs-border);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    color: #ffffff;
    font: 13px/1.4 var(--pgs-font);
    font-weight: normal;
    text-align: left;
    text-shadow: none;
}

/* --- Title bar --- */
.pgs-titlebar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    background: var(--pgs-bar-bg);
    border-bottom: 1px solid var(--pgs-divider);
}

/* Desktop panel drags by its title bar (perilMakeSettingsDraggable) */
#peril-menu .pgs-titlebar {
    cursor: move;
    user-select: none;
}

.pgs-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
}

.pgs-close {
    cursor: pointer;
    font-size: 19px;
    line-height: 1;
    opacity: .7;
    padding: 0 4px;
}

.pgs-close:hover {
    color: var(--pgs-accent);
    opacity: 1;
}

/* --- Scrollable body --- */
.pgs-content {
    flex: 1 1 auto;
    min-height: 0;
    /* lets it shrink and scroll inside the panel's max height */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 12px 12px;
}

/* --- Sections (Warnings, Map display), banded like the Settings window --- */
.pgs-section {
    margin: 10px 0 0;
    padding: 0 6px 6px;
    border-radius: 8px;
}

.pgs-section:nth-of-type(odd) {
    background: var(--pgs-section-light);
}

.pgs-section:nth-of-type(even) {
    background: var(--pgs-section-dark);
}

.pgs-section-hd {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 6px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--pgs-divider);
}

/* All on / All off */
.pgs-quick {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.pgs-quick button {
    padding: 2px 10px;
    font: 600 11px var(--pgs-font);
    letter-spacing: 0;
    text-transform: none;
    color: #ffffff;
    background: var(--pgs-field-bg);
    border: 1px solid var(--pgs-field-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.pgs-quick button:hover {
    background: var(--pgs-accent);
    border-color: var(--pgs-accent);
}

/* --- Rows --- */
.pgs-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 2px 6px 2px 4px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
}

.pgs-row:hover {
    background: var(--pgs-hover);
}

.pgs-label {
    flex: 1 1 auto;
    min-width: 0;
}

.pgs-group-row .pgs-label {
    font-weight: 600;
}

/* Single rows (SWW, FWW, Map display) line up with the group names */
.pgs-single {
    padding-left: 30px;
}

/* Group expand chevron */
.pgs-expand {
    flex: 0 0 18px;
    padding: 0;
    color: #ffffff;
    background: none;
    border: none;
    cursor: pointer;
    opacity: .8;
}

.pgs-expand i {
    font-size: 10px;
    transition: transform .15s ease;
}

.pgs-group.open .pgs-expand i {
    transform: rotate(90deg);
}

/* How many of the group's warnings are on, e.g. 2/4 */
.pgs-count {
    flex: 0 0 auto;
    font-size: 11px;
    opacity: .75;
    font-variant-numeric: tabular-nums;
}

.pgs-group-items {
    display: none;
    margin: 0 0 4px 13px;
    padding-left: 9px;
    border-left: 1px solid var(--pgs-divider);
}

.pgs-group.open .pgs-group-items {
    display: block;
}

/* --- Colour swatches: the colour each warning is drawn in --- */
.pgs-swatches {
    flex: 0 0 auto;
    display: inline-flex;
    gap: 3px;
}

.pgs-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Area outlines are lines, not fills */
.pgs-swatch--line {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    box-shadow: none;
}

/* --- Switches (real checkboxes, styled) --- */
.pgs-switch {
    position: relative;
    flex: 0 0 auto;
    width: 38px;
    height: 20px;
}

.pgs-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.pgs-slider {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: var(--pgs-field-bg);
    border: 1px solid var(--pgs-field-border);
    pointer-events: none;
    transition: background .15s ease, border-color .15s ease;
}

.pgs-slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform .15s ease;
}

.pgs-switch input:checked+.pgs-slider {
    background: var(--pgs-accent);
    border-color: var(--pgs-accent);
}

.pgs-switch input:checked+.pgs-slider::after {
    transform: translateX(18px);
}

/* Group with only some warnings on: half orange, knob in the middle */
.pgs-switch input:indeterminate+.pgs-slider {
    background: linear-gradient(90deg, var(--pgs-accent) 50%, var(--pgs-field-bg) 50%);
    border-color: var(--pgs-accent);
}

.pgs-switch input:indeterminate+.pgs-slider::after {
    transform: translateX(9px);
}

.pgs-switch input:focus-visible+.pgs-slider {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* --- Phones: full width, larger touch targets --- */
@media only screen and (max-width: 932px) {

    #perilMob-menu.pgs-panel {
        top: 60px;
        width: calc(100vw - 32px);
        max-height: calc(100vh - 200px);
        font-size: 15px;
    }

    .pgs-row {
        min-height: 42px;
    }

    .pgs-quick button {
        padding: 4px 12px;
        font-size: 12px;
    }
}