/* Lms3access — requirement popover.
   All rules scoped to .l3a-popover so styles don't leak into the host site. */

.l3a-popover.popover {
    /* Brand + neutral tones come from the EXT:theme global palette
       (Custom.css :root); the original standalone values act as fallbacks. */
    --l3a-surface: color-mix(in srgb, var(--colorsecondary10, #fbfaf7) 40%, #fff);
    --l3a-surface-2: color-mix(in srgb, var(--colorsecondary10, #f3f1ea) 70%, #fff);
    --l3a-ink: var(--colorsecondary, #1a1a1a);
    --l3a-muted: color-mix(in srgb, var(--colorsecondary, #6b6b6b) 72%, #fff);
    --l3a-hairline: color-mix(in srgb, var(--colorsecondary, #000) 10%, transparent);
    /* Inherit host theme if it has retuned the Bootstrap semantic palette */
    --l3a-pass: var(--bs-success, #1f7a4c);
    --l3a-fail: var(--bs-danger, #a63232);
    --l3a-accent: var(--colorprimary, var(--l3a-ink));
    --l3a-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    --bs-popover-bg: var(--l3a-surface);
    --bs-popover-border-color: var(--l3a-hairline);
    --bs-popover-border-radius: 10px;
    --bs-popover-inner-border-radius: 10px;
    --bs-popover-max-width: 340px;
    --bs-popover-body-padding-x: 0;
    --bs-popover-body-padding-y: 0;

    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.04),
        0 12px 28px -10px rgba(20, 20, 20, 0.18),
        0 2px 6px -2px rgba(20, 20, 20, 0.08);
    color: var(--l3a-ink);
    letter-spacing: 0.005em;
}

.l3a-popover.popover .popover-body { padding: 0; }

.l3a-popover .l3a-shell {
    position: relative;
    background-image:
        radial-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 3px 3px, 7px 7px;
    background-position: 0 0, 1px 1px;
    border-radius: inherit;
    overflow: hidden;
}

/* Meter */
.l3a-meter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--l3a-hairline);
    background: linear-gradient(180deg, var(--l3a-surface-2), transparent);
}
.l3a-meter__track {
    position: relative;
    flex: 1;
    height: 3px;
    background: var(--l3a-hairline);
    border-radius: 2px;
    overflow: hidden;
}
.l3a-meter__fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--l3a-fail);
    transition: width 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.l3a-meter.is-pass .l3a-meter__fill { background: var(--l3a-pass); }
.l3a-meter.is-partial .l3a-meter__fill {
    background: repeating-linear-gradient(
        -45deg,
        var(--l3a-fail) 0 4px,
        color-mix(in srgb, var(--l3a-fail) 55%, transparent) 4px 8px
    );
}
.l3a-meter.is-zero .l3a-meter__fill { width: 0 !important; }
.l3a-meter__count {
    font: 500 11px/1 var(--l3a-mono);
    letter-spacing: 0.08em;
    color: var(--l3a-muted);
    white-space: nowrap;
}
.l3a-meter__count b { color: var(--l3a-ink); font-weight: 600; }
.l3a-meter__count em { font-style: normal; }

/* Rows */
.l3a-popover .l3a-body { display: flex; flex-direction: column; }

.l3a-row {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 14px;
    border-left: 2px solid transparent;
    position: relative;
}
.l3a-row + .l3a-row { border-top: 1px dashed var(--l3a-hairline); }

.l3a-row.is-pass { border-left-color: var(--l3a-pass); }
.l3a-row.is-fail {
    border-left-color: var(--l3a-fail);
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--l3a-fail) 6%, transparent),
        transparent 60%
    );
}

.l3a-row__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-top: 1px;
}
.l3a-row.is-pass .l3a-row__icon i { color: var(--l3a-pass); font-size: 18px; }
.l3a-row.is-fail .l3a-row__icon i {
    color: var(--l3a-fail);
    font-size: 18px;
    animation: l3a-fail-pulse 2.4s ease-in-out infinite;
}

.l3a-row__title {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--l3a-ink);
    font-weight: 500;
}
.l3a-row.is-pass .l3a-row__title {
    color: var(--l3a-muted);
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, var(--l3a-muted) 40%, transparent);
    text-decoration-thickness: 1px;
}
.l3a-row__diag {
    margin-top: 3px;
    font: 400 11.5px/1.4 var(--l3a-mono);
    color: var(--l3a-muted);
    letter-spacing: 0.01em;
}

/* Group header */
.l3a-sep {
    height: 1px;
    margin: 0 14px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--l3a-hairline) 12%,
        var(--l3a-hairline) 88%,
        transparent
    );
}
.l3a-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 4px;
    font: 600 10px/1 var(--l3a-mono);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--l3a-muted);
}
.l3a-group__head.is-pass { color: var(--l3a-pass); }
.l3a-group__head.is-fail { color: var(--l3a-fail); }
.l3a-group__mode::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: currentColor;
    margin-right: 6px;
    border-radius: 1px;
    transform: translateY(-1px);
}
.l3a-group__count { font-weight: 500; opacity: 0.7; }

