/* props.css - the properties panel (#right-panel), owned by props.js.

   Quiet and precise, dense like a pro tool: a header with the panel title, sections separated
   by hairlines, compact two-column rows (label | control) and numbers in mono. The highlighter
   is never used here (it marks the active mode and tool only); pressed toggles use the ink
   tint, and proof red appears only on Delete and redaction. The shell (app.js) owns the
   panel's size and drawer behaviour; this file styles what is inside it. */

/* Closed with the header's close button (settings.rightPanel = false). */
#right-panel[data-closed] { display: none; }

#right-panel > .props-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--fs-s);
    line-height: 1.4;
}

/* Rows set their own display; make the hidden attribute win. */
.props-panel [hidden] { display: none !important; }

/* ------------------------------------------------------------------ header */

.props-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--line);
}

.props-titles { flex: 1 1 auto; min-width: 0; }

.props-title {
    margin: 0;
    font: 600 var(--fs-m)/1.25 var(--font-ui);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The title takes focus (tabindex -1) when a rebuild removes the button that had it, so it gets
   a ring only for keyboard users, like every other control. */
.props-title:focus { outline: none; }
.props-title:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

.props-caption {
    margin: 2px 0 0;
    font-size: var(--fs-xs);
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.props-close { flex: none; }

.props-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 12px;
}

/* ------------------------------------------------------------------ sections & rows */

.props-sec {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px 14px;
    min-width: 0;
}

.props-sec + .props-sec { border-top: 1px solid var(--line); }

.props-sec-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.props-sec-title {
    margin: 0;
    font: 600 var(--fs-xs)/1.3 var(--font-ui);
    color: var(--text-2);
    letter-spacing: 0.01em;
}

.props-sec-aside {
    font: 500 var(--fs-xs)/1 var(--font-mono);
    color: var(--text-3);
}

.props-row {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    min-height: 32px;
}

.props-label {
    min-width: 0;
    font-size: var(--fs-s);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.props-ctl {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.props-ctl > * { min-width: 0; }
/* a lone labelled ghost button (e.g. "Document properties") lines its icon up with the values
   above it, which also gives the label the room it needs in the 288px panel */
.props-ctl > .btn.ghost.sm:only-child:has(> .btn-label) { margin-left: -10px; }

/* Controls rebuilt in place when their value changes; the wrapper takes no space. */
.props-swap { display: contents; }
.props-grow > * { flex: 1 1 auto; min-width: 0; }

.props-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.props-btns {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}

.props-spacer { flex: 1 1 auto; }
.props-block { display: flex; flex-direction: column; gap: 6px; }
.props-seg { flex: 0 1 auto; max-width: 100%; }

/* ------------------------------------------------------------------ numbers */

.props-num,
.props-num input {
    font-family: var(--font-mono);
    font-size: var(--fs-s);
    font-variant-numeric: tabular-nums;
}

.props-num { min-width: 0; }
.props-num input { min-width: 0; width: 100%; }
.props-ctl > .props-num { flex: 0 1 120px; }
.props-inline > .props-num { flex: 1 1 auto; max-width: 132px; }

.props-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    margin-bottom: 2px;
}

.props-axis {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.props-axis > .props-num { flex: 1 1 auto; }

.props-axis-key {
    flex: none;
    width: 12px;
    font: 500 var(--fs-xs)/1 var(--font-mono);
    color: var(--text-3);
    text-align: center;
}

.props-value {
    min-width: 0;
    font-family: var(--font-mono);
    font-size: var(--fs-s);
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.props-muted { color: var(--text-3); }

.props-ellipsis {
    display: block;
    font-family: var(--font-ui);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.props-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

/* ------------------------------------------------------------------ inputs */

.props-input { width: 100%; min-width: 0; }
.props-upper { text-transform: uppercase; letter-spacing: 0.03em; }

.props-textarea {
    width: 100%;
    min-height: 64px;
    resize: vertical;
    font: inherit;
    font-size: var(--fs-s);
    line-height: 1.45;
}

/* Toggle buttons (bold, flips, arrows, lock): pressed = ink tint, never the highlighter. */
.props-press[aria-pressed="true"] {
    background: var(--ink-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink-line);
}

.props-panel .is-disabled { opacity: 0.5; }

/* ------------------------------------------------------------------ chips & colour dots */

.props-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.props-chips-label {
    margin-right: 2px;
    font-size: var(--fs-xs);
    color: var(--text-3);
}

.props-chip {
    appearance: none;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text-2);
    font: 500 var(--fs-xs)/1 var(--font-mono);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}

.props-chip:hover { background: var(--surface-3); color: var(--text); }

.props-chip[aria-pressed="true"] {
    background: var(--ink-soft);
    border-color: var(--ink-line);
    color: var(--ink);
}

/* Stamp presets read as labels, not code. */
.props-chips-wrap .props-chip {
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0.04em;
}

.props-dots {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.props-dot {
    appearance: none;
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--pill);
    background: transparent;
    cursor: pointer;
}

.props-dot::before {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: var(--pill);
    background: var(--dot);
    box-shadow: 0 0 0 1px var(--line-strong);
    transition: box-shadow var(--dur-fast) var(--ease);
}

.props-dot:hover::before { box-shadow: 0 0 0 1px var(--text-3); }
.props-dot[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

.props-chip:focus-visible,
.props-dot:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

@media (pointer: coarse) {
    .props-chip { min-height: 36px; padding: 0 10px; }
    .props-dot { width: 40px; height: 40px; }
}

/* ------------------------------------------------------------------ arrange, align, actions */

.props-align {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.props-seg3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px;
    padding: 2px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
}

.props-seg3 > .props-align-btn {
    justify-content: center;
    min-width: 0;
    padding-inline: 4px;
    font-size: var(--fs-xs);
}

.props-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.props-actions > :last-child { margin-left: auto; }

/* ------------------------------------------------------------------ notes & callouts */

.props-note {
    margin: 0;
    font-size: var(--fs-xs);
    line-height: 1.45;
    color: var(--text-3);
}

/* Lines up under the controls column (label 84px + gap 10px). */
.props-note-inset { margin-left: 94px; }

.props-note-warn { color: var(--amber); }

.props-note-red {
    padding: 8px 10px;
    border-radius: var(--radius-s);
    background: var(--red-soft);
    color: var(--red);
}

.props-tip { font-size: var(--fs-s); color: var(--text-2); }
.props-pad { padding: 16px; }

.props-warn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-s);
    background: var(--amber-soft);
    color: var(--amber);
    font-size: var(--fs-xs);
    line-height: 1.45;
}

.props-callout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--fs-xs);
}

/* ------------------------------------------------------------------ page card */

.props-pagecard {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.props-sheet {
    flex: none;
    display: grid;
    place-items: center;
    margin: 6px 2px;
    border-radius: 2px;
    background: var(--paper);
    box-shadow: var(--shadow-page);
    transition: width var(--dur) var(--ease), height var(--dur) var(--ease);
}

.props-sheet-num {
    font: 500 var(--fs-xs)/1 var(--font-mono);
    /* The sheet is --paper (white) in both themes, so its label is derived from paper-side
       tokens, not the theme's --text-3 (3.46:1 on white in dark): ~5.8:1 in light and dark. */
    color: color-mix(in srgb, var(--marker-text) 62%, var(--paper));
}

.props-facts {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.props-facts .props-row {
    grid-template-columns: 60px minmax(0, 1fr);
    min-height: 28px;
}

/* Third-party sections (registerPropsSection) get sensible defaults for plain controls. */
.props-custom input:not([type="checkbox"]):not([type="radio"]),
.props-custom select,
.props-custom textarea { max-width: 100%; }
