/* ==========================================================================
   zzzzzzzzzzzzzzz_editor_sheets.css — list pickers as bottom sheets, colour rows with
   one palette sheet, slider + value box (P4; decisions D-5 and D-4; artboards
   D4Grid, D4Pick, D4Hex, D5Font, D5Layout, D3A). Markup: pages/new_content/editor_sheet_controls.py;
   behaviour: assets/editor_sheets.js. No state lives here. Loads after the category CSS
   on purpose (it owns the colour sheet view that swaps in for the panel).
   Metrics are the artboards' (docs/design/post_editor_mockup_2026-10/); the artboards draw the
   sheet body with 16 px side padding, the shell's body has 14, so grids and views add 2 px.
   ========================================================================== */

/* Icons (lucide outlines as masks, like .sp-editor-icon) ------------------------- */
.sp-sheet-icon {
  display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor;
  -webkit-mask: var(--sp-sheet-icon) center / contain no-repeat; mask: var(--sp-sheet-icon) center / contain no-repeat;
}
.sp-sheet-icon--back { --sp-sheet-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M15 6l-6 6 6 6'/></svg>"); }
.sp-sheet-icon--forward { --sp-sheet-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 6l6 6-6 6'/></svg>"); }
.sp-sheet-icon--close { --sp-sheet-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 6l12 12M18 6L6 18'/></svg>"); }

/* Generic button chrome (border, fill, min sizes, font) is reset for every button this file draws. */
#editor-workspace-root :is(.sp-color-back, .sp-color-swatch, .sp-color-action, .sp-color-trigger),
.sp-sheet-list-close {
  border: 0 !important; background-color: transparent !important; box-shadow: none !important; min-height: 0 !important; min-width: 0 !important;
  -webkit-appearance: none; appearance: none;
}

/* Colour rows (D-4): swatch + hex chip; the real control stays mounted, hidden ------ */
#editor-workspace-root .sp-color-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
#editor-workspace-root .sp-color-field > .sp-color-trigger + * { display: none !important; }
#editor-workspace-root .sp-color-trigger {
  box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 1 1 auto; min-width: 0;
  min-height: 44px; margin: 0; padding: 0; color: var(--sp-text); cursor: pointer; text-align: left; font: 500 13px/17px var(--sp-font-ui) !important;
}
#editor-workspace-root .sp-editor-row .sp-color-trigger, #editor-workspace-root .sp-step4-field-card .sp-color-trigger { justify-content: flex-end; }
#editor-workspace-root .sp-color-chip {
  box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 6px;
  border: 1px solid var(--sp-border-strong); border-radius: 999px; background: var(--sp-surface); color: var(--sp-text);
}
#editor-workspace-root .sp-color-chip .sp-sheet-icon { width: 16px; height: 16px; color: var(--sp-text-2); }
#editor-workspace-root .sp-color-value { font: 700 13px/17px var(--sp-font-ui); letter-spacing: .02em; }
#editor-workspace-root .sp-color-trigger.is-auto .sp-color-value { font-weight: 500; color: var(--sp-text-2); }
.sp-color-dot, .sp-color-preview {
  box-sizing: border-box; display: inline-block; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--swatch, transparent); border: 1.5px solid #3a3c44;
}
.sp-color-trigger.is-auto .sp-color-dot {
  background: conic-gradient(#3a3c44 25%, #22242b 0 50%, #3a3c44 0 75%, #22242b 0) 0 0 / 10px 10px;
}
#editor-workspace-root .sp-color-trigger:focus-visible, #editor-workspace-root .sp-range:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }

/* The colour sheet replaces the panel inside the sheet body (it must stay in #editor-tools: the
   keyboard composer accepts a field only there). Its head starts where the body's top padding
   ends, so the title sits where the artboards draw it (D4Grid: 44 px head under the grip). ------- */
#editor-workspace-root[data-color-sheet] .sp-editor-sheet-body > :not(#editor-color-sheet) { display: none !important; }
.sp-color-sheet { display: flex; flex-direction: column; min-width: 0; margin-top: -6px; color: var(--sp-text); font: 500 14px/18px var(--sp-font-ui); }
.sp-color-sheet[hidden], .sp-color-view[hidden] { display: none; }
.sp-color-head { box-sizing: border-box; display: flex; align-items: center; height: 44px; margin: 0 -6px 0 -6px; }
#editor-workspace-root .sp-color-back {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px;
  margin: 0; padding: 0; color: var(--sp-text); cursor: pointer; border-radius: 12px;
}
.sp-color-title { flex: 1; min-width: 0; margin: 0; font: 700 17px/22px var(--sp-font-display); color: var(--sp-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#editor-workspace-root .sp-color-action {
  box-sizing: border-box; height: 44px; margin: 0; padding: 0 8px; cursor: pointer;
  font: 500 13px/17px var(--sp-font-ui) !important; color: var(--sp-text-2) !important;
}
.sp-color-sheet[data-view="grid"] .sp-color-action[data-color-action="reset"], .sp-color-sheet[data-view="custom"] .sp-color-action[data-color-action="auto"],
.sp-color-sheet:not([data-auto="true"]) .sp-color-action[data-color-action="auto"] { display: none; }
.sp-color-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0; justify-items: center; margin: 3px 2px 0; }
#editor-workspace-root .sp-color-swatch {
  --dot: 34px; position: relative; box-sizing: border-box; display: block; width: 100%; max-width: 48px; height: 44px; margin: 0; padding: 0;
  cursor: pointer; border-radius: 0;
}
.sp-color-swatch::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: var(--dot); height: var(--dot); margin: calc(var(--dot) / -2) 0 0 calc(var(--dot) / -2);
  box-sizing: border-box; border-radius: 50%; background: var(--swatch); border: 1.5px solid #3a3c44;
}
.sp-color-swatch.is-on::before { outline: 2px solid var(--sp-text); outline-offset: 2px; }
.sp-color-swatch:focus-visible::before { outline: 2px solid var(--sp-accent); outline-offset: 2px; }
#editor-workspace-root .sp-color-custom-open {
  box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: calc(100% - 4px); height: 44px; margin: 9px 2px 0; padding: 0 12px;
  border: 1px solid var(--sp-border-strong); border-radius: 10px; background: var(--sp-surface); color: var(--sp-text); cursor: pointer;
  font: 500 14.5px/18px var(--sp-font-ui) !important; text-align: left;
}
.sp-color-custom-open > :nth-child(2) { flex: 1; }
.sp-color-custom-open .sp-sheet-icon { color: var(--sp-text-2); }
.sp-color-wheel { width: 22px; height: 22px; flex: none; border-radius: 50%; background: conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.sp-color-view[data-view="custom"] { display: flex; flex-direction: column; margin: 0 2px; }
.sp-color-sv {
  position: relative; box-sizing: border-box; height: 132px; margin-top: 4px; border-radius: 12px; touch-action: none; cursor: crosshair;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(var(--hue, 0), 100%, 50%));
}
.sp-color-hue {
  position: relative; box-sizing: border-box; height: 16px; margin-top: 12px; border-radius: 8px; touch-action: none; cursor: pointer;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.sp-color-thumb {
  position: absolute; box-sizing: border-box; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 3px solid #fff; background: var(--swatch, #fff); box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); pointer-events: none;
}
.sp-color-hue .sp-color-thumb { top: 50%; }
.sp-color-hexrow { display: flex; align-items: center; gap: 10px; height: 44px; margin-top: 12px; }
.sp-color-hexrow .sp-color-preview { width: 44px; height: 44px; border-radius: 10px; }
.sp-color-hexbox {
  box-sizing: border-box; display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; height: 44px; padding: 0 12px;
  border: 1px solid var(--sp-border-strong); border-radius: 10px; background: var(--sp-surface);
}
.sp-color-hexbox:focus-within { border: 1.5px solid var(--sp-accent); }
.sp-color-hexbox .sp-color-dot { display: none; width: 24px; height: 24px; }
.sp-color-hash { margin-right: -4px; color: var(--sp-text-2); font: 700 14px/18px var(--sp-font-mono); }
#editor-workspace-root .sp-color-hexbox .sp-color-hex {
  box-sizing: border-box; flex: 1; min-width: 0; height: 100%; padding: 0; border: 0 !important; outline: 0 !important; box-shadow: none !important; background: transparent !important;
  color: var(--sp-text); caret-color: var(--sp-accent); font: 700 15px/20px var(--sp-font-mono); text-transform: uppercase;
}
.sp-color-recent { display: flex; align-items: center; gap: 8px; height: 32px; margin-top: 12px; color: var(--sp-text-2); font: 500 12.5px/16px var(--sp-font-ui); }
.sp-color-recent .sp-color-swatch { --dot: 28px; width: 28px; max-width: none; height: 32px; }
.sp-color-composer-name { display: none; }

