/* Thing-detail route: header, viewer well, model/part panels. Sits inside the
   shell content region (flex height, not `min-height: 100vh`). */

.thing-detail-page {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(0.75rem, 2vw, 1.75rem) clamp(1rem, 3vw, 2.5rem);
}

.thing-detail-header,
.thing-detail-summary,
.thing-detail-copy,
.detail-panel,
.selected-model-panel,
.parts-list,
.part-row-body {
    display: flex;
    flex-direction: column;
}

.thing-detail-header {
    gap: 0.5rem;
}

.thing-detail-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
}

.thing-detail-title-row h1,
.detail-panel h2,
.selected-model-panel h2,
.part-row h3 {
    margin: 0;
    color: var(--color-emphasis);
    letter-spacing: -0.03em;
}

.thing-detail-title-row h1 {
    font-size: clamp(2.1rem, 5vw, 4rem);
    line-height: 0.95;
}

.thing-detail-creator,
.detail-muted,
.model-row-summary,
.part-notes,
.viewer-unavailable p {
    margin: 0;
    color: var(--color-subtle);
}

.thing-detail-stats,
.part-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    margin: 0;
    color: var(--color-muted);
    font-family: var(--font-mono);
    font-size: 0.76rem;
}

.thing-detail-stats div,
.part-row-meta div {
    display: contents;
}

.thing-detail-stats dt,
.part-row-meta dt {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.thing-detail-stats dd,
.part-row-meta dd {
    margin: 0;
}

.thing-detail-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(18rem, 0.95fr);
    align-items: start;
    gap: clamp(1rem, 3vw, 1.5rem);
    padding: clamp(1rem, 3vw, 1.5rem);
}

.thing-detail-viewer {
    aspect-ratio: 4 / 3;
    min-height: 20rem;
    max-height: 34rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-panel);
    overflow: hidden;
}

.detail-asset-viewer,
.detail-asset-viewer .model-viewer-boundary,
.detail-asset-viewer .model-viewer-stage {
    height: 100%;
    min-height: 0;
}

.detail-asset-viewer .model-viewer-boundary {
    border: 0;
    background: transparent;
}

.detail-asset-viewer .model-viewer-stage {
    grid-template-rows: 1fr;
}

.model-viewer-preview-image {
    grid-row: 1;
    grid-column: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thing-detail-summary {
    justify-content: space-between;
    gap: 1rem;
}

.thing-detail-copy {
    gap: 0.85rem;
}

.thing-detail-chips,
.thing-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.thing-detail-actions {
    align-items: center;
}

.thing-detail-actions .detail-action-error {
    flex-basis: 100%;
    margin: 0;
    color: var(--color-error);
    font-size: 0.85rem;
}

.thing-detail-actions .button-primary {
    min-width: 9.5rem;
}

.model-row:disabled,
.model-row[disabled] {
    cursor: not-allowed;
    opacity: 0.52;
    filter: saturate(0.7);
}

.thing-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.detail-panel {
    gap: 0.85rem;
    padding: 1rem;
}

.thing-detail-grid > .detail-panel:nth-child(-n + 2) {
    align-self: stretch;
    height: 100%;
}

.detail-panel-heading {
    display: flex;
    align-items: baseline;
}

.detail-panel-heading h2,
.selected-model-heading h2 {
    font-size: clamp(1.25rem, 2vw, 1.6rem);
    line-height: 1.1;
}

.selected-model-heading {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.model-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.model-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-panel);
    background: var(--color-base);
    color: var(--color-text);
    text-align: left;
}

.model-row:hover,
.model-row.is-selected {
    border-color: var(--color-primary);
}

.model-row.is-selected {
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.model-row-title {
    font-weight: 700;
}

.model-row-meta {
    color: var(--color-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.selected-model-panel,
.part-row-body {
    gap: 0.65rem;
}

.part-download {
    align-self: flex-start;
}

.parts-list {
    gap: 0.75rem;
}

.part-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-panel);
    background: var(--color-base);
}

.part-row-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-pill);
    color: var(--color-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.viewer-unavailable {
    min-height: 12rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-panel);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
}

@media (max-width: 820px) {
    .thing-detail-shell,
    .thing-detail-grid {
        grid-template-columns: 1fr;
    }

    .thing-detail-title-row {
        display: grid;
        align-items: start;
    }
}
