/* The certificate designer (FR-0025): the page drawn by js/certificateDesigner.js (cdz-…) and the
   designer's own panels (cd-…). One plain file, because the script makes the page's elements
   itself and a component's own stylesheet does not reach those. Versioned with the script. */

/* ── the drawn page ─────────────────────────────────────────────────────── */

.cdz-page {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    overflow: hidden;
    background: #fff;
    /* A bold or italic the font has no file for is drawn plain, as in the PDF; never faked. */
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.cdz-thumb {
    position: relative;
    flex: none;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}

.cdz-thumb .cdz-page {
    touch-action: auto;
    pointer-events: none;
}

.cdz-el {
    position: absolute;
    box-sizing: border-box;
}

.cdz-el.cdz-text {
    display: flex;
    align-items: center;
    /* One line, with every space as typed: the PDF keeps two spaces as two. */
    white-space: pre;
}

.cdz-el.cdz-text > span {
    display: block;
    width: 100%;
}

.cdz-el.cdz-text.cdz-wrap {
    align-items: flex-start;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cdz-el svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.cdz-el img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cdz-border {
    position: absolute;
    box-sizing: border-box;
    pointer-events: none;
}

.cdz-controls {
    display: flex;
    align-items: flex-start;
}

.cdz-table {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
}

.cdz-cell {
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-bottom: 0 solid rgba(120, 130, 145, .35);
}

.cdz-cell.cdz-right {
    text-align: right;
}

/* while designing */

.cdz-design .cdz-el {
    cursor: move;
}

.cdz-design .cdz-el:hover {
    outline: 1px dashed rgba(0, 113, 193, .6);
}

.cdz-design .cdz-el.cdz-selected {
    outline: 2px solid var(--bc-blue, #0071c1);
}

/* A thin line is hard to hit: it is taken hold of a little above and below too. */
.cdz-design .cdz-line::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -8px;
    bottom: -8px;
}

/* An empty frame lets the pointer through to what lies inside it; its edges take hold of it. */
.cdz-design .cdz-hollow {
    pointer-events: none;
}

.cdz-edge {
    position: absolute;
    pointer-events: auto;
}

.cdz-edge.cdz-top { left: 0; right: 0; top: -6px; height: 12px; }
.cdz-edge.cdz-bottom { left: 0; right: 0; bottom: -6px; height: 12px; }
.cdz-edge.cdz-left { top: 0; bottom: 0; left: -6px; width: 12px; }
.cdz-edge.cdz-right { top: 0; bottom: 0; right: -6px; width: 12px; }

/* What this event's PDF leaves out (no route file, no picture) still shows where it would be. */
.cdz-absent {
    border: 2px dashed rgba(90, 105, 125, .55);
    background: repeating-linear-gradient(135deg, rgba(120, 135, 155, .10) 0 12px, rgba(120, 135, 155, .20) 12px 24px);
}

.cdz-handle {
    position: absolute;
    box-sizing: border-box;
    background: #fff;
    border: 3px solid var(--bc-blue, #0071c1);
    border-radius: 50%;
    z-index: 50;
}

.cdz-handle-nw, .cdz-handle-se { cursor: nwse-resize; }
.cdz-handle-ne, .cdz-handle-sw { cursor: nesw-resize; }
.cdz-handle-w, .cdz-handle-e { cursor: ew-resize; }

.cdz-guide {
    position: absolute;
    background: #e0338a;
    z-index: 40;
    pointer-events: none;
}

/* ── the designer's page ────────────────────────────────────────────────── */

.cd-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bc-surface);
    color: var(--bc-ink);
    font-size: .875rem;
}

.cd-shell button,
.cd-shell input,
.cd-shell select,
.cd-shell textarea {
    font: inherit;
    color: inherit;
}

.cd-loading {
    padding: 1.5rem;
}

.cd-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem .8rem;
    padding: .55rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--bc-border);
    box-shadow: 0 2px 6px rgba(20, 60, 110, .06);
}

.cd-bar h2 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 700;
}

.cd-back {
    display: inline-block;
    max-width: 26rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .84rem;
    color: var(--bc-blue);
    text-decoration: none;
}

.cd-back:hover {
    text-decoration: underline;
}

.cd-grow {
    flex: 1;
}

.cd-pick {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--bc-ink-muted);
}

.cd-pick select {
    max-width: 15rem;
    padding: .32rem .5rem;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: #fff;
}

.cd-seg {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
}

.cd-seg button {
    padding: .36rem .8rem;
    border: 0;
    background: #fff;
    font-size: .84rem;
    font-weight: 600;
    color: var(--bc-ink-muted);
}

.cd-seg button.on {
    background: var(--bc-blue);
    color: #fff;
}

.cd-state {
    font-size: .8rem;
    font-weight: 600;
    color: var(--bc-success);
}

.cd-state.dirty {
    color: #8a5a00;
}

.cd-notice {
    margin: .6rem 1rem 0;
    padding: .55rem .8rem;
    border: 1px solid var(--bc-blue-mid);
    border-radius: 8px;
    background: var(--bc-blue-light);
    font-size: .84rem;
    line-height: 1.45;
}

