/* DATA DARE detail pages — learning workflow geometry (extends design system) */

.fi-dd-detail {
    display: flex;
    flex-direction: column;
    gap: var(--fd-dd-detail-gap, var(--fd-space-4, 16px));
    padding-block: var(--fd-space-4, 16px) var(--fd-space-8, 2rem);
}

.fi-dd-detail-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--fd-dd-detail-gap, var(--fd-space-4, 16px));
    align-items: start;
    width: 100%;
    min-width: 0;
}

.fi-dd-detail-main {
    display: flex;
    flex-direction: column;
    gap: var(--fd-dd-detail-gap, var(--fd-space-4, 16px));
    min-width: 0;
}

.fi-dd-detail-discussion-inline .fi-dd-discussion-detail {
    position: sticky;
    top: calc(var(--fd-header-offset, 64px) + 0.75rem);
    max-height: calc(100vh - var(--fd-header-offset, 64px) - 1.5rem);
    overflow: auto;
}

@media (min-width: 961px) {
    .fi-dd-detail-workspace {
        grid-template-columns: var(--fd-grid-dd-detail-workspace);
        gap: var(--fd-dd-workspace-gap, clamp(20px, 2vw, 28px));
    }

    .fi-dd-detail-discussion-inline {
        min-width: 0;
    }
}

.fi-dd-detail-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    font-size: 0.875rem;
}

.fi-dd-detail-breadcrumb a {
    color: inherit;
    text-decoration: none;
}

