/*
 * TB Flux Card. Loaded only on the page with [flux_card] (a Standalone
 * Play tool page, so no theme CSS is present).
 *
 * Anything that must print (sheet pattern, hole fills, card paper, white
 * label boxes) is drawn as SVG or <img>, never as a CSS background, so it
 * prints with "Background graphics" off.
 */

@page { size: letter; margin: 0; }

body {
    margin: 0;
    background: #f1f1f0;
}

.fc {
    --fc-ink: #0a0a0a;
    --fc-yellow: #ffd814;
    --fc-paper: #fbfaf5;
    --fc-grey: #4a4a48;
    --fc-focus: #ffd814;
    min-height: 100vh;
    color: var(--fc-ink);
    font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}
.fc *, .fc *::before, .fc *::after { box-sizing: border-box; }
.fc button { font-family: inherit; }
.fc a { color: #1e3a6b; }
.fc a:hover { color: #15294a; }
.fc [hidden] { display: none !important; }

.fc :focus-visible {
    outline: 3px solid var(--fc-ink);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--fc-focus);
}

.fc-visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Pattern definitions: present but invisible. Not display:none, which would
   break the url(#…) fills in some browsers. */
.fc-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.fc-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f1f1f0;
}

/* ---- Top bar ---- */

.fc-bar {
    background: var(--fc-ink);
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 10px 20px;
}
.fc-bar__brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.fc .fc-bar__back {
    color: #bdbdbb;
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 12px 0;
}
.fc .fc-bar__back:hover { color: #fff; }
.fc-bar__title {
    margin: 0;
    font-family: "Mouse Memoirs", Impact, sans-serif;
    font-weight: 400;
    font-size: 30px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
}
.fc-bar__by { color: #bdbdbb; font-size: 12px; }
.fc-bar__tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.fc-paper {
    display: flex;
    border: 1px solid #5a5a5a;
    border-radius: 6px;
    padding: 3px;
    gap: 3px;
}
.fc-paper__btn {
    min-height: 38px;
    min-width: 52px;
    padding: 0 12px;
    border: 0;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    cursor: pointer;
    background: transparent;
    color: #fff;
}
.fc-paper__btn[aria-pressed="true"] { background: #fff; color: var(--fc-ink); }

.fc-printbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fc-print-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    border: 0;
    border-radius: 6px;
    background: var(--fc-yellow);
    color: var(--fc-ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}
.fc-print-btn:hover { background: #ffe24d; }
.fc-printbox__hint { color: #bdbdbb; font-size: 11px; }

.fc .fc-bar :focus-visible { outline-color: #fff; }

/* ---- Main: stage + side panel ---- */

.fc-main { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: stretch; }

.fc-stage {
    flex: 999 1 560px;
    min-width: 0;
    position: relative;
    overflow: hidden;
    background: #3f3f45;
    min-height: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 48px 20px;
}
.fc-stage__sheet { position: absolute; inset: 0; width: 100%; height: 100%; }

.fc-actions {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.fc-flux-btn {
    min-height: 64px;
    min-width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 32px;
    border: 3px solid var(--fc-ink);
    border-radius: 6px;
    background: var(--fc-ink);
    color: #fff;
    font-family: "Mouse Memoirs", Impact, sans-serif !important;
    font-size: 40px;
    letter-spacing: 0.08em;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--fc-yellow);
}
.fc-flux-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--fc-yellow); }
.fc-flux-btn:focus-visible { box-shadow: 0 5px 0 var(--fc-yellow), 0 0 0 6px var(--fc-focus); }
.fc-hint {
    margin: 0;
    padding: 6px 12px;
    background: var(--fc-paper);
    border: 1px solid #262626;
    font-size: 12px;
    color: #262626;
    text-align: center;
}

/* ---- The card (screen and print share this) ---- */

.fc-card {
    position: relative;
    width: 100%;
    max-width: calc(var(--fc-card-w) * 1);
    aspect-ratio: var(--fc-aspect);
    container-type: inline-size;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18), 0 14px 34px rgba(0, 0, 0, 0.32);
}
.fc-card__paper,
.fc-card__art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.fc-sq {
    position: absolute;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    container-type: size;
    -webkit-tap-highlight-color: transparent;
}
.fc-sq:disabled { cursor: default; }
.fc .fc-sq:focus-visible { outline: 3px solid var(--fc-focus); outline-offset: 1px; box-shadow: 0 0 0 5px var(--fc-ink); }
@media (hover: hover) {
    .fc-sq:not(:disabled):hover .fc-sq__icon img { transform: scale(1.06) rotate(-2deg); }
}

.fc-sq__icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.fc-sq__icon img {
    width: var(--fc-icon);
    height: var(--fc-icon);
    object-fit: contain;
    display: block;
    transition: transform 160ms ease;
}

/* The hole: centred on its spot (set by the script), grows in when punched. */
.fc-sq__hole {
    position: absolute;
    left: 26%;
    top: 26%;
    width: var(--fc-hole);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.fc-sq__star {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    transform: scale(0) rotate(-40deg);
    transition: transform 180ms cubic-bezier(.3, 1.6, .5, 1);
}
.fc-sq.is-punched .fc-sq__star { transform: none; }

/* Chad and punch tool, placed on the hole's centre by the script. */
.fc-chad,
.fc-tool {
    position: absolute;
    pointer-events: none;
}
.fc-chad { transform: translate(-50%, -50%); z-index: 2; }
.fc-chad__inner,
.fc-chad__star { display: block; width: 100%; }
.fc-chad__star { aspect-ratio: 1; overflow: visible; }

.fc-tool { z-index: 3; transform: translate(calc(var(--fc-anchor-x) * -1), calc(var(--fc-anchor-y) * -1)); }
.fc-tool__img {
    display: block;
    width: 100%;
    height: auto;
    transform-origin: var(--fc-anchor-x) var(--fc-anchor-y);
    filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35));
}

.fc-card__code {
    position: absolute;
    transform: translate(var(--fc-code-shift, 0), -82%);
    font-family: "Courier Prime", "Courier New", monospace;
    color: #55554f;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

/* Calibrate mode (?calibrate=1, admins). */
.fc-cal {
    position: absolute;
    z-index: 4;
    outline: 2px solid #e5007e;
    outline-offset: -1px;
    color: #e5007e;
    font: 700 12px/1 "Courier Prime", monospace;
    padding: 2px 3px;
    pointer-events: none;
}
.fc-panel__cal {
    margin: 0;
    padding: 10px 12px;
    border: 2px solid #e5007e;
    background: #fff;
    font-size: 12px;
}

/* ---- Dialog ---- */

.fc-dialog {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.45);
    padding: 20px;
}
.fc-dialog__box {
    width: 100%;
    max-width: 340px;
    background: var(--fc-paper);
    border: 3px solid var(--fc-ink);
    padding: 24px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.fc-dialog__title {
    margin: 0;
    font-family: "Mouse Memoirs", Impact, sans-serif;
    font-weight: 400;
    font-size: 32px;
    letter-spacing: 0.04em;
    line-height: 1;
}
/* The Print dialog covers the whole window, not just the stage. */
.fc-dialog--print { position: fixed; z-index: 30; }
.fc-dialog__text { margin: 0; color: #3d3d3b; line-height: 1.5; }
.fc-dialog__buttons { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.fc-btn {
    min-height: 44px;
    padding: 0 16px;
    border: 2px solid var(--fc-ink);
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.fc-btn--ghost { background: transparent; color: var(--fc-ink); }
.fc-btn--solid { background: var(--fc-ink); color: #fff; }

/* ---- Side panel ---- */

.fc-panel {
    flex: 1 1 320px;
    min-width: 0;
    max-width: 100%;
    background: #e8e8e6;
    border-left: 1px solid #c9c9c6;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.fc-panel__intro { display: flex; flex-direction: column; gap: 10px; }
.fc-panel__intro p { margin: 0; line-height: 1.6; }
.fc-panel__title {
    margin: 0;
    font-family: "Mouse Memoirs", Impact, sans-serif;
    font-weight: 400;
    font-size: 30px;
    letter-spacing: 0.04em;
    line-height: 1;
}
.fc-panel__group { display: flex; flex-direction: column; gap: 12px; }
.fc-panel__group--tight { gap: 8px; }
.fc-panel__label {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #3d3d3b;
}

.fc-swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fc-swatch {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 4px;
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}
.fc-swatch svg {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #b9b9b5;
    border-radius: 3px;
}
.fc-swatch span { font-size: 11px; font-weight: 500; color: #262626; text-align: center; }
.fc-swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--fc-ink); }

.fc-ink { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.fc-ink input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--fc-ink); }
.fc-ink strong { font-weight: 600; }

.fc-code {
    margin: 0;
    font-family: "Courier Prime", "Courier New", monospace;
    font-size: 15px;
    letter-spacing: 0.02em;
    word-break: break-all;
    background: var(--fc-paper);
    border: 1px dashed #8a8a86;
    padding: 10px 12px;
}
.fc-panel__note { margin: 0; font-size: 12px; color: var(--fc-grey); line-height: 1.5; }

.fc-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.5; }
.fc-steps strong { font-weight: 600; }

/* ---- Footer ---- */

.fc-foot {
    background: #fff;
    border-top: 1px solid #c9c9c6;
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fc-grey);
}
.fc-foot__links { display: flex; gap: 16px; flex-wrap: wrap; }
.fc-foot__links a { display: inline-block; padding: 8px 0; }

/* ---- Phone width ---- */

@media (max-width: 600px) {
    .fc-bar { padding: 8px 16px; }
    .fc-stage { min-height: 0; padding: 32px 16px; gap: 22px; }
    .fc-panel { border-left: 0; border-top: 1px solid #c9c9c6; padding: 24px 16px; }
    .fc-foot { padding: 12px 16px; }
    .fc-flux-btn { min-width: 180px; font-size: 36px; }
}

/* ---- Reduced motion: nothing flies, holes just appear ---- */

@media (prefers-reduced-motion: reduce) {
    .fc-sq__star,
    .fc-sq__icon img { transition: none; }
    .fc-sq:not(:disabled):hover .fc-sq__icon img { transform: none; }
}

/* ---- Print sheet ---- */

.fc-print { display: none; }

@media print {
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        height: auto !important;
    }
    /* Only the tool prints: no admin bar, consent banner or other plugin output. */
    body > *:not(#fc-root) { display: none !important; }
    .fc { min-height: 0; }
    .fc-app,
    .fc-dialog { display: none !important; }

    .fc,
    .fc * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .fc-print {
        display: block;
        position: relative;
        width: 8.5in;
        height: 11in;
        overflow: hidden;
        color: #1d1d1b;
        font-family: Inter, sans-serif;
        break-after: avoid;
        page-break-after: avoid;
        --fc-card-top: 300px;
        --fc-gap: 60px;
        --fc-title-top: 72px;
    }
    .fc[data-paper="a4"] .fc-print {
        width: 210mm;
        height: 296.5mm; /* a hair under 297 mm, so rounding never spills onto a second page */
        --fc-card-top: 340px;
        --fc-gap: 76px;
        --fc-title-top: 96px;
    }
    .fc[data-paper="letter"] .fc-print { height: 10.99in; }

    .fc-print__sheet { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

    .fc-print__box { position: absolute; }
    .fc-print__box > * { position: relative; }
    .fc-print__box > .fc-print__boxbg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
    .fc-print__box p { margin: 0; }

    .fc-print__title {
        top: var(--fc-title-top);
        left: 50%;
        width: 480px;
        margin-left: -240px;
        border: 1.5px solid #1d1d1b;
        padding: 16px 20px;
        text-align: center;
        display: flex;
        flex-direction: column;
        gap: 4px;
        font-size: 14px;
    }
    .fc-print__h1 {
        font-family: "Mouse Memoirs", Impact, sans-serif;
        font-size: 44px;
        letter-spacing: 0.06em;
        line-height: 1;
    }

    .fc-print__card {
        position: absolute;
        top: var(--fc-card-top);
        left: 50%;
        width: var(--fc-card-w);
        height: var(--fc-card-h);
        margin-left: calc(var(--fc-card-w) / -2);
    }
    .fc-card--print {
        width: 100%;
        max-width: none;
        height: 100%;
        box-shadow: none;
    }
    .fc-card--print .fc-sq { cursor: default; }
    .fc-card--print .fc-sq__star { transition: none; }

    .fc-crop {
        position: absolute;
        width: 36px;
        height: 36px;
        overflow: visible;
        fill: none;
        stroke: #1d1d1b;
        stroke-width: 1;
    }
    .fc-crop--tl { left: -36px; top: -36px; }
    .fc-crop--tr { right: -36px; top: -36px; }
    .fc-crop--bl { left: -36px; bottom: -36px; }
    .fc-crop--br { right: -36px; bottom: -36px; }

    .fc-print__howto {
        left: 72px;
        right: 72px;
        top: calc(var(--fc-card-top) + var(--fc-card-h) + var(--fc-gap));
        bottom: 72px;
        border: 1.5px solid #1d1d1b;
        padding: 20px 24px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        font-size: 13px;
        line-height: 1.5;
    }
    .fc-print__h2 {
        font-family: "Mouse Memoirs", Impact, sans-serif;
        font-size: 26px;
        letter-spacing: 0.04em;
        line-height: 1;
    }
    .fc-print__box .fc-print__meta {
        margin-top: auto;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        font-family: "Courier Prime", monospace;
        font-size: 12px;
    }

    /* Save ink: white sheet, borderless title, a rule above "How to use it". */
    .fc[data-ink="1"] .fc-print__boxbg { display: none; }
    .fc[data-ink="1"] .fc-print__title { border: 0; }
    .fc[data-ink="1"] .fc-print__howto {
        border: 0;
        border-top: 1px solid #1d1d1b;
        padding: 20px 0 0;
    }
}