/* A notice stays in sight under the bar when the page has been scrolled: what it says
   (not saved, leave or stay) answers something just clicked. */
.cd-notice:not(.cd-narrow) {
    position: sticky;
    top: 4.6rem;
    z-index: 15;
}

.cd-notice.warn {
    border-color: #ecd58a;
    background: var(--bc-warning-bg);
    color: var(--bc-warning);
}

.cd-notice.bad {
    border-color: #e9b4ba;
    background: var(--bc-danger-bg);
    color: var(--bc-danger);
}

.cd-notice ul {
    margin: .3rem 0 0;
    padding-left: 1.2rem;
}

.cd-notice .bc-btn {
    margin-left: .5rem;
}

/* Placing pieces needs room: said only where the three columns have folded into one. */
.cd-narrow {
    display: none;
}

.cd-work {
    flex: 1;
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr) 296px;
    align-items: start;
    min-height: 0;
}

.cd-side {
    position: sticky;
    top: 4.1rem;
    max-height: calc(100vh - 4.1rem);
    overflow: auto;
    background: #fff;
}

.cd-side.left {
    border-right: 1px solid var(--bc-border);
}

.cd-side.right {
    border-left: 1px solid var(--bc-border);
}

.cd-side section {
    padding: .85rem .9rem;
    border-bottom: 1px solid #e6eef6;
}

.cd-side h3 {
    margin: 0 0 .5rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--bc-blue-dark);
}

.cd-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border-bottom: 1px solid var(--bc-border);
}

.cd-tabs button {
    padding: .6rem .3rem .5rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: #fff;
    font-size: .84rem;
    font-weight: 700;
    color: var(--bc-ink-muted);
}

.cd-tabs button.on {
    border-bottom-color: var(--bc-blue);
    color: var(--bc-blue-dark);
}

.cd-hint {
    margin: 0 0 .6rem;
    font-size: .78rem;
    line-height: 1.4;
    color: var(--bc-ink-muted);
}

.cd-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
}

.cd-preset {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .35rem .35rem .4rem;
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    background: #fff;
    text-align: left;
}

.cd-preset:hover {
    border-color: var(--bc-blue);
    box-shadow: 0 2px 8px rgba(0, 113, 193, .15);
}

.cd-preset.on {
    border-color: var(--bc-blue);
    background: var(--bc-blue-light);
}

.cd-preset-pic {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 104px;
    overflow: hidden;
    border-radius: 5px;
    background: #eef2f6;
}

.cd-preset b {
    font-size: .8rem;
}

.cd-preset span {
    font-size: .72rem;
    line-height: 1.25;
    color: var(--bc-ink-muted);
}

.cd-wide {
    display: flex;
    align-items: center;
    gap: .55rem;
    width: 100%;
    padding: .55rem .7rem;
    border: 1px dashed var(--bc-blue-mid);
    border-radius: 8px;
    background: #fff;
    font-weight: 600;
    text-align: left;
    color: var(--bc-blue-dark);
}

.cd-wide:hover {
    background: var(--bc-blue-light);
}

.cd-wide small {
    display: block;
    font-size: .74rem;
    font-weight: 400;
    color: var(--bc-ink-muted);
}

/* A file picker dressed as the wide button: the input itself is there for the keyboard, out of sight. */
.cd-upload {
    position: relative;
    cursor: pointer;
}

.cd-upload.busy {
    opacity: .6;
    cursor: progress;
}

.cd-upload input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: inherit;
}

.cd-upload:focus-within {
    outline: 2px solid var(--bc-blue);
    outline-offset: 2px;
}

/* The club's own pictures, as small tiles. */
/* "Copy from": the club's designs, one under the other; a club design no event prints can be removed. */
.cd-sources {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.cd-source {
    position: relative;
}

.cd-source .cd-wide {
    width: 100%;
}

.cd-source-remove {
    position: absolute;
    top: .25rem;
    right: .3rem;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    color: var(--bc-ink-soft, #5b6470);
    background: transparent;
    cursor: pointer;
}

.cd-source-remove:hover {
    color: #b3261e;
    background: rgba(179, 38, 30, .1);
}

.cd-pictures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
    margin-top: .6rem;
}

.cd-picture {
    position: relative;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: #fff;
}

.cd-picture-add {
    display: block;
    width: 100%;
    padding: .3rem;
    border: 0;
    background: none;
    text-align: left;
}

.cd-picture-add:hover img {
    outline: 2px solid var(--bc-blue);
}

/* A chequered ground, so a see-through logo shows its edges. */
.cd-picture-add img {
    display: block;
    width: 100%;
    height: 62px;
    object-fit: contain;
    border-radius: 3px;
    background: repeating-conic-gradient(#eef1f4 0% 25%, #fff 0% 50%) 0 0 / 12px 12px;
}

.cd-picture-add span {
    display: block;
    margin-top: .25rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .72rem;
    color: var(--bc-ink-muted);
}

.cd-picture-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 1.3rem;
    height: 1.3rem;
    padding: 0;
    border: 1px solid var(--bc-border);
    border-radius: 50%;
    background: #fff;
    font-size: .9rem;
    line-height: 1;
    color: var(--bc-ink-muted);
}

.cd-picture-remove:hover {
    border-color: var(--bc-danger);
    color: var(--bc-danger);
}

.cd-picture-ask {
    display: flex;
    gap: .25rem;
    padding: 0 .3rem .3rem;
}

.cd-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.cd-chip {
    padding: .22rem .65rem;
    border: 1px solid var(--bc-border);
    border-radius: 999px;
    background: var(--bc-surface);
    font-size: .8rem;
}

.cd-chip:hover {
    border-color: var(--bc-blue);
    background: var(--bc-blue-light);
}

.cd-chip.block {
    border-style: dashed;
    border-radius: 6px;
    background: #fff;
}

/* the desk and the page on it */

.cd-desk {
    min-width: 0;
    min-height: calc(100vh - 3.6rem);
    background: #dfe7ee;
}

.cd-deskbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .45rem .8rem;
    font-size: .8rem;
    color: var(--bc-ink-muted);
}