/* Sliders: the NumberInput stays the owner, the range is id-less ----------------------- */
#editor-workspace-root .sp-slider-field { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; width: 100%; }
#editor-workspace-root .sp-editor-row > .sp-slider-field { max-width: none; width: auto; flex: 1 1 0; }
#editor-workspace-root .sp-editor-row:has(> .sp-slider-field) > .sp-editor-row-label { flex: 0 0 auto; min-width: 64px; }
#editor-workspace-root .sp-slider-field .mantine-NumberInput-root { flex: none; width: 66px !important; min-width: 0; }
#editor-workspace-root #editor-tools.sp-editor-sheet .sp-slider-field .mantine-NumberInput-input { text-align: center !important; font-weight: 700 !important; padding: 0 6px !important; min-width: 0 !important; }
#editor-workspace-root .sp-slider-field .sp-range {
  --fill: 0%; -webkit-appearance: none; appearance: none; flex: 1 1 auto; min-width: 0; height: 44px; margin: 0; padding: 0; background: transparent; cursor: pointer;
}
.sp-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--sp-accent) var(--fill), var(--sp-border-strong) var(--fill)); }
.sp-range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--sp-border-strong); }
.sp-range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--sp-accent); }
.sp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border: 0; border-radius: 50%; background: var(--sp-text); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.sp-range::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--sp-text); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }

