/* Live art pages (Random Art series): the Live / Legacy switch, the canvas stage, the
   control panel and sliders. Follows Bootstrap's theme variables, so light and dark work;
   the artwork keeps its own background.

   Layout: the title and switch on one row; below, the artwork beside a side panel, so the
   whole drawing and its controls fit in the window together. The artwork's height is capped
   by the window (--fit); --ar is its aspect ratio. Switching Live / Legacy moves nothing:
   the canvas and the original render take the same box, and the code takes exactly the
   controls' space in the panel (it scrolls inside it). */

.art-page {
    --fit: calc(100svh - 11.75rem);
    max-width: 76rem;
    margin-inline: auto;
    padding-block: 0.5rem 3rem;
}
.art-head {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}
.art-head h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.15; }
/* "← Random Art · Random Art 13" above the piece's name */
.art-crumb { display: flex; gap: 0.5rem; margin: 0 0 0.1rem; font-size: 0.8rem; color: var(--bs-secondary-color); }
.art-crumb a { color: inherit; text-decoration: none; }
.art-crumb a:hover, .art-crumb a:focus-visible { color: var(--bs-emphasis-color); text-decoration: underline; }
.art-crumb span::before { content: "·"; margin-right: 0.5rem; }

/* ---------- the switch ---------- */
.art-switch {
    display: inline-flex;
    padding: 0.2rem;
    gap: 0.2rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    background: var(--bs-tertiary-bg);
}
.art-switch button {
    border: 0;
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-size: 0.875rem;
    background: transparent;
    color: var(--bs-body-color);
}
.art-switch button[aria-pressed="true"] {
    background: var(--bs-emphasis-color);
    color: var(--bs-body-bg);
}

/* ---------- artwork beside the side panel ---------- */
.art-layout { display: grid; gap: 0.75rem 1.5rem; }
.art-side { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.art-intro { font-size: 0.88rem; margin: 0; }
.art-note {
    font-size: 0.82rem;
    color: var(--bs-secondary-color);
    border-left: 3px solid var(--bs-border-color);
    padding-left: 0.75rem;
    margin: 0;
}

/* The controls set the slot's size; the code is laid exactly over them. The view not shown
   keeps its space, invisibly */
.art-slot { display: grid; position: relative; }
.art-slot > * { grid-area: 1 / 1; min-width: 0; }
.art-slot > [hidden] { display: block !important; visibility: hidden; }
.art-slot > .art-code { position: absolute; inset: 0; display: flex !important; flex-direction: column; }

/* The canvas and the Legacy frame: the artwork's shape, never taller than the window */
.live-art-stage, .art-legacy-frame {
    position: relative;
    display: block;
    width: min(100%, calc(var(--fit) * var(--ar, 1)));
    aspect-ratio: var(--ar, 1);
    margin-inline: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    overflow: hidden;
}
.live-art-stage canvas { display: block; }
.art-legacy-figure { margin: 0; }

/* Legacy renders fill the frame (letterboxed on its background); several get ‹ 1 / n › */
.art-legacy-frame > a, .art-legacy-frame > img { position: absolute; inset: 0; display: block; }
.art-legacy-frame img { width: 100%; height: 100%; object-fit: contain; }
.art-legacy-nav {
    position: absolute;
    left: 50%;
    bottom: 0.6rem;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    max-width: calc(100% - 1.2rem);
    padding: 0.2rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}
.art-legacy-nav .la-btn { padding: 0.1rem 0.7rem; background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.art-legacy-nav .la-btn:hover, .art-legacy-nav .la-btn:focus-visible { border-color: #fff; }
.art-legacy-count { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

@media (min-width: 992px) {
    .art-layout { grid-template-columns: auto 20rem; justify-content: center; align-items: start; }
    /* No percentages in an auto-sized column: size from the window directly */
    .live-art-stage, .art-legacy-frame { width: min(calc(var(--fit) * var(--ar, 1)), calc(100vw - 26rem), 52rem); }
}

/* ---------- the bar and sliders ---------- */
.live-art-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}
.la-btn {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-size: 0.875rem;
}
.la-btn:hover, .la-btn:focus-visible { border-color: var(--bs-emphasis-color); }
.la-auto { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.875rem; }
.la-seed { font-size: 0.78rem; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.la-save { margin-left: auto; }
.live-art-controls {
    padding: 0.85rem 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    background: var(--bs-tertiary-bg);
}
.la-fields {
    display: grid;
    align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.5rem 1.25rem;
}
.la-fields.is-compact { grid-template-columns: repeat(auto-fill, minmax(8.25rem, 1fr)); }
.la-control.is-wide { grid-column: 1 / -1; }
.la-apply { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }
.la-pending { margin-right: auto; font-size: 0.78rem; color: var(--bs-secondary-color); }
.la-generate.is-pending { background: var(--bs-emphasis-color); border-color: var(--bs-emphasis-color); color: var(--bs-body-bg); font-weight: 600; }
.la-control { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.85rem; }
.la-label { display: flex; justify-content: space-between; color: var(--bs-body-color); }
.la-label output { color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }

/* ---------- legacy: the Mathematica code ---------- */
.art-code h2 { font-size: 0.95rem; font-weight: 650; margin-bottom: 0.25rem; }
.art-code-note { font-size: 0.8rem; color: var(--bs-secondary-color); margin-bottom: 0.5rem; }
.art-code pre {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    font-size: 0.74rem;
    line-height: 1.45;
    padding: 0.85rem 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    background: var(--bs-tertiary-bg);
    white-space: pre-wrap;
    overflow: auto;
}
.art-code pre code { background: transparent; padding: 0; }

/* ---------- previous / next piece ---------- */
.art-pager {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    max-width: 46rem;
    margin: 2.5rem auto 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--bs-border-color);
}
.art-pager a { text-decoration: none; color: inherit; }
.art-pager-prev, .art-pager-next { display: flex; flex-direction: column; }
.art-pager-next { text-align: right; grid-column: 3; }
.art-pager-label { font-size: 0.75rem; color: var(--bs-secondary-color); }
.art-pager-name { font-weight: 650; }
.art-pager-all { font-size: 0.875rem; padding: 0.3rem 0.9rem; border: 1px solid var(--bs-border-color); border-radius: 999px; }
.art-pager a:hover .art-pager-name, .art-pager-all:hover { color: var(--bs-emphasis-color); text-decoration: underline; }

/* ---------- below the fold: how it's made ---------- */
.art-how { max-width: 46rem; margin: 2rem auto 0; font-size: 0.92rem; }
.art-how h2 { font-size: 1.05rem; font-weight: 650; }
