/* Shared pieces of the vault's interface: icons, buttons, chips, focus.
   Every colour is a token from ../tokens.css, and every class here starts with pv- so it cannot meet
   anything else on a page. */

/* The hidden attribute has to win over every display rule below: a class that sets display would otherwise
   quietly show what the script hid, which happened three times before this line existed. */
.pv-page [hidden] {
    display: none !important;
}

/* --- Icons: drawn by Client/ui/icons.js into a [data-pv-icon] placeholder ----------------------------------- */

[data-pv-icon] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pv-icon {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Focus: a ring for the keyboard, never for the mouse ---------------------------------------------------- */

.pv-page :is(button, a, input, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* --- Buttons ------------------------------------------------------------------------------------------------ */

.pv-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-5);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--type-body);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--motion-hover), border-color var(--motion-hover);
}

.pv-button:hover:not(:disabled) {
    background: var(--surface-3);
}

.pv-button--primary {
    border-color: var(--accent-border);
    background: var(--accent-fill);
    color: var(--on-accent);
}

.pv-button--primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.pv-button:disabled {
    border-color: var(--border-subtle);
    background: var(--surface-2);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

/* A round of Argon2id takes most of a second; the button says so while it runs. */
.pv-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--on-accent);
    border-radius: 50%;
}

[data-busy] > .pv-spinner {
    display: inline-block;
    animation: pv-spin 0.8s linear infinite;
}

@keyframes pv-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    [data-busy] > .pv-spinner { animation-duration: 2.4s; }
}

.pv-iconbutton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-card);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--motion-hover), color var(--motion-hover);
}

.pv-iconbutton:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text-primary);
}

.pv-iconbutton:disabled {
    color: var(--text-disabled);
    cursor: not-allowed;
}

.pv-iconbutton[aria-pressed="true"] {
    background: var(--accent-subtle);
    color: var(--accent-text);
}

.pv-textbutton {
    align-self: center;
    padding: var(--space-2) var(--space-3);
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    font: inherit;
    font-size: var(--type-caption);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* --- A small label: a folder, a tag ------------------------------------------------------------------------- */

.pv-chip {
    display: inline-block;
    max-width: 100%;
    padding: 2px 10px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: var(--type-caption);
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pv-chip[hidden] {
    display: none;
}

/* On a phone or a coarse pointer everything that is pressed is a full finger wide. */
@media (max-width: 720px), (pointer: coarse) {
    .pv-iconbutton {
        width: 44px;
        height: 44px;
    }
}
