/* The post editor (views/editor.js and views/editor/*): post type, words, files and their order, the cover study of a text post,
   preview, and the save controls. Builds on design.css and base.css; everything here is prefixed ed-. */

.ed { max-width: 1120px; }
.ed-head { align-items: flex-end; }
.ed-back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.ed-back:hover { color: var(--ink); }
.ed-eyebrow { margin-bottom: 0; }
.ed-view { display: inline-flex; gap: 22px; border-bottom: 1px solid var(--rule); }
.ed-view .tab { margin-bottom: -1px; }
.ed-view .tab[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* --- The form ---------------------------------------------------------------- */
.ed-form { min-width: 0; }
.ed-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.ed-columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
.ed-main, .ed-side { min-width: 0; }
.ed-side { padding-top: 0; }
.ed-type { display: grid; gap: 10px; margin-bottom: 28px; }
.ed-kinds { display: inline-flex; width: max-content; max-width: 100%; border: 1px solid var(--rule); padding: 3px; }
.ed-kind { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px; border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; transition: background .18s, color .18s; }
.ed-kind:hover { color: var(--ink); background: var(--wash); }
.ed-kind.is-active, .ed-kind.is-active:hover { background: var(--ink); color: var(--paper); }
.ed-kind[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.ed-kind[aria-disabled="true"]:hover { background: transparent; color: var(--muted); }

.ed-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.ed-label-row label { margin: 0; }
.ed-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ed-count.is-near { color: var(--bronze); font-weight: 600; }
#entry-title { font-size: clamp(20px, 3vw, 26px); letter-spacing: -.03em; padding: 14px 15px; }
.ed-body { min-height: 320px; line-height: 1.75; font-size: 16px; }
.ed[data-kind="image"] .ed-body, .ed[data-kind="video"] .ed-body { min-height: 140px; }
.ed .field-error:empty { display: none; }
.ed-side .field { margin-bottom: 22px; }
.ed-cover-note { margin: 0 0 22px; }

/* --- Media: drop zone, files, order ---------------------------------------------- */
.ed-media { margin: 0 0 24px; }
.ed-media-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ed-media-head .eyebrow span { margin-left: 10px; color: var(--muted); letter-spacing: .08em; font-weight: 500; }
.ed-media .form-error { margin: 0 0 10px; }
.ed-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 150px; padding: 24px 18px; border: 1px dashed var(--muted); background: transparent; color: var(--ink); text-align: center; transition: border-color .18s, background .18s; }
.ed-dropzone > * { pointer-events: none; }
.ed-dropzone svg { color: var(--bronze); }
.ed-dropzone strong { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.ed-drop-hint { max-width: 380px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.ed-dropzone:hover:not(:disabled), .ed-dropzone.is-over { border-color: var(--bronze); background: var(--wash); }
.pick-only { display: none; }
.ed-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.ed-dropzone + .ed-items, .ed-dropzone + .ed-video-field { margin-top: 14px; }
.ed-item { min-width: 0; border: 1px solid var(--rule); background: var(--white); }
.ed-item.is-failed, .ed-video-field.is-failed { border-color: var(--danger); }
.ed-thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; overflow: hidden; background: var(--wash); color: var(--muted); }
.ed-pic { display: contents; }
.ed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ed-index { position: absolute; left: 0; top: 0; padding: 4px 8px; background: var(--ink); color: var(--paper); font-size: 10px; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.ed-item-body { padding: 8px; }
.ed-alt { padding: 8px 9px; min-height: 40px; font-size: 12px; }
.ed-upload-status { margin: 6px 0 0; font-size: 11px; line-height: 1.5; color: var(--danger); }
.ed-item-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 6px; }
.ed-item-actions .icon-button { width: 40px; height: 40px; flex-shrink: 0; }
.ed-item-actions [data-action="media-remove"] { margin-left: auto; }
.ed-name { flex: 1 1 100%; order: -1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted); }
.ed-progress { display: block; width: 100%; height: 3px; margin-top: 8px; border: 0; background: var(--rule); appearance: none; overflow: hidden; }
.ed-progress::-webkit-progress-bar { background: var(--rule); }
.ed-progress::-webkit-progress-value { background: var(--bronze); transition: width .2s; }
.ed-progress::-moz-progress-bar { background: var(--bronze); }

.ed-video-field { border: 1px solid var(--rule); background: var(--white); }
.ed-video { display: block; width: 100%; max-height: 380px; background: var(--black); }
.ed-video-field .ed-progress { margin: 0; }
.ed-video-field .ed-upload-status { padding: 0 12px; }
.ed-video-field .ed-item-actions { flex-wrap: nowrap; margin: 0; padding: 6px 6px 6px 12px; }
.ed-video-field .ed-name { order: 0; flex: 1 1 auto; }

/* --- Cover study of a text post ----------------------------------------------------- */
.ed-cover-field.is-over { outline: 1px dashed var(--bronze); outline-offset: 6px; }
.ed-cover { margin: 12px 0 0; aspect-ratio: 16 / 10; overflow: hidden; background: var(--wash); }
.ed-cover img { width: 100%; height: 100%; object-fit: cover; }
.ed-cover-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* --- Preview ------------------------------------------------------------------------ */
.ed-preview { padding: 28px 0 8px; border-top: 1px solid var(--rule); }
.ed-preview-label { margin-bottom: 26px; }
.ed-article { max-width: 760px; }
.ed-article-title { margin-top: 12px; font-size: clamp(32px, 5.6vw, 56px); letter-spacing: -.05em; line-height: 1.04; overflow-wrap: anywhere; }
.ed-article-deck { margin-top: 14px; max-width: 56ch; font-size: clamp(17px, 2.2vw, 21px); line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.ed-article-byline { margin-top: 20px; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.ed-article-cover { margin: 26px 0 0; aspect-ratio: 16 / 8; max-height: 440px; overflow: hidden; background: var(--wash); }
.ed-article-cover img { width: 100%; height: 100%; object-fit: cover; }
.ed-article-media { display: grid; gap: 18px; margin-top: 26px; }
.ed-article-media figure { margin: 0; background: var(--wash); }
.ed-article-media img { width: 100%; height: auto; max-height: 80dvh; object-fit: contain; margin: 0 auto; }
.ed-article-media video { display: block; width: 100%; max-height: 70dvh; background: var(--black); }
.ed-article-body { margin-top: 28px; max-width: 68ch; font-size: 18px; line-height: 1.8; }
.ed-article-body p { overflow-wrap: anywhere; }
.ed-article-body p + p { margin-top: 1.3em; }
.ed-article-body p:first-child::first-letter { float: left; padding: .08em .1em 0 0; font-size: 3.1em; font-weight: 500; line-height: .9; letter-spacing: -.04em; color: var(--bronze); }
.ed-empty-note { margin-top: 22px; font-size: 13px; color: var(--muted); }
.ed-lock-note { display: flex; align-items: flex-start; gap: 12px; margin-top: 30px; padding: 16px 18px; border: 1px solid var(--rule); border-top: 2px solid var(--bronze); background: var(--white); font-size: 13px; line-height: 1.65; color: var(--muted); }
.ed-lock-note svg { margin-top: 3px; color: var(--bronze); }

/* --- Saving --------------------------------------------------------------------------- */
.ed-error { margin: 4px 0 12px; }
.ed-status { min-height: 18px; margin: 0 0 12px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.ed-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-top: 12px; padding-top: 20px; border-top: 1px solid var(--rule); }
.ed-footer-note { max-width: 52ch; font-size: 12px; line-height: 1.6; color: var(--muted); }
.ed-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ed-cancel { display: flex; justify-content: flex-end; margin-top: 14px; }
.ed-cancel .button { min-height: 40px; }

/* A save in progress: what cannot be used looks like it. The Cancel button sits outside the fieldset and stays at full strength. */
.ed-fields:disabled :is(input, select, textarea) { background: var(--wash); color: var(--muted); cursor: not-allowed; }
.ed-fields:disabled :is(.ed-dropzone, .ed-item, .ed-video-field, .ed-cover) { opacity: .6; }
.ed-fields:disabled :is(.button, .icon-button, .ed-kind) { opacity: .45; pointer-events: none; }
.ed-fields:disabled .tab { opacity: .45; }
.ed-fields[aria-busy="true"] { cursor: progress; }

/* --- Narrow screens ---------------------------------------------------------------------- */
@media (max-width: 960px) {
  .ed-columns { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .ed-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 0 20px; }
  .ed-side > .ed-cover-field, .ed-side > .ed-cover-note { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .ed-view { width: 100%; }
  .ed-view .tab { flex: 1; justify-content: center; }
  .ed-kinds { display: flex; width: 100%; }
  .ed-kind { flex: 1; padding: 8px; min-height: 44px; }
  .ed-body { min-height: 260px; }
  .ed-items { grid-template-columns: minmax(0, 1fr); }
  .ed-item { display: grid; grid-template-columns: 96px minmax(0, 1fr); }
  .ed-thumb { aspect-ratio: auto; min-height: 96px; }
  .ed-alt { min-height: 44px; font-size: 16px; }
  .ed-item-actions { gap: 8px; }
  .ed-item-actions .icon-button { width: 44px; height: 44px; }
  .ed-dropzone { min-height: 130px; padding: 20px 14px; }
  .ed-footer, .ed-actions { flex-direction: column; align-items: stretch; }
  .ed-actions .button { width: 100%; }
  .ed-article-body { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .ed-kind, .ed-dropzone, .ed-progress::-webkit-progress-value { transition: none; }
}

/* Touch screens (a tablet is wider than the phone breakpoint, so this does not wait for it): nothing can be dropped, so say "choose"
   instead of "drop", and give every editor control a 44 px target. */
@media (pointer: coarse) {
  .drop-only { display: none; }
  .pick-only { display: inline; }
  .ed-kind { min-height: 44px; }
  .ed-alt { min-height: 44px; font-size: 16px; }
  .ed-item-actions .icon-button { width: 44px; height: 44px; min-height: 44px; }
  .ed-cancel .button { min-height: 44px; }
  .ed-dropzone { min-height: 150px; }
  .ed-cover-actions .button { min-height: 44px; }
}
