{#
    Styles for the shared help modal.

    Rendered from inside each page's {% block inline_styles %}, so the rules land
    in <head> next to the rest of the page's CSS — same as everything else in this
    project, but written once instead of three times.
#}
.help-modal {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(460px, calc(100% - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: none;
    background: transparent;
    overflow: visible;
}

.help-modal:not([open]) {
    display: none;
}

.help-modal::backdrop {
    background: var(--color-overlay);
}

/* showModal() makes the page behind inert but still scrollable — reading the
   modal on a short screen would otherwise drag the battery out from under it. */
body:has(.help-modal[open]) {
    overflow: hidden;
}

.help-card {
    position: relative;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    box-shadow: var(--shadow-dialog);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    text-align: left;
}

.help-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    /* The glyph is the whole resting control, so it carries the contrast. */
    color: var(--color-text-muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.help-close:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.help-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    padding-right: 32px;
}

.help-viewer-intro {
    margin-top: 10px;
    color: var(--color-text-muted);
    font-size: 15px;
    line-height: 1.55;
}

.help-reading-guide {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.help-reading-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px 14px;
    border-radius: var(--radius-md);
}

.help-reading-row-high {
    background: var(--color-success-subtle);
}

.help-reading-row-low {
    background: var(--color-warning-subtle);
}

.help-reading-row-empty {
    background: var(--color-danger-subtle);
}

.help-reading-row p {
    min-width: 0;
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
}

.help-reading-row-high strong {
    color: var(--color-success);
}

.help-reading-row-low strong {
    color: var(--color-warning);
}

.help-reading-row-empty strong {
    color: var(--color-danger);
}

.help-mini-battery {
    display: inline-flex;
    align-items: center;
    flex: 0 0 39px;
}

.help-mini-battery-body {
    display: inline-block;
    width: 36px;
    height: 18px;
    padding: 2px;
    border: 2px solid currentColor;
    border-radius: 5px;
}

.help-mini-battery-terminal {
    display: inline-block;
    width: 3px;
    height: 8px;
    border-radius: 0 2px 2px 0;
    background: currentColor;
}

.help-mini-battery-fill {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: currentColor;
}

.help-mini-battery-high {
    color: var(--color-charge-high);
}

.help-mini-battery-high .help-mini-battery-fill {
    width: 82%;
}

.help-mini-battery-low {
    color: var(--color-charge-medium);
}

.help-mini-battery-low .help-mini-battery-fill {
    width: 16%;
}

.help-mini-battery-empty {
    color: var(--color-charge-low);
}

.help-mini-battery-empty .help-mini-battery-fill {
    width: 100%;
    background: repeating-linear-gradient(
        45deg,
        var(--color-danger-hatch) 0 4px,
        transparent 4px 8px
    );
}

.help-viewer-note {
    margin-top: var(--space-md);
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1.6;
}

/* Owner card: one block per scale, so a second scale joins as a sibling. */
.help-scales {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.help-scale {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
}

.help-scale-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.help-scale-title {
    color: var(--color-text);
    font-size: 15px;
    font-weight: 700;
}

.help-scale-subtitle {
    color: var(--color-text-muted);
    font-weight: 400;
}

.help-scale-facts {
    margin-top: 10px;
    padding-left: 20px;
}

.help-scale-facts li {
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.help-scale-facts li + li {
    margin-top: 4px;
}

.help-scale-facts li::marker {
    color: var(--color-text-faint);
}

.help-actions {
    margin-top: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.help-done {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-action);
    color: var(--color-on-action);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.help-done:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-action-hover);
}

.help-cta {
    color: var(--color-accent);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.help-cta:hover {
    text-decoration: underline;
}

/* Triggers — a round "?" where there is a header to hang it on, a plain text
   link where there is not. */
.help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.help-trigger:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.help-trigger.is-help-unopened {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
    animation: help-pulse 2.2s ease-in-out infinite;
}

.help-trigger.is-help-unopened:hover {
    background: var(--color-accent-subtle-hover);
    color: var(--color-text);
}

.help-trigger-corner {
    position: absolute;
    top: 16px;
    right: 16px;
}

.help-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-link {
    padding: 0;
    border: none;
    background: none;
    color: var(--color-accent);
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

@keyframes help-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 var(--color-accent-pulse);
    }

    50% {
        box-shadow: 0 0 0 6px transparent;
    }
}

@media (max-width: 480px) {
    .help-card {
        padding: 26px 20px;
    }

    .help-title {
        font-size: 20px;
    }
}
