/* Lightcurve Discovery — responsive layout tokens and page tweaks.
 *
 * Unit policy (production):
 * - rem/em: typography, spacing, radii (respects user root font / zoom)
 * - clamp(rem, vh, rem): panel heights (small monitors + low viewport height)
 * - px: Ag Grid theme hairlines only (third-party grid expects pixel metrics)
 */

.lc-discovery-page {
    font-size: 0.85rem;
    --lc-discovery-select-font-size: 0.85rem;
    --lc-discovery-space-xs: 0.25rem;
    --lc-discovery-space-sm: 0.375rem;
    --lc-discovery-space-md: 0.5rem;
    --lc-discovery-space-lg: 0.625rem;
    --lc-discovery-space-xl: 0.75rem;
    --lc-discovery-text-xs: 0.75rem;
    --lc-discovery-text-sm: 0.85rem;
    --lc-discovery-radius-sm: 0.25rem;
    /* --lc-discovery-panel-height: clamp(20rem, 45vh, 30rem); */
    --lc-discovery-panel-height: clamp(20rem, 400px, 30rem);    /* 400px as Aladin applet */
    --lc-discovery-panel-height-compact: clamp(13.75rem, 38vh, 22.5rem);
    --lc-discovery-graph-height: clamp(17.5rem, 55vh, 35rem);
    --lc-discovery-card-max-height: clamp(5rem, 22vh, 10rem);
}

.lc-discovery-page-title {
    line-height: 1.25;
    word-break: break-word;
}

.lc-discovery-intro {
    line-height: 1.45;
}

.lc-discovery-field-stack {
    display: flex;
    flex-direction: column;
    gap: var(--lc-discovery-space-sm);
    margin-bottom: var(--lc-discovery-space-lg);
}

.lc-discovery-submit-actions {
    margin-bottom: var(--lc-discovery-space-lg);
}

.lc-discovery-search-status {
    margin-bottom: var(--lc-discovery-space-lg);
    padding: var(--lc-discovery-space-sm) var(--lc-discovery-space-md);
    font-size: var(--lc-discovery-text-xs);
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.35);
    border-radius: var(--lc-discovery-radius-sm);
}

/* Compact spinner reserved before Retrieve in the header actions group. */
.lc-discovery-catalog-busy {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.lc-discovery-catalog-header-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--lc-discovery-space-md);
    margin-bottom: var(--lc-discovery-space-md);
}

.lc-discovery-catalog-header-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    flex: 1 1 auto;
}

