/**
 * Editorial Chassis (v2) — Writing Environment
 * Governance, Records, and Desk. Obsidian-grade focus experience.
 */

/* ── Stage wrapper ── */
.editorial-stage {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  --canvas-max: 740px;
}

/* ── Sticky Toolbar ── */
.editorial-toolbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-m);
  display: flex;
  align-items: center;
  height: 52px;
  z-index: 100;
  width: 100%;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.editorial-toolbar__left,
.editorial-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  flex-shrink: 0;
}

.editorial-toolbar__right {
  margin-left: auto;
}

.editorial-toolbar__group--center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Category head + dropdown — replaces the old flat 8-button row.
   Same structure on desktop and mobile: a single icon button per category
   (Inline, Headings, Insert, View) opens a dropdown with that category's
   original buttons. Keeps the toolbar's footprint constant regardless of
   how many formatting options exist within a category. ── */
.editorial-toolbar__category {
  position: relative;
}

.editorial-toolbar__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 4px;
  gap: 2px;
  z-index: 200;
}

.editorial-toolbar__category.open .editorial-toolbar__dropdown {
  display: flex;
}

.editorial-toolbar__cat-head.open {
  background: var(--hover);
  color: var(--text);
}

.editorial-toolbar__btn {
  background: none;
  border: none;
  color: var(--muted);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}

.editorial-toolbar__btn:hover,
.editorial-toolbar__btn.active {
  background: var(--hover);
  color: var(--text);
}

.editorial-toolbar__btn .material-symbols-outlined {
  font-size: 19px;
}

.editorial-toolbar__divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Type picker (toolbar select) ── */
.editorial-type-picker {
  height: 32px;
  padding: 0 var(--space-s);
  font-size: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  font-weight: 500;
  transition: border-color 0.12s;
}

.editorial-type-picker:hover,
.editorial-type-picker:focus {
  border-color: var(--primary);
}

.editorial-type-picker option,
.editorial-type-picker optgroup {
  background: var(--bg);
  color: var(--text);
}

/* ── Status label ── */
.editorial-status {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
}

.editorial-status.pulse {
  animation: save-pulse 1.6s ease;
}

@keyframes save-pulse {
  0%   { color: var(--muted); }
  25%  { color: var(--primary); }
  75%  { color: var(--primary); }
  100% { color: var(--muted); }
}

