/*
  Membership cards: the designer (.mcd-*), the card dialog (.mcg-*), and the
  small inputs they share (.mc-*).

  A global sheet rather than CSS isolation: most of what is styled here is
  markup the component does not own - the card SVG the renderer returns as a
  string, and the child input components - which isolation cannot reach
  without ::deep on every rule.

  Colours come from the theme tokens, so the designer follows the app theme.
  The card itself never does: it is drawn from the design alone.
*/

/*====================================================================
  Shared inputs
====================================================================*/

.mc-num {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

    .mc-num .form-control {
        padding-left: 3.4em;
        padding-right: .4em;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .mc-num.has-suffix .form-control {
        padding-right: 2.2em;
    }

.mc-num__label,
.mc-num__suffix {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--fs-xs, 11px);
    color: var(--c-ink-3, #8b7f82);
    pointer-events: none;
}

.mc-num__label {
    left: .55em;
    font-weight: 600;
}

.mc-num__suffix {
    right: 1.6em;
}

.mc-color {
    display: flex;
    gap: .3rem;
    align-items: center;
    min-width: 0;
}

.mc-color__swatch {
    flex: 0 0 2rem;
    width: 2rem;
    height: 1.9rem;
    padding: 2px;
    border: 1px solid var(--c-line, #e5e7eb);
    border-radius: var(--r-sm, 4px);
    background: var(--c-surface, #fff);
    cursor: pointer;
}

    .mc-color__swatch.is-none {
        background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 50% / 8px 8px;
    }

.mc-color__mode {
    flex: 1 1 auto;
    min-width: 0;
}

/*====================================================================
  Designer shell
====================================================================*/

.mcd {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 2000);
    display: flex;
    flex-direction: column;
    background: var(--c-bg, #f6f4f1);
    color: var(--c-ink, #241a1c);
    font-size: var(--fs-sm, 13px);
    outline: none;
}

.mcd-top {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .5rem .75rem;
    background: var(--c-surface, #fff);
    border-bottom: 1px solid var(--c-line, #eae4dd);
}

.mcd-top__title {
    font-weight: 700;
    white-space: nowrap;
}

    .mcd-top__title i {
        color: var(--c-primary, #a8394a);
        margin-right: .25rem;
    }

.mcd-name {
    width: 16rem;
    max-width: 100%;
    font-weight: 600;
}

.mcd-unsaved {
    font-size: var(--fs-xs, 11px);
    color: var(--c-warning, #b45309);
    white-space: nowrap;
}

    .mcd-unsaved i {
        font-size: 7px;
        vertical-align: middle;
    }

.mcd-top__spacer {
    flex: 1 1 auto;
}

.mcd-top__preview {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin: 0;
    white-space: nowrap;
}

    .mcd-top__preview span {
        color: var(--c-ink-3, #8b7f82);
        font-size: var(--fs-xs, 11px);
    }

    .mcd-top__preview select {
        max-width: 14rem;
    }

.mcd-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 300px;
}

.mcd-left,
.mcd-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--c-surface, #fff);
}

.mcd-left {
    border-right: 1px solid var(--c-line, #eae4dd);
}

.mcd-right {
    border-left: 1px solid var(--c-line, #eae4dd);
}

.mcd-left__body,
.mcd-right__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: .75rem;
}

.mcd-tabs {
    display: flex;
    border-bottom: 1px solid var(--c-line, #eae4dd);
}

    .mcd-tabs button {
        flex: 1 1 0;
        border: 0;
        background: none;
        padding: .55rem .25rem;
        font-size: var(--fs-xs, 11px);
        font-weight: 600;
        color: var(--c-ink-3, #8b7f82);
        border-bottom: 2px solid transparent;
    }

        .mcd-tabs button.is-on {
            color: var(--c-primary, #a8394a);
            border-bottom-color: var(--c-primary, #a8394a);
        }

        .mcd-tabs button:disabled {
            opacity: .45;
        }

.mcd-group {
    margin: 1rem 0 .4rem;
    font-size: var(--fs-xs, 11px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-ink-3, #8b7f82);
}

.mcd-help {
    font-size: var(--fs-xs, 11px);
    color: var(--c-ink-3, #8b7f82);
    margin: .25rem 0 .5rem;
    line-height: 1.4;
}

    .mcd-help code {
        font-size: inherit;
    }

/*--- add palette ---*/

.mcd-palette {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .3rem;
}

.mcd-palette__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .45rem .2rem;
    border: 1px solid var(--c-line, #eae4dd);
    border-radius: var(--r-md, 6px);
    background: var(--c-surface, #fff);
    color: var(--c-ink-2, #4b3f42);
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
    transition: border-color .1s, background .1s;
}

    .mcd-palette__item i {
        font-size: 14px;
        color: var(--c-primary, #a8394a);
    }

    .mcd-palette__item:hover,
    .mcd-palette__item:focus-visible {
        border-color: var(--c-primary, #a8394a);
        background: var(--c-primary-soft, #fbeff1);
    }

/*--- layers ---*/

.mcd-layers {
    list-style: none;
    margin: 0;
    padding: 0;
}

    .mcd-layers li {
        display: flex;
        align-items: center;
        gap: 1px;
        border-radius: var(--r-sm, 4px);
        padding: 1px 2px;
    }

        .mcd-layers li.is-sel {
            background: var(--c-primary-soft, #fbeff1);
        }

        .mcd-layers li.is-hidden .mcd-layers__name {
            opacity: .5;
            text-decoration: line-through;
        }

.mcd-layers__name {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .4rem;
    border: 0;
    background: none;
    padding: .3rem .25rem;
    text-align: left;
    color: inherit;
}

    .mcd-layers__name span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mcd-layers__name i {
        width: 1rem;
        color: var(--c-ink-3, #8b7f82);
    }

.mcd-icon-btn {
    flex: 0 0 auto;
    width: 1.7rem;
    height: 1.7rem;
    border: 0;
    border-radius: var(--r-sm, 4px);
    background: none;
    color: var(--c-ink-3, #8b7f82);
    font-size: 12px;
}

    .mcd-icon-btn:hover:not(:disabled) {
        background: var(--c-surface-2, #f3f0ec);
        color: var(--c-ink, #241a1c);
    }

    .mcd-icon-btn:disabled {
        opacity: .3;
    }

/*--- saved designs ---*/

.mcd-designs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .4rem;
}

    .mcd-designs button {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: .3rem;
        padding: .4rem;
        border: 1px solid var(--c-line, #eae4dd);
        border-radius: var(--r-md, 6px);
        background: var(--c-surface, #fff);
        text-align: left;
        color: inherit;
    }

    .mcd-designs li.is-sel button {
        border-color: var(--c-primary, #a8394a);
        box-shadow: 0 0 0 2px var(--c-primary-soft, #fbeff1);
    }

.mcd-designs__thumb {
    display: flex;
    justify-content: center;
    height: 70px;
}

    .mcd-designs__thumb svg {
        height: 100%;
        width: auto;
        max-width: 100%;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .15));
    }

.mcd-designs__name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}

/*====================================================================
  Canvas
====================================================================*/

.mcd-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.mcd-canvasbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .5rem .75rem;
}

.mcd-canvasbar__size {
    margin-left: auto;
    color: var(--c-ink-3, #8b7f82);
    font-size: var(--fs-xs, 11px);
    font-variant-numeric: tabular-nums;
}

.mcd-zoom {
    min-width: 4rem;
    font-variant-numeric: tabular-nums;
}

.mcd-stage {
    flex: 1 1 auto;
    min-height: 260px;
    overflow: auto;
    display: grid;
    place-items: center;
    padding: 32px;
    background-color: var(--c-surface-2, #efebe6);
    background-image: radial-gradient(rgba(0, 0, 0, .07) 1px, transparent 1px);
    background-size: 16px 16px;
}

.mcd-canvas {
    position: relative;
    flex: 0 0 auto;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18), 0 1px 3px rgba(0, 0, 0, .12);
    border-radius: 2px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.mcd-svg,
.mcd-svg svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.mcd-box {
    position: absolute;
    cursor: move;
    outline: 1px dashed transparent;
}

    .mcd-box:hover {
        outline-color: rgba(37, 99, 235, .55);
    }

    .mcd-box.is-sel {
        outline: 1.5px solid #2563eb;
        z-index: 2;
    }

    .mcd-box.is-locked {
        cursor: default;
    }

        .mcd-box.is-locked.is-sel {
            outline-style: dashed;
        }

.mcd-h {
    position: absolute;
    width: 9px;
    height: 9px;
    background: #fff;
    border: 1.5px solid #2563eb;
    border-radius: 2px;
    z-index: 3;
}

.mcd-h--nw { left: -5px; top: -5px; cursor: nwse-resize; }
.mcd-h--n { left: calc(50% - 4.5px); top: -5px; cursor: ns-resize; }
.mcd-h--ne { right: -5px; top: -5px; cursor: nesw-resize; }
.mcd-h--e { right: -5px; top: calc(50% - 4.5px); cursor: ew-resize; }
.mcd-h--se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.mcd-h--s { left: calc(50% - 4.5px); bottom: -5px; cursor: ns-resize; }
.mcd-h--sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.mcd-h--w { left: -5px; top: calc(50% - 4.5px); cursor: ew-resize; }

.mcd-guide {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    background: #ec4899;
}

.mcd-guide--v {
    top: -12px;
    bottom: -12px;
    width: 1px;
}

.mcd-guide--h {
    left: -12px;
    right: -12px;
    height: 1px;
}

.mcd-hint {
    margin: 0;
    padding: .4rem .75rem;
    font-size: var(--fs-xs, 11px);
    color: var(--c-ink-3, #8b7f82);
    text-align: center;
}

/*====================================================================
  Properties
====================================================================*/

.mcd-panel-head {
    display: flex;
    align-items: center;
    gap: .5rem;
}

    .mcd-panel-head > i {
        color: var(--c-primary, #a8394a);
        width: 1rem;
        text-align: center;
    }

.mcd-actions {
    display: flex;
    gap: 2px;
    margin-top: .4rem;
}

.mcd-grid2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .35rem;
}

.mcd-field {
    margin-bottom: .45rem;
}

    .mcd-field > label {
        display: block;
        margin-bottom: .15rem;
        font-size: var(--fs-xs, 11px);
        font-weight: 600;
        color: var(--c-ink-2, #4b3f42);
    }

.mcd-align,
.mcd-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: .4rem 0;
}

    .mcd-align button,
    .mcd-toggles button {
        min-width: 2rem;
        height: 1.9rem;
        padding: 0 .45rem;
        border: 1px solid var(--c-line, #eae4dd);
        border-radius: var(--r-sm, 4px);
        background: var(--c-surface, #fff);
        color: var(--c-ink-2, #4b3f42);
        font-size: 12px;
        font-weight: 600;
    }

        .mcd-align button:hover:not(:disabled),
        .mcd-toggles button:hover {
            border-color: var(--c-primary, #a8394a);
        }

        .mcd-toggles button.is-on {
            background: var(--c-primary, #a8394a);
            border-color: var(--c-primary, #a8394a);
            color: var(--c-on-primary, #fff);
        }

        .mcd-align button:disabled {
            opacity: .4;
        }

.mcd-toggles__gap {
    width: .5rem;
}

.mcd-text {
    font-family: var(--f-mono, Consolas, monospace);
    font-size: 12px;
    resize: vertical;
}

/* InputFile renders a bare <input type=file>; it sits invisibly over a
   button-styled label so the upload looks like every other button. */
.mcd-upload {
    position: relative;
    overflow: hidden;
    margin: .25rem 0 .5rem;
}

    .mcd-upload input[type=file] {
        position: absolute;
        inset: 0;
        opacity: 0;
        cursor: pointer;
    }

.mcd-logo-thumb {
    height: 2rem;
    max-width: 5rem;
    object-fit: contain;
    border: 1px solid var(--c-line, #eae4dd);
    border-radius: var(--r-sm, 4px);
    background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 50% / 8px 8px;
}

/*====================================================================
  New-design gallery
====================================================================*/

.mcd-gallery {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .45);
}

.mcd-gallery__panel {
    width: min(860px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 1rem;
    border-radius: var(--r-lg, 10px);
    background: var(--c-surface, #fff);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

.mcd-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .75rem;
}

.mcd-gallery__item {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .6rem;
    border: 1px solid var(--c-line, #eae4dd);
    border-radius: var(--r-md, 6px);
    background: var(--c-surface, #fff);
    text-align: left;
    color: inherit;
}

    .mcd-gallery__item:hover,
    .mcd-gallery__item:focus-visible {
        border-color: var(--c-primary, #a8394a);
        box-shadow: 0 0 0 2px var(--c-primary-soft, #fbeff1);
    }

.mcd-gallery__thumb {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 110px;
    margin-bottom: .25rem;
    border-radius: var(--r-sm, 4px);
    background: var(--c-surface-2, #f3f0ec);
}

    .mcd-gallery__thumb svg {
        height: 92px;
        width: auto;
        max-width: 92%;
        filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .2));
    }

/* Narrow screens: the card first, then the panels under it. */
@media (max-width: 991.98px) {
    .mcd-body {
        grid-template-columns: minmax(0, 1fr);
        grid-auto-rows: auto;
        overflow-y: auto;
    }

    .mcd-main {
        order: -1;
        min-height: 60vh;
    }

    .mcd-left,
    .mcd-right {
        border: 0;
        border-top: 1px solid var(--c-line, #eae4dd);
    }

    .mcd-name {
        width: 100%;
    }
}

/*====================================================================
  Card dialog (generate, download, print)
====================================================================*/

.mcg-toolbar {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

    .mcg-toolbar .form-label {
        margin-bottom: .15rem;
        font-size: var(--fs-xs, 11px);
    }

.mcg-toolbar__design {
    flex: 1 1 14rem;
    min-width: 12rem;
}

.mcg-single {
    display: flex;
    justify-content: center;
    padding: .75rem;
    border-radius: var(--r-md, 6px);
    background: var(--c-surface-2, #f3f0ec);
}

    .mcg-single svg {
        width: 100%;
        max-width: 460px;
        height: auto;
        filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .18));
    }

    .mcg-single.is-portrait svg {
        max-width: 260px;
    }

.mcg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: .75rem;
}

.mcg-tile {
    border: 1px solid var(--c-line, #eae4dd);
    border-radius: var(--r-md, 6px);
    padding: .5rem;
    background: var(--c-surface, #fff);
}

    .mcg-tile svg {
        display: block;
        width: 100%;
        height: auto;
        max-height: 220px;
        filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .15));
    }

.mcg-tile__foot {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-top: .4rem;
    font-size: var(--fs-xs, 11px);
}

    .mcg-tile__foot span {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.mcg-photo {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.mcg-photo__img {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--c-line, #eae4dd);
    background: var(--c-surface-2, #f3f0ec);
}

.mcg-progress {
    font-size: var(--fs-xs, 11px);
    color: var(--c-ink-3, #8b7f82);
}
