/*
 * Layout for the <details> sections in the API description.
 * Swagger UI strips class and style attributes from the description, so everything is targeted
 * with descendant selectors, scoped to the description so the rest of the page is untouched.
 * Text colours are inherited, so the sections follow both the light and the dark Swagger UI theme.
 */

.swagger-ui .info .description details {
    margin: 0;
}

.swagger-ui .info .description details > summary {
    font-size: 16px;
    cursor: pointer;
    /* Same box open and closed, so the summary text does not move when the section is toggled. */
    padding: 8px 0;
    border-bottom: 1px solid transparent;
}

/*
 * An open section keeps its summary at the top of the window so it can be closed from anywhere
 * inside it. It scrolls away with the section, because sticky positioning ends with the parent.
 * The background hides the text scrolling underneath and has to match the page in each theme.
 */
.swagger-ui .info .description details[open] > summary {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fafafa;
    border-bottom-color: rgba(128, 128, 128, 0.3);
}

html.dark-mode .swagger-ui .info .description details[open] > summary {
    background: #1c2022;
}

.swagger-ui .info .description details > :not(summary) {
    margin: 8px 0 8px 48px;
}

.swagger-ui .info .description details > h4 {
    margin-top: 32px;
}

.swagger-ui .info .description details > summary + h4 {
    margin-top: 16px;
}

/* The close link ends the section, so it lines up with the summary instead of the indented content. */
.swagger-ui .info .description details > p:last-child {
    margin: 24px 0 0 0;
    padding: 8px 0;
    border-top: 1px solid rgba(128, 128, 128, 0.3);
    font-size: 16px;
}

/* Styled like the summary it mirrors: same size and colour, with an arrow pointing back up. */
.swagger-ui .info .description details > p:last-child a {
    color: inherit;
    font-size: inherit;
    text-decoration: none;
    cursor: pointer;
}

.swagger-ui .info .description details > p:last-child a::before {
    content: "\25B2";
    display: inline-block;
    width: 1.3em;
    font-size: 0.8em;
}

.swagger-ui .info .description details img {
    max-width: 100%;
    height: auto;
    margin: 8px 0 12px 0;
    /* Visible on every side, slightly heavier towards the bottom right. */
    box-shadow: 3px 4px 14px 2px rgba(0, 0, 0, 0.3);
}

/* Any shadow or glow makes the image look blurred on the dark page. A shadow takes up no space, so the image stays in the same place. */
html.dark-mode .swagger-ui .info .description details img {
    box-shadow: none;
}

.swagger-ui .info .description details p,
.swagger-ui .info .description details li {
    line-height: 1.5;
}
