/* Poster & Sticker Editor. Loaded only on /editor/. */

.ed-intro { padding: .4rem 0 1.4rem; }
.ed-intro h1 { font-size: clamp(1.9rem, 1rem + 3vw, 3.2rem); margin-bottom: .6rem; }
.ed-intro p { max-width: 62ch; margin: 0; font-size: 1.1rem; }
.ed-shell { width: min(100% - 16px, 1560px); margin-inline: auto; }
.ed-loading { background: var(--paper); border: var(--line) solid var(--ink); padding: 1.4rem; font-weight: 700; }
.ed-loading.is-error { background: #ffd6e6; }

.ed { display: flex; flex-direction: column; background: var(--paper); border: var(--line) solid var(--ink); box-shadow: 8px 8px 0 var(--ink); }

/* compact controls inside the editor */
.ed input[type="text"], .ed input[type="number"], .ed select, .ed textarea { padding: .4rem .55rem; border-width: 2px; box-shadow: none; font-size: .92rem; line-height: 1.3; min-height: 2.3rem; }
.ed textarea { min-height: 5rem; }
.ed input[type="range"] { width: 100%; accent-color: var(--cobalt); margin: 0; min-height: 1.6rem; }
.ed input[type="color"] { width: 3rem; height: 2.1rem; padding: 0; border: 2px solid var(--ink); background: #fff; cursor: pointer; }
.ed input[type="checkbox"], .ed input[type="radio"] { width: 1.15rem; height: 1.15rem; accent-color: var(--cobalt); margin: 0; flex: none; }
.ed label { font-weight: 650; font-size: .88rem; }

.ed-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: 700 .88rem/1.1 var(--text); padding: .55rem .75rem; min-height: 2.4rem; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); cursor: pointer; text-decoration: none; }
.ed-btn:hover { background: var(--yellow); }
.ed-btn:active { box-shadow: 0 0 0 var(--ink); }
.ed-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; background: var(--paper); }
.ed-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.ed-btn-primary { background: var(--pink); }
.ed-btn-danger { background: #ffd6e6; }
.ed-btn-icon { min-width: 2.4rem; font-size: 1.15rem; padding-inline: .5rem; }
.ed-btn-wide { width: 100%; }
.ed-file { cursor: pointer; }

.ed-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1.1rem; padding: .75rem .9rem; background: var(--yellow); border-bottom: var(--line) solid var(--ink); }
.ed-name { flex: 1 1 200px; max-width: 320px; }
.ed-name label { display: block; margin-bottom: .2rem; }
.ed-group { display: flex; flex-wrap: wrap; gap: .4rem; }
.ed-group-end { margin-left: auto; }

.ed-body { display: grid; grid-template-columns: minmax(0, 1fr) 430px; height: clamp(600px, 84vh, 920px); min-height: 0; }
.ed-col { overflow-y: auto; padding: 1rem; background: var(--paper); min-height: 0; }
.ed-col-left { border-right: var(--line) solid var(--ink); }
.ed-col-right { border-left: var(--line) solid var(--ink); }
.ed-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #b7b2c6; }

