/* mutation-workshop.css: Mutation Workshop (.mw-*). */
/* ============================================================
   MUTATION WORKSHOP (.mw-*)
   Own namespace rather than more .workbench-* variants: create_pet's
   workbench is a tall form beside one sticky preview, this page is a
   before/after comparison with the controls underneath. The two want
   opposite layouts, and sharing classes is what produced the version
   where both canvases were squeezed into one 320px column.
   ============================================================ */

/* The whole panel is one <form>, and the global `form` rule is a 420px flex
   column, so every grid below silently collapsed to ~38% of the page and hit
   its own narrow breakpoint, with the flex gap stacking on top of the sections'
   own margins. display:block because .mw-compare/.mw-controls/.mw-commit each
   own their vertical rhythm already. */
.mw-form { display: block; max-width: none; }

/* Before/after: the comparison IS the page, so it gets the full width and
   both canvases get equal room. Nothing here is sticky: the player looks
   at this, changes a control below, and looks back. */
.mw-compare {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 24px;
}
.mw-compare__pane { min-width: 0; }
.mw-compare .preview-canvas { min-height: 320px; margin-bottom: 8px; }
.mw-compare__label {
    margin: 0 0 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.72em;
    font-weight: 700;
}
.mw-compare__label--accent { color: var(--color-primary); }
.mw-compare__caption {
    margin: 0;
    text-align: center;
    font-size: 0.8em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 1.4em;
}
.mw-compare__arrow {
    align-self: center;
    padding-top: 40px;
    font-size: 1.6em;
    color: var(--text-muted);
}

/* Gallery gets ~2/3, the two appearance trays stack in the remaining third. */
.mw-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
.mw-appearance { display: flex; flex-direction: column; gap: 20px; }
/* A <fieldset> brings its own border/padding and won't shrink in a grid track
   by default; these trays reuse .workbench-section's chrome instead. Their
   accessible name comes from aria-labelledby, not a <legend>: see the template. */
.mw-gallery-section, .mw-appearance fieldset { min-width: 0; margin: 0; }

.mw-gallery-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.mw-gallery-filter { flex: 1 1 180px; margin: 0; }
.mw-gallery-filter input { width: 100%; }
.mw-gallery-group + .mw-gallery-group { margin-top: 18px; }
.mw-gallery-group__label {
    margin: 0 0 8px;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.mw-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 10px;
}
.mw-gallery-empty { margin: 14px 0 0; }

/* Swatch: same visually-hidden-radio + :has() pattern as .species-pick-card, so
   it stays a plain keyboard-navigable radio group with Alpine absent. */
.mw-swatch {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 8px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    cursor: pointer;
    text-align: center;
    overflow: hidden;
}
.mw-swatch input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mw-swatch__art {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: block;
}
.mw-swatch__name {
    font-size: 0.72em;
    line-height: 1.25;
    color: var(--text-secondary);
    font-weight: 600;
}
@media (hover: hover) { .mw-swatch:hover { border-color: var(--color-primary); } }
.mw-swatch:has(input:checked) { border-color: var(--color-primary); background: var(--bg-hover); }
.mw-swatch:has(input:checked) .mw-swatch__name { color: var(--text-primary); }
.mw-swatch:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }
/* Selection is not signalled by border colour alone: a checkmark medallion
   carries it for anyone who can't separate the two border states. */
.mw-swatch__check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.mw-swatch:has(input:checked) .mw-swatch__check { opacity: 1; transform: scale(1); }

/* Blend modes as radio cards carrying their own explanation, rather than a
   3-item <select> of ImageMagick operator names. All three descriptions stay
   visible so the choice can be compared without clicking through it. */
.mw-blend-grid { display: flex; flex-direction: column; gap: 8px; }
.mw-blend-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    cursor: pointer;
}
.mw-blend-card input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mw-blend-card__name { font-weight: 700; font-size: 0.9em; color: var(--text-primary); }
.mw-blend-card__desc { font-size: 0.78em; line-height: 1.4; color: var(--text-muted); }
@media (hover: hover) { .mw-blend-card:hover { border-color: var(--color-primary); } }
.mw-blend-card:has(input:checked) { border-color: var(--color-primary); background: var(--bg-hover); }
.mw-blend-card:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.mw-opacity-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.mw-tint-toggle { margin-top: 4px; }
/* .marking-opacity's 100px range is sized for create_pet's narrow marking cards;
   here the slider is the whole control, so let it take the tray's width. Scoped
   so the marking editor keeps its compact version. */
.mw-appearance .marking-opacity { gap: 10px; }
.mw-appearance .marking-opacity input[type="range"] { flex: 1 1 auto; width: auto; min-width: 120px; }

/* Commit bar: the spend is its own surface at the end of the flow, not the
   last item in a column of controls. */
.mw-commit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    gap: 20px;
    align-items: end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}
.mw-commit__summary { min-width: 0; }
.mw-commit__what { margin: 2px 0 8px; font-size: 1.05em; }
.mw-commit__what .text-muted { font-size: 0.82em; font-weight: 400; }
.mw-commit__action { display: flex; flex-direction: column; gap: 8px; }

.mutation-remove-form .hint-warn { margin: 6px 0 0; }

.mw-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.mw-empty__icon { font-size: 2.2em; margin: 0 0 8px; opacity: 0.6; }
.mw-empty p { margin: 0; }

