/*
 * Visual recap workspace: the shell shared by every recap page (meeting recap,
 * portfolio snapshot and the eight template recaps). Colours, type and
 * controls come from /tools/shared/ffy-ui.css; this file only arranges them.
 * The recap preview is the hero: it sits in the middle and always fits.
 */

.workspace {
    display: grid;
    grid-template-columns: minmax(19rem, 23rem) minmax(0, 1fr) minmax(17.5rem, 20.5rem);
    gap: var(--section-gap);
    align-items: start;
    max-width: 124rem;
    margin: 0 auto;
    padding: var(--section-gap) clamp(.75rem, 2vw, 1.5rem) 2.5rem;
}

.panel {
    background: var(--surface-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--card-pad);
    box-shadow: var(--shadow-card);
}

.panel-heading, .preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }

.panel-heading h1, .panel-heading h2, .preview-heading h2 {
    margin: .3rem 0 0;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.25;
}

/* --- editor ----------------------------------------------------------- */

.privacy-box {
    margin: 1rem 0 .4rem;
    padding: .85rem .95rem;
    border: 1px solid rgb(95 227 191 / 22%);
    border-radius: var(--radius-md);
    background: linear-gradient(150deg, rgb(95 227 191 / 7%), rgb(95 227 191 / 2%));
}

.switch-row, .confirm-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; cursor: pointer; }
.switch-row strong { color: var(--text-primary); font-size: var(--text-md); font-weight: 650; }
.switch-row small { display: block; margin-top: .2rem; color: var(--text-secondary); font-size: var(--text-xs); line-height: 1.45; font-weight: 500; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: .7rem; color: var(--text-primary); font-size: var(--label-size); font-weight: 700; letter-spacing: var(--label-spacing); text-transform: uppercase; }

.form-section { border-top: 1px solid var(--border-subtle); }
.form-section:last-child { border-bottom: 1px solid var(--border-subtle); }

.form-section summary {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 3.2rem;
    padding: .55rem .1rem;
    color: var(--text-primary);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    list-style: none;
    cursor: pointer;
}

.form-section summary::-webkit-details-marker { display: none; }

.form-section summary > span:first-child {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    flex: none;
    border-radius: .5rem;
    border: 1px solid #2f7c6a;
    background: var(--tile-teal);
    color: var(--accent-mint);
    font-size: .66rem;
    letter-spacing: .02em;
}

.form-section summary::after {
    content: "";
    width: .5rem;
    height: .5rem;
    margin-left: auto;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg) translateY(-2px);
    transition: transform .2s var(--ease);
}

.form-section[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.form-section summary output { margin-left: auto; color: var(--accent-mint); font-size: var(--text-xs); letter-spacing: .04em; }
.form-section summary output + *:not(*) { display: none; }
.form-section summary output.is-invalid { color: var(--warning); }
.form-section[open] > fieldset { padding: .2rem .1rem 1.2rem; }
.form-section fieldset > label, .form-section fieldset > .field { display: block; margin: .75rem 0; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.field-grid > label { display: block; margin: .75rem 0 0; }
.field-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.bucket-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(5rem, .8fr); gap: .1rem .75rem; }
.bucket-grid label { display: block; margin-top: .6rem; }

/* --- preview: the hero -------------------------------------------------- */

.preview-panel {
    position: sticky;
    top: calc(var(--header-h) + var(--section-gap));
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: radial-gradient(60rem 30rem at 50% -10%, rgb(31 143 119 / 16%), transparent 70%), rgb(4 9 10 / 72%);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.preview-heading { align-items: center; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border-subtle); }
.preview-heading h2 { margin-top: .2rem; font-size: var(--text-md); }
#dimension, #dimension-label, .dimension { color: var(--text-secondary); font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; white-space: nowrap; }
.preview-theme-control { display: flex; align-items: center; gap: .85rem; padding: .65rem 1.2rem; border-bottom: 1px solid var(--border-subtle); background: rgb(95 227 191 / 5%); }
.preview-theme-control label { flex: none; margin: 0; color: var(--text-primary); font-size: var(--label-size); font-weight: 700; letter-spacing: var(--label-spacing); text-transform: uppercase; }
.ffy-tool .preview-theme-control select { width: min(100%, 18rem); min-height: 2.7rem; margin: 0 0 0 auto; border-color: var(--border-strong); cursor: pointer; }

/* the whole recap always fits the stage: width = min(stage width, stage height × ratio) */
.preview-stage {
    position: relative;
    display: grid;
    place-items: center;
    height: calc(100vh - var(--header-h) - var(--section-gap) * 2 - 7.3rem);
    min-height: 30rem;
    padding: clamp(.8rem, 2vw, 1.6rem);
    container-type: size;
}

#recap-preview, #meeting-preview, #snapshot-preview, .recap-frame {
    width: min(100cqw, 100cqh * var(--ratio, .8));
    max-width: 100%;
    line-height: 0;
    border-radius: .35rem;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgb(255 255 255 / 5%), 0 28px 70px rgb(0 0 0 / 55%);
}

#recap-preview svg, #meeting-preview svg, #snapshot-preview svg { display: block; width: 100%; height: auto; }

/* --- design and export ---------------------------------------------------- */

