/* ----------------------------------------------------------------------
   Configuration reference: per-field anchors, profile filtering,
   global config index styling.
   ---------------------------------------------------------------------- */

/* Field wrapper carries the toml path id and the profile level class. */
.hmp-field {
    scroll-margin-top: 4rem;
    position: relative;
    margin: 0 -0.5rem 0.75rem -0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.hmp-field:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

@media (prefers-color-scheme: dark) {
    .hmp-field:hover {
        background-color: rgba(125, 175, 255, 0.06);
    }
}

/* Header line: <code>field_name</code>  in TOML:  <code>[parent.field]</code> */
.hmp-field-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

.hmp-field-name {
    font-family: var(--pst-font-family-monospace);
    font-size: 1rem;
    font-weight: 700;
    color: var(--pst-color-primary);
    background-color: var(--pst-color-surface);
    border-left: 3px solid var(--pst-color-primary);
    padding: 0.25rem 0.7rem;
    border-radius: 0 4px 4px 0;
}

.hmp-field-arrow {
    color: var(--pst-color-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-style: normal;
    user-select: none;
}

.hmp-field-toml {
    font-family: var(--pst-font-family-monospace);
    font-size: 0.92rem;
    color: var(--pst-color-text-base);
    background-color: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--pst-color-border);
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
}

@media (prefers-color-scheme: dark) {
    .hmp-field-toml {
        background-color: rgba(255, 255, 255, 0.04);
    }
}

.hmp-field:target,
.hmp-field:focus-within {
    background-color: var(--pst-color-info-bg, rgba(13, 110, 253, 0.06));
    border-radius: 4px;
    transition: background-color 0.4s ease-in-out;
}

/* Anchor copy: hovering a field reveals a permalink icon. */
.hmp-field::before {
    content: "";
    position: absolute;
    left: -1.4rem;
    top: 1rem;
    width: 1rem;
    height: 1rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236c757d'><path d='M6.354 5.5h4.792a1.5 1.5 0 0 1 0 3h-1.04a4.5 4.5 0 0 1-1.04 3H11.5a4.5 4.5 0 0 0 0-9H6.354a4.5 4.5 0 0 0-4.404 5.354A4.486 4.486 0 0 1 6.354 5.5z'/><path d='M9.646 10.5H4.854a1.5 1.5 0 0 1 0-3h1.04a4.5 4.5 0 0 1 1.04-3H4.5a4.5 4.5 0 0 0 0 9h5.146a4.5 4.5 0 0 0 4.404-5.354A4.486 4.486 0 0 1 9.646 10.5z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.hmp-field:hover::before {
    opacity: 0.6;
}

/* Profile-driven visibility classes: applied on the parent body. */
body.hmp-show-user .hmp-field-level-dev,
body.hmp-show-user .hmp-field-level-expert {
    display: none;
}

body.hmp-show-dev .hmp-field-level-expert {
    display: none;
}

/* Per-section toggle bar above the Fields section -- iOS-style pill switch. */
.hmp-level-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0.25rem;
    margin: 0.5rem 0 1.25rem 0;
    background-color: var(--pst-color-surface-secondary, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--pst-color-border);
    border-radius: 999px;
    font-size: 0.8rem;
    flex-wrap: nowrap;
}

.hmp-level-toggle-label {
    font-weight: 600;
    color: var(--pst-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    padding: 0 0.65rem 0 0.55rem;
    user-select: none;
}

.hmp-level-btn {
    border: none;
    background-color: transparent;
    color: var(--pst-color-text-base);
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.hmp-level-btn:hover:not(.is-active) {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--pst-color-primary);
}

.hmp-level-btn.is-active {
    background-color: var(--pst-color-primary);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    cursor: default;
}

@media (prefers-color-scheme: dark) {
    .hmp-level-toggle {
        background-color: rgba(255, 255, 255, 0.05);
    }
    .hmp-level-btn:hover:not(.is-active) {
        background-color: rgba(255, 255, 255, 0.06);
    }
}

/* Configuration index list-table tweaks. */
table.hmp-config-index {
    font-size: 0.85rem;
}

table.hmp-config-index td {
    vertical-align: middle;
    padding: 0.35rem 0.6rem;
}

table.hmp-config-index td:first-child code,
table.hmp-config-index td:first-child .docutils.literal {
    font-weight: 600;
    color: var(--pst-color-primary);
    background: transparent;
    border: none;
    padding: 0;
}

table.hmp-config-index td:nth-child(3),
table.hmp-config-index td:nth-child(4) {
    text-align: center;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

/* TOML breadcrumb shown above the field list (built by hmp-config-reference.js). */
.hmp-toml-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    margin: 0;
    padding: 0.5rem 0.75rem;
    font-family: var(--pst-font-family-monospace);
    font-size: 0.85rem;
    color: var(--pst-color-text-muted);
    background-color: var(--pst-color-background, #ffffff);
    border-bottom: 1px solid var(--pst-color-border);
    position: sticky;
    top: var(--pst-header-height, 4rem);
    z-index: 5;
    backdrop-filter: blur(6px);
}

.hmp-toml-breadcrumb a {
    color: var(--pst-color-primary);
    text-decoration: none;
}

.hmp-toml-breadcrumb a:hover {
    text-decoration: underline;
}

.hmp-toml-breadcrumb-sep {
    color: var(--pst-color-text-muted);
    user-select: none;
}

/* Per-field TOML path rendered as chiplets (built by hmp-config-reference.js). */
.hmp-toml-chips {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
    flex-wrap: wrap;
    font-family: var(--pst-font-family-monospace);
    font-size: 0.85rem;
}

.hmp-toml-bracket {
    color: var(--pst-color-text-muted);
    font-weight: 600;
    user-select: none;
}

.hmp-toml-sep {
    color: var(--pst-color-text-muted);
    opacity: 0.6;
    user-select: none;
    font-size: 0.75rem;
}

.hmp-toml-chip {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: 4px;
    background-color: rgba(13, 110, 253, 0.08);
    color: var(--pst-color-primary);
    text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease;
}

a.hmp-toml-chip:hover {
    background-color: rgba(13, 110, 253, 0.18);
    text-decoration: none;
}

.hmp-toml-chip-dyn {
    background-color: rgba(159, 122, 234, 0.12);
    color: #6d28d9;
    font-style: italic;
}

@media (prefers-color-scheme: dark) {
    .hmp-toml-chip {
        background-color: rgba(125, 175, 255, 0.12);
    }
    a.hmp-toml-chip:hover {
        background-color: rgba(125, 175, 255, 0.22);
    }
    .hmp-toml-chip-dyn {
        background-color: rgba(196, 181, 253, 0.18);
        color: #c4b5fd;
    }
}

/* Admonition rendering of multi-value Field(examples=[...]). */
.hmp-field-examples.admonition {
    margin: 0.5rem 0 0.75rem 0;
    border-left: 3px solid #f59e0b;
    background-color: rgba(245, 158, 11, 0.06);
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    font-size: 0.88rem;
}

.hmp-field-examples.admonition > .admonition-title {
    color: #b45309;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    background: transparent;
    padding: 0;
}

.hmp-field-examples.admonition ul {
    margin: 0;
    padding-left: 1.1rem;
}

@media (prefers-color-scheme: dark) {
    .hmp-field-examples.admonition {
        background-color: rgba(245, 158, 11, 0.12);
    }
    .hmp-field-examples.admonition > .admonition-title {
        color: #fbbf24;
    }
}

/* Discriminated-union tab-set (sphinx_design): trim its visual weight. */
.hmp-config-fields .sd-tab-set {
    margin: 0.5rem 0 1rem 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--pst-color-border);
}

.hmp-config-fields .sd-tab-set > input[type="radio"] + label {
    background-color: var(--pst-color-surface);
    border: none;
    border-right: 1px solid var(--pst-color-border);
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--pst-color-text-muted);
    transition: all 0.12s ease;
}

.hmp-config-fields .sd-tab-set > input[type="radio"]:checked + label {
    background-color: var(--pst-color-background);
    color: var(--pst-color-primary);
    border-bottom: 2px solid var(--pst-color-primary);
}

.hmp-config-fields .sd-tab-content {
    padding: 0.75rem 1rem;
    background-color: var(--pst-color-background);
}

/* ER diagram thumbnail style (#11): compact preview with click-to-expand cue. */
.hmp-er-thumbnail {
    position: relative;
    max-height: 360px;
    overflow: hidden;
    border: 1px solid var(--pst-color-border);
    border-radius: 6px;
    padding: 0.75rem;
    background-color: var(--pst-color-surface);
    cursor: zoom-in;
    transition: max-height 0.25s ease;
}

.hmp-er-thumbnail .er-diagram {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.hmp-er-thumbnail::after {
    content: "Click to zoom";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    color: var(--pst-color-text-muted);
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--pst-color-surface) 65%
    );
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hmp-er-thumbnail .hmp-er-hint {
    display: none;
}

/* ----------------------------------------------------------------------
   Quick search across every TOML path (config_reference/index.rst).
   ---------------------------------------------------------------------- */

.hmp-config-search {
    margin: 0.5rem 0 1.5rem 0;
}

#hmp-config-search-input {
    width: 100%;
    padding: 0.6rem 0.9rem;
    font-size: 1rem;
    font-family: var(--pst-font-family-monospace);
    border: 1px solid var(--pst-color-border);
    border-radius: 0.5rem;
    background-color: var(--pst-color-surface);
    color: var(--pst-color-text-base);
}

