/* Surface and control styles for pages rooted in .titan-plugin. */
.titan-plugin {
    --tp-default-text: #18243b;
    --tp-default-muted: #52627b;
    --tp-default-surface: #fff;
    --tp-default-subtle: #f4f7fc;
    --tp-default-line: #dbe3ef;
    --tp-default-control-line: #8595ad;
    --tp-default-focus: #355bc6;
    --tp-default-success-text: #126039;
    --tp-default-success-bg: #e8f7ee;
    --tp-default-warning-text: #7b4711;
    --tp-default-warning-bg: #fff3dd;
    --tp-text: var(--titan-ui-text, var(--tp-default-text));
    --tp-muted: var(--titan-ui-muted, var(--tp-default-muted));
    --tp-surface: var(--titan-ui-surface, var(--tp-default-surface));
    --tp-subtle: var(--titan-ui-subtle, var(--tp-default-subtle));
    --tp-line: var(--titan-ui-line, var(--tp-default-line));
    --tp-control-line: var(--titan-ui-control-border, var(--tp-default-control-line));
    --tp-focus: var(--titan-focus, var(--tp-default-focus));
    --tp-primary: var(--titan-primary, #254aa5);
    --tp-radius: var(--titan-ui-radius, 16px);
    --tp-control-radius: var(--titan-ui-control-radius, 8px);
    --tp-control-height: var(--titan-ui-control-height, 44px);
    --tp-gap: var(--titan-ui-gap, 1rem);
    --tp-panel-space: var(--titan-ui-panel-space, clamp(1rem, 2.5vw, 1.5rem));
    --tp-mono: ui-monospace, SFMono-Regular, Consolas, monospace;

    box-sizing: border-box;
    color-scheme: light dark;
    color: var(--tp-text);
    font: 1rem/1.5 var(--titan-ui-font, system-ui, sans-serif);
    max-inline-size: var(--titan-ui-page-width, 1440px);
    margin-inline: auto;
    padding: clamp(1rem, 3vw, 2rem);
}

:where([data-bs-theme="light"]) .titan-plugin,
.titan-plugin[data-titan-theme="light"] {
    color-scheme: light;
}

:where([data-bs-theme="dark"]) .titan-plugin,
.titan-plugin[data-titan-theme="dark"] {
    color-scheme: dark;
}

@supports (color: light-dark(white, black)) {
    .titan-plugin {
        --tp-default-text: light-dark(#18243b, #e9eef8);
        --tp-default-muted: light-dark(#52627b, #a8b7cf);
        --tp-default-surface: light-dark(#fff, #151e2e);
        --tp-default-subtle: light-dark(#f4f7fc, #1b273b);
        --tp-default-line: light-dark(#dbe3ef, #34445c);
        --tp-default-control-line: light-dark(#8595ad, #7184a1);
        --tp-default-focus: light-dark(#355bc6, #9dbbff);
        --tp-default-success-text: light-dark(#126039, #99e7b7);
        --tp-default-success-bg: light-dark(#e8f7ee, #17392d);
        --tp-default-warning-text: light-dark(#7b4711, #ffce86);
        --tp-default-warning-bg: light-dark(#fff3dd, #432d19);
    }
}

.titan-plugin *,
.titan-plugin *::before,
.titan-plugin *::after {
    box-sizing: inherit;
}

.titan-plugin [hidden] {
    display: none !important;
}

.titan-plugin :where(h1, h2, h3) {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.titan-plugin h1 {
    font-size: var(--titan-ui-title-size, clamp(1.75rem, 4vw, 3rem));
}

.titan-plugin h2 {
    font-size: var(--titan-ui-section-size, clamp(1.125rem, 2vw, 1.375rem));
}

.titan-plugin h3 {
    font-size: 1.125rem;
}

.titan-plugin .tp-caption {
    margin-block: 0.5rem 1rem;
    color: var(--tp-muted);
}

.titan-plugin .tp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    gap: var(--tp-gap);
}

.titan-plugin .tp-panel {
    min-inline-size: 0;
    padding: var(--tp-panel-space);
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius);
    background: var(--tp-surface);
    box-shadow: var(--titan-ui-shadow, 0 3px 16px rgb(20 35 60 / 5%));
}

.titan-plugin .tp-section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-block-end: 1.1rem;
}

.titan-plugin .tp-section-heading .tp-caption {
    margin: 0;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.titan-plugin :is(.tp-action, .tp-field) {
    min-block-size: var(--tp-control-height);
    border: 1px solid var(--tp-control-line);
    border-radius: var(--tp-control-radius);
    font: inherit;
}

.titan-plugin .tp-action {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.45rem 0.875rem;
    border-color: transparent;
    background: var(--tp-primary);
    color: var(--titan-on-primary, #fff);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
}

.titan-plugin .tp-action--secondary {
    border-color: var(--tp-control-line);
    background: var(--tp-surface);
    color: var(--tp-text);
}

.titan-plugin .tp-action:hover:not(:disabled) {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.titan-plugin .tp-action--secondary:hover:not(:disabled) {
    background: var(--tp-subtle);
}

.titan-plugin .tp-action:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.titan-plugin .tp-field {
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
    padding: 0.45rem 0.65rem;
    background: var(--tp-surface);
    color: var(--tp-text);
    font-size: 1rem;
    font-weight: 500;
}

.titan-plugin .tp-field::placeholder {
    color: var(--tp-muted);
    opacity: 1;
}

.titan-plugin :where(a, button, input, select, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--tp-focus);
    outline-offset: 3px;
}

.titan-plugin .tp-sr-only,
.titan-plugin [data-tp-feedback]:empty,
.titan-plugin .tp-skip:not(:focus) {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.titan-plugin .tp-skip:focus {
    position: absolute;
    z-index: 2;
    inset-block-start: 1rem;
    inset-inline-start: 1rem;
    padding: 0.6rem 1rem;
    border-radius: var(--tp-control-radius);
    background: var(--tp-surface);
    color: var(--tp-text);
}

.titan-plugin .tp-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--tp-subtle);
    color: var(--tp-muted);
    font-size: 0.8125rem;
    font-weight: 650;
}

.titan-plugin .tp-status::before {
    inline-size: 0.4rem;
    block-size: 0.4rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.titan-plugin .tp-status[data-state="active"],
.titan-plugin .tp-alert[data-kind="success"] {
    background: var(--tp-default-success-bg);
    color: var(--tp-default-success-text);
}

.titan-plugin .tp-status[data-state="validation"],
.titan-plugin .tp-alert[data-kind="warning"] {
    background: var(--tp-default-warning-bg);
    color: var(--tp-default-warning-text);
}

.titan-plugin .tp-alert,
.titan-plugin .tp-empty {
    padding: var(--tp-panel-space);
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-control-radius);
    background: var(--tp-subtle);
}

.titan-plugin .tp-alert {
    margin: 1rem 0 0;
    font-size: 0.9rem;
}

.titan-plugin .tp-empty {
    padding-block: clamp(1.5rem, 6vw, 3rem);
    text-align: center;
}

.titan-plugin .tp-empty .tp-caption {
    margin-block-end: 0;
}

.titan-plugin .tp-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr)) auto;
    align-items: end;
    gap: 0.75rem;
    min-inline-size: 0;
    margin: 0 0 1.1rem;
    padding: 0;
    border: 0;
}

.titan-plugin .tp-control {
    display: grid;
    gap: 0.375rem;
    min-inline-size: 0;
}

.titan-plugin .tp-control label {
    font-size: 0.8125rem;
    font-weight: 650;
}

.titan-plugin .tp-table-wrap {
    overflow: auto;
    border: 1px solid var(--tp-line);
    border-radius: 12px;
}

.titan-plugin .tp-table {
    inline-size: 100%;
    min-inline-size: 39rem;
    border-spacing: 0;
    border-collapse: collapse;
    text-align: start;
}

.titan-plugin .tp-table :is(th, td) {
    padding: 0.85rem 0.9rem;
    border-block-end: 1px solid var(--tp-line);
    text-align: start;
    vertical-align: top;
}

.titan-plugin .tp-table thead th {
    background: var(--tp-subtle);
    color: var(--tp-muted);
    font-size: 0.8125rem;
    font-weight: 700;
}

.titan-plugin .tp-table tbody tr:last-child > * {
    border-block-end: 0;
}

.titan-plugin .tp-table tbody {
    font-size: 0.875rem;
}

.titan-plugin .tp-table th[scope="row"] {
    font-weight: 650;
}

.titan-plugin .tp-table time {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.titan-plugin .tp-cell-label {
    display: none;
}

.titan-plugin .tp-version {
    display: inline-block;
    padding: 0.2rem 0.475rem;
    border: 1px solid var(--tp-line);
    border-radius: 6px;
    background: var(--tp-subtle);
    font: 650 0.8125rem/1.4 var(--tp-mono);
}

.titan-plugin .tp-disclosure {
    min-inline-size: 6rem;
}

.titan-plugin .tp-disclosure summary {
    padding-block: 0.2rem;
    color: var(--tp-text);
    cursor: pointer;
    font-weight: 650;
    white-space: nowrap;
}

.titan-plugin .tp-disclosure[open] {
    max-inline-size: 28rem;
}

.titan-plugin .tp-disclosure .tp-caption {
    margin-block: 0.5rem 0.75rem;
}

.titan-plugin .tp-disclosure dl {
    margin-block: 0 0.8rem;
}

.titan-plugin .tp-disclosure dl > div + div {
    margin-block-start: 0.45rem;
}

.titan-plugin .tp-disclosure dt {
    color: var(--tp-muted);
    font-size: 0.8125rem;
}

.titan-plugin .tp-disclosure dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.titan-plugin .tp-disclosure code {
    font: 0.8125rem/1.45 var(--tp-mono);
}

/* The standalone preview owns its canvas and uses the components above. */
.tp-preview-page {
    margin: 0;
    background: #f0f4fa;
}

@media (prefers-color-scheme: dark) {
    .tp-preview-page {
        background: #101727;
    }
}

.tp-preview-page:has(.tp-preview[data-titan-theme="light"]) {
    background: #f0f4fa;
}

.tp-preview-page:has(.tp-preview[data-titan-theme="dark"]) {
    background: #101727;
}

.titan-plugin.tp-preview {
    position: relative;
    max-inline-size: 82rem;
    padding-block-start: 0;
    padding-block-end: 3rem;
}

.titan-plugin .tp-topbar,
.titan-plugin .tp-brand,
.titan-plugin .tp-theme {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
}

.titan-plugin .tp-topbar {
    justify-content: space-between;
    padding-block: 1rem;
}

.titan-plugin .tp-brand {
    font-size: 0.9375rem;
    font-weight: 700;
}

.titan-plugin .tp-brand-mark {
    display: grid;
    inline-size: 2rem;
    aspect-ratio: 1;
    place-items: center;
    border-radius: 8px;
    background: #203f87;
    color: #fff;
    font: 750 0.8125rem/1 var(--tp-mono);
}

.titan-plugin .tp-theme {
    color: var(--tp-muted);
    font-size: 0.8125rem;
    font-weight: 650;
}

.titan-plugin .tp-theme .tp-field {
    inline-size: auto;
}

.titan-plugin .tp-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem 2rem;
    padding: clamp(1.25rem, 5vw, 3.5rem);
    border: 1px solid #395078;
    border-radius: calc(var(--tp-radius) + 4px);
    background: linear-gradient(115deg, #142441 0%, #1d3460 58%, #25467b 100%);
    color: #fff;
}

.titan-plugin .tp-hero-context {
    margin: 0 0 0.75rem;
    color: #c7dafb;
    font-size: 0.875rem;
    font-weight: 650;
}

.titan-plugin .tp-hero .tp-caption {
    max-inline-size: 42rem;
    margin-block: 0.75rem 0;
    color: #e0eafd;
}

.titan-plugin .tp-demo-label {
    padding: 0.35rem 0.65rem;
    border: 1px solid #9db5e0;
    border-radius: 6px;
    color: #edf3ff;
    font-size: 0.8125rem;
    font-weight: 650;
}

.titan-plugin .tp-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--tp-gap);
    margin-block: var(--tp-gap);
}

.titan-plugin .tp-stat {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.titan-plugin .tp-stat dt {
    color: var(--tp-muted);
    font-size: 0.8125rem;
    font-weight: 650;
}

.titan-plugin .tp-stat dd {
    margin: auto 0 0;
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 700;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 61rem) {
    .titan-plugin .tp-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .titan-plugin .tp-search {
        grid-column: 1 / 3;
    }
}

@media (max-width: 46rem) {
    .titan-plugin .tp-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .titan-plugin .tp-table-wrap {
        overflow: visible;
        border: 0;
    }

    .titan-plugin .tp-table {
        display: block;
        min-inline-size: 0;
    }

    .titan-plugin .tp-table thead {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }

    .titan-plugin .tp-table tbody {
        display: grid;
        gap: 0.75rem;
    }

    .titan-plugin .tp-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 0.5rem;
        padding: 0.85rem;
        border: 1px solid var(--tp-line);
        border-radius: var(--tp-control-radius);
    }

    .titan-plugin .tp-table :is(th, td) {
        display: block;
        padding: 0;
        border: 0;
        overflow-wrap: anywhere;
    }

    .titan-plugin .tp-table :is(th[scope="row"], td:last-child) {
        grid-column: 1 / -1;
    }

    .titan-plugin .tp-cell-label {
        display: block;
        margin-block-end: 0.15rem;
        color: var(--tp-muted);
        font-size: 0.75rem;
    }

    .titan-plugin .tp-table td:last-child {
        padding-block-start: 0.65rem;
        border-block-start: 1px solid var(--tp-line);
    }
}

@media (max-width: 26rem) {
    .titan-plugin .tp-stats {
        gap: 0.5rem;
    }

    .titan-plugin .tp-stat {
        padding: 0.65rem;
    }

    .titan-plugin .tp-stat dt {
        font-size: 0.75rem;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 24rem) {
    .titan-plugin .tp-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .titan-plugin .tp-search {
        grid-column: auto;
    }

}

@media (forced-colors: active) {
    .titan-plugin :is(.tp-action, .tp-status, .tp-demo-label) {
        border-color: ButtonText;
    }

    .titan-plugin :where(a, button, input, select, summary, [tabindex]):focus-visible {
        outline-color: Highlight;
    }
}
