/*
 * PageTree default blocks - shared styles.
 *
 * Every rule uses :where() so its specificity is zero: a theme overrides any of
 * them with a plain selector. Colors and sizes come from the --ptb-* custom
 * properties below, which a theme can redefine on :root.
 */

:where(:root) {
    --ptb-primary: #2563eb;
    --ptb-primary-contrast: #ffffff;
    --ptb-secondary: #475569;
    --ptb-secondary-contrast: #ffffff;
    --ptb-light: #f3f4f6;
    --ptb-light-contrast: inherit;
    --ptb-dark: #1f2937;
    --ptb-dark-contrast: #ffffff;
    --ptb-border: rgba(0, 0, 0, 0.12);
    --ptb-muted: rgba(0, 0, 0, 0.6);
    --ptb-radius: 0.5rem;
    --ptb-gap: 1.5rem;
    --ptb-space-s: 1rem;
    --ptb-space-m: 2rem;
    --ptb-space-l: 4rem;
    --ptb-space-xl: 6rem;
    --ptb-container: 1200px;
}

/* Block wrapper */

:where(.ptb) {
    box-sizing: border-box;
    margin-block: 0 var(--ptb-space-s);
}

:where(.ptb) *,
:where(.ptb) *::before,
:where(.ptb) *::after {
    box-sizing: inherit;
}

:where(.ptb) img {
    max-width: 100%;
    height: auto;
}

/* Alignment helpers */

:where(.ptb-align--left) { text-align: left; }
:where(.ptb-align--center) { text-align: center; }
:where(.ptb-align--right) { text-align: right; }

/* Color themes, for blocks with a background */

:where(.ptb-theme--light) {
    background-color: var(--ptb-light);
    color: var(--ptb-light-contrast);
}

:where(.ptb-theme--dark) {
    background-color: var(--ptb-dark);
    color: var(--ptb-dark-contrast);
}

:where(.ptb-theme--primary) {
    background-color: var(--ptb-primary);
    color: var(--ptb-primary-contrast);
}

/* Buttons: <a class="ptb-btn ptb-btn--primary ptb-btn--m"> */

:where(.ptb-btn) {
    display: inline-block;
    padding: 0.75em 1.5em;
    border: 2px solid transparent;
    border-radius: var(--ptb-radius);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

:where(.ptb-btn:hover, .ptb-btn:focus-visible) {
    opacity: 0.85;
}

:where(.ptb-btn--primary) {
    background-color: var(--ptb-primary);
    border-color: var(--ptb-primary);
    color: var(--ptb-primary-contrast);
}

:where(.ptb-btn--secondary) {
    background-color: var(--ptb-secondary);
    border-color: var(--ptb-secondary);
    color: var(--ptb-secondary-contrast);
}

:where(.ptb-btn--outline) {
    background-color: transparent;
    border-color: currentColor;
    color: inherit;
}

:where(.ptb-btn--link) {
    padding-inline: 0;
    background-color: transparent;
    color: inherit;
    text-decoration: underline;
}

:where(.ptb-btn--s) { font-size: 0.875rem; }
:where(.ptb-btn--m) { font-size: 1rem; }
:where(.ptb-btn--l) { font-size: 1.25rem; }

/* A primary button on a primary background stays visible */
:where(.ptb-theme--primary) :where(.ptb-btn--primary) {
    background-color: var(--ptb-primary-contrast);
    border-color: var(--ptb-primary-contrast);
    color: var(--ptb-primary);
}

/* Placeholder shown in the editor when a block has no content yet */

:where(.ptb-placeholder) {
    padding: var(--ptb-space-m);
    border: 1px dashed var(--ptb-border);
    border-radius: var(--ptb-radius);
    color: var(--ptb-muted);
    font-style: italic;
    text-align: center;
}

/* Text only read by screen readers */

:where(.ptb-sr-only) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
