/* Stampa online – the photo editor (assets/js/ui/photo-editor.js): the photo large on its print, on a soft table,
   with the controls beside it on large screens and under it on phones; and the decoration tools. */
.stampa-online-editor { width: min(1120px, calc(100vw - 48px)); height: min(760px, calc(100dvh - 48px)); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 0; border-radius: 18px; background: var(--stampa-online-paper); box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .55); }
.stampa-online-editor[open] { animation: stampa-online-editor-in .2s ease-out; }
.stampa-online-editor:focus { outline: none; }
.stampa-online-editor::backdrop { background: rgba(18, 18, 18, .62); backdrop-filter: blur(3px); }
@keyframes stampa-online-editor-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
html.stampa-online-editor-open { overflow: hidden; }
.stampa-online-editor-in { display: grid; height: 100%; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "stage head" "stage controls" "stage foot"; }

.stampa-online-editor-head { grid-area: head; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 18px 14px 6px 24px; }
.stampa-online-editor-heading { min-width: 0; }
.stampa-online-editor .stampa-online-editor-title { margin: 0; font-family: var(--stampa-online-font-display); font-size: 1.4rem; line-height: 1.15; }
.stampa-online-editor-sub { margin: 4px 0 0; color: var(--stampa-online-muted); font-size: .9rem; }
.stampa-online-editor-head-actions { display: flex; gap: 2px; margin-top: -4px; }

/* The table: the print in the middle as large as it fits; while framing, the rest of the photo shows faintly around it. */
.stampa-online-editor-stage { grid-area: stage; position: relative; overflow: hidden; background: radial-gradient(120% 90% at 50% 40%, #f8f7f4 0%, #e7e5df 100%); outline: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.stampa-online-editor-stage:focus-visible { box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .22); }
.stampa-online-editor-table { position: absolute; inset: 40px 76px 64px; display: grid; place-items: center; container-type: size; pointer-events: none; }
.stampa-online-editor .stampa-online-paper { position: relative; z-index: 1; width: min(100cqw, calc(100cqh * var(--paper, var(--r, 1)))); height: auto; aspect-ratio: var(--paper, var(--r, 1)); background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .16), 0 24px 48px -20px rgba(0, 0, 0, .55); }
.stampa-online-editor .stampa-online-photo.is-loading .stampa-online-photo-img { opacity: 0; }
.stampa-online-editor-ghost { position: absolute; z-index: 0; opacity: 0; pointer-events: none; transition: opacity .2s; }
.stampa-online-editor-ghost .stampa-online-photo-img { position: absolute; max-width: none; }
.stampa-online-editor-ghost .stampa-online-vignette { display: none; }
.stampa-online-editor-stage.is-adjusting .stampa-online-editor-ghost { opacity: .3; }
.stampa-online-editor.is-fit .stampa-online-editor-ghost, .stampa-online-editor.is-unknown .stampa-online-editor-ghost { display: none; }
.stampa-online-editor.can-move .stampa-online-editor-stage { cursor: grab; }
.stampa-online-editor.can-move .stampa-online-editor-stage.is-adjusting { cursor: grabbing; }
.stampa-online-editor-decor { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.stampa-online-editor.is-decorating .stampa-online-editor-decor, .stampa-online-editor.is-decorating .stampa-online-tf { pointer-events: auto; }
.stampa-online-editor-grid { position: absolute; inset: 0; z-index: 3; pointer-events: none; background-image: linear-gradient(rgba(255, 255, 255, .55) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .55) 1px, transparent 1px); background-size: calc(100% / 6) calc(100% / 6); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); }
.stampa-online-editor-nav { position: absolute; top: 50%; z-index: 4; display: grid; place-items: center; width: 44px; height: 44px; margin-top: -22px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .94); color: var(--stampa-online-ink); box-shadow: 0 2px 10px rgba(0, 0, 0, .18); cursor: pointer; transition: opacity .15s; }
.stampa-online-editor-nav:disabled { opacity: 0; pointer-events: none; }
.stampa-online-editor-nav.is-prev { left: 16px; }
.stampa-online-editor-nav.is-next { right: 16px; }
.stampa-online-editor-hint { position: absolute; left: 50%; bottom: 18px; z-index: 4; margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .9); color: var(--stampa-online-muted); font-size: .82rem; white-space: nowrap; transform: translateX(-50%); pointer-events: none; }
.stampa-online-editor-hint:empty { display: none; }