/* ── Save CTA ── */
.editorial-save-btn {
  padding: 0 var(--space-m);
  height: 34px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.editorial-save-btn__icon {
  display: none; /* desktop: label only, shown on mobile below */
  font-size: 18px;
}

/* ── Writing Canvas ── */
.editorial-canvas {
  flex: 1;
  padding: 56px var(--space-l) 120px;
  max-width: calc(var(--canvas-max) + 2 * var(--space-l));
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ── Title input ── */
.editorial-title-input {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--ff-display);
  font-size: 36px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  caret-color: var(--accent-red);
}

.editorial-title-input::placeholder {
  color: var(--muted);
  opacity: 0.4;
  font-weight: 700;
}

/* ── Summary / lead paragraph input ── */
.editorial-summary-input {
  display: block;
  width: 100%;
  min-height: 60px;
  border: none;
  border-left: 3px solid var(--border);
  background: transparent;
  outline: none;
  resize: none;
  padding: 4px 0 4px 16px;
  font-family: var(--ff-body);
  font-size: 16px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 32px;
  caret-color: var(--accent-red);
  transition: border-color 0.15s;
}

.editorial-summary-input:focus {
  border-left-color: var(--primary);
  color: var(--text);
}

.editorial-summary-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* ── Body textarea ── */
.editorial-editor-textarea {
  display: block;
  width: 100%;
  min-height: 72vh;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  padding-bottom: 120px;
  font-family: var(--ff-body);
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  caret-color: var(--accent-red);
}

.editorial-editor-textarea::placeholder {
  color: var(--muted);
  opacity: 0.35;
}

/* ── Preview pane ── */
.editorial-preview-pane {
  width: 100%;
  min-height: 72vh;
  padding-bottom: 120px;
  line-height: 1.85;
  color: var(--text);
}

.editorial-preview-pane h1 {
  font-family: var(--ff-display);
  font-size: 28px;
  font-weight: 800;
  margin: 2em 0 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.editorial-preview-pane h2 {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 700;
  margin: 1.8em 0 0.4em;
  color: var(--text);
}

.editorial-preview-pane h3 {
  font-family: var(--ff-display);
  font-size: 17px;
  font-weight: 700;
  margin: 1.5em 0 0.3em;
  color: var(--text);
}

.editorial-preview-pane h4,
.editorial-preview-pane h5,
.editorial-preview-pane h6 {
  font-family: var(--ff-display);
  font-size: 15px;
  font-weight: 700;
  margin: 1.3em 0 0.3em;
  color: var(--text);
}

.editorial-preview-pane h5 {
  font-size: 14px;
}

.editorial-preview-pane h6 {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.editorial-preview-pane del {
  color: var(--muted);
}

.editorial-preview-pane table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.2em;
  font-size: 0.92em;
}

.editorial-preview-pane th,
.editorial-preview-pane td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.editorial-preview-pane th {
  background: var(--card-2);
  font-weight: 700;
}

.editorial-preview-pane li input[type="checkbox"] {
  margin-right: 6px;
}

.editorial-preview-pane p {
  margin-bottom: 1.2em;
}

.editorial-preview-pane blockquote {
  border-left: 3px solid var(--accent-red);
  padding-left: 1.2em;
  margin: 1.5em 0;
  font-style: italic;
  color: var(--muted);
}

.editorial-preview-pane ul,
.editorial-preview-pane ol {
  padding-left: 1.8em;
  margin-bottom: 1.2em;
}

.editorial-preview-pane li {
  margin-bottom: 0.3em;
}

.editorial-preview-pane code {
  background: var(--card-2);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.88em;
}

.editorial-preview-pane pre {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 1.2em;
}

.editorial-preview-pane pre code {
  background: none;
  padding: 0;
}

.editorial-preview-pane a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.editorial-preview-pane hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* ── Focus Mode ──
   Hides the surrounding shell chrome (context bar, options bar, top bar,
   primary sidebar) so the canvas gets full width. Deliberately does NOT
   touch .editorial-toolbar's size/position/visibility — an earlier version
   of this rule resized the toolbar to a fixed 700px and hid it behind
   opacity:0 until hovered, which read as "Focus Mode changes the
   toolbar's behavior" rather than "Focus Mode hides the chrome around the
   toolbar" (Chizola, 2026-06-23). The toolbar should look identical
   in and out of Focus Mode.

   The 4 selectors below were also wrong before this fix — #ws-context-bar,
   #ws-options-bar, .ws-topbar, .ws-primary-sidebar don't exist anywhere in
   workspace_shell.html (confirmed by grep — real ids/classes are
   #ics-context-bar, #ics-options-bar, .ics-stage__topbar, .ics-sidebar).
   None of the four ever matched, so Focus Mode never actually hid any
   chrome at all, on top of the toolbar bug — fixed both in the same pass. ── */
body.focus-mode #ics-context-bar,
body.focus-mode #ics-options-bar,
body.focus-mode .ics-stage__topbar,
body.focus-mode .ics-sidebar {
  display: none !important;
}

body.focus-mode #main-stage {
  margin: 0 !important;
  max-width: 100% !important;
}

body.focus-mode .editorial-canvas {
  max-width: 700px;
  margin: 0 auto;
  padding-top: 80px;
}

/* ── Mobile (<1024px) — the Desk editor on phone/narrow viewports ── */
@media (max-width: 1023px) {
  /* Toolbar: drop absolute centering (nowhere to center into on a phone
     width) — 4 category-head buttons fit a fixed row without needing the
     scroll mechanism the flat 8-button row used to require. */
  .editorial-toolbar {
    padding: 0 var(--space-s);
    gap: var(--space-s);
  }

  .editorial-toolbar__left {
    display: none; /* "Steward drafting…" status — desktop-only, no room on phone */
  }

  .editorial-toolbar__group--center {
    position: static;
    transform: none;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }

  .editorial-toolbar__right {
    flex-shrink: 0;
  }

  /* Save button: icon only on mobile, full label stays desktop-only —
     the label was the single biggest space consumer in the toolbar's
     right-hand group. */
  .editorial-save-btn {
    padding: 0 10px;
  }

  .editorial-save-btn__icon {
    display: block;
  }

  .editorial-save-btn__label {
    display: none;
  }

  /* Canvas: desktop's generous 56px top / 120px bottom padding is dead
     space on a phone. The mobile lifecycle bar in record.html's mobile
     block is `position: fixed; bottom: 64px` (above the bottom nav) and
     sits outside document flow, so no canvas padding can make room for
     it — it can overlap canvas content regardless. Padding here only
     reduces how much gets hidden, it can't fully solve the overlap; see
     editorial_v2.css's comment trail / web-ui-mobile-strategy.md for the
     real fix (give the lifecycle bar a non-fixed home in the flow). */
  .editorial-canvas {
    padding: 20px var(--space-s) 140px;
    max-width: 100%;
  }

  .editorial-title-input {
    font-size: 26px;
    margin-bottom: 14px;
  }

  .editorial-summary-input {
    font-size: 15px;
    margin-bottom: 20px;
  }

  .editorial-editor-textarea,
  .editorial-preview-pane {
    font-size: 16px; /* keep >=16px so iOS Safari doesn't auto-zoom on focus */
    min-height: 60vh;
  }

  .editorial-preview-pane {
    padding: 0;
  }
}

/* ── Context navigation (Desk context bar) ── */
.ics-context-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ics-context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.ics-context-item:hover {
  background: var(--hover);
  color: var(--text);
}

.ics-context-item .material-symbols-outlined {
  font-size: 17px;
  color: var(--primary);
  flex-shrink: 0;
}

/* ── Draft items in context bar ── */
.ws-draft-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.12s, background 0.12s;
}

.ws-draft-item:hover {
  background: var(--hover);
  border-color: var(--border);
}
