/* Editor (docs/design-system.md, Editor): fills the window the way Figma,
   Keynote and Canva do. A 56px white bar on top; under it the 300px white
   columns at the window edges and the grey work area between them, with
   the slide floating on it and the film strip under the slide. The slide
   size comes from components/editor_modal.cljs, which fits a 9:16 slide
   and the strip into the measured work area; the sizes it reads are the
   ones below. */

.editor {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-page);
  animation: modal-fade-in var(--duration-base) var(--ease-out);
}

.editor--closing {
  animation: modal-fade-out var(--duration-base) var(--ease-out) forwards;
  pointer-events: none;
}

.editor__bar {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 56px;
  padding: 0 var(--space-2) 0 var(--space-6);
  background: var(--color-bg-surface);
  box-shadow: 0 var(--border-width) 0 var(--color-border-subtle);
}

.editor__title {
  margin: 0;
  font-size: var(--text-section);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.editor__save-state {
  font-size: var(--text-note);
  color: var(--color-text-muted);
}

.editor__save-state--error {
  color: var(--color-error);
}

/* On the white bar the close button is a plain icon, as in a modal. */
.editor__close {
  margin-left: auto;
  background: none;
}

.editor__close:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-bg-page);
}

.editor__body {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* A column at the window edge, not a card: no radius, no border. Its
   parts are 16px apart; a group gap makes 32px between groups. */
.editor__column {
  flex-shrink: 0;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-bg-surface);
}

.editor__column > * {
  flex-shrink: 0;
}

.editor__group-gap {
  height: 0;
}

/* Add to schedule and Publish sit at the bottom of the post
   column; the column scrolls when its fields are taller than the window. */
.editor__column-foot {
  margin-top: auto;
  padding-top: var(--space-4);
}

.editor__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.editor__group + .editor__group {
  margin-top: var(--space-8);
}

.editor__group-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

/* A row of the text-block inspector, the way Figma's and Keynote's are
   built: 40px tall, a 64px note label on the left, the control on the
   right; a control that explains itself spans the row. */
.editor__prop {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height);
}

.editor__prop--full {
  grid-template-columns: minmax(0, 1fr);
}

.editor__prop-label {
  font-size: var(--text-note);
  color: var(--color-text-muted);
}

.editor__pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
}

/* Add background, Add stroke: as wide as the label, not the row. */
.editor__prop-action {
  justify-self: start;
}

.editor__color-row .color-input {
  flex: 1;
}

.editor__text {
  min-height: 64px;
}

.editor__color-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

/* Style presets: 40px squares showing "Aa" in the preset. */
.editor__presets {
  display: flex;
  gap: var(--space-2);
}

.editor__preset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  line-height: 1;
  color: var(--color-text);
  background: var(--color-bg-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.editor__preset:hover,
.editor__preset:focus-visible {
  border-color: var(--color-text);
  outline: none;
}

.editor__preset > span {
  padding: 2px var(--space-1);
  border-radius: var(--radius-small);
}

/* The remove button beside a color: white on white, so it keeps the line. */
.editor__remove {
  flex-shrink: 0;
  box-shadow: inset 0 0 0 var(--border-width) var(--color-border);
}

.editor__remove:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-bg-surface);
  box-shadow: inset 0 0 0 var(--border-width) var(--color-text);
}

.editor__stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.editor__stack--loose {
  gap: var(--space-4);
}

.editor__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.editor__note {
  margin: 0;
  font-size: var(--text-note);
  color: var(--color-text-muted);
}

.editor__work {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6);
  overflow: hidden;
}

/* The one thing that floats. */
.editor__slide {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--radius-media);
  background: var(--color-text);
  box-shadow: var(--shadow-slide);
}

/* Film strip: 40x71 thumbnails, inactive ones at 60%, the active one with
   the selected preview's amber outline; the padding keeps that outline
   inside the strip when it scrolls sideways. */
.editor__strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  height: 79px;
  padding: var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
}

.editor__thumb {
  flex-shrink: 0;
  width: 40px;
  height: 71px;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: var(--radius-thumb);
  background: var(--color-text);
  opacity: 0.6;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease-default);
  /* A long press drags a thumbnail on touch: no callout or text selection
     over the image while the finger rests on it. */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* SlideThumb rounds its frame at the preview radius; a thumbnail is 4. */
.editor__thumb > * {
  border-radius: var(--radius-thumb) !important;
}

.editor__thumb:hover,
.editor__thumb[aria-current="true"] {
  opacity: 1;
}

/* While a thumbnail is dragged, its place in the strip is the gap where
   the slide will land. */
.editor__thumb--gap {
  opacity: 1;
  background: none;
  outline: var(--border-width) dashed var(--color-text-muted);
  outline-offset: calc(-1 * var(--border-width));
}

.editor__thumb--gap > * {
  visibility: hidden;
}

/* The dragged thumbnail under the pointer. */
.editor__thumb--lifted {
  opacity: 1;
  cursor: grabbing;
}

.editor__strip-add {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 71px;
  padding: 0;
  color: var(--color-text-muted);
  background: none;
  border: var(--border-width) dashed var(--color-text-muted);
  border-radius: var(--radius-thumb);
  cursor: pointer;
}

.editor__strip-add:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

/* Phone: one scrolling column under the sticky bar - the slide with the
   strip, the slide column, the post column. */
@media (max-width: 860px) {
  .editor {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .editor__bar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-left: var(--space-4);
  }

  .editor__body {
    flex: none;
    flex-direction: column;
  }

  .editor__work {
    order: 1;
    padding: var(--space-4);
    overflow: visible;
  }

  .editor__column {
    width: auto;
    overflow-y: visible;
  }

  .editor__column--slide {
    order: 2;
  }

  .editor__column--post {
    order: 3;
  }

  .editor__column-foot {
    margin-top: 0;
  }
}