/* Controls */
.stampa-online-editor-controls { grid-area: controls; display: flex; flex-direction: column; gap: 16px; min-height: 0; padding: 12px 24px 16px; overflow: auto; }
.stampa-online-tabs { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; padding: 3px; border-radius: 12px; background: var(--stampa-online-soft); }
.stampa-online-tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; padding: 4px 2px; border: 0; border-radius: 9px; background: transparent; color: var(--stampa-online-muted); font: 600 .74rem var(--stampa-online-font); cursor: pointer; }
.stampa-online-tabs button[aria-selected="true"] { background: var(--stampa-online-paper); color: var(--stampa-online-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.stampa-online-editor.no-edit .stampa-online-tabs, .stampa-online-editor.no-edit [data-edit-only] { display: none; }
.stampa-online-editor.no-copies [data-copies-row] { display: none; }
.stampa-online-panel { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 14px; }

/* Filters: the photo itself in each look */
.stampa-online-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; }
.stampa-online-filter { display: grid; justify-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--stampa-online-muted); font: 600 .74rem var(--stampa-online-font); cursor: pointer; }
.stampa-online-filter-swatch { display: block; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--stampa-online-soft); box-shadow: 0 0 0 1px var(--stampa-online-line); transition: box-shadow .15s; }
.stampa-online-filter-swatch img { display: block; width: 100%; height: 100%; object-fit: cover; }
.stampa-online-filter:hover .stampa-online-filter-swatch { box-shadow: 0 0 0 2px var(--stampa-online-line-strong); }
.stampa-online-filter[aria-checked="true"] { color: var(--stampa-online-ink); }
.stampa-online-filter[aria-checked="true"] .stampa-online-filter-swatch { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--stampa-online-accent); }

/* Adjustments: sliders starting from the middle */
.stampa-online-adjust { display: grid; gap: 2px 16px; }
.stampa-online-adj { display: grid; gap: 0; margin: 0; color: var(--stampa-online-muted); font-size: .82rem; font-weight: 600; }
.stampa-online-adj output { color: var(--stampa-online-ink); }
.stampa-online-panel > .stampa-online-pill { justify-self: start; }

