/* Octave admin: page editor only (grid, blocks, inspector). Uses the custom properties
   of admin.css; no colour literal here (admin-tests/unit/lint.test.js). Rows, cards,
   badges, buttons, tabs and menus come from admin.css; this file only lays out what the
   editor adds. */

/* ---------- Layout ---------- */

/* Three panes side by side: no admin.css layout has three columns. */
.o-ed-panes {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr) minmax(14rem, 20rem);
  gap: var(--s-4);
  align-items: start;
}

.o-ed-pane {
  min-width: 0;
}

/* The top bar wraps its groups; the title takes what is left. */
.o-ed-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin-bottom: var(--s-4);
}

.o-ed-title {
  flex: 1 1 14rem;
  margin: 0;
}

.o-ed-state {
  margin: 0;
  color: var(--c-muted);
}

/* The pane tabs exist only under 900 px (editor.js swaps the tab semantics). */
.o-ed-tabs {
  display: none;
}

@media (max-width: 899.98px) {
  .o-ed-tabs {
    display: flex;
    margin-bottom: var(--s-4);
  }

  .o-ed-panes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Preview ---------- */

/* The live preview (preview_frame.js): the frame keeps the previewed device's width and
   the page's full height (--o-pv-height, from the overlay) and is scaled down to the pane
   (--o-pv-scale); the sizer takes the scaled box and the stage scrolls over it, so the
   scroll position survives a reload. No admin.css rule scales a frame. */
.o-pv-stage {
  max-height: calc(100vh - 12rem);
  overflow: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

.o-pv-sizer {
  --o-pv-w: 1280px;
  width: calc(var(--o-pv-w) * var(--o-pv-scale, 1));
  height: calc(var(--o-pv-height, 40rem) * var(--o-pv-scale, 1));
  margin-inline: auto;
  overflow: hidden;
}

.pv-tablet .o-pv-sizer {
  --o-pv-w: 820px;
}

.pv-phone .o-pv-sizer {
  --o-pv-w: 390px;
}

.o-pv-frame {
  display: block;
  width: var(--o-pv-w);
  height: var(--o-pv-height, 40rem);
  border: 0;
  transform: scale(var(--o-pv-scale, 1));
  transform-origin: 0 0;
}

/* ---------- Structure ---------- */

/* On top of .o-plain-list: a smaller gap, no bottom margin, and one track that may
   shrink below its content (long texts are cut by .o-st-text). */
.o-st-sections,
.o-st-blocks {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2);
  margin: 0;
}

.o-st-section {
  padding: var(--s-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

/* A block list is indented under its section along a rule, like the page tree. */
.o-st-blocks {
  margin: var(--s-2) 0;
  padding-left: var(--s-3);
  border-left: 1px solid var(--c-border);
}

.o-st-row {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

/* The grip shows that a row can be dragged (drawn with text, no image). */
.o-st-grip::before {
  content: "⋮⋮";
  color: var(--c-muted);
  cursor: grab;
}

/* An item is a full-width text button, not a .o-btn: it reads as an outline row. */
.o-st-item {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s-2);
  min-width: 0;
  min-height: 2.75rem;
  padding: var(--s-1) var(--s-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.o-st-item:hover {
  background: var(--c-bg-alt);
}

.o-st-item[aria-current="true"] {
  border-color: var(--c-primary);
  background: var(--c-bg-alt);
}

.o-st-name {
  font-weight: 600;
}

.o-st-text {
  min-width: 0;
  overflow: hidden;
  color: var(--c-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.o-st-empty {
  margin: var(--s-2) 0;
  color: var(--c-muted);
}

/* ---------- Block icons and palette ---------- */

/* Sprite icons follow the text colour and size (the site's .o-icon is not loaded here). */
.o-ed-icon {
  flex: none;
  width: 1.25em;
  height: 1.25em;
  fill: currentColor;
}

.o-ed-palette {
  position: relative;
}

/* The block list is a .o-menu (position, border, background, shadow) that opens to the
   right of its button, as a scrolling grid of icon + name + help entries. */
.o-ed-pop {
  left: 0;
  right: auto;
  display: grid;
  gap: var(--s-1);
  width: min(22rem, 90vw);
  max-height: 60vh;
  overflow-y: auto;
}

.o-ed-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 var(--s-2);
  align-items: center;
  min-height: 2.75rem;
  padding: var(--s-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.o-ed-pick:hover,
.o-ed-pick:focus {
  background: var(--c-bg-alt);
}

.o-ed-pick-name {
  font-weight: 600;
}

.o-ed-pick-help {
  grid-column: 2;
  color: var(--c-muted);
  font-size: var(--t-sm);
}

/* ---------- Section library ---------- */

.o-ed-layouts {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr));
}

.o-ed-layout {
  display: grid;
  gap: var(--s-2);
  width: 100%;
  height: 100%;
  padding: var(--s-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.o-ed-layout:hover {
  border-color: var(--c-primary);
}

/* ---------- Miniature 12-column grid (library schematics, placement ruler) ---------- */

/* The site's placement classes (o-c / o-s) mean the same here; the site stylesheet is
   not loaded in the admin, so they are mapped again, scoped to .o-mini. A cell always
   carries a span class (grid.js classesFor); without a start class it is placed
   automatically, as on the site. */
.o-mini {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2px;
}

.o-mini-cell {
  min-height: 0.75rem;
  border-radius: var(--r-sm);
  background: var(--c-border);
}

.o-mini-empty {
  border: 1px dashed var(--c-border);
  background: transparent;
}

.o-mini .o-c1 { grid-column-start: 1; }
.o-mini .o-c2 { grid-column-start: 2; }
.o-mini .o-c3 { grid-column-start: 3; }
.o-mini .o-c4 { grid-column-start: 4; }
.o-mini .o-c5 { grid-column-start: 5; }
.o-mini .o-c6 { grid-column-start: 6; }
.o-mini .o-c7 { grid-column-start: 7; }
.o-mini .o-c8 { grid-column-start: 8; }
.o-mini .o-c9 { grid-column-start: 9; }
.o-mini .o-c10 { grid-column-start: 10; }
.o-mini .o-c11 { grid-column-start: 11; }
.o-mini .o-c12 { grid-column-start: 12; }
.o-mini .o-s1 { grid-column-end: span 1; }
.o-mini .o-s2 { grid-column-end: span 2; }
.o-mini .o-s3 { grid-column-end: span 3; }
.o-mini .o-s4 { grid-column-end: span 4; }
.o-mini .o-s5 { grid-column-end: span 5; }
.o-mini .o-s6 { grid-column-end: span 6; }
.o-mini .o-s7 { grid-column-end: span 7; }
.o-mini .o-s8 { grid-column-end: span 8; }
.o-mini .o-s9 { grid-column-end: span 9; }
.o-mini .o-s10 { grid-column-end: span 10; }
.o-mini .o-s11 { grid-column-end: span 11; }
.o-mini .o-s12 { grid-column-end: span 12; }

/* ---------- Placement ---------- */

.o-ed-ruler {
  display: grid;
  gap: var(--s-1);
  margin-top: var(--s-3);
  padding: var(--s-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

.o-ruler-row .o-mini-cell {
  min-height: 1.5rem;
}

.o-ruler-mine {
  background: var(--c-primary);
}

/* A spinbutton reads as a value box between its − and + buttons. */
.o-ed-spin {
  min-width: 3.5rem;
  min-height: 2.75rem;
  padding: var(--s-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  text-align: center;
}

.o-ed-step {
  min-width: 2.75rem;
}

.o-ed-spin[aria-disabled="true"],
.o-ed-step[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Properties ---------- */

/* The rich-text region is a div, not a textarea: .o-input's min-height fits one line, so
   give it room to click into, and keep long words inside the narrow pane. */
.o-rt {
  min-height: 6rem;
  overflow-wrap: anywhere;
}

/* Section background swatches: .o-swatch paints only the base background; these show the
   other tokens of the site palette (the theme classes on the swatch define them). */
.o-swatch-bg-alt {
  background: var(--c-bg-alt);
}

.o-swatch-bg-primary {
  background: var(--c-primary);
  color: var(--c-on-primary);
}

.o-swatch-bg-accent {
  background: var(--c-accent);
  color: var(--c-on-accent);
}

/* Page settings drawer: the modal dialog docked along the inline end, full height, so
   the page stays visible beside it (dvh: the actions stay above a phone's browser bar;
   vh for browsers without it). */
.o-dialog-drawer {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  margin-block: 0;
  margin-inline: auto 0;
  border-radius: 0;
}
