/* Banner Editor — chrome is dark so the artboard reads as the bright thing on
 * the desk, the way an image editor does. The artboard itself never inherits
 * these colours: it paints exactly what the banner document says. */

:root {
  --chrome: #232326;
  --chrome-2: #2c2c30;
  --chrome-3: #36363b;
  --line: #45454c;
  --ink: #eceae5;
  --ink-dim: #a9a6a0;
  --accent: #4c9cf5;
  --snap: #ff4fd8;

  /* Curvature: every rounded surface carries an explicit radius equal to exactly
   * half its rendered height, with a 1.5 superellipse for a continuous
   * transition. The artboard resets it — banner artwork must stay true to the
   * document it draws. */
  corner-shape: superellipse(1.5);
  --r-tool: 15px; /* 30px tall */
  --r-mini: 13px; /* 26px tall */
  --r-field: 16px; /* 32px tall */
  --r-row: 14px; /* 28px tall */
  --r-sheet: 24px; /* content-driven height, so an explicit radius instead */
  font-size: 15px;
}

/* corner-shape inherits per spec, but this engine does not pass it down — a
 * child of a superellipse parent paints a plain round corner. So each rounded
 * chrome surface declares it; artwork stays out of this list. */
button.tool,
button.mini,
input.num,
select.sel,
input.txt,
.layer-row,
.layer-menu,
.menu-item,
.panel input[type="text"],
.panel input[type="number"],
.panel input[type="color"],
.panel select,
.panel textarea,
.modal,
#json-text {
  corner-shape: superellipse(1.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--chrome);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- top bar --------------------------------------------------------------- */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 8px 12px;
  background: var(--chrome-2);
  border-bottom: 1px solid var(--line);
}

.group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-right: 6px;
}

.dim {
  color: var(--ink-dim);
}

.sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}

.readout {
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

button.tool,
button.mini {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-tool);
  background: var(--chrome-3);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

button.mini {
  height: 26px;
  padding: 0 8px;
  border-radius: var(--r-mini);
  font-size: 13px;
}

button.tool:hover,
button.mini:hover {
  background: #42424a;
}

button.tool:disabled,
button.mini:disabled {
  opacity: 0.4;
  cursor: default;
}

button.is-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #08131f;
  font-weight: 600;
}

input.num,
select.sel,
input.txt {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-tool);
  background: var(--chrome);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

input.num {
  width: 74px;
}

select.sel {
  max-width: 260px;
}

/* --- workspace ------------------------------------------------------------- */

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 236px 1fr 304px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--chrome-2);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.panel-right {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
}

.count {
  font-weight: 600;
}

.panel-body {
  overflow: auto;
  padding: 10px;
  min-height: 0;
}

.panel-foot {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

.layer-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--r-row);
  cursor: default;
  user-select: none;
}

.layer-row:hover {
  background: var(--chrome-3);
}

.layer-row.is-selected {
  background: var(--accent);
  color: #08131f;
}

.layer-row.is-hidden .layer-name {
  opacity: 0.45;
  text-decoration: line-through;
}

.layer-glyph {
  width: 18px;
  text-align: center;
  font-size: 12px;
  opacity: 0.85;
}

.layer-name {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-act {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.75;
}

.layer-act:hover {
  opacity: 1;
}

/* Right-click menu. Items are 32px tall, so their radius is exactly half that;
 * the sheet is content-driven, so it takes an explicit radius that stays
 * concentric with its items (16px + the 8px inset). */
.layer-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  background: var(--chrome-2);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
}

.menu-item {
  display: block;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-field);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.menu-item:hover:not(:disabled) {
  background: var(--accent);
  color: #08131f;
}

.menu-item:disabled {
  color: var(--ink-dim);
  opacity: 0.45;
  cursor: default;
}

.menu-sep {
  height: 1px;
  margin: 6px 8px;
  background: var(--line);
}

/* --- stage ----------------------------------------------------------------- */

.stage-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  outline: none;
}

.stage {
  flex: 1;
  overflow: auto;
  padding: 28px;
  background: #1b1b1e;
}

.artboard {
  position: relative;
  background: #ffffff;
  box-shadow: 0 0 0 1px #000000, 0 18px 48px rgba(0, 0, 0, 0.55);
  transform-origin: top left;
}

.grid-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.layers {
  position: absolute;
  inset: 0;
  /* Banner geometry is the document's business: no inherited curvature here. */
  corner-shape: round;
}

.layer {
  position: absolute;
  cursor: move;
}

.layer.is-locked {
  cursor: default;
}

.layer-body {
  width: 100%;
  height: 100%;
}

.layer-body img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.text-body {
  width: 100%;
  height: 100%;
  white-space: pre-wrap;
  overflow: hidden;
  line-height: 1.15;
}

.button-body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-align: center;
  /* The generated button is a UI surface, so it gets the same continuous
   * curvature as the chrome: radius = half the height, superellipse 1.5. */
  corner-shape: superellipse(1.5);
}

.button-body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Selection chrome lives in the overlay so it never scales with layer styles. */

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  corner-shape: round;
}

.selection {
  position: absolute;
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: #ffffff;
  pointer-events: auto;
}

.handle[data-dir="nw"],
.handle[data-dir="se"] {
  cursor: nwse-resize;
}

.handle[data-dir="ne"],
.handle[data-dir="sw"] {
  cursor: nesw-resize;
}

.handle[data-dir="n"],
.handle[data-dir="s"] {
  cursor: ns-resize;
}

.handle[data-dir="e"],
.handle[data-dir="w"] {
  cursor: ew-resize;
}

.guide {
  position: absolute;
  background: var(--snap);
  pointer-events: none;
}

.guide.is-vertical {
  width: 1px;
  top: 0;
  bottom: 0;
}

.guide.is-horizontal {
  height: 1px;
  left: 0;
  right: 0;
}

.status {
  padding: 5px 12px;
  font-size: 13px;
  color: var(--ink-dim);
  background: var(--chrome-2);
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

/* --- properties ------------------------------------------------------------ */

.row {
  margin-bottom: 10px;
}

.row.is-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.row.is-trio {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

label.field {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  margin-bottom: 4px;
}

.panel input[type="text"],
.panel input[type="number"],
.panel select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: var(--chrome);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1;
}

.panel textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: var(--chrome);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  min-height: 62px;
  resize: vertical;
  line-height: 1.4;
}

.panel input[type="color"] {
  width: 100%;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-tool);
  background: var(--chrome);
}

.panel input[type="range"] {
  width: 100%;
}

.panel input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.section {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.hint {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.5;
}

.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  font-size: 13px;
  color: var(--ink-dim);
}

.keys kbd {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 14px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  /* 18px tall cap, so the radius is exactly half of it. */
  border-radius: 9px;
  background: var(--chrome);
  color: var(--ink);
  white-space: nowrap;
}

.align-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- JSON popup ------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 10, 12, 0.62);
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(760px, 100%);
  max-height: 100%;
  padding: 12px;
  background: var(--chrome-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

#json-text {
  flex: 1;
  min-height: 260px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: var(--chrome);
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.modal-foot .spacer {
  flex: 1;
}