.stampa-online-quality { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--stampa-online-muted); font-size: .88rem; }
.stampa-online-quality i { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--stampa-online-good); }
.stampa-online-quality.is-low { color: var(--stampa-online-warn-ink); }
.stampa-online-quality.is-low i { background: #f2b600; }
.stampa-online-quality:not(.is-great):not(.is-good):not(.is-low) { visibility: hidden; }

.stampa-online-editor-foot { grid-area: foot; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px 20px; border-top: 1px solid var(--stampa-online-line); }
.stampa-online-editor-actions { display: flex; gap: 4px; min-width: 0; }
.stampa-online-action { color: var(--stampa-online-muted); }
.stampa-online-action:hover:not(:disabled) { color: var(--stampa-online-ink); }
.stampa-online-editor-done { flex: none; min-width: 120px; }

/* Texts, clipart, frames */
.stampa-online-text-input { width: 100%; min-height: 64px; padding: 10px 12px; border: 1.5px solid var(--stampa-online-line-strong); border-radius: var(--stampa-online-radius-sm); background: #fff; color: var(--stampa-online-ink); font: 400 16px/1.35 var(--stampa-online-font); resize: vertical; }
.stampa-online-text-input:focus { border-color: var(--stampa-online-dark); outline: none; }
.stampa-online-fonts { display: flex; gap: 6px; min-width: 0; overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: none; }
.stampa-online-row-controls > .stampa-online-fonts { flex: 1 1 0; }
.stampa-online-font { flex: none; display: grid; justify-items: center; gap: 2px; min-width: 64px; padding: 6px 8px; border: 1.5px solid var(--stampa-online-line); border-radius: var(--stampa-online-radius-sm); background: #fff; color: var(--stampa-online-muted); font: 600 .7rem var(--stampa-online-font); cursor: pointer; }
.stampa-online-font[aria-checked="true"] { border-color: var(--stampa-online-dark); color: var(--stampa-online-ink); }
.stampa-online-font-sample { color: var(--stampa-online-ink); font-size: 1.25rem; line-height: 1.2; }
.stampa-online-panel .stampa-online-row { flex-wrap: wrap; }
.stampa-online-panel .stampa-online-row > .stampa-online-row-controls { flex: 1; justify-content: flex-end; }
.stampa-online-panel .stampa-online-row input[type="range"] { max-width: 220px; }
.stampa-online-panel-actions { display: flex; justify-content: space-between; gap: 4px; padding-top: 6px; border-top: 1px solid var(--stampa-online-line); }
.stampa-online-clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; max-height: 220px; overflow: auto; padding: 2px; }
.stampa-online-clip { display: grid; place-items: center; aspect-ratio: 1; padding: 8px; border: 1.5px solid var(--stampa-online-line); border-radius: var(--stampa-online-radius-sm); background: #fff; cursor: pointer; }
.stampa-online-clip:hover { border-color: var(--stampa-online-dark); }
.stampa-online-clip img { display: block; width: 100%; height: 100%; object-fit: contain; }
.stampa-online-frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px 8px; }
.stampa-online-frame { display: grid; gap: 4px; justify-items: center; padding: 0; border: 0; background: none; color: var(--stampa-online-muted); font: 600 .74rem var(--stampa-online-font); cursor: pointer; }
.stampa-online-frame canvas { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 0 0 1px var(--stampa-online-line); }
.stampa-online-frame[aria-checked="true"] { color: var(--stampa-online-ink); }
.stampa-online-frame[aria-checked="true"] canvas { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--stampa-online-accent); }

/* Selection handles over a surface (assets/js/ui/transform.js) */
.stampa-online-tf { position: absolute; inset: 0; z-index: 5; outline: 0; touch-action: none; pointer-events: none; }
.stampa-online-tf-box { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .25); pointer-events: none; }
.stampa-online-tf-box::after { content: ''; position: absolute; left: 50%; top: -22px; width: 1.5px; height: 22px; background: #fff; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .5); }
.stampa-online-tf-handle, .stampa-online-tf-turn { position: absolute; width: 14px; height: 14px; border: 1.5px solid var(--stampa-online-dark); border-radius: 3px; background: #fff; pointer-events: auto; touch-action: none; }
.stampa-online-tf-handle.is-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.stampa-online-tf-handle.is-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.stampa-online-tf-handle.is-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.stampa-online-tf-handle.is-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.stampa-online-tf-turn { left: 50%; top: -30px; margin-left: -8px; width: 16px; height: 16px; border-radius: 50%; cursor: grab; }
.stampa-online-tf-box.is-locked .stampa-online-tf-handle, .stampa-online-tf-box.is-locked .stampa-online-tf-turn, .stampa-online-tf-box.is-locked::after { display: none; }
@media (pointer: coarse) {
	.stampa-online-tf-handle { width: 20px; height: 20px; }
	.stampa-online-tf-handle.is-nw, .stampa-online-tf-handle.is-sw { left: -11px; }
	.stampa-online-tf-handle.is-ne, .stampa-online-tf-handle.is-se { right: -11px; }
	.stampa-online-tf-handle.is-nw, .stampa-online-tf-handle.is-ne { top: -11px; }
	.stampa-online-tf-handle.is-sw, .stampa-online-tf-handle.is-se { bottom: -11px; }
	.stampa-online-tf-turn { width: 22px; height: 22px; margin-left: -11px; top: -36px; }
}
.stampa-online-tf-guide { position: absolute; background: #ff3d7f; pointer-events: none; }
.stampa-online-tf-guide.is-v { left: 50%; top: 0; bottom: 0; width: 1px; }
.stampa-online-tf-guide.is-h { top: 50%; left: 0; right: 0; height: 1px; }

/* Phones: full screen, the print on top, the controls under it in a steady height. */
@media (max-width: 760px) {
	.stampa-online-editor { width: 100vw; height: 100dvh; border-radius: 0; }
	.stampa-online-editor-in { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: "head" "stage" "controls" "foot"; }
	.stampa-online-editor-head { align-items: center; padding: 8px 6px 8px 16px; }
	.stampa-online-editor .stampa-online-editor-title { font-size: 1.15rem; }
	.stampa-online-editor-sub { margin-top: 1px; font-size: .82rem; }
	.stampa-online-editor-head-actions { margin: 0; }
	.stampa-online-editor-table { inset: 18px 48px 42px; }
	.stampa-online-editor-nav { width: 34px; height: 34px; margin-top: -17px; }
	.stampa-online-editor-nav.is-prev { left: 7px; }
	.stampa-online-editor-nav.is-next { right: 7px; }
	.stampa-online-editor-hint { bottom: 9px; font-size: .76rem; }
	.stampa-online-editor-controls { gap: 12px; max-height: 46dvh; padding: 10px 14px 4px; }
	.stampa-online-tabs button { min-height: 44px; font-size: .7rem; }
	.stampa-online-panel { min-height: 132px; }
	.stampa-online-filters { display: flex; gap: 10px; overflow-x: auto; margin: -4px -14px 0; padding: 4px 14px 2px; scrollbar-width: none; }
	.stampa-online-filter { flex: 0 0 66px; }
	.stampa-online-adjust { grid-template-columns: 1fr 1fr; }
	.stampa-online-editor-foot { padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 0; }
}
