/* ==========================================================================
   POLISH — craft that belongs to every skin, not to one look.

   Deliberately conservative: nothing here changes a colour, a size or a
   spacing decision that a skin owns. It adds the things that are correct
   regardless of aesthetic — focus that is visible, feedback that arrives on
   press rather than release, numerals that do not reflow, and honouring the
   three accessibility preferences the platform exposes.

   Loaded last so it can rely on whatever the active skin has defined.
   ========================================================================== */

/* ---- Focus -------------------------------------------------------------
   A visible focus ring is not decoration; it is the only way a keyboard user
   knows where they are. :focus-visible means pointer users never see it, so
   there is no aesthetic cost to getting this right. The offset keeps the ring
   off the control's own border so both stay readable.                       */

.pv-btn:focus-visible,
.pv-nav-link:focus-visible,
.pv-tab:focus-visible,
.pv-menu-item:focus-visible,
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--pv-accent);
    outline-offset: 2px;
    border-radius: var(--pv-r-sm, 8px);
}

.pv-input:focus-visible,
select.pv-input:focus-visible,
textarea.pv-input:focus-visible {
    outline: none;                       /* the ring below reads better on a field */
    border-color: var(--pv-accent);
    box-shadow: var(--pv-ring);
}

/* ---- Press feedback ----------------------------------------------------
   Feedback belongs on pointer-down. Waiting for the click to fire means the
   control is silent for the whole time a finger is on it, which is exactly
   when a person is asking "did that register?". The scale is small on purpose:
   enough to feel, not enough to notice.                                     */

.pv-btn,
.pv-nav-link,
.pv-menu-item {
    transition: transform 90ms ease-out, background-color 140ms ease-out,
                border-color 140ms ease-out, box-shadow 140ms ease-out;
}
.pv-btn:active { transform: scale(.978); }
.pv-nav-link:active,
.pv-menu-item:active { transform: scale(.99); }

/* A disabled control should look unavailable before it is clicked, not after. */
.pv-btn:disabled,
.pv-btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---- Numerals ----------------------------------------------------------
   Tabular figures in anything that counts, so a value changing from 9 to 10
   does not shift the layout and columns line up down the page.              */

.pv-kpi-value,
.pv-stat-value,
.pv-table td,
.pv-badge { font-variant-numeric: tabular-nums lining-nums; }

/* ---- Selection ---------------------------------------------------------- */

::selection {
    background: var(--pv-accent-soft);
    color: var(--pv-text);
}

/* ==========================================================================
   ACCESSIBILITY PREFERENCES
   Three independent signals, three different answers. Reduced motion is not
   "no feedback" — it is feedback without vestibular movement, so opacity and
   colour survive while travel and overshoot do not.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    .pv-btn:active,
    .pv-nav-link:active,
    .pv-menu-item:active { transform: none; }
}

/* Frosted surfaces become solid rather than merely less blurred — a weak blur
   is the worst of both, costing legibility without the material reading. */
@media (prefers-reduced-transparency: reduce) {
    .pv-topbar,
    .pv-sidebar,
    .pv-menu,
    .pv-modal {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: var(--pv-surface) !important;
    }
    .pv-topbar::after { display: none; }
}

@media (prefers-contrast: more) {
    .pv-card,
    .pv-kpi,
    .pv-chart-card,
    .pv-input,
    .pv-btn-subtle {
        border-color: var(--pv-text-muted) !important;
    }
    .pv-muted,
    .pv-text-xs.pv-muted { color: var(--pv-text) !important; }
}

/* ==========================================================================
   PRESENTATION MODE — strip the chrome, maximise the data.

   From the InsightDeck spec, but built skin-agnostic because it is useful in
   any of them: when you are showing a client their own numbers on a shared
   screen, the sidebar, topbar and tab strip are all furniture. This hides them
   and gives the whole viewport to the content.

   Toggled by PVPresent (partials/topbar.php); Escape exits.
   ========================================================================== */

html.pv-presenting .pv-sidebar,
html.pv-presenting .pv-topbar,
html.pv-presenting .pv-tabs,
html.pv-presenting .pv-mig-banner,
html.pv-presenting #ai-widget,
html.pv-presenting .pv-ai-widget { display: none !important; }

html.pv-presenting .pv-main { margin-left: 0 !important; width: 100% !important; }
html.pv-presenting .pv-content {
    max-width: none !important;
    padding: 2rem 2.5rem 4rem !important;
    margin: 0 !important;
}
/* Charts get the room that the chrome gave up. */
html.pv-presenting .pv-chart-card { min-height: 60vh; }

/* The only control left on screen. Fixed, quiet, and always reachable. */
.pv-present-exit { display: none; }
html.pv-presenting .pv-present-exit {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9999;
    padding: .55rem 1rem;
    border: 1px solid var(--pv-border);
    border-radius: 999px;
    background: var(--pv-surface);
    color: var(--pv-text);
    box-shadow: var(--pv-shadow-lg);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