.fi-dd-detail-breadcrumb a:hover,
.fi-dd-detail-breadcrumb a:focus-visible {
    color: var(--fd-gold, #d99a16);
}

.fi-dd-detail-header {
    display: grid;
    grid-template-columns: minmax(var(--fd-slot-dd-detail-min, 140px), var(--fd-slot-dd-detail-max, 240px)) minmax(0, 1fr);
    gap: var(--fd-space-5, 1.25rem);
    padding: var(--fd-space-5, 1.25rem);
    align-items: start;
}

.fi-dd-detail-header__thumb {
    width: 100%;
    aspect-ratio: var(--fd-dd-card-media-ratio, var(--fd-slot-card-ratio, 4 / 3));
    object-fit: contain;
    object-position: center bottom;
    border-radius: var(--fd-radius-md, 12px);
    background: var(--fd-bg-secondary, #f5eedc);
}

.fi-dd-detail-header__thumb--placeholder {
    /* ASSET DEPENDENT — preserve slot; do not stretch missing artwork */
    min-height: calc(var(--fd-slot-dd-detail-min, 140px) * 0.75);
    background: var(--fd-bg-secondary, #f5eedc);
}

.fi-dd-detail-header__code,
.fi-dd-question-hero__code {
    font-family: ui-monospace, monospace;
    font-size: 0.8125rem;
    color: var(--fd-muted-text, #6f6a62);
    margin: 0 0 0.35rem;
}

.fi-dd-detail-header__summary {
    margin: 0.5rem 0 0;
    max-width: 62ch;
}

.fi-dd-detail-header__badges,
.fi-dd-question-hero__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.fi-dd-detail-section,
.fi-dd-detail-actions,
.fi-dd-discussion-detail {
    padding: var(--fd-space-4, 16px);
}

.fi-dd-detail-section .fd-heading-md,
.fi-dd-discussion-detail .fd-heading-md {
    font-size: var(--fd-text-h4, 1.125rem);
}

.fi-dd-detail-section__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--fd-space-2, 8px);
    align-items: center;
    margin-bottom: var(--fd-space-2, 8px);
}

.fi-dd-detail-section__foot {
    margin-top: var(--fd-space-4, 1rem);
}

.fi-dd-disclosure__summary {
    cursor: pointer;
    list-style: none;
}

.fi-dd-disclosure__summary::-webkit-details-marker {
    display: none;
}

.fi-dd-disclosure__body {
    margin-top: var(--fd-space-3, 12px);
}

.fi-dd-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fi-dd-prose {
    line-height: 1.65;
    white-space: pre-wrap;
    max-width: var(--fd-measure-dd-prose, 62ch);
}

.fi-dd-meta-grid dt,
.fd-meta-strip strong {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fd-muted-text, #6f6a62);
}

.fi-dd-share {
    padding: var(--fd-space-4, 1rem) var(--fd-space-5, 1.25rem);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.fi-dd-share__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Sticky share strip — opt-in via the stickyShare flag on the share partial.
   Used on the dataset detail page, where the strip leads the page and then
   pins under the site header for the rest of the scroll. Sits below the header
   (z-index 500) and its mobile overlay (499) so those still cover it. */
.fi-dd-share--sticky {
    position: sticky;
    top: calc(var(--fd-header-offset, 64px) + 0.5rem);
    z-index: 20;
    box-shadow: var(--fd-shadow-soft);
}

/* On phones the base rule stacks the strip into a column, which would eat most
   of the screen once pinned. Keep it a single compact row instead. */
@media (max-width: 767px) {
    .fi-dd-share.fi-dd-share--sticky {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .fi-dd-share.fi-dd-share--sticky .fi-dd-share__actions {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        justify-content: flex-end;
        gap: 0.35rem;
    }

    .fi-dd-share.fi-dd-share--sticky .fi-dd-share__actions .fd-btn {
        flex: 0 1 auto;
        padding-inline: 0.6rem;
        font-size: 0.8125rem;
        white-space: nowrap;
    }
}

/* Narrowest phones: drop the visible heading so the four buttons still fit on
   one line. It stays in the accessibility tree for screen readers. */
@media (max-width: 480px) {
    .fi-dd-share.fi-dd-share--sticky .fi-dd-share-label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    .fi-dd-share.fi-dd-share--sticky .fi-dd-share__actions {
        width: 100%;
        justify-content: space-between;
    }
}

.fi-dd-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fi-dd-file-list .fd-file-row {
    padding: var(--fd-space-4, 1rem);
    border-radius: var(--fd-radius-md, 12px);
    background: rgba(255, 255, 255, 0.35);
}

.fi-dd-version-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.fi-dd-version-tab {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--fd-soft-border, rgba(32, 32, 32, 0.075));
    text-decoration: none;
    color: inherit;
    font-size: 0.875rem;
    transition: border-color 150ms ease, background 150ms ease;
}

.fi-dd-version-tab.is-active {
    background: rgba(217, 154, 22, 0.12);
    border-color: rgba(217, 154, 22, 0.45);
}

.fi-dd-model-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.fi-dd-model-preview__card {
    padding: var(--fd-space-4, 1rem);
    border-radius: var(--fd-radius-md, 12px);
    background: rgba(255, 255, 255, 0.35);
}

.fi-dd-question-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.fi-dd-question-filters .fd-chip.is-active {
    background: rgba(217, 154, 22, 0.14);
    border-color: rgba(217, 154, 22, 0.45);
}

.fi-dd-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    list-style: none;
    padding: 0;
    margin: 0.35rem 0 0;
}

.fi-dd-question-hero {
    padding: var(--fd-space-4, 16px);
}

.fi-dd-question-hero__dataset {
    color: var(--fd-gold, #d99a16);
    text-decoration: none;
    font-size: 0.875rem;
}

.fi-dd-question-focus__text {
    font-size: clamp(1.05rem, 1.5vw, 1.2rem);
    max-width: var(--fd-measure-dd-prose, 62ch);
}

.fi-dd-question-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: center;
    padding: var(--fd-space-4, 1rem) var(--fd-space-5, 1.25rem);
}

.fi-dd-question-nav > :first-child {
    justify-self: start;
}

.fi-dd-question-nav > :last-child {
    justify-self: end;
}

.fi-dd-question-nav__position {
    text-align: center;
    font-size: 0.875rem;
    white-space: nowrap;
}

.fi-dd-solution-preview-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fi-dd-solution-preview {
    padding: var(--fd-space-4, 1rem);
}

.fi-dd-solution-preview__head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.fi-dd-solution-preview__excerpt {
    margin: 0.35rem 0 0.75rem;
    color: var(--fd-muted-text, #6f6a62);
}

.fi-dd-discussion-detail__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.fi-dd-discussion-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Compact DD download gate — shared journey modal shell, denser panel width */
.fi-dd-download-gate.fi-journey-gate-modal .fd-modal__panel,
.fi-dd-download-gate .fd-modal__panel {
    width: min(480px, calc(100vw - 32px));
    max-height: min(78vh, 560px);
}

.fi-dd-download-gate__meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--fd-space-2, 8px);
    margin: 0 0 var(--fd-space-3, 12px);
}

.fi-dd-download-gate__meta dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--fd-muted-text, #6f6a62);
}

