/* MatterShot — app chrome. The css-v2 design system (loaded via /css-v2/main.css
   in index.html) provides tokens + every primitive; this file styles the
   editor-specific surfaces: the tool rail, canvas stage, contextual options
   bar, action bar, empty state and the inline text editor. */

@import url("/css-v2/tokens.css");

html, body { height: 100%; margin: 0; background: var(--pm-black); color: var(--pm-white); }
body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: var(--ff-body);
  overflow: hidden;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* ------------------------------------------------------------------ */
/* Editor frame                                                        */
/* ------------------------------------------------------------------ */
.ms-app { flex: 1; min-height: 0; display: flex; }

.ms-rail {
  flex: 0 0 auto;
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--pm-ink);
  border-inline-end: 1px solid var(--border-color-subtle);
  overflow-y: auto;
  overflow-x: hidden;
}
.ms-rail__sep { width: 24px; height: 1px; background: var(--border-color-subtle); margin: 6px 0; flex: 0 0 auto; }

.ms-tool {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--pm-gray-300);
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--dur-fast) var(--ease-out-expo), color var(--dur-fast) var(--ease-out-expo);
}
.ms-tool svg { width: 20px; height: 20px; }
.ms-tool:hover { background: var(--pm-gray-800); color: var(--pm-white); }
.ms-tool:focus-visible { outline: 2px solid var(--pm-accent); outline-offset: 1px; }
.ms-tool.is-active { background: color-mix(in srgb, var(--pm-purple-500) 30%, transparent); color: var(--pm-white); border-color: var(--pm-purple-400); }

.ms-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.ms-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #141418;
}
.ms-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ms-stage.is-dragover { outline: 2px dashed var(--pm-accent); outline-offset: -8px; }

/* ------------------------------------------------------------------ */
/* Contextual options bar                                              */
/* ------------------------------------------------------------------ */
.ms-options {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: none;
  align-items: center;
  gap: var(--sp-3);
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  background: color-mix(in srgb, var(--pm-ink) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color-base);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow-x: auto;
  overflow-y: visible;
}
.ms-options.is-visible { display: flex; }

.ms-opt { display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; }
.ms-opt + .ms-opt { border-inline-start: 1px solid var(--border-color-subtle); padding-inline-start: var(--sp-3); }
.ms-opt__label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pm-gray-400); white-space: nowrap; }
.ms-opt__ctrl { display: flex; align-items: center; gap: 6px; }
.ms-opt--hint { justify-content: center; color: var(--pm-gray-400); font-size: var(--fs-100); max-width: 320px; }

.ms-swatches { display: flex; align-items: center; gap: 4px; }
.ms-swatch {
  width: 22px; height: 22px; border-radius: 6px; padding: 0;
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}
.ms-swatch.is-active { outline: 2px solid var(--pm-accent); outline-offset: 1px; }
.ms-swatch--custom { overflow: hidden; background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); }
.ms-swatch--custom::-webkit-color-swatch-wrapper { padding: 0; }
.ms-swatch--custom::-webkit-color-swatch { border: none; }

.ms-slider { display: flex; align-items: center; gap: 8px; }
.ms-slider .form-slider { width: 120px; }
.ms-slider__val { min-width: 3ch; font-size: var(--fs-100); color: var(--pm-gray-300); font-variant-numeric: tabular-nums; }

.ms-options .form-select { min-width: 92px; padding: 5px 26px 5px 10px; font-size: var(--fs-100); }

.ms-seg { display: inline-flex; border: 1px solid var(--border-color-base); border-radius: var(--radius-sm); overflow: hidden; }
.ms-seg__btn { padding: 5px 10px; background: transparent; color: var(--pm-gray-300); font-size: var(--fs-100); border: 0; }
.ms-seg__btn:hover { color: var(--pm-white); }
.ms-seg__btn.is-active { background: var(--pm-purple-500); color: var(--pm-white); }

.ms-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-100); color: var(--pm-gray-200); }
.ms-toggle input { accent-color: var(--pm-purple-400); width: 16px; height: 16px; }

.ms-options .btn { white-space: nowrap; }
.ms-btn-danger { color: #ff8593 !important; border-color: rgba(255,70,90,0.4) !important; }

.ms-resize { display: flex; align-items: center; gap: 6px; }
.ms-num {
  width: 70px; padding: 5px 8px; font: inherit; font-size: var(--fs-100);
  color: var(--pm-white); background: var(--pm-gray-900);
  border: 1px solid var(--border-color-base); border-radius: var(--radius-sm);
}
.ms-resize__x { color: var(--pm-gray-400); }

/* ------------------------------------------------------------------ */
/* Action bar                                                          */
/* ------------------------------------------------------------------ */
.ms-actionbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 8px 12px;
  background: var(--pm-ink);
  border-block-start: 1px solid var(--border-color-subtle);
}
.ms-actgroup { display: flex; align-items: center; gap: 4px; }
.ms-actgroup--end { margin-inline-start: auto; }
.ms-actbtn {
  height: 36px; min-width: 36px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--pm-gray-300);
  border: 1px solid transparent; background: transparent;
}
.ms-actbtn svg { width: 18px; height: 18px; }
.ms-actbtn:hover { background: var(--pm-gray-800); color: var(--pm-white); }
.ms-actbtn:disabled { opacity: 0.4; pointer-events: none; }
.ms-actbtn:focus-visible { outline: 2px solid var(--pm-accent); outline-offset: 1px; }
.ms-zoom { font-size: var(--fs-100); font-variant-numeric: tabular-nums; color: var(--pm-gray-200); }
.ms-actionbar .btn { display: inline-flex; align-items: center; gap: 6px; }
.ms-actionbar .btn svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ */
/* Empty state                                                         */
/* ------------------------------------------------------------------ */
.ms-empty {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  background:
    radial-gradient(700px 400px at 50% 30%, rgba(115,0,139,0.16), transparent 60%),
    #141418;
}
.ms-empty__inner { max-width: 520px; text-align: center; }
.ms-empty__icon { display: inline-flex; opacity: 0.9; margin-bottom: var(--sp-4); }
.ms-empty__title { font-family: var(--ff-display); font-size: var(--fs-600); margin: 0 0 var(--sp-3); }
.ms-empty__lead { color: var(--pm-gray-300); margin: 0 0 var(--sp-5); }
.ms-empty__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: center; }
.ms-empty__delay { display: inline-flex; align-items: center; gap: 8px; margin-top: var(--sp-4); color: var(--pm-gray-400); font-size: var(--fs-100); }

/* ------------------------------------------------------------------ */
/* Inline text editor overlay                                          */
/* ------------------------------------------------------------------ */
.ms-textedit {
  position: absolute; z-index: 7;
  margin: 0; padding: 0; border: 0;
  background: transparent;
  color: #fff;
  outline: 1px dashed var(--pm-purple-400);
  outline-offset: 4px;
  resize: none; overflow: hidden;
  white-space: pre;
  box-sizing: content-box;
  caret-color: var(--pm-accent);
  transform-origin: top left;
}

/* Hide the floating cookie chip inside the editor — it overlaps the action
   bar; the panel is still reachable from Settings. */
.consent__chip { display: none !important; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 760px) {
  .ms-app { flex-direction: column; }
  .ms-rail {
    width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    border-inline-end: none; border-block-end: 1px solid var(--border-color-subtle);
    padding: 8px;
  }
  .ms-rail__sep { width: 1px; height: 24px; margin: 0 4px; }
  .ms-options { top: 8px; }
  .ms-slider .form-slider { width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  .ms-tool { transition: none; }
}