.ed-panel + .ed-panel { margin-top: 1.3rem; padding-top: 1.2rem; border-top: var(--line) solid var(--ink); }
.ed-h { font-family: var(--display); font-weight: 400; font-size: 1.05rem; margin: 0 0 .8rem; letter-spacing: 0; }
.ed-col { overflow-x: hidden; }
.ed-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; }
.ed-row { display: flex; gap: .45rem; min-width: 0; }
.ed-row > .ed-btn { flex: 1 1 0; min-width: 0; padding-inline: .35rem; }
.ed-row-wrap { flex-wrap: wrap; }
.ed-row-wrap > .ed-btn { flex: 1 1 auto; min-width: 0; padding-inline: .6rem; }
.ed-note { font-size: .84rem; line-height: 1.5; margin: .6rem 0 0; }
.ed-field { margin-bottom: .8rem; }
.ed-field > label { display: block; margin-bottom: .25rem; }
.ed-field-inline { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.ed-field-inline > label { margin: 0; }
.ed-pair { display: grid; grid-template-columns: minmax(0, 1fr) 5.2rem; gap: .6rem; align-items: center; }
.ed-check { display: flex; align-items: center; gap: .55rem; margin: 0 0 .7rem; }
.ed-radio { display: flex; align-items: center; gap: .55rem; margin: .3rem 0; font-size: .95rem; }
.ed-fieldset { border: 2px solid var(--ink); margin: 0 0 .9rem; padding: .5rem .8rem .8rem; min-width: 0; }
.ed-fieldset legend { font-weight: 800; padding: 0 .4rem; font-size: .9rem; }

.ed-box { border: 2px solid var(--ink); margin: 0 0 .9rem; background: #fff; }
.ed-box > summary { cursor: pointer; padding: .6rem .75rem; font-weight: 800; background: var(--yellow); font-size: .95rem; list-style-position: inside; }
.ed-box[open] > summary { border-bottom: 2px solid var(--ink); }
.ed-box-inner { padding: .8rem .8rem .3rem; }
.ed-fx { border: 2px solid var(--ink); margin: .2rem 0 .7rem; padding: .2rem .7rem .55rem; min-width: 0; }
.ed-fx legend { display: flex; align-items: center; gap: .5rem; padding: 0 .35rem; }
.ed-fx legend label { font-weight: 750; }
.ed-fx-inner { padding-top: .5rem; }

.ed-layers { list-style: none; margin: 0 0 .8rem; padding: 0; border: 2px solid var(--ink); background: #fff; max-height: 15rem; overflow-y: auto; }
.ed-layer { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-bottom: 2px solid rgba(20, 18, 58, .18); cursor: pointer; font-size: .92rem; line-height: 1.3; }
.ed-layer:last-child { border-bottom: 0; }
.ed-layer:hover { background: #f4f1e6; }
.ed-layer.is-selected { background: var(--cobalt); color: var(--paper); }
.ed-layer.is-hidden .ed-layer-name { opacity: .6; font-style: italic; }
.ed-layer-kind { flex: none; font-size: .72rem; font-weight: 800; padding: .1rem .4rem; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); }
.ed-layer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-layer-empty { padding: .8rem; font-size: .9rem; cursor: default; }
.ed-layers:focus-visible { outline-offset: 2px; }

/* stage */
.ed-stage { position: relative; flex: 1; min-height: 0; overflow: auto; display: flex; padding: 22px; }
.ed-stage.is-drop { outline: 4px dashed var(--cobalt); outline-offset: -10px; }
.ed-canvas-wrap { position: relative; margin: auto; flex: none; line-height: 0; box-shadow: 8px 8px 0 var(--ink); border: 2px solid var(--ink); background-color: #fff; background-image: conic-gradient(#dcd8e6 25%, transparent 0 50%, #dcd8e6 0 75%, transparent 0); background-size: 24px 24px; }
#ed-canvas { display: block; touch-action: none; cursor: default; }
#ed-canvas:focus-visible { outline: 4px solid var(--cobalt); outline-offset: 4px; }
#ed-overlay { position: absolute; inset: 0; pointer-events: none; }
.ed-stage[data-tool="hand"] #ed-canvas { cursor: grab; }
.ed-stage[data-tool="color"] #ed-canvas { cursor: crosshair; }
.ed-stage[data-tool="eraser"] #ed-canvas { cursor: none; }
.ed-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; pointer-events: none; }
.ed-empty-card { pointer-events: auto; background: var(--paper); border: var(--line) solid var(--ink); box-shadow: var(--shadow); padding: 1.3rem 1.5rem; max-width: 30rem; }
.ed-empty-card h2 { font-size: 1.7rem; margin-bottom: .6rem; }
.ed-empty-card p { margin-bottom: .8rem; font-size: 1rem; line-height: 1.55; }
.ed-empty-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 0 !important; }

.ed-statusbar { background: var(--paper); border-top: var(--line) solid var(--ink); padding: .5rem .9rem; min-height: 2.9rem; }
.ed-status, .ed-alert { margin: 0; font-size: .92rem; line-height: 1.4; }
.ed-status { font-weight: 650; }
.ed-alert { font-weight: 800; color: #a3003c; }
.ed-alert:empty, .ed-status:empty { display: none; }

.ed-tabs { display: none; }

/* dialogs */
.dlg { border: var(--line) solid var(--ink); padding: 1.3rem 1.5rem 1.5rem; background: var(--paper); color: var(--ink); width: min(94vw, 780px); max-height: 90vh; overflow-y: auto; box-shadow: 10px 10px 0 var(--ink); }
.dlg-small { width: min(94vw, 520px); }
.dlg::backdrop { background: rgba(20, 18, 58, .62); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.dlg-head h2 { font-size: 1.6rem; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0 .5rem; }
.dlg-msg { min-height: 1.4rem; font-weight: 650; font-size: .92rem; margin: .4rem 0 .8rem; }
.dlg .notice { font-size: .92rem; padding: .7rem .9rem; box-shadow: none; margin-bottom: 1rem; }
.dlg .table-wrap { margin-top: 0; }
.project-list { list-style: none; margin: 0; padding: 0; }
.project-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: .5rem .9rem; align-items: center; padding: .7rem; border: 2px solid var(--ink); margin-bottom: .7rem; background: #fff; }
.project-item.is-current { background: #fff6c8; }
.project-thumb { width: 64px; height: 64px; object-fit: contain; background: #e9e6ee; border: 2px solid var(--ink); }
.project-thumb-empty { display: block; }
.project-info { display: grid; gap: .15rem; min-width: 0; }
.project-name { overflow-wrap: anywhere; }
.project-meta { font-size: .85rem; }
.project-open-now { font-size: .8rem; font-weight: 800; }
.project-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.project-actions input[type="text"] { flex: 1 1 12rem; width: auto; }
.project-confirm { font-weight: 700; font-size: .9rem; }
.project-empty { padding: 1rem; border: 2px dashed var(--ink); background: #fff; }

/* narrow screens: stage first, panels below one at a time */
@media (max-width: 1060px) {
  .ed-body { display: flex; flex-direction: column; height: auto; }
  .ed-center { order: -1; }
  .ed-stage { height: min(62vh, 560px); flex: none; }
  .ed-col { overflow: visible; border: 0; padding: .9rem; }
  .ed-col-left, .ed-col-right { border: 0; }
  .ed-tabs { display: flex; position: sticky; bottom: 0; z-index: 5; background: var(--ink); border-top: var(--line) solid var(--ink); }
  .ed-tabs button { flex: 1; font: 700 .95rem/1 var(--text); padding: .95rem .4rem; background: var(--paper); color: var(--ink); border: 0; border-right: 2px solid var(--ink); cursor: pointer; min-height: 3rem; }
  .ed-tabs button:last-child { border-right: 0; }
  .ed-tabs button[aria-pressed="true"] { background: var(--cobalt); color: var(--paper); }
  .ed-tabs button:focus-visible { outline-offset: -5px; outline-color: var(--yellow); }
  .ed[data-tab="photo"] [data-panel]:not([data-panel="photo"]),
  .ed[data-tab="look"] [data-panel]:not([data-panel="look"]),
  .ed[data-tab="output"] [data-panel]:not([data-panel="output"]),
  .ed[data-tab="title"] [data-panel]:not([data-panel="title"]) { display: none; }
  .ed-col > .ed-h { display: none; }
  .ed-panel + .ed-panel { margin-top: 0; padding-top: 0; border-top: 0; }
  .ed-group-end { margin-left: 0; }
  .ed-name { max-width: none; flex-basis: 100%; }
}
@media (max-width: 560px) {
  .ed-stage { padding: 12px; height: min(58vh, 480px); }
  .ed-btn { font-size: .84rem; padding: .5rem .6rem; }
}

/* printing: only the exported picture */
.print-only { display: none; }
@media print {
  body.page-editor * { visibility: hidden !important; }
  body.page-editor { background: #fff !important; }
  body.page-editor dialog { display: none !important; }
  body.page-editor #print-root, body.page-editor #print-root * { visibility: visible !important; }
  body.page-editor #print-root { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  body.page-editor #print-root img { display: block; width: 100%; height: auto; max-height: 100vh; object-fit: contain; }
}

/* =====================================================================
   Polish layer: static details only.
   ===================================================================== */
.ed { overflow: visible; }

/* dark top bar with a printer's colour bar under it */
.ed-top { position: relative; margin-bottom: 14px; background: var(--ink); color: var(--paper); border-bottom: 4px solid var(--ink); gap: .7rem 1.2rem; }
.ed-top::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; background: var(--strip); border-bottom: 3px solid var(--ink); }
.ed-top label { color: var(--paper); }
.ed-top input[type="text"] { border-color: var(--paper); }
.ed-top .ed-btn { box-shadow: none; border-color: var(--paper); }
.ed-top .ed-btn:hover { background: var(--yellow); }
.ed-top .ed-btn[aria-pressed="true"] { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.ed-top .ed-btn:disabled { opacity: .38; background: var(--paper); }
.ed-top .ed-btn-primary { background: var(--pink); }
.ed-top :focus-visible { outline-color: var(--yellow); }
.ed-btn svg { width: 1.1rem; height: 1.1rem; flex: none; }
.ed-btn-icon svg { width: 1.2rem; height: 1.2rem; }

/* tool tiles */
.ed-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.ed-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ed-tile { flex-direction: column; gap: .3rem; padding: .75rem .25rem .6rem; font-size: .8rem; box-shadow: 3px 3px 0 var(--ink); }
.ed-tile svg { width: 1.7rem; height: 1.7rem; }
.ed-tile-photo { background: var(--yellow); }
.ed-tile-text { background: var(--pink); }
.ed-tile:hover { background: var(--cobalt); color: var(--paper); }

/* panel headings as pasted labels */
.ed-h { display: inline-block; padding: .3rem .8rem; margin: 0 0 1rem; background: var(--yellow); color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); font-size: .95rem; letter-spacing: 0; }
[data-panel="add"] .ed-h { background: var(--pink); }
[data-panel="canvas"] .ed-h { background: var(--cobalt); color: var(--paper); }
[data-panel="adjust"] .ed-h { background: var(--paper); }
.ed-panel + .ed-panel { border-top: 0; padding-top: 0; margin-top: 1.6rem; }

/* layer list and actions */
.ed-layers { box-shadow: 3px 3px 0 var(--ink); }
.ed-layer[data-kind="text"] .ed-layer-kind { background: var(--pink); }
.ed-layer[data-kind="shape"] .ed-layer-kind { background: var(--paper); }
.ed-layer-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
.ed-layer-actions .ed-btn { flex-direction: column; gap: .15rem; padding: .45rem .1rem .4rem; font-size: .7rem; min-height: 3.2rem; box-shadow: 2px 2px 0 var(--ink); }
.ed-layer-actions .ed-btn svg { width: 1.15rem; height: 1.15rem; }

/* stage: dotted work table */
.ed-center { background-color: #b7b2c6; background-image: radial-gradient(rgba(20, 18, 58, .22) 1.7px, transparent 1.9px); background-size: 24px 24px; }
.ed-canvas-wrap { box-shadow: 10px 10px 0 var(--ink); }
.ed-statusbar { border-top-width: 4px; }

/* sliders in the house style */
.ed input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; height: 1.7rem; cursor: pointer; }
.ed input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: var(--ink); border-radius: 0; }
.ed input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 22px; margin-top: -8px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 0; box-shadow: 2px 2px 0 var(--ink); }
.ed input[type="range"]::-moz-range-track { height: 6px; background: var(--ink); border-radius: 0; }
.ed input[type="range"]::-moz-range-thumb { width: 12px; height: 18px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 0; box-shadow: 2px 2px 0 var(--ink); }
.ed input[type="range"]:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 4px; }
.ed-box { box-shadow: 3px 3px 0 var(--ink); }
.ed-box > summary { background: var(--paper); border-bottom: 0; }
.ed-box[open] > summary { background: var(--yellow); }
.ed-fx > legend label { font-size: .9rem; }
.ed-empty-card { box-shadow: 8px 8px 0 var(--ink); border-width: 4px; }

@media (max-width: 1060px) {
  .ed-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ed-tile { flex-direction: row; justify-content: flex-start; gap: .6rem; padding: .7rem .8rem; font-size: .9rem; }
  .ed-tile svg { width: 1.3rem; height: 1.3rem; }
}

/* =====================================================================
   Touch targets: at least 44 px on small screens and on any touch screen.
   ===================================================================== */
@media (max-width: 1060px), (pointer: coarse) {
  .ed-btn { min-height: 2.75rem; }
  .ed-btn-icon { min-width: 2.75rem; }
  .ed .ed-btn, .ed-layer-actions .ed-btn { min-height: 2.75rem; }
  .ed-layer-actions .ed-btn { min-height: 3.4rem; }
  .ed input[type="text"], .ed input[type="number"], .ed select { min-height: 2.75rem; }
  .ed textarea { min-height: 6rem; }
  .ed input[type="range"] { min-height: 2.75rem; }
  .ed input[type="range"]::-webkit-slider-thumb { width: 24px; height: 32px; margin-top: -13px; }
  .ed input[type="range"]::-moz-range-thumb { width: 18px; height: 26px; }
  .ed input[type="checkbox"], .ed input[type="radio"] { width: 1.6rem; height: 1.6rem; }
  .ed-check, .ed-radio { min-height: 2.75rem; }
  .ed-layer { min-height: 2.75rem; }
  .ed input[type="color"] { width: 3.6rem; height: 2.75rem; }
  .ed-box > summary { min-height: 2.75rem; padding-block: .75rem; }
  .ed-fx legend { min-height: 2.75rem; }
  .ed-tabs button { min-height: 3.25rem; }
  .ed-tile { min-height: 3.5rem; }
}

/* the three shape buttons stay on one row on narrow screens */
@media (max-width: 1060px) {
  .ed-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ed-tiles-3 .ed-tile { flex-direction: column; justify-content: center; gap: .25rem; padding: .6rem .2rem; font-size: .8rem; }
}


/* =====================================================================
   Photo Print Studio: the six steps.
   ===================================================================== */
.ed-steps { display: grid; gap: 0; }
.ed-step > summary { display: flex; align-items: center; gap: .7rem; list-style: none; }
.ed-step > summary::-webkit-details-marker { display: none; }
.ed-step > summary::after { content: ""; margin-left: auto; flex: none; width: .55rem; height: .55rem; border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: rotate(45deg); margin-top: -.2rem; }
.ed-step[open] > summary::after { transform: rotate(-135deg); margin-top: .2rem; }
.ed-step-n { flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; background: var(--pink); color: var(--ink); border: 2px solid var(--ink); font-family: var(--display); font-size: .95rem; line-height: 1; }
.ed-step[open] > summary .ed-step-n { background: var(--paper); }
.ed-subbox { margin: .3rem 0 .6rem; }
.is-off { opacity: .45; }
.ed-pair-single { grid-template-columns: minmax(0, 1fr); }
.ed-check-main { margin-bottom: .9rem; font-weight: 700; }
.ed-check-main label { font-size: 1rem; }
.ed-note-first { margin-top: 0; }
.ed-col-right { padding-top: 1.1rem; }
.ed-col-right > .ed-h { margin-bottom: 1rem; }
.ed-fieldset { background: #fff; }

/* =====================================================================
   Screenprint inks (step 3) and the ink sheets in the export dialog.
   --swatch is set from script to the color of each ink.
   ===================================================================== */
.ed-fx-screen { border-width: 3px; background: #fff; }
.ed-ink { border-left: .6rem solid var(--swatch, var(--ink)); padding-left: .7rem; margin: 0 0 .7rem; }
.ed-subhead { font-weight: 800; margin-top: 1.1rem; }
.ed-fx.is-paused legend { opacity: .6; }
.ed-pause-note { margin: .3rem 0 .2rem; }
.ed-ink-export { border-top: 2px solid var(--ink); margin-top: .8rem; padding-top: .2rem; }
.ed-ink-export .ed-btn { margin-top: .6rem; }
.ed-note + .ed-check { margin-top: .8rem; }
.ed-note + .ed-field { margin-top: .8rem; }
