/* Backtick editor. Only ever loaded on localhost - see cms_editor_assets(). */

:root {
  --cms-ink: #111;
  --cms-paper: #fdfdfd;
  --cms-accent: #ffe152;   /* same yellow the site uses for link hovers */
}

/* ── Toolbar ─────────────────────────────────────────────── */

.cms-bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 0.75em;
  padding: 0.4em 0.8em;
  background: var(--cms-ink);
  color: var(--cms-paper);
  font: 12px/1.6 ui-monospace, Menlo, Consolas, monospace;
}

body.cms-on .cms-bar { display: flex; }
/* The page is pushed down by exactly the bar's height, measured in JS -
   the bar wraps to two lines on a narrow window, so a fixed value slips. */

.cms-bar strong { letter-spacing: 0.08em; white-space: nowrap; }
.cms-bar button { white-space: nowrap; }
.cms-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cms-bar .cms-spacer { margin-left: auto; }

.cms-bar button {
  font: inherit;
  padding: 0.25em 0.7em;
  border: 1px solid var(--cms-paper);
  background: transparent;
  color: var(--cms-paper);
  cursor: pointer;
}
.cms-bar button:hover { background: var(--cms-accent); color: var(--cms-ink); }

.cms-status { opacity: 0.75; flex: 1; }

/* On a phone the buttons are the point and the chatter isn't - let the bar
   wrap onto two rows and drop the running commentary. The page offset is
   measured from the bar's real height, so wrapping doesn't cause overlap. */
@media (max-width: 640px) {
  .cms-bar { flex-wrap: wrap; gap: 0.35em; padding: 0.45em 0.5em; }
  .cms-bar > span:not(.cms-status) { display: none; }   /* hint and spacer */
  .cms-bar strong { flex: 0 0 auto; }

  /* Keep the status beside the label on one truncated line, not its own row. */
  .cms-status { flex: 1 1 auto; min-width: 0; }

  /* Two buttons per row. Password is dropped - it lives on /cms/ too. */
  .cms-bar button { flex: 1 1 40%; padding: 0.45em 0.5em; }
  .cms-bar button.cms-secondary { display: none; }

  /* No drag and no ⌘S on a phone, so the hint is just taking up room. */
  .cms-panel-foot .cms-hint { display: none; }
  .cms-panel-inner { width: 96vw; height: 88vh; }
}
.cms-status.cms-error { color: #ff8b8b; opacity: 1; }
.cms-status.cms-good  { color: #9dff8b; opacity: 1; }

/* ── Editable blocks ─────────────────────────────────────── */

body.cms-on .cms-region,
body.cms-on .cms-post {
  position: relative;
  outline: 1px dashed #999;
  outline-offset: 4px;
  cursor: pointer;
}

body.cms-on .cms-region:hover,
body.cms-on .cms-post:hover {
  outline: 2px solid var(--cms-ink);
  background: rgba(255, 225, 82, 0.18);
}

/* Name tag so it's obvious which block is which */
body.cms-on .cms-region::before,
body.cms-on .cms-post::before {
  content: attr(data-cms-label);
  position: absolute;
  top: -1.5em;
  left: 0;
  z-index: 10;
  padding: 0 0.4em;
  background: var(--cms-ink);
  color: var(--cms-paper);
  font: 10px/1.6 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
  opacity: 0;
}
body.cms-on .cms-region:hover::before,
body.cms-on .cms-post:hover::before { opacity: 1; }

.cms-empty { color: #999; font-style: italic; }

/* ── Edit panel ──────────────────────────────────────────── */

.cms-panel {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.cms-panel-inner {
  display: flex;
  flex-direction: column;
  width: min(900px, 92vw);
  height: min(80vh, 720px);
  background: var(--cms-paper);
  border: 2px solid var(--cms-ink);
  font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace;
  color: var(--cms-ink);
}

.cms-panel-head {
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.5em 0.8em;
  border-bottom: 1px solid var(--cms-ink);
}
.cms-panel-head strong { font-size: 13px; }
.cms-panel-head .cms-spacer { margin-left: auto; }

.cms-panel textarea {
  flex: 1;
  width: 100%;
  padding: 0.8em;
  border: 0;
  resize: none;
  font: 13px/1.7 ui-monospace, Menlo, Consolas, monospace;
  color: var(--cms-ink);
  background: var(--cms-paper);
  tab-size: 2;
}
.cms-panel textarea:focus { outline: 2px solid var(--cms-accent); outline-offset: -2px; }

.cms-panel-foot {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.8em;
  border-top: 1px solid var(--cms-ink);
}
.cms-panel-foot .cms-spacer { margin-left: auto; }
.cms-panel-foot .cms-hint { opacity: 0.6; font-size: 11px; }

.cms-panel button,
.cms-panel input[type="date"] {
  font: 12px/1.6 ui-monospace, Menlo, Consolas, monospace;
  padding: 0.3em 0.8em;
  border: 1px solid var(--cms-ink);
  background: var(--cms-paper);
  color: var(--cms-ink);
  cursor: pointer;
}
.cms-panel button:hover { background: var(--cms-accent); }
.cms-panel button.cms-danger:hover { background: #ff8b8b; }
.cms-panel button[disabled] { opacity: 0.45; cursor: default; }
.cms-panel button.cms-primary { background: var(--cms-ink); color: var(--cms-paper); }
.cms-panel button.cms-primary:hover { background: var(--cms-accent); color: var(--cms-ink); }

/* Drop target feedback while dragging an image over the textarea */
.cms-panel-inner.cms-dropping { outline: 3px solid var(--cms-accent); }
.cms-panel-inner.cms-dropping textarea { background: rgba(255, 225, 82, 0.15); }

.cms-msg { font-size: 11px; }
.cms-msg.cms-error { color: #b00; }
.cms-msg.cms-good  { color: #070; }

/* ── Thumbnail crop strip ────────────────────────────────── */

.cms-crop-strip {
  display: flex;
  align-items: center;
  gap: 0.6em;
  flex-wrap: wrap;
  padding: 0.6em 0.8em;
  border-top: 1px solid var(--cms-ink);
}

/* Same shape and framing as the real thumbnail, so what you line up here is
   what the blog page shows. */
.cms-crop {
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border: 1px solid var(--cms-ink);
  cursor: crosshair;
  touch-action: none;
  overflow: hidden;
}

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

.cms-crop-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -5px 0 0 -5px;
  border: 1px solid var(--cms-ink);
  border-radius: 50%;
  background: var(--cms-accent);
  pointer-events: none;
}

/* ── Add-a-gig form ──────────────────────────────────────── */

.cms-fields {
  display: grid;
  gap: 0.7em;
  padding: 1em 0.8em;
}

.cms-field {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  align-items: center;
  gap: 0.8em;
}

.cms-field span { font-size: 12px; }

.cms-field input {
  font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace;
  padding: 0.4em 0.6em;
  border: 1px solid var(--cms-ink);
  background: var(--cms-paper);
  color: var(--cms-ink);
}
.cms-field input:focus { outline: 2px solid var(--cms-accent); outline-offset: -1px; }

/* ── Login ───────────────────────────────────────────────── */

.cms-login input[type="password"] {
  font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace;
  padding: 0.4em 0.6em;
  border: 1px solid var(--cms-ink);
}
