/*
 * Core Saved Designs — My Account list + cart-line button feedback + toast.
 *
 * The in-modal failure banner (`.csd-modal__error`) takes all its chrome from
 * `.core-validation-messages` (core-validation-messages.css).
 *
 * Theme variables (--ink, --ink-soft, --rule-strong, --err, --dur-fast,
 * --ease, --fs-12) come from the theme's main.css. Values are inlined
 * with safe fallbacks so the styles survive on configurator pages where
 * the cart theme tokens may not be in scope.
 */

/* ---- My Account list ------------------------------------------- */

.csd-wrap {
    margin: 0;
}

/* Empty state = a sunken card (Design.md §7.5: Pebble fill), so it takes the
   card radius like its siblings. The border keeps Rule Strong because it is
   DASHED — a dashed hairline in plain Rule barely reads. */
.csd-empty {
    padding: 24px;
    border: 1px dashed var(--rule-strong);
    border-radius: var(--r-md);
    color: var(--ink-soft);
    font-size: var(--fs-14);
    line-height: 1.5;
    background: var(--paper-soft);
}

.csd-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

/* The canonical card, restated against the tokens rather than borrowed from
   the Theme's `.card` — the plugin is a separate release unit and must draw a
   card on any theme (the same reason core-tokens.css carries the elevation
   scale). Paper, 1px Rule, --r-md, no shadow (Design.md §7.5). */
.csd-card {
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: opacity var(--dur-base) var(--ease);
}

.csd-card__thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--paper-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.csd-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.csd-card__thumb__placeholder {
    color: var(--ink-soft);
    font-size: var(--fs-13);
    text-align: center;
    padding: 8px;
}

.csd-card__body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.csd-card__title {
    font-size: 15px;
    font-weight: var(--fw-semibold);
    margin: 0;
    color: var(--ink);
    line-height: 1.3;
}

.csd-card__meta {
    margin: 0;
    font-size: var(--fs-12);
    color: var(--ink-soft);
}

.csd-card__actions {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
}

/* Card action buttons — body, colours and sizing all come from
   `.core-btn .core-btn-{primary,secondary,--danger} .core-btn--sm
   .core-btn--inline` (core-controls.css, Design.md §7.1). The `--edit` and
   `--delete` modifiers are gone with the bodies they carried: Edit/Load is now
   plain Primary (its hover was an off-token `#000`), and Delete is the shared
   Danger variant, which inverts to a solid Error fill rather than only
   recolouring its text. All that is left here is the JS-driven busy state. */
.csd-btn.csd-busy {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---- Cart Save button state -----------------------------------
   Keyed on the `data-action` hook the binding itself selects, not on a
   theme class. These two rules used to read `.li__foot__link.csd-saved`,
   a class from the workshop-docket basket that the 2026-08-11 basket
   rebuild retired network-wide — so they could not have matched anything
   the theme renders today even once the link is back. See the cart-page
   note in core-saved-designs-bindings.js for the state of that link. */

[data-action="save-design"].csd-saved {
    color: var(--ink);
    pointer-events: none;
    opacity: 0.7;
}

[data-action="save-design"].csd-busy {
    opacity: 0.5;
    pointer-events: none;
}

/* ---- Toast --------------------------------------------------- */

.csd-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    /* Chrome — Coal fill, Paper text, --r-md, --shadow-3 — from the shared
       `.core-toast` (core-modal.css). There are no colour variants: a
       failure goes to the validation banner, not a toast (Design.md §11.17). */
    max-width: min(420px, calc(100vw - 32px));
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
    z-index: calc(var(--z-modal) + 1);
    pointer-events: none;
    text-align: center;
}

.csd-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* The optional link a toast can carry. The toast itself is pointer-events:
   none so it never eats a click meant for the page underneath — the child
   opts back in, which is the whole reason the link is clickable at all. */
.csd-toast__action {
    display: inline-block;
    margin-left: 10px;
    color: inherit;
    font-weight: var(--fw-semibold);
    text-decoration: underline;
    pointer-events: auto;
}

/* ---- Config-summary buttons -------------------------------------- */

.config-summary__design-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Save / Load design — body comes from `.core-btn .core-btn-secondary
   .core-btn--sm .core-btn--inline`. The pre-#229 body sat at ~38px, between
   §7.1's Small and Default rungs; it takes Small, because a ladder with a rung
   per consumer is not a ladder. The one override is the corner: Small's
   `--r-xs` read as square beside the Continue button, so these take the
   Default rung's `--r-sm` to match it. Scoped to its row so it outranks
   `.core-btn--sm` whichever order the two sheets print in. */
.config-summary__design-actions .csd-config-btn {
    border-radius: var(--r-sm);
}

