/**
 * Ipsum-specific layout only. Colors, type, shape, spacing, and
 * components all come from assets/css/tokens.css + components.css.
 * Nothing here should hardcode a color or size that a --ds-* token
 * already covers.
 */

/* Flex column so .layout can grow to fill leftover vertical space,
   keeping .site-footer pinned to the bottom of the viewport when
   generated content is short instead of floating right below it. */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: var(--ds-spacing-6) var(--ds-spacing-6) calc(var(--ds-spacing-8) * 2);
}

/* A plain top bar, not a colored hero block: title + tagline on the
   left, the theme toggle on the right, separated from the page body by
   a hairline border rather than a tinted card. Full width, not capped -
   only the generated text (see #output below) keeps a reading
   line-length cap. */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ds-spacing-4);
    flex-wrap: wrap;
    padding-bottom: var(--ds-spacing-6);
    margin-bottom: var(--ds-spacing-8);
    border-bottom: 1px solid var(--ds-color-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--ds-spacing-3);
}

.brand-mark {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.page-header h1 {
    letter-spacing: -0.02em;
}

.tagline {
    margin-top: var(--ds-spacing-1);
    color: var(--ds-color-text-muted);
}

.theme-toggle {
    flex-shrink: 0;
}

.layout {
    display: flex;
    flex-direction: column;
    gap: var(--ds-spacing-6);
    flex: 1;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--ds-spacing-4);
}

.field-checkbox {
    justify-content: flex-end;
}

.field-actions {
    flex-direction: row;
    align-items: flex-end;
    gap: var(--ds-spacing-3);
}

.field-actions .ds-button--primary {
    flex: 1;
}

.output-panel {
    min-height: 200px;
}

/* The output panel itself is full width, but the text inside stays at a
   comfortable reading line-length (~75ch) and centers within the panel,
   rather than stretching edge to edge on wide monitors. */
#output {
    display: block;
    max-width: 75ch;
    margin: 0 auto;
    line-height: 1.7;
}

#output p {
    margin: 0 0 1em;
}

#output p:last-child {
    margin-bottom: 0;
}

.site-footer {
    margin-top: var(--ds-spacing-8);
    padding-top: var(--ds-spacing-6);
    border-top: 1px solid var(--ds-color-border);
    text-align: center;
}

.site-footer p {
    font: var(--ds-type-body-sm);
    color: var(--ds-color-text-faint);
}

.site-footer a {
    color: var(--ds-color-text-muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--ds-color-accent);
    text-decoration: underline;
}

/* Only shown once app.js detects the page has scrolled past a threshold
   (see assets/js/app.js) - unlike the header theme toggle, this one is
   meant to float over scrolled content, so it only exists in the DOM's
   visible state while there's something to scroll back up from. */
.back-to-top {
    position: fixed;
    right: var(--ds-spacing-6);
    bottom: var(--ds-spacing-6);
    box-shadow: var(--ds-shadow-md);
    font-size: 16px;
}

/* .ds-icon-button sets display: inline-flex as an author-stylesheet rule,
   which otherwise wins the cascade over the browser's own (lower-priority
   user-agent) `[hidden] { display: none }` rule - without this, the
   `hidden` attribute would have no visible effect here. */
.back-to-top[hidden] {
    display: none;
}

@media (max-width: 720px) {
    body {
        padding: var(--ds-spacing-4) var(--ds-spacing-4) calc(var(--ds-spacing-8) * 2);
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .field-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