@media (max-width: 1024px) {
    .mw-controls { grid-template-columns: 1fr; }
    .mw-commit,
    .mutation-remove-form { grid-template-columns: 1fr; align-items: stretch; }
}
@media (width < 768px) {
    /* Stack the comparison and drop the arrow: side-by-side at this width made
       both canvases too small to read the very difference they exist to show. */
    .mw-compare { grid-template-columns: 1fr; gap: 16px; }
    .mw-compare__arrow { display: none; }
    .mw-compare .preview-canvas { min-height: 260px; }
    .mw-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}
body.reduced-motion .mw-swatch__check { transition-duration: 0.001s; }

.cost-summary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cost-summary-label {
    margin: 0 0 2px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.72em;
    font-weight: 700;
}
.cost-line { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 0.9em; font-variant-numeric: tabular-nums; }
.cost-line--total {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 2px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1em;
}
.cost-summary-free { color: var(--color-success-text); font-weight: 600; margin: 0; }
/* Why the price is showing instead of "Free forge". Warning-toned, not error-toned:
   nothing has gone wrong, the pet is simply outside what a free forge covers. */
.cost-summary-note { color: var(--color-warning-text); font-size: 0.85em; margin: 0; }
.marking-free-note { color: var(--color-warning-text); font-size: 0.85em; margin: 4px 0 0; }
/* Spells out exactly what a free forge covers, up front, rather than leaving a
   new Captain to infer it from the price flipping to "Free" as they build. */
.free-forge-callout {
    display: grid;
    gap: 4px;
    margin: 14px 0;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--color-success-text);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-success-text) 8%, var(--bg-surface));
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}
.free-forge-callout strong { color: var(--text-primary); }
.free-forge-callout p { margin: 0; }
.free-forge-callout ul { margin: 0; padding-left: 1.2em; }
.free-forge-callout li { margin: 2px 0; }
.cost-summary-balance { color: var(--text-muted); font-size: 0.8em; margin: 0; font-variant-numeric: tabular-nums; }
.btn-block { width: 100%; justify-content: center; }

/* Saved appearance recipes sit below the refraction rather than competing with
   the live preview. The card/list treatment keeps a growing collection scannable
   without turning the workbench into another dense dashboard. */
.saved-designs-panel {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.saved-designs-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.saved-designs-eyebrow {
    margin: 0 0 4px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72em;
    font-weight: 700;
}
.saved-designs-help {
    max-width: 640px;
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}
.saved-design-count {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.82em;
    font-variant-numeric: tabular-nums;
}
.saved-design-feedback {
    min-height: 1.35em;
    margin: 12px 0 4px;
    color: var(--color-success-text);
    font-size: 0.86em;
}
.saved-design-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    margin-top: 8px;
}
.saved-design-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    padding: 13px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}
.saved-design-card-main {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}
.saved-design-swatches {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 3px;
    width: 42px;
}
.saved-design-swatch {
    display: block;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%);
}
.saved-design-swatch--marking { width: 12px; height: 12px; }
.saved-design-name {
    overflow: hidden;
    margin: 0;
    color: var(--text-primary);
    font-size: 0.96em;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.saved-design-meta {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 0.76em;
    line-height: 1.35;
}
.saved-design-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
}
.saved-design-actions form { margin: 0; }
.saved-design-empty {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 14px;
    color: var(--text-secondary);
    background: var(--bg-subtle);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.88em;
}
.saved-design-empty strong { color: var(--text-primary); }
.saved-design-editor {
    display: grid;
    grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
    align-items: end;
    gap: 12px 18px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}
.saved-design-editor-copy label {
    display: block;
    color: var(--text-primary);
    font-size: 0.9em;
    font-weight: 700;
}
.saved-design-editor-copy p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.78em;
}
.saved-design-editor-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.saved-design-editor-controls input { min-width: 0; flex: 1 1 auto; }
.saved-design-current {
    grid-column: 2;
    margin: -4px 0 0;
    color: var(--text-muted);
    font-size: 0.78em;
}
.saved-design-current strong { color: var(--text-secondary); }

@media (width < 768px) {
    .saved-designs-panel { padding: 16px; }
    .saved-designs-heading { align-items: flex-start; }
    .saved-design-card { align-items: flex-start; flex-direction: column; }
    .saved-design-actions { width: 100%; }
    .saved-design-actions .btn { flex: 1 1 0; justify-content: center; }
    .saved-design-editor { grid-template-columns: 1fr; }
    .saved-design-current { grid-column: 1; }
}

/* Phones: the preview leads, the fields follow, and the cost panel with the Begin
   button comes last. Lifting the whole aside above the fields (order: -1) put Begin
   ahead of the name and species a player hadn't chosen yet. display: contents lets
   the preview and cost panel sit in the single column as separate items. */
@media (width < 768px) {
    .workbench-grid { grid-template-columns: 1fr; }
    .workbench-aside { display: contents; }
    .workbench-grid .preview-frame { order: -1; }
}

body.reduced-motion .preview-canvas { transition-duration: 0.001s; }
/* Drop the rotation but keep the ring a *state* signal. The `opacity` here has to
   stay scoped to .htmx-request: an unscoped `opacity: .6` has the same specificity
   as both the idle `opacity: 0` and the in-flight `opacity: 1` rules above and
   comes later in the cascade, so it won them both: the ring sat permanently at
   0.6 and a reduced-motion player got no in-flight indication at all. */
body.reduced-motion .preview-canvas::before { animation: none; }
body.reduced-motion .preview-canvas.htmx-request::before { opacity: 0.6; }

