/* tools/collage-maker.css
   The collage maker: the collage on the left (on a phone, pinned at the top
   so it stays in view while the layout, size and style change underneath),
   the settings in tabs on the right. Same album look as the other tools:
   near-black ground, glass tiles, white pills. */

/* The title fonts, from the card maker's self-hosted set (SIL OFL). */
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 400 600; font-display: swap; src: url('/fonts/cards/PlayfairDisplay-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'Great Vibes'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/cards/GreatVibes-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/cards/Montserrat-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-style: italic; font-weight: 500; font-display: swap; src: url('/fonts/cards/CormorantGaramond-italic-latin.woff2') format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/cards/Caveat-normal-400_700-latin.woff2') format('woff2'); }

.cm-sample-btn {
    margin-top: 6px;
    font-size: 13px;
    padding: 8px 4px;
    min-height: 36px;
}

.cm-sample-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

#results-view > .error-container:empty {
    display: none;
}

#results-view > .error-container {
    margin-bottom: 12px;
    text-align: center;
}

/* ── The editor ─────────────────────────────────────────────── */
.cm-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
}

.cm-stage {
    position: sticky;
    top: 88px;
    z-index: 3;
    background: var(--tile-fill);
    border: 1px solid var(--tile-border);
    border-radius: var(--tile-radius);
    padding: 16px;
    min-width: 0;
}

.cm-canvas-box {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.cm-canvas {
    display: block;
    touch-action: none;
    cursor: grab;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.cm-canvas:active {
    cursor: grabbing;
}

.cm-bar {
    margin-top: 14px;
}

.cm-bar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cm-bar-row[hidden] {
    display: none;
}

.cm-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.cm-pill svg {
    width: 17px;
    height: 17px;
    flex: none;
}

.cm-pill:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.5);
}

.cm-pill:active:not(:disabled) {
    transform: scale(0.97);
}

.cm-pill:disabled {
    opacity: 0.4;
    cursor: default;
}

.cm-pill--quiet {
    border-color: transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
}

.cm-pill--solid {
    background: rgba(255, 255, 255, 0.95);
    color: #1d1b20;
    border-color: transparent;
    font-weight: 600;
}

.cm-pill--solid:hover:not(:disabled) {
    background: #fff;
}

.cm-zoom {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    flex: 1 1 180px;
    max-width: 280px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
}

.cm-zoom input {
    flex: 1;
    min-width: 0;
}

.cm-hint {
    margin: 10px 0 0;
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.55);
}

/* ── Settings panel ─────────────────────────────────────────── */
.cm-panel {
    background: var(--tile-fill);
    border: 1px solid var(--tile-border);
    border-radius: var(--tile-radius);
    padding: 14px;
    min-width: 0;
}

.cm-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 14px;
}

.cm-tab {
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cm-tab:hover {
    color: #fff;
}

.cm-tab.is-active {
    background: rgba(255, 255, 255, 0.95);
    color: #1d1b20;
    font-weight: 600;
}

.cm-tab:focus-visible,
.cm-pill:focus-visible,
.cm-layout:focus-visible,
.cm-size:focus-visible,
.cm-swatch:focus-visible,
.cm-font:focus-visible,
.cm-seg button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.cm-tabpanel[hidden] {
    display: none;
}

.cm-tabpanel {
    min-height: 150px;
}

/* Layouts */
.cm-layouts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.cm-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 76px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cm-layout:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

.cm-layout.is-active {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 0 1px #fff;
}

.cm-layout-frame {
    position: relative;
    display: block;
}

.cm-layout-cell {
    position: absolute;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.42);
}

.cm-layout.is-active .cm-layout-cell {
    background: rgba(255, 255, 255, 0.85);
}

.cm-note {
    margin: 10px 0 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.65);
}

.cm-note:empty {
    display: none;
}

/* Sizes */
.cm-sizes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.cm-size {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cm-size:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

.cm-size.is-active {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 0 1px #fff;
}

.cm-size-icon {
    flex: none;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    margin: 0 4px;
}

.cm-size-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cm-size-name {
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.25;
}

.cm-size-sub {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
}

/* Sliders and fields */
.cm-slider,
.cm-field {
    margin-bottom: 16px;
}

.cm-slider label,
.cm-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 6px;
}

.cm-label--sub {
    margin-top: 12px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
}

.cm-label[hidden] {
    display: none;
}

.cm-val {
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
}

.cm-optional {
    font-weight: 400;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
}

.cm-panel input[type="range"],
.cm-zoom input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 32px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    cursor: pointer;
}

.cm-panel input[type="range"]::-webkit-slider-runnable-track,
.cm-zoom input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.22);
    border: 0;
}

.cm-panel input[type="range"]::-moz-range-track,
.cm-zoom input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.22);
}

.cm-panel input[type="range"]::-webkit-slider-thumb,
.cm-zoom input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -9px;
    border-radius: 50%;
    border: 0;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.cm-panel input[type="range"]::-moz-range-thumb,