.lc-discovery-catalog-header-actions {
    display: flex;
    align-items: center;
    gap: var(--lc-discovery-space-md);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.lc-discovery-catalog-title {
    line-height: 1.25;
    word-break: break-word;
    min-width: 0;
}

.lc-discovery-field-row {
    display: grid;
    align-items: center;
    column-gap: var(--lc-discovery-space-md);
}

.lc-discovery-field-label {
    margin: 0;
    width: 3em;
    flex-shrink: 0;
}

.lc-discovery-field-input {
    width: 100%;
    min-width: 0;
}

.lc-discovery-field-row-target {
    grid-template-columns: 3em minmax(0, 1fr) 1.25em;
}

.lc-discovery-field-row-target .lc-discovery-field-input-wide {
    grid-column: 2;
}

.lc-discovery-field-row-target .lc-discovery-field-help {
    grid-column: 3;
    justify-self: start;
}

.lc-discovery-field-row-time {
    grid-template-columns: minmax(0, 1fr) 6.5em 1.25em;
}

.lc-discovery-field-row-time .lc-discovery-field-input {
    grid-column: 1;
    width: 100%;
}

.lc-discovery-page .lc-discovery-field-unit,
.lc-discovery-page .lc-discovery-field-unit.form-select {
    font-size: var(--lc-discovery-select-font-size);
}

.lc-discovery-field-row-time .lc-discovery-field-unit {
    grid-column: 2;
    width: 100%;
    min-width: 0;
}

.lc-discovery-field-row-time .lc-discovery-field-help {
    grid-column: 3;
    justify-self: start;
}

.lc-discovery-object-card .card-body {
    line-height: 1.15;
    max-height: var(--lc-discovery-card-max-height);
    font-size: var(--lc-discovery-text-sm);
    overflow-y: auto;
    overflow-x: hidden;
}

.lc-discovery-object-markdown {
    font-size: inherit;
    color: inherit;
}

.lc-discovery-object-markdown strong,
.lc-discovery-object-markdown code {
    font-weight: inherit;
    color: inherit;
    background: transparent;
}

.lc-discovery-object-markdown :last-child {
    margin-bottom: 0;
}

.lc-discovery-help-btn {
    display: inline;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0 0.1em;
    margin: 0;
    color: #446e9b;
    font-family: "Comic Sans MS", "Comic Sans", cursive;
    font-size: 1.05em;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    vertical-align: baseline;
    user-select: none;
}

.lc-discovery-help-btn:hover,
.lc-discovery-help-btn:focus-visible {
    color: #2a4566;
    background: transparent;
    text-decoration: underline;
    outline: none;
    box-shadow: none;
}

.lc-discovery-help-popover {
    max-width: min(24rem, 92vw);
}

.lc-discovery-help-popover .popover-body {
    max-height: min(50vh, 20rem);
    overflow-y: auto;
    font-size: var(--lc-discovery-text-sm, 0.85rem);
    line-height: 1.45;
}

.lc-discovery-catalog-grid {
    height: var(--lc-discovery-panel-height);
    width: 100%;
    min-height: 0;
    overflow-x: auto;
}

.lc-discovery-catalog-body-row {
    align-items: stretch;
}

.lc-discovery-aladin-col {
    display: flex;
    flex-direction: column;
    gap: var(--lc-discovery-space-md);
    min-width: 0;
}

.lc-discovery-aladin-wrap {
    width: 100%;
    max-width: 100%;
    min-height: var(--lc-discovery-panel-height);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
}

.lc-discovery-aladin-wrap > div {
    max-width: 100%;
}

.lc-discovery-aladin-hint {
    font-size: var(--lc-discovery-text-sm);
    line-height: 1.4;
}

.lc-discovery-aladin-empty {
    font-size: var(--lc-discovery-text-sm);
    line-height: 1.4;
    padding: var(--lc-discovery-space-xl) var(--lc-discovery-space-xs);
}

/* Ag Grid: keep pixel metrics for row geometry; use rem for readable text scaling. */
.lc-discovery-catalog-aggrid.ag-theme-balham {
    --ag-row-height: 1.8rem;
    --ag-header-height: 1.8rem;
    --ag-cell-horizontal-padding: 0.45rem;
    --ag-font-size: 0.75rem;
}

.lc-discovery-catalog-aggrid .ag-root-wrapper,
.lc-discovery-catalog-aggrid .ag-center-cols-viewport,
.lc-discovery-catalog-aggrid .ag-body-viewport {
    overflow-x: auto;
}

.lc-discovery-catalog-aggrid .ag-cell,
.lc-discovery-catalog-aggrid .ag-header-cell,
.lc-discovery-catalog-aggrid .ag-header-cell-label {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
    line-height: 1.15;
}

.lc-discovery-catalog-aggrid .ag-cell,
.lc-discovery-catalog-aggrid .ag-cell-wrapper {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.lc-discovery-catalog-aggrid .ag-cell-value,
.lc-discovery-catalog-aggrid .lc-discovery-catalog-cell,
.lc-discovery-catalog-aggrid .lc-discovery-catalog-cell-numeric {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.lc-discovery-catalog-aggrid .lc-discovery-catalog-cell-numeric {
    font-variant-numeric: tabular-nums;
    text-align: right;
    width: 100%;
}

.lc-discovery-catalog-aggrid .ag-cell:not(:last-child) {
    border-right: 1px solid var(--ag-border-color, #bdc3c7);
}

.lc-discovery-catalog-aggrid .ag-header-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.lc-discovery-catalog-aggrid .ag-header-cell-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    width: 100%;
}

.lc-discovery-catalog-aggrid .ag-right-aligned-header .ag-header-cell-label {
    justify-content: flex-start;
    flex-direction: row;
}

.lc-discovery-catalog-aggrid .lc-discovery-row-highlight {
    background-color: #fff3cd !important;
    font-weight: 600;
}

.lc-discovery-graph-wrap {
    width: 100%;
    min-height: var(--lc-discovery-graph-height);
    height: var(--lc-discovery-graph-height);
}

.lc-discovery-tabs.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

@media (max-width: 575.98px) {
    .lc-discovery-page {
        --lc-discovery-panel-height: var(--lc-discovery-panel-height-compact);
        --lc-discovery-graph-height: clamp(14rem, 45vh, 28rem);
        --lc-discovery-card-max-height: clamp(4.5rem, 18vh, 8rem);
    }
}

@media (max-height: 720px) {
    .lc-discovery-page {
        --lc-discovery-panel-height: clamp(11rem, 38vh, 22rem);
        --lc-discovery-graph-height: clamp(12rem, 42vh, 24rem);
        --lc-discovery-card-max-height: clamp(4rem, 16vh, 7rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .lc-discovery-tabs.nav-tabs {
        scroll-behavior: auto;
    }
}

.lc-discovery-plot-alert {
    margin-top: var(--lc-discovery-space-md);
    width: 100%;
}