#hmp-config-search-input:focus {
    outline: none;
    border-color: var(--pst-color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.hmp-config-search-results {
    margin-top: 0.5rem;
    max-height: 28rem;
    overflow-y: auto;
}

.hmp-config-search-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hmp-config-search-item {
    border-bottom: 1px solid var(--pst-color-border);
    padding: 0.5rem 0.4rem;
}

.hmp-config-search-item:last-child {
    border-bottom: none;
}

.hmp-config-search-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--pst-color-text-base);
    flex-wrap: wrap;
}

.hmp-config-search-link:hover {
    color: var(--pst-color-primary);
}

.hmp-config-search-path {
    font-family: var(--pst-font-family-monospace);
    font-weight: 600;
    color: var(--pst-color-primary);
    background: transparent;
    padding: 0;
}

.hmp-config-search-path mark {
    background-color: rgba(255, 213, 79, 0.45);
    color: inherit;
    padding: 0 0.1rem;
    border-radius: 2px;
}

.hmp-config-search-type {
    font-family: var(--pst-font-family-monospace);
    font-size: 0.8rem;
    color: var(--pst-color-text-muted);
}

.hmp-config-search-profile {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    background-color: var(--pst-color-surface);
    border: 1px solid var(--pst-color-border);
}

.hmp-config-search-profile-user {
    color: #166534;
    border-color: #86efac;
    background-color: rgba(34, 197, 94, 0.1);
}

.hmp-config-search-profile-dev {
    color: #92400e;
    border-color: #fcd34d;
    background-color: rgba(245, 158, 11, 0.1);
}

.hmp-config-search-profile-expert {
    color: #991b1b;
    border-color: #fca5a5;
    background-color: rgba(239, 68, 68, 0.1);
}

.hmp-config-search-desc {
    margin: 0.2rem 0 0 0;
    color: var(--pst-color-text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

.hmp-config-search-empty {
    padding: 0.4rem 0.2rem;
    font-style: italic;
    color: var(--pst-color-text-muted);
}