/* Two-option choices in a redesigned panel: the segmented control gets the row's room. */
#editor-workspace-root .sp-editor-row > .mantine-SegmentedControl-root[data-full-width] { flex: 1 1 auto; max-width: none; }

/* ==========================================================================
   PHONE: list pickers open as bottom sheets (fixes the full-width dropdown flicker, F-01).
   Exact phone media query (tests/test_layout_mode_contract.py).
   ========================================================================== */
@media (max-width: 599px), (max-width: 767px) and (max-aspect-ratio: 10/13) {
  body:where([data-sp-has~="sheet-list-visible"]):not(.sp-s):not(.sp-s)::before { content: ''; position: fixed; inset: 0; z-index: 2090; background: rgba(0, 0, 0, .6); }
  .mantine-Select-dropdown.sp-sheet-list {
    position: fixed !important; top: auto !important; right: 0 !important; bottom: 0 !important; left: 0 !important;
    width: auto !important; min-width: 0 !important; max-width: none !important; margin: 0 !important; z-index: 2100 !important;
    box-sizing: border-box; padding: 0 8px calc(14px + env(safe-area-inset-bottom, 0px));
    background: #14161c !important; border: 0 !important; border-top: 1px solid var(--sp-border-strong) !important; border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .5) !important; color: var(--sp-text) !important; overflow: hidden;
  }
  .sp-sheet-list .mantine-Select-options { padding: 0 !important; }
  .sp-sheet-list .mantine-Select-options > div { max-height: min(62vh, 560px) !important; }
  .sp-sheet-list-head { display: block; }
  .sp-sheet-list-grip { display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: #3a3c44; }
  .sp-sheet-list-bar { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 6px 0 4px 12px; }
  .mantine-Select-dropdown.sp-sheet-list .sp-sheet-list-title { min-width: 0; font: 700 20px/24px var(--sp-font-display) !important; color: var(--sp-text) !important; }
  .sp-sheet-list-close {
    box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; margin: 0; padding: 0;
    border-radius: 12px; color: var(--sp-text-2); cursor: pointer;
  }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option {
    background: transparent !important; color: var(--sp-text) !important; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 46px; padding: 0 12px; border-radius: 12px; font: 400 18px/24px var(--sp-font-ui);
  }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option > svg { display: none; }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option.sp-rich > span:not(.sp-rich-copy, .sp-layout-thumb) { display: none; }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option[data-checked]::after {
    content: ''; order: 2; width: 20px; height: 20px; flex: none; margin-left: auto; background: var(--sp-accent);
    -webkit-mask: var(--sp-check) center / contain no-repeat; mask: var(--sp-check) center / contain no-repeat;
    --sp-check: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l4.5 4.5L19 7.5'/></svg>");
  }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option[data-checked] { background: var(--sp-chip) !important; }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option:is(:hover, :active) { background: var(--sp-surface) !important; }
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option[data-checked]:is(:hover, :active) { background: var(--sp-chip) !important; }
  /* D5Layout: thumbnail + title + one line of description */
  .mantine-Select-dropdown.sp-sheet-list .mantine-Select-option.sp-rich { height: 78px; padding: 0 12px; gap: 14px; font-size: 0 !important; justify-content: flex-start; }
  .sp-rich-copy { display: block; flex: 1 1 auto; min-width: 0; }
  .mantine-Select-dropdown.sp-sheet-list .sp-rich-title { display: block; font: 600 14.5px/18px var(--sp-font-ui) !important; color: var(--sp-text) !important; }
  .mantine-Select-dropdown.sp-sheet-list .sp-rich-desc { display: block; margin-top: 2px; font: 400 12.5px/16px var(--sp-font-ui) !important; color: var(--sp-text-2) !important; }
  .sp-layout-thumb {
    box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; gap: 5px; flex: none; width: 104px; height: 54px; padding: 0 8px;
    border: 1px solid var(--sp-border-strong); border-radius: 8px; background: var(--sp-bg);
  }
  .sp-layout-thumb i { display: flex; align-items: center; gap: 4px; height: 10px; }
  .sp-layout-thumb i:nth-child(1) { --bar: 44px; }
  .sp-layout-thumb i:nth-child(2) { --bar: 34px; }
  .sp-layout-thumb i:nth-child(3) { --bar: 24px; }
  .sp-layout-thumb[data-layout="logo_bar"] i:nth-child(1), .sp-layout-thumb[data-layout="bar_tip_image"] i:nth-child(1) { --bar: 54px; }
  .sp-layout-thumb[data-layout="logo_bar"] i:nth-child(2), .sp-layout-thumb[data-layout="bar_tip_image"] i:nth-child(2) { --bar: 42px; }
  .sp-layout-thumb[data-layout="logo_bar"] i:nth-child(3), .sp-layout-thumb[data-layout="bar_tip_image"] i:nth-child(3) { --bar: 30px; }
  .sp-layout-thumb b { display: block; flex: none; }
  .sp-layout-thumb .l { order: 1; width: 20px; height: 5px; border-radius: 3px; background: #8a867e; }
  .sp-layout-thumb .r { order: 2; width: var(--bar); height: 9px; border-radius: 2px; background: var(--sp-accent); }
  .sp-layout-thumb .d { order: 3; width: 10px; height: 10px; border-radius: 50%; background: #38bdf8; }
  .sp-layout-thumb[data-layout="label_logo_bar"] .d { order: 2; }
  .sp-layout-thumb[data-layout="label_logo_bar"] .r { order: 3; }
  .sp-layout-thumb[data-layout="logo_label_bar"] .d { order: 0; }
  .sp-layout-thumb[data-layout="logo_bar"] .d { order: 0; }
  .sp-layout-thumb[data-layout="logo_bar"] .l { display: none; }
  .sp-layout-thumb[data-layout="bar_tip_image"] .d { width: 11px; height: 11px; margin: -1px 0 -1px -7px; }

  /* Keyboard composer: the colour sheet shows only its hex field under a 40 px name row (D4Hex);
     102 px = 1 border + 40 name + 6 gap + 44 field + 11 padding, like every other composer. */
  #editor-workspace-root[data-keyboard="true"] .sp-color-sheet { margin-top: 0; }
  #editor-workspace-root[data-keyboard="true"] .sp-color-sheet > :not(.sp-color-composer-name):not(.sp-color-view[data-view="custom"]) { display: none; }
  #editor-workspace-root[data-keyboard="true"] .sp-color-view[data-view="custom"] { margin: 0; }
  #editor-workspace-root[data-keyboard="true"] .sp-color-view[data-view="custom"] > :not(.sp-color-hexrow) { display: none; }
  #editor-workspace-root[data-keyboard="true"] .sp-color-hexrow { margin-top: 6px; }
  #editor-workspace-root[data-keyboard="true"] .sp-color-composer-name { order: -1; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px; }
  .sp-color-composer-name small { font: 700 10.5px/14px var(--sp-font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--sp-text-2); }
  .sp-color-composer-name i { width: 3px; height: 3px; border-radius: 50%; background: var(--sp-text-3); }
  .sp-color-composer-name b { font: 600 14px/20px var(--sp-font-ui); color: var(--sp-text); }
  #editor-workspace-root[data-keyboard="true"] .sp-color-hexrow .sp-color-preview { display: none; }
  #editor-workspace-root[data-keyboard="true"] .sp-color-hexbox { border: 1.5px solid var(--sp-accent); }
  #editor-workspace-root[data-keyboard="true"] .sp-color-hexbox .sp-color-dot { display: inline-block; }
  /* Sliders: the keyboard field is the value box alone (the row's label and range hide). */
  #editor-workspace-root[data-keyboard="true"] .sp-slider-field .sp-range { display: none; }
  #editor-workspace-root[data-keyboard="true"] .sp-slider-field .mantine-NumberInput-root { width: 100% !important; }
}
