/* ============================================================
   Cutout — what this tool adds to the shell.
   ============================================================ */

/* Two columns. There is one picture and nothing to list, and a list panel
   holding one row would be padding. */
.workspace { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1180px) { .workspace { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 960px) { .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: max(320px, 55dvh) auto; } }

.viewport canvas { position: absolute; inset: 0; }
/* The shell gives the dock display:flex, which outranks the hidden attribute. */
.viewport-dock[hidden] { display: none; }
.viewport canvas[data-cursor="grab"] { cursor: grab; }
.viewport canvas[data-cursor="grabbing"] { cursor: grabbing; }
.viewport canvas[data-cursor="none"] { cursor: none; }
.viewport canvas[data-cursor="split"] { cursor: ew-resize; }

/* Eight controls and a title do not fit across a phone, and a bar that
   overflows widens the page under it. Buttons with a word lose the word, and
   the shortcuts list goes, since this is the width without a keyboard. */
@media (max-width: 620px) {
  .md-top-app-bar { gap: 2px; padding: 0 6px 0 10px; }
  .md-top-app-bar #btn-shortcuts { display: none; }
  .md-top-app-bar .md-button.has-icon { width: 40px; padding: 0; gap: 0; font-size: 0; }
  .md-top-app-bar .md-button.has-icon svg { width: 20px; height: 20px; }
}

/* ---------- Before a picture ---------- */
.empty {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center;
  color: var(--md-sys-color-on-surface-variant);
}
.empty[hidden] { display: none; }
.empty .empty-icon svg { width: 48px; height: 48px; fill: currentColor; opacity: 0.55; }
.empty h2 {
  margin: 8px 0 0; max-width: 32ch; text-wrap: balance;
  font: 400 24px/32px var(--md-sys-typescale-plain-font);
  color: var(--md-sys-color-on-surface);
}
.empty p { margin: 0; font: 400 14px/20px var(--md-sys-typescale-plain-font); }
.empty .md-button { margin-top: 12px; }

/* ---------- Progress ---------- */
.progress {
  position: absolute; left: 50%; top: 50%; z-index: 6;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100% - 32px));
  padding: 16px 20px 14px;
  border-radius: var(--md-sys-shape-corner-l);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 90%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: var(--app-hairline);
}
.progress[hidden] { display: none; }
.progress p { margin: 0; }
.progress-stage { font: 500 14px/20px var(--md-sys-typescale-plain-font); color: var(--md-sys-color-on-surface); }
.progress-head { display: flex; align-items: center; gap: 12px; }
.progress-detail:empty { display: none; }
.progress-detail {
  margin-top: 8px !important;
  font: 400 12px/16px var(--md-sys-typescale-plain-font);
  color: var(--md-sys-color-on-surface-variant);
  font-variant-numeric: tabular-nums;
}
.progress-track {
  position: relative; height: 4px; margin-top: 12px; overflow: hidden;
  border-radius: 2px; background: var(--md-sys-color-surface-container-highest);
}
.progress-bar {
  position: absolute; inset: 0 auto 0 0; width: var(--at, 0%);
  border-radius: 2px; background: var(--md-sys-color-primary);
  transition: width 240ms var(--md-sys-motion-standard);
}
/* A bar only when there is a number behind it, which is the download. The
   model thinking has no percentage to give, and a bar sliding across for
   twenty seconds reads as stuck rather than busy. A spinner promises
   nothing except that it is working, which is the truth. */
.progress-spinner {
  display: none; flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--md-sys-color-surface-container-highest);
  border-top-color: var(--md-sys-color-primary);
  animation: progress-spin 0.8s linear infinite;
}
.progress[data-indeterminate="true"] {
  width: auto; max-width: calc(100% - 32px);
  padding: 14px 20px 14px 16px;
}
.progress[data-indeterminate="true"] .progress-spinner { display: block; }
.progress[data-indeterminate="true"] .progress-track { display: none; }
.progress[data-indeterminate="true"] .progress-stage { white-space: nowrap; }
.progress[data-indeterminate="true"] .progress-detail { margin-left: 32px !important; }
@keyframes progress-spin { to { transform: rotate(360deg); } }
/* The shell cuts every animation to 1ms for reduced motion, which would turn
   this into a flicker. A slow turn is the calmer way to say "still working". */
@media (prefers-reduced-motion: reduce) {
  .progress-spinner { animation-duration: 2s !important; }
}

/* ---------- Compare ---------- */
.compare-line {
  position: absolute; top: 0; bottom: 0; z-index: 4; width: 0;
  pointer-events: none;
  border-left: 2px solid var(--md-sys-color-surface);
  outline: 1px solid color-mix(in srgb, var(--md-sys-color-on-surface) 30%, transparent);
  transform: translateX(-1px);
}
.compare-line[hidden] { display: none; }
.compare-knob {
  position: absolute; top: 50%; left: -1px;
  display: grid; place-items: center; width: 36px; height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--md-sys-color-surface);
  box-shadow: var(--app-hairline);
  color: var(--md-sys-color-on-surface);
}
.compare-knob svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Brush ---------- */
/* Two rings, light and dark, so it reads on a white shirt and a black coat. */
.brush-cursor {
  position: absolute; left: 0; top: 0; z-index: 4;
  width: 48px; height: 48px;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.95);
  outline: 1px solid rgba(0, 0, 0, 0.55);
  outline-offset: 0;
  transform: translate(-50%, -50%);
}
.brush-cursor[hidden] { display: none; }

/* ---------- Inspector ---------- */
.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.export-actions .md-button { justify-content: center; }
.engine-note { margin: 16px 4px 0 !important; }
.credits { margin: 6px 4px 16px !important; }
.credits a { color: inherit; }
.hint[hidden] { display: none; }

/* ---------- "Powered by" credit ----------
   Lives in the DOM on top of the canvas, never inside it, so it is present
   while you work and absent from every export. */
.viewport-credit {
  /* One number controls the whole badge: the artwork is 100x32 at scale 1. */
  --credit-scale: 2;
  position: absolute; top: 12px; right: 12px; z-index: 5;
  display: block; padding: 0; line-height: 0;
  border-radius: calc(9px * var(--credit-scale)); overflow: hidden;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 82%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--app-hairline);
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-standard);
}
.viewport-credit:hover { background: var(--md-sys-color-surface-container-high); }
.viewport-credit svg {
  display: block;
  width: calc(100px * var(--credit-scale));
  height: calc(32px * var(--credit-scale));
}
.viewport-credit .credit-label { fill: var(--md-sys-color-on-surface-variant); }
.viewport-credit .credit-name,
.viewport-credit .credit-mark { fill: var(--md-sys-color-on-surface); }

/* Step it back on narrow viewports so it cannot run into the hint chip. */
@media (max-width: 1180px) { .viewport-credit { --credit-scale: 1.5; } }
@media (max-width: 960px)  { .viewport-credit { --credit-scale: 1.25; } }