.design-panel { position: sticky; top: calc(var(--header-h) + var(--section-gap)); }
.design-group { padding: 1.05rem 0; border-bottom: 1px solid var(--border-subtle); }
.design-group:first-of-type { padding-top: 1.15rem; }
.design-label, .select-label { display: block; margin: 0 0 .55rem; color: var(--text-primary); font-size: var(--label-size); font-weight: 700; letter-spacing: var(--label-spacing); text-transform: uppercase; }
.select-label select, .design-group select { margin-top: 0; }

.design-group > legend { float: left; width: 100%; padding: 0; margin: 0 0 .7rem; }
.design-group > legend + * { clear: both; }
.theme-picker { display: grid; gap: .55rem; }
.theme-picker label { cursor: pointer; }
.theme-picker input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }

.theme-picker span {
    display: grid;
    grid-template-columns: 3.6rem 1fr;
    grid-template-rows: auto auto;
    column-gap: .8rem;
    align-items: center;
    padding: .55rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: rgb(255 255 255 / 2%);
    transition: border-color .15s var(--ease), background-color .15s var(--ease);
}

.theme-picker label:hover span { border-color: var(--border-strong); }
.theme-picker input:checked + span { border-color: var(--accent-mint); background: rgb(95 227 191 / 7%); box-shadow: 0 0 0 1px var(--accent-mint) inset; }
.theme-picker input:focus-visible + span { box-shadow: var(--focus-ring); }

.template-card > i { grid-row: 1 / 3; width: 3.6rem; height: 2.6rem; padding: .35rem; border-radius: .5rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .2rem; align-items: end; }
.template-card > i b { display: block; height: 45%; border-radius: .15rem; background: currentColor; }
.template-card > i b:nth-child(2) { height: 80%; }
.template-card > i b:nth-child(3) { height: 62%; }
.template-card strong { align-self: end; color: var(--text-primary); font-size: var(--text-sm); }
.template-card small { color: var(--text-secondary); font-size: var(--text-xs); }
.template-card[data-premium] strong, .template-card[data-premium] small { color: inherit; }
.template-card--midnight > i { background: linear-gradient(145deg, #14292c, #060c0e); color: #5fe3bf; box-shadow: inset 0 0 0 1px #223b3c; }
.template-card--midnight > i b:nth-child(2) { background: #e6c27f; }
.template-card--ivory > i { background: linear-gradient(145deg, #fffdf9, #efe8da); color: #0e8768; }
.template-card--ivory > i b:nth-child(2) { background: #b98a3e; }

.branding-summary strong, .branding-summary small { display: block; }
.branding-summary strong { color: var(--accent-mint); font-size: var(--text-sm); }
.branding-summary small { margin-top: .3rem; color: var(--text-secondary); line-height: 1.45; }

.validation-message {
    min-height: 2.9rem;
    margin: 1rem 0;
    padding: .7rem .85rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: var(--surface-sunken);
    font-size: var(--text-sm);
    line-height: 1.45;
}

.validation-message.has-error { color: var(--danger); border-color: rgb(255 143 128 / 40%); background: rgb(255 143 128 / 6%); }

.confirm-row { justify-content: flex-start; line-height: 1.45; color: var(--text-secondary); font-size: var(--text-xs); }
.confirm-row input { margin-top: .1rem !important; }

/* ExportBar: copy is the primary action, downloads sit beside each other */
.export-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: 1rem; }
.export-grid button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: var(--button-h);
    padding: .5rem .4rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: rgb(255 255 255 / 4%);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}

.export-grid button:hover:not(:disabled) { border-color: var(--accent-mint); background: rgb(95 227 191 / 8%); }
.export-grid .copy-button, .export-grid .print-button { grid-column: 1 / -1; }
.export-grid .copy-button { border-color: transparent; background: var(--accent-mint); color: var(--accent-mint-ink); font-size: var(--text-md); }
.export-grid .copy-button:hover:not(:disabled) { background: #7eedcf; box-shadow: var(--glow-mint); }
.export-grid .export-caption { grid-column: 1 / -1; margin: .35rem 0 -.1rem; color: var(--text-tertiary); font-size: var(--label-size); font-weight: 700; letter-spacing: var(--label-spacing); text-transform: uppercase; }

.local-note { margin: 1rem 0 0; color: var(--text-tertiary); font-size: var(--text-xs); line-height: 1.55; }

/* --- tablet: editor and design share the left column --------------------- */

@media (max-width: 78rem) {
    .workspace { grid-template-columns: minmax(19rem, 23rem) minmax(0, 1fr); }
    .design-panel { position: static; grid-column: 1; }
    .preview-panel { grid-column: 2; grid-row: 1 / span 2; }
}

/* --- phones: one panel at a time ------------------------------------------ */

@media (max-width: 48rem) {
    .workspace { display: block; padding: .75rem .75rem 2rem; }
    [data-panel] { display: none; }
    [data-panel].is-mobile-active { display: block; }
    .preview-panel { position: static; }
    .design-panel { position: static; }
    .preview-stage { height: auto; min-height: 0; container-type: normal; padding: .75rem; }
    .preview-theme-control { padding: .65rem .8rem; }
    #recap-preview, #meeting-preview, #snapshot-preview, .recap-frame { width: 100%; }
    .field-grid--three { grid-template-columns: 1fr; }
    .export-grid button { min-height: 3.2rem; }
}

@media (max-width: 28rem) {
    .field-grid { grid-template-columns: 1fr; }
}