.cd-icon {
    padding: .2rem .55rem;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: #fff;
    font-size: .8rem;
    color: var(--bc-ink-muted);
}

.cd-icon:disabled {
    opacity: .4;
    cursor: default;
}

.cd-stage {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: .4rem 1rem 2rem;
}

.cd-pagewrap {
    position: relative;
    flex: none;
    background: #fff;
    box-shadow: 0 6px 24px rgba(20, 40, 70, .25);
}

/* what is selected */

.cd-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-bottom: .65rem;
}

.cd-field > label,
.cd-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bc-ink-muted);
}

.cd-field input[type=text],
.cd-field input[type=number],
.cd-field select,
.cd-field textarea {
    width: 100%;
    padding: .35rem .5rem;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: #fff;
}

.cd-field textarea {
    min-height: 3.2rem;
    resize: vertical;
}

.cd-field input[type=range] {
    width: 100%;
}

.cd-row {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
}

.cd-row > * {
    flex: 1;
    min-width: 0;
}

.cd-tog {
    display: inline-flex;
    flex: none;
    align-self: flex-start;
    overflow: hidden;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
}

.cd-tog button {
    min-width: 2.1rem;
    padding: .3rem .6rem;
    border: 0;
    border-right: 1px solid var(--bc-border);
    background: #fff;
}

.cd-tog button:last-child {
    border-right: 0;
}

.cd-tog button.on {
    background: var(--bc-blue);
    color: #fff;
}

.cd-tog button:disabled {
    opacity: .4;
    cursor: default;
}

.cd-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem;
}

.cd-swatches input[type=color] {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: #fff;
}

.cd-sw {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 50%;
}

.cd-sw.on {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--bc-blue);
}

.cd-sw.none {
    background: linear-gradient(135deg, #fff 45%, #d33 45% 55%, #fff 55%);
}

.cd-mm {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .35rem;
}

.cd-mm label {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    font-size: .68rem;
    color: var(--bc-ink-muted);
}

.cd-mm input {
    width: 100%;
    padding: .25rem .3rem;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
}

.cd-checks > label:not(.cd-label) {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .12rem 0;
    font-size: .84rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--bc-ink);
}

.cd-acts {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.cd-small {
    padding: .25rem .6rem;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: #fff;
    font-size: .8rem;
    font-weight: 600;
    color: var(--bc-ink-muted);
}

.cd-small:hover {
    border-color: var(--bc-blue);
    color: var(--bc-blue-dark);
}

.cd-small.danger {
    color: var(--bc-danger);
}

.cd-tip {
    padding: .6rem .7rem;
    border: 1px solid var(--bc-blue-mid);
    border-radius: 8px;
    background: var(--bc-blue-light);
    font-size: .8rem;
    line-height: 1.45;
}

.cd-tip + .cd-tip {
    margin-top: .5rem;
}

.cd-warn {
    padding: .5rem .7rem;
    border: 1px solid #ecd58a;
    border-radius: 8px;
    background: var(--bc-warning-bg);
    font-size: .8rem;
    line-height: 1.4;
    color: var(--bc-warning);
}

/* The editor's seventh tile shows the event's own page. */
.cd-tile-pic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 10 / 9;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 4px;
    background: #eef1f4;
}

/* No design yet: a pencil where the page will be. */
.cd-tile-pic:empty::before {
    content: "\270E";
    font-size: 2.2rem;
    line-height: 1;
    color: #9aa7b4;
}

@media (max-width: 1000px) {
    .cd-bar {
        position: static;
    }

    .cd-notice:not(.cd-narrow) {
        top: .4rem;
    }

    .cd-work {
        grid-template-columns: minmax(0, 1fr);
    }

    .cd-side {
        position: static;
        max-height: none;
    }

    .cd-side.left {
        order: 2;
        border-right: 0;
        border-top: 1px solid var(--bc-border);
    }

    .cd-side.right {
        order: 3;
        border-left: 0;
        border-top: 1px solid var(--bc-border);
    }

    .cd-desk {
        min-height: 0;
    }

    .cd-narrow {
        display: block;
    }
}