/* Clickable failed rows */
.l3a-row--link {
    text-decoration: none;
    color: inherit;
    grid-template-columns: 28px 1fr 16px;
    cursor: pointer;
    transition: background 160ms ease;
}
.l3a-row--link:hover,
.l3a-row--link:focus-visible {
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--l3a-fail) 12%, transparent),
        color-mix(in srgb, var(--l3a-fail) 3%, transparent) 70%,
        transparent
    );
    text-decoration: none;
    color: inherit;
}
.l3a-row--link:focus-visible { outline: 1px dashed var(--l3a-fail); outline-offset: -2px; }

.l3a-row__chev {
    align-self: center;
    font-size: 13px;
    color: var(--l3a-fail);
    opacity: 0.55;
    transition: opacity 160ms ease, transform 160ms ease;
}
.l3a-row--link:hover .l3a-row__chev,
.l3a-row--link:focus-visible .l3a-row__chev {
    opacity: 1;
    transform: translate(1px, -1px);
}

/* Collapse toggle */
.l3a-shell.is-collapsed .l3a-row.is-pass { display: none; }
.l3a-shell.is-collapsed .l3a-row + .l3a-row.is-pass,
.l3a-shell.is-collapsed .l3a-row.is-pass + .l3a-row { border-top: 0; }