.cm-zoom input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 0;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.cm-panel input[type="range"]:focus-visible,
.cm-zoom input[type="range"]:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    border-radius: 4px;
}

.cm-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cm-swatch {
    position: relative;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

.cm-swatch.is-active {
    box-shadow: 0 0 0 2px #0d0d0f, 0 0 0 4px #fff;
}

.cm-swatch--pick {
    display: inline-block;
    background: conic-gradient(#f44, #fd4, #4d6, #4cf, #64f, #f4c, #f44);
}

.cm-swatch--pick input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
    padding: 0;
}

.cm-text {
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    padding: 9px 12px;
    font: inherit;
    font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.cm-text:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.45);
}

.cm-text::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.cm-fonts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cm-font {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cm-font.is-active {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px #fff;
}

.cm-seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.cm-seg button {
    min-height: 40px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cm-seg button.is-active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-weight: 600;
}

/* Save */
.cm-save {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.cm-save-btn {
    min-height: 48px;
    width: 100%;
    cursor: pointer;
}

.cm-save-btn:disabled {
    opacity: 0.7;
    cursor: progress;
}

.cm-save-note {
    grid-column: 1 / -1;
    margin: 0;
    text-align: center;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
}

/* ── Page copy: sample collages and the sizes table ─────────── */
.cm-ideas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin: 8px 0 40px;
}

.cm-idea {
    margin: 0;
}

.cm-idea > img,
.cm-sample {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 14px;
}

.cm-sample {
    display: grid;
    box-sizing: border-box;
    overflow: hidden;
}

.cm-sample img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    min-height: 0;
    min-width: 0;
}

/* A story: one large photo above three, the names along the bottom. */
.cm-sample--story {
    aspect-ratio: 9 / 16;
    max-height: 100%;
    background: #f6f1e8;
    padding: 4%;
    gap: 2.5%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: minmax(0, 3fr) minmax(0, 1.4fr) auto;
    width: auto;
    height: auto;
}

.cm-idea:has(.cm-sample--story) .cm-sample--story {
    width: 56.25%;
    margin-left: auto;
    margin-right: auto;
}

.cm-sample--story img:first-child {
    grid-column: 1 / -1;
}

.cm-sample-title {
    grid-column: 1 / -1;
    text-align: center;
    font-family: 'Great Vibes', cursive;
    font-size: clamp(0.95rem, 1.7vw, 1.4rem);
    white-space: nowrap;
    color: #2a2a2d;
    padding: 2% 0 0;
}

/* A travel-style even grid: three by two, white spacing. */
.cm-sample--grid {
    background: #fff;
    padding: 3%;
    gap: 3%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
}

.cm-idea h3 {
    margin: 0 0 6px;
}

.cm-idea p {
    margin: 0;
}

.cm-table-wrap {
    overflow-x: auto;
    margin: 0 0 40px;
    -webkit-overflow-scrolling: touch;
}

.cm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.cm-table th,
.cm-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: top;
}

.cm-table th {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

.cm-table td {
    color: rgba(255, 255, 255, 0.72);
}

.cm-table td:nth-child(3) {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ── Narrower screens ───────────────────────────────────────── */
@media (max-width: 1000px) {
    .cm-editor {
        grid-template-columns: minmax(0, 1fr) 320px;
    }
}

@media (max-width: 760px) {
    .cm-editor {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    /* The collage stays pinned under the header while the panel scrolls. */
    .cm-stage {
        top: 72px; /* under the floating header (16px + 56px) */
        margin: 0 -16px;
        padding: 10px 16px 8px;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        background: rgba(13, 13, 15, 0.97);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    .cm-canvas-box {
        min-height: 160px;
    }

    .cm-bar {
        margin-top: 10px;
    }

    .cm-bar-row {
        flex-wrap: nowrap;
        gap: 6px;
    }

    .cm-pill {
        padding: 0 14px;
        font-size: 0.88rem;
    }

    .cm-zoom span {
        display: none;
    }

    .cm-hint {
        margin-top: 6px;
        font-size: 0.75rem;
    }

    .cm-panel {
        padding: 12px;
    }

    /* Layouts scroll sideways under the thumb instead of stacking rows. */
    .cm-layouts {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .cm-layouts::-webkit-scrollbar {
        display: none;
    }

    .cm-layout {
        flex: 0 0 72px;
        scroll-snap-align: start;
    }

    .cm-tabpanel {
        min-height: 0;
    }

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

    .cm-save {
        grid-template-columns: 104px minmax(0, 1fr);
    }

    /* The table fits the phone: the shape is in the size's name anyway. */
    .cm-table {
        font-size: 0.85rem;
    }

    .cm-table th:nth-child(2),
    .cm-table td:nth-child(2) {
        display: none;
    }

    .cm-table th,
    .cm-table td {
        padding: 8px 6px;
    }

    .cm-table td:nth-child(3) {
        white-space: normal;
    }
}