.csd-config-btn.csd-busy {
    opacity: 0.55;
    pointer-events: none;
}

/* ---- Modal shell (save + load) ----------------------------------- */

.csd-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scrim + panel chrome come from `.core-modal-scrim` / `.core-modal-panel`
   (core-modal.css); these blocks carry only positioning and sizing. */
.csd-modal__backdrop {
    position: absolute;
    inset: 0;
}

.csd-modal__panel {
    position: relative;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* Header, title, body and footer come from the shared `.core-modal-header` /
   `-title` / `-body` / `-footer` (core-modal.css). */

/* The header's "×" wears `.core-btn--close` (core-controls.css, efficiency
   #229) — the same primitive as the configurator popup's dismiss and the bulk
   table's remove-row. It had drifted to a 22px glyph in a rectangular hit box
   purely because the shared body lived in a sheet this surface doesn't load.
   Nothing local is needed: the header's flex row places it. */

.csd-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.csd-modal__field label {
    font-size: var(--fs-13);
    font-weight: var(--fw-regular);
    color: var(--ink-soft);
}

/* Stacked fields need air between them. Both modals that carry more than one
   (share since D29, save since D41) had them butting together. */
.csd-modal__field + .csd-modal__field {
    margin-top: 14px;
}

/* `type="email"` is listed explicitly: the share modal's return-address field
   has been one since D29 and was picking up none of this box model. */
.csd-modal__field input[type="text"],
.csd-modal__field input[type="email"] {
    box-sizing: border-box;
    width: 100%;
    min-height: var(--h-control);   /* §7.2 */
    padding: 10px 12px;
    font-size: var(--fs-14);
    border: 1px solid var(--rule-interactive);
    border-radius: var(--r-sm);
}

.csd-modal__field input[type="text"]:focus,
.csd-modal__field input[type="email"]:focus,
.csd-modal__field textarea:focus {
    /* The standard field focus (§7.2) — the same as `.core-input`. */
    outline: none;
    border-color: var(--ink);
    box-shadow: var(--focus-ring);
}

/* The line under a field that says what the address is for (D41). Sits below
   the input, not above, so the label stays the thing the eye lands on. */
.csd-modal__help {
    margin: 0;
    font-size: var(--fs-13);
    line-height: 1.4;
    color: var(--ink-soft);
}

/* Marketing opt-in: box beside its label, both on one baseline. Overrides the
   column stack the field shares with every text field. */
.csd-modal__field--check {
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

.csd-modal__field--check input[type="checkbox"] {
    flex: 0 0 auto;
    margin-top: 2px;
}

.csd-modal__field--check label {
    line-height: 1.4;
}

/* Share modal: the note field (D29). Matches the text input's box model so
   the two read as one control family. */
.csd-modal__field textarea {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: var(--fs-14);
    line-height: 1.4;
    border: 1px solid var(--rule-interactive);
    border-radius: var(--r-sm);
    resize: vertical;
}

.csd-modal__intro {
    margin: 0 0 12px;
    font-size: var(--fs-14);
    line-height: 1.5;
    color: var(--ink-soft);
}

/* The minted link sits beside its Copy button; the input takes the slack so
   a long URL never pushes the button off the panel. */
.csd-share__row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.csd-share__row input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    /* Design.md §5.4 "One height per row": the field matches its 32px Copy
       button rather than standing ~10px taller beside it. */
    box-sizing: border-box;
    height: var(--h-btn-sm);
    padding: 0 12px;
    font-size: var(--fs-13);
    letter-spacing: var(--tracking-normal);
    border: 1px solid var(--rule-interactive);
    border-radius: var(--r-sm);
}

.csd-share__row .csd-btn {
    flex: 0 0 auto;
}

.csd-modal__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.csd-modal__loading,
.csd-modal__empty {
    padding: 32px 8px;
    text-align: center;
    color: var(--ink-soft);
    font-size: var(--fs-14);
}

/* ---- Initial-design notices (edit-from-cart banner + stale-line notice) */

/* Sunken card (Pebble fill) — same radius as its siblings above. */
.core-initial-design-notice {
    margin: 0 0 16px;
    padding: 12px 16px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-md);
    color: var(--ink-soft);
    font-size: var(--fs-14);
    line-height: 1.4;
    background: var(--paper-soft);
}

.core-initial-design-notice--edit,
.core-initial-design-notice--shared {
    border-color: var(--rule-strong);
    border-left: 3px solid var(--ink);
    color: var(--ink);
    background: var(--paper);
}

/* The customer's note, stacked under the shared-design banner. Steps back to
   the sunken treatment so the instruction above it stays the louder line. */
.core-initial-design-notice--shared-note {
    margin-top: -8px;
}