.l3a-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    border: 0;
    border-top: 1px solid var(--l3a-hairline);
    background: transparent;
    color: var(--l3a-muted);
    font: 500 11px/1 var(--l3a-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease;
}
.l3a-toggle:hover {
    background: color-mix(in srgb, var(--l3a-accent) 8%, var(--l3a-surface-2));
    color: var(--l3a-accent);
}
.l3a-toggle:focus-visible {
    outline: 1px dashed var(--l3a-accent);
    outline-offset: -2px;
    color: var(--l3a-accent);
}
.l3a-toggle i { transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.l3a-shell:not(.is-collapsed) .l3a-toggle i { transform: rotate(180deg); }

/* Pinned state — subtle ring in the project accent so it feels on-brand */
.l3a-popover.popover.is-pinned {
    outline: 1px solid color-mix(in srgb, var(--l3a-accent) 45%, transparent);
    outline-offset: 1px;
}

/* Skeleton (while the fetch is in flight) */
.l3a-shell--loading .l3a-meter__fill {
    background: repeating-linear-gradient(
        -45deg,
        var(--l3a-hairline) 0 6px,
        transparent 6px 12px
    );
    width: 100% !important;
    animation: l3a-skel-sweep 1.4s linear infinite;
}
.l3a-row--skeleton { pointer-events: none; }

.l3a-skel {
    display: inline-block;
    background: linear-gradient(
        90deg,
        var(--l3a-hairline) 0%,
        color-mix(in srgb, var(--l3a-hairline) 40%, transparent) 50%,
        var(--l3a-hairline) 100%
    );
    background-size: 200% 100%;
    border-radius: 2px;
    animation: l3a-skel-shimmer 1.4s ease-in-out infinite;
}
.l3a-skel--dot { width: 14px; height: 14px; border-radius: 50%; }
.l3a-skel--line {
    display: block;
    height: 10px;
    width: 82%;
    margin-top: 2px;
}
.l3a-skel--line.l3a-skel--short { width: 54%; margin-top: 6px; height: 8px; }

@keyframes l3a-skel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes l3a-skel-sweep {
    0%   { opacity: 0.7; }
    50%  { opacity: 1; }
    100% { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
    .l3a-skel, .l3a-shell--loading .l3a-meter__fill { animation: none; }
}

/* ── Preview card replacing the locked content element ────────── */
.l3a-placeholder {
    position: relative;
    margin: 16px 0;
    isolation: isolate;
}
.l3a-placeholder__card {
    border: 1px dashed color-mix(in srgb, var(--bs-body-color, #000) 16%, transparent);
    border-radius: 10px;
    padding: 18px 58px 18px 18px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--bs-body-color, #000) 3%, transparent),
        transparent
    );
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 80px;
}
.l3a-placeholder__bar {
    height: 10px;
    border-radius: 4px;
}

/* ── Trigger pill — replaces the plain lock icon ──────────────── */
.l3a-trigger {
    --l3a-trigger-hue: var(--bs-danger, #a63232);

    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px 2px 3px;
    height: 22px;
    border: 1px solid color-mix(in srgb, var(--l3a-trigger-hue) 32%, transparent);
    background: color-mix(in srgb, var(--l3a-trigger-hue) 7%, transparent);
    border-radius: 999px;

    color: var(--l3a-trigger-hue);
    font: 600 10px/1 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.04em;
    white-space: nowrap;
    vertical-align: middle;

    cursor: pointer;
    user-select: none;
    transition: background 160ms ease, border-color 160ms ease,
                transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.l3a-trigger:hover {
    background: color-mix(in srgb, var(--l3a-trigger-hue) 16%, transparent);
    border-color: color-mix(in srgb, var(--l3a-trigger-hue) 60%, transparent);
    transform: translateY(-1px);
}
.l3a-trigger:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--bs-primary, currentColor) 55%, transparent);
    outline-offset: 2px;
}
.l3a-trigger[aria-expanded="true"] {
    background: color-mix(in srgb, var(--l3a-trigger-hue) 20%, transparent);
    border-color: var(--l3a-trigger-hue);
}
.l3a-trigger[data-l3a-state="pass"] {
    --l3a-trigger-hue: var(--bs-success, #1f7a4c);
}

.l3a-trigger--corner {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
}

/* Menu variant — primary signifier is the padlock, the ring is a
   silent progress hint only. No numeric fraction at menu-row scale. */
.l3a-trigger--menu {
    width: 26px;
    height: 26px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: 50%;
    position: relative;
}
.l3a-trigger--menu .l3a-trigger__ring {
    position: absolute;
    inset: 2px;
    width: calc(100% - 4px);
    height: calc(100% - 4px);
}
.l3a-trigger--menu .l3a-trigger__fill { stroke-width: 2; }
.l3a-trigger--menu .l3a-trigger__track { stroke-width: 1.5; }
.l3a-trigger--menu .l3a-trigger__lock {
    transform-origin: 12px 12px;
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.l3a-trigger--menu:hover .l3a-trigger__lock { transform: translateY(-1px); }
.l3a-trigger--menu[data-l3a-state="pass"] .l3a-trigger__lock {
    transform: rotate(-8deg) translate(0.5px, -0.5px);
}

.l3a-trigger__ring { flex: 0 0 auto; overflow: visible; }
.l3a-trigger__track { stroke: color-mix(in srgb, currentColor 22%, transparent); }
.l3a-trigger__fill {
    stroke: currentColor;
    stroke-dasharray: 0 100;
    transition: stroke-dasharray 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.l3a-trigger__count {
    font-variant-numeric: tabular-nums;
    padding-right: 1px;
}

.l3a-trigger:not([data-l3a-ratio]) .l3a-trigger__fill {
    stroke-dasharray: 4 5;
    animation: l3a-trigger-dash 1s linear infinite;
}
@keyframes l3a-trigger-dash { to { stroke-dashoffset: -9; } }

@media (prefers-reduced-motion: reduce) {
    .l3a-trigger:hover { transform: none; }
    .l3a-trigger:not([data-l3a-ratio]) .l3a-trigger__fill { animation: none; }
    .l3a-trigger__fill { transition: none; }
}

/* Error */
.l3a-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--l3a-fail);
    font-size: 13px;
}

/* Motion */
@keyframes l3a-fail-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}
.l3a-popover.popover.show .l3a-shell {
    animation: l3a-enter 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes l3a-enter {
    from { opacity: 0; transform: translateY(-2px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .l3a-popover.popover.show .l3a-shell,
    .l3a-row.is-fail .l3a-row__icon i { animation: none; }
    .l3a-meter__fill { transition: none; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .l3a-popover.popover {
        --l3a-surface: #1a1a1c;
        --l3a-surface-2: #222226;
        --l3a-ink: #ededed;
        --l3a-muted: #9a9a9a;
        --l3a-hairline: rgba(255, 255, 255, 0.08);
        --l3a-pass: var(--bs-success, #6ed49c);
        --l3a-fail: var(--bs-danger, #f48a8a);
        /* No dark theme tokens exist in EXT:theme; a light-tuned brand color
           on dark surfaces would misfire, so the accent falls back to ink. */
        --l3a-accent: var(--l3a-ink);
        box-shadow:
            0 1px 0 rgba(0, 0, 0, 0.3),
            0 14px 40px -12px rgba(0, 0, 0, 0.6);
    }
    .l3a-popover .l3a-shell {
        background-image:
            radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
            radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    }
}
[data-bs-theme="dark"] .l3a-popover.popover {
    --l3a-surface: #1a1a1c;
    --l3a-surface-2: #222226;
    --l3a-ink: #ededed;
    --l3a-muted: #9a9a9a;
    --l3a-hairline: rgba(255, 255, 255, 0.08);
    --l3a-pass: var(--bs-success, #6ed49c);
    --l3a-fail: var(--bs-danger, #f48a8a);
    --l3a-accent: var(--l3a-ink);
}