.fi-dd-download-gate__meta dd {
    margin: 0.15rem 0 0;
    font-weight: 600;
}

@media (max-width: 430px) {
    .fi-dd-download-gate__meta {
        grid-template-columns: 1fr;
    }
}

.fd-question-row + .fd-question-row,
.fi-dd-detail-section .fd-question-row {
    margin-top: 0.75rem;
}

@media (max-width: 767px) {
    .fi-dd-detail-header {
        grid-template-columns: 1fr;
    }

    .fi-dd-detail-header__thumb {
        max-width: min(100%, var(--fd-slot-dd-detail-max, 240px));
    }

    .fi-dd-question-nav {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .fi-dd-question-nav > :first-child,
    .fi-dd-question-nav > :last-child {
        justify-self: stretch;
    }

    .fi-dd-question-nav__position {
        order: -1;
    }

    .fi-dd-share {
        flex-direction: column;
        align-items: stretch;
    }

    .fi-dd-share__actions .fd-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (max-width: 639px) {
    .fd-file-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* Detail discussion — inline sidebar @desktop, drawer @≤960px */
.fi-dd-detail-discussion-inline {
    display: block;
}

.fi-dd-detail-discussion-drawer.fi-dd-discussion {
    display: none;
}

.fi-dd-detail-discussion-toggle {
    display: none;
    position: fixed;
    right: var(--fd-space-4, 16px);
    bottom: max(var(--fd-space-4, 16px), env(safe-area-inset-bottom, 0px));
    z-index: 40;
    box-shadow: var(--fd-shadow-elevated);
    min-height: var(--fd-touch-min, 44px);
}

@media (max-width: 960px) {
    .fi-dd-detail-discussion-inline {
        display: none;
    }

    .fi-dd-detail-workspace {
        grid-template-columns: 1fr;
    }

    .fi-dd-detail-discussion-drawer.fi-dd-discussion {
        display: block;
        position: fixed;
        inset: auto 0 0 0;
        width: 100%;
        max-width: 100%;
        max-height: var(--fd-dd-mobile-drawer-max-height, min(78dvh, 560px));
        transform: translateY(110%);
        transition: transform var(--fd-duration-slow, 250ms) var(--fd-ease);
        z-index: 50;
        border-radius: var(--fd-radius-lg, 22px) var(--fd-radius-lg, 22px) 0 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: var(--fd-space-4, 16px);
        padding-bottom: max(var(--fd-space-4, 16px), env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    .fi-dd-detail-discussion-drawer.fi-dd-discussion.is-open {
        transform: translateY(0);
    }

    .fi-dd-detail-discussion-toggle {
        display: inline-flex;
        left: max(var(--fd-space-3, 12px), env(safe-area-inset-left, 0px));
        right: max(var(--fd-space-3, 12px), env(safe-area-inset-right, 0px));
        width: auto;
        justify-content: center;
    }
}

@media (max-width: 430px) {
    .fi-dd-detail {
        padding-block: var(--fd-space-3, 12px) var(--fd-space-10, 40px);
    }

    .fi-dd-detail-header__body .fd-heading-xl {
        font-size: var(--fd-text-h2);
    }

    .fi-dd-detail-section,
    .fi-dd-detail-actions,
    .fi-dd-discussion-detail {
        padding: var(--fd-space-3, 12px);
    }
}

@media (max-width: 320px) {
    .fi-dd-detail-header__body .fd-heading-xl,
    .fi-dd-question-hero__title {
        font-size: var(--fd-text-h3);
    }
}

@media (prefers-reduced-motion: reduce) {
    .fi-dd-detail-discussion-drawer.fi-dd-discussion {
        transition: none;
    }
}
