/* Advisor Settings -> Workspace -> Document branding.
   The preview mirrors reporting/document_theme.py; keep the two in step. */

.doc-brand-status {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0;
    color: var(--advisor-color-muted);
    font-size: 13px;
}

.doc-brand-status--error { color: var(--advisor-color-negative); }

.doc-brand-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 40px;
    align-items: start;
}

/* ---- Form ------------------------------------------------------------- */

.doc-brand-form {
    display: grid;
    gap: 28px;
    min-width: 0;
}

.doc-brand-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.doc-brand-group > legend {
    grid-column: 1 / -1;
    width: 100%;
    margin-bottom: 14px;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--advisor-color-border);
    color: var(--advisor-color-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.doc-brand-group > *:not(legend):not(.doc-brand-field) { grid-column: 1 / -1; }

.doc-brand-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.doc-brand-field--wide { grid-column: 1 / -1; }

.doc-brand-field > span {
    color: var(--advisor-color-ink);
    font-size: 12px;
    font-weight: 600;
}

/* Folio editor anatomy (styles/folio/folio-editor.css .folio-input); the
   settings route is not inside .folio, so the skin is applied here. */
.doc-brand-field input,
.doc-brand-field textarea {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--f-line-strong, #c9bda3);
    border-radius: 9px;
    background: var(--f-paper, #fffdf8);
    color: var(--f-ink, #1b1d19);
    font: 400 13.5px/1.3 var(--f-font-ui, "Segoe UI", sans-serif);
    box-shadow: none;
    outline: none;
    appearance: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.doc-brand-field textarea {
    height: auto;
    min-height: 68px;
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
}

.doc-brand-field :is(input, textarea)::placeholder { color: var(--f-faint, #aaa18e); }
.doc-brand-field :is(input, textarea):hover:not(:disabled) { border-color: var(--f-dim, #807a6a); }

.doc-brand-field :is(input, textarea):focus {
    border-color: var(--f-accent, #236f5d);
    box-shadow: 0 0 0 3px var(--f-accent-soft, #deeee7);
}

.doc-brand-field :is(input, textarea):disabled {
    border-color: var(--f-line, #dfd5bf);
    background: var(--f-inset, #f0eadb);
    color: var(--f-muted, #5d5b50);
    cursor: not-allowed;
}

.doc-brand-field > small,
.doc-brand-logo-copy > small,
.doc-brand-variants > p {
    color: var(--advisor-color-muted);
    font-size: 12px;
    line-height: 1.45;
}

/* Logo */

.doc-brand-logo {
    display: grid;
    grid-template-columns: 184px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
}

.doc-brand-logo-thumb {
    display: grid;
    place-items: center;
    height: 84px;
    padding: 14px 16px;
    border: 1px solid var(--advisor-color-border);
    border-radius: var(--advisor-radius-panel);
    background: color-mix(in srgb, var(--doc-accent, #80601d) 10%, var(--doc-ink, #151917));
}

.doc-brand-logo-thumb .doc-brand-logo-empty { color: rgba(255, 253, 248, 0.64); }

/* The thumbnail shows the masthead the PDF will use. */
.doc-brand-logo-thumb--light {
    --doc-reink: var(--doc-ink, #151917);
    background: var(--doc-paper, #fffdf8);
}

.doc-brand-logo-thumb .doc-brand-mark { --doc-logo-unit: 44px; }
.doc-brand-logo-thumb .doc-brand-mark img { max-width: 148px; max-height: 44px; }

.doc-brand-logo-empty {
    color: var(--advisor-color-subtle, var(--advisor-color-muted));
    font-size: 12px;
}

.doc-brand-logo-copy {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.doc-brand-logo-copy > strong {
    color: var(--advisor-color-ink);
    font-size: 13px;
}

.doc-brand-logo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

/* The file input sits invisibly inside a styled label, so the control reads
   as one button instead of the browser's "Choose File / No file chosen". */
.doc-brand-file {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.doc-brand-file input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.doc-brand-file:focus-within {
    outline: 2px solid var(--advisor-color-accent);
    outline-offset: 2px;
}

.doc-brand-text-button {
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--advisor-color-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.doc-brand-text-button:hover { color: var(--advisor-color-negative); }

/* Segmented choices share one shape: logo treatment and typography. */

.doc-brand-choice {
    display: inline-flex;
    justify-self: start;
    padding: 3px;
    border: 1px solid var(--advisor-color-border);
    border-radius: var(--advisor-radius-pill, 999px);
    background: var(--advisor-color-surface-muted);
}

.doc-brand-choice label { position: relative; }

.doc-brand-choice input,
.doc-brand-type input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.doc-brand-choice span {
    display: block;
    padding: 6px 14px;
    border-radius: var(--advisor-radius-pill, 999px);
    color: var(--advisor-color-muted);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.doc-brand-choice input:checked + span {
    color: var(--advisor-color-ink);
    background: var(--advisor-color-surface-solid, #fff);
    box-shadow: 0 1px 2px rgba(21, 25, 23, 0.12), 0 0 0 1px var(--advisor-color-border);
}

.doc-brand-choice input:focus-visible + span,
.doc-brand-type input:focus-visible + span {
    outline: 2px solid var(--advisor-color-accent);
    outline-offset: 2px;
}

.doc-brand-variants {
    border-top: 1px solid var(--advisor-color-border);
    padding-top: 12px;
}

.doc-brand-variants > summary {
    color: var(--advisor-color-ink);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.doc-brand-variants > p { margin: 8px 0 4px; }

.doc-brand-variant {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--advisor-color-border);
}

.doc-brand-variant:last-child { border-bottom: 0; }

.doc-brand-variant > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.doc-brand-variant b { color: var(--advisor-color-ink); font-size: 12px; font-weight: 600; }
.doc-brand-variant small { color: var(--advisor-color-muted); font-size: 11px; overflow-wrap: anywhere; }

.doc-brand-variant-thumb {
    display: grid;
    place-items: center;
    height: 40px;
    padding: 6px;
    border: 1px solid var(--advisor-color-border);
    border-radius: 6px;
}

.doc-brand-variant-thumb--light { background: var(--doc-paper, #fffdf8); }
.doc-brand-variant-thumb--dark { background: var(--doc-ink, #151917); }
.doc-brand-variant-thumb img { max-width: 80px; max-height: 26px; object-fit: contain; }

/* Color and type */

.doc-brand-swatches {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.doc-brand-swatch {
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
    padding: 8px 10px 8px 8px;
    border: 1px solid var(--advisor-color-border);
    border-radius: var(--advisor-radius-control, 8px);
    background: var(--advisor-color-surface-solid, #fff);
    cursor: pointer;
}

.doc-brand-swatch input[type="color"] {
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(21, 25, 23, 0.18);
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.doc-brand-swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.doc-brand-swatch input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.doc-brand-swatch input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }

.doc-brand-swatch > span { display: grid; gap: 1px; min-width: 0; }
.doc-brand-swatch b { color: var(--advisor-color-ink); font-size: 12px; font-weight: 600; }
.doc-brand-swatch code {
    color: var(--advisor-color-muted);
    font-family: var(--advisor-font-mono);
    font-size: 11px;
}

.doc-brand-contrast {
    min-height: 0;
    margin: -4px 0 0;
    color: var(--advisor-color-negative);
    font-size: 12px;
}

.doc-brand-contrast:empty { display: none; }

.doc-brand-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.doc-brand-type { position: relative; min-width: 0; }

.doc-brand-type > span {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--advisor-color-border);
    border-radius: var(--advisor-radius-control, 8px);
    background: var(--advisor-color-surface-solid, #fff);
    cursor: pointer;
}

.doc-brand-type i {
    grid-row: span 2;
    color: var(--advisor-color-ink);
    font-family: "Finn Fraunces", var(--advisor-font-display);
    font-size: 26px;
    font-style: normal;
    font-weight: 600;
    line-height: 1;
}

.doc-brand-type--modern i { font-family: "Inter", var(--advisor-font-body); font-size: 23px; }
.doc-brand-type b { color: var(--advisor-color-ink); font-size: 12px; font-weight: 600; }
.doc-brand-type small { color: var(--advisor-color-muted); font-size: 11px; }

.doc-brand-type input:checked + span {
    border-color: var(--advisor-color-ink);
    box-shadow: inset 0 0 0 1px var(--advisor-color-ink);
}

.doc-brand-group:disabled .doc-brand-swatch,
.doc-brand-group:disabled .doc-brand-type > span,
.doc-brand-group:disabled .doc-brand-choice span { cursor: default; }

/* Save row */

.doc-brand-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--advisor-color-border);
}

.doc-brand-notice {
    flex: 1 1 260px;
    margin: 0;
    color: var(--advisor-color-muted);
    font-size: 12px;
}

.doc-brand-notice.error { color: var(--advisor-color-negative); }

/* ---- Preview: a scaled first page of the Household Action Plan -------- */

.doc-brand-preview {
    position: sticky;
    top: 24px;
    margin: 0;
}

.doc-brand-preview figcaption {
    margin-top: 10px;
    color: var(--advisor-color-muted);
    font-size: 11px;
    line-height: 1.45;
}

.doc-brand-page {
    --doc-display: "Finn Fraunces", var(--advisor-font-display);
    --doc-body: "Finn Instrument", var(--advisor-font-body);
    --doc-mono: var(--f-font-mono, var(--advisor-font-mono));
    /* Mirrors reporting/document_theme.py: the band is the ink warmed by the
       brand; the canvas, card edges, and brand text derive from the brand. */
    --doc-band: color-mix(in srgb, var(--doc-accent) 10%, var(--doc-ink));
    --doc-on-band: color-mix(in srgb, var(--doc-paper) 96%, var(--doc-band));
    --doc-on-band-muted: color-mix(in srgb, var(--doc-paper) 64%, var(--doc-band));
    --doc-warm: color-mix(in srgb, var(--doc-accent) 62%, var(--doc-ink));
    --doc-canvas: color-mix(in srgb, var(--doc-warm) 7%, var(--doc-paper));
    --doc-line: color-mix(in srgb, var(--doc-warm) 24%, var(--doc-paper));
    --doc-ground: color-mix(in srgb, var(--doc-accent) 11%, var(--doc-paper));
    --doc-brand-ink: color-mix(in srgb, var(--doc-accent) 55%, var(--doc-ink));
    --doc-muted: color-mix(in srgb, var(--doc-ink) 66%, var(--doc-paper));
    --doc-dim: color-mix(in srgb, var(--doc-ink) 52%, var(--doc-paper));
    --doc-hairline: color-mix(in srgb, var(--doc-ink) 15%, var(--doc-paper));
    display: flex;
    flex-direction: column;
    aspect-ratio: 8.5 / 11;
    overflow: hidden;
    border: 1px solid rgba(21, 25, 23, 0.1);
    border-radius: 3px;
    color: var(--doc-ink);
    background: var(--doc-canvas);
    box-shadow: 0 1px 2px rgba(21, 25, 23, 0.06), 0 12px 32px rgba(21, 25, 23, 0.12);
    font-family: var(--doc-body);
}

.doc-brand-page--modern {
    --doc-body: "Inter", var(--advisor-font-body);
    --doc-display: var(--doc-body);
}

.doc-brand-band {
    --doc-reink: var(--doc-paper);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 13%;
    padding: 0 10%;
    border-bottom: 0.75px solid var(--doc-accent);
    color: var(--doc-on-band);
    background: var(--doc-band);
}

/* A color logo that would lose its color on the dark band sits on a light
   masthead instead: paper fill, ink text, the accent rule kept. */
.doc-brand-band--light {
    --doc-reink: var(--doc-ink);
    --doc-on-band: var(--doc-ink);
    --doc-on-band-muted: var(--doc-muted);
    background: var(--doc-paper);
}

/* Marks are sized by visual area (see documentBrandingMarkSize); the unit is
   the masthead's logo height. Without a measured shape, contain to the box. */
.doc-brand-mark { --doc-logo-unit: 22px; display: inline-block; max-width: 100%; line-height: 0; }
.doc-brand-mark img { display: block; max-width: 132px; max-height: 22px; object-fit: contain; }
.doc-brand-mark[style*="--doc-logo-w"] img {
    width: calc(var(--doc-logo-w) * var(--doc-logo-unit));
    height: auto;
    max-width: 100%;
    max-height: none;
}

/* A one-color mark that would not read is re-inked: the image sizes the box,
   the mask paints it in the masthead's re-ink color. Never on a plaque. */
.doc-brand-mark--recolor {
    background: var(--doc-reink, var(--doc-paper));
    -webkit-mask: var(--doc-logo) center / contain no-repeat;
    mask: var(--doc-logo) center / contain no-repeat;
}

.doc-brand-mark--recolor img { visibility: hidden; }

.doc-brand-wordmark {
    font-family: var(--doc-display);
    font-size: 12px;
    font-weight: 500;
}

.doc-brand-prepared {
    display: grid;
    gap: 2px;
    font-size: 6.5px;
    text-align: right;
    white-space: nowrap;
}

.doc-brand-prepared small,
.doc-brand-eyebrow,
.doc-brand-summary dt,
.doc-brand-footer > span:nth-child(2) {
    font-family: var(--doc-mono);
    font-size: 4.8px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.doc-brand-prepared small { color: var(--doc-on-band-muted); }

.doc-brand-body {
    display: flex;
    flex-direction: column;
    padding: 8% 10% 0;
}

.doc-brand-eyebrow { margin-bottom: 5px; color: var(--doc-brand-ink); font-size: 5.2px; }

.doc-brand-title {
    font-family: var(--doc-display);
    font-size: 19px;
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.015em;
}

.doc-brand-byline { margin-top: 2px; color: var(--doc-muted); font-size: 6.3px; }

.doc-brand-intro {
    max-width: 88%;
    margin: 8px 0 10px;
    color: var(--doc-muted);
    font-size: 6.6px;
    line-height: 1.55;
}

.doc-brand-summary,
.doc-brand-card {
    border: 0.75px solid var(--doc-line);
    border-radius: 6px;
    background: var(--doc-paper);
}

.doc-brand-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 12px;
    overflow: hidden;
}

.doc-brand-summary div { padding: 6px 8px 7px; }
.doc-brand-summary div + div { border-left: 0.75px solid var(--doc-line); }
.doc-brand-summary dt { color: var(--doc-dim); }

.doc-brand-summary dd {
    margin: 4px 0 0;
    font-family: var(--doc-display);
    font-size: 11px;
    font-weight: 500;
}

.doc-brand-summary .is-brand { color: var(--doc-brand-ink); }

.doc-brand-card { overflow: hidden; }

.doc-brand-section {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 7px 8px 6px;
    border-bottom: 0.75px solid var(--doc-line);
}

.doc-brand-section b { font-family: var(--doc-display); font-size: 10px; font-weight: 500; }
.doc-brand-section span { color: var(--doc-muted); font-size: 5.5px; }

.doc-brand-rows { margin: 0; padding: 0; list-style: none; }

.doc-brand-rows li {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 36px 50px;
    gap: 6px;
    align-items: start;
    padding: 5px 8px;
    border-bottom: 0.5px solid var(--doc-hairline);
    font-size: 5.8px;
    line-height: 1.35;
}

.doc-brand-rows li:last-child { border-bottom: 0; }
.doc-brand-rows li.is-yours { background: var(--doc-ground); }
.doc-brand-rows li span:last-child { color: var(--doc-muted); }
.doc-brand-rows .is-you { color: var(--doc-brand-ink); font-weight: 600; }

/* Folio's emerald status chip (folio-editor.css in-progress). */
.doc-brand-rows .doc-brand-chip {
    white-space: nowrap;
    justify-self: start;
    padding: 1px 4px;
    border: 0.5px solid #b9d9cc;
    border-radius: 999px;
    color: #236f5d !important;
    background: #deeee7;
    font-family: var(--doc-mono);
    font-size: 4.4px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.doc-brand-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    margin: auto 10% 0;
    padding: 7px 0 9%;
    border-top: 0.5px solid var(--doc-line);
    color: var(--doc-muted);
    font-size: 5.3px;
}

.doc-brand-footer > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-brand-footer > span:nth-child(2) { color: var(--doc-dim); font-size: 4.4px; }
.doc-brand-footer b { color: var(--doc-ink); font-weight: 600; }

.doc-brand-footer em {
    grid-column: 1 / -1;
    display: -webkit-box;
    overflow: hidden;
    font-style: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

@media (max-width: 1080px) {
    .doc-brand-editor { grid-template-columns: 1fr; }
    .doc-brand-preview { position: static; max-width: 380px; }
}

@media (max-width: 620px) {
    .doc-brand-group,
    .doc-brand-types,
    .doc-brand-swatches { grid-template-columns: 1fr; }
    .doc-brand-logo { grid-template-columns: 1fr; }
    .doc-brand-variant { grid-template-columns: 72px minmax(0, 1fr); }
    .doc-brand-choice { flex-wrap: wrap; border-radius: var(--advisor-radius-panel); }
}
