/*
 * Feature 91.2 — Editor vertical density.
 *
 * Presentation-only overrides for the shared Editor shell. These rules are
 * intentionally scoped to .editor-page and avoid document/export geometry.
 */

@media (min-width: 901px) {
  .editor-page .topbar {
    gap: 10px;
    padding: 9px 18px;
  }

  .editor-page .topbar .brand-mark {
    width: 30px;
    height: 30px;
  }

  .editor-page .brand-word {
    font-size: 21px;
  }

  .editor-page .topbar-actions,
  .editor-page .editor-tools {
    gap: 7px;
  }

  .editor-page .document-identity {
    width: 180px;
    max-width: 180px;
    flex: 0 0 180px;
    min-height: 34px;
    padding: 5px 8px;
  }

  .editor-page .save-status {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
    flex: 0 0 170px;
    padding: 5px 7px;
  }

  .editor-page .editor-pane {
    padding: 16px 18px 20px;
  }

  .editor-page .preview-pane {
    padding: 18px 18px 24px;
    gap: 9px;
  }

  .editor-page .preview-controls {
    padding: 3px;
  }

  .editor-page .template-chip {
    min-height: 30px;
    padding: 5px 10px;
  }

  .editor-page .preview-review-framing {
    padding: 7px 10px;
    gap: 8px;
    line-height: 1.35;
  }

  .editor-page .preview-top {
    margin-bottom: 4px;
  }

  .editor-page .quick-actions {
    padding: 3px;
  }

  .editor-page .preview-save-status {
    min-height: 30px;
    padding: 0 9px;
  }

  .editor-page .icon-btn {
    width: 30px;
    height: 30px;
  }

  .editor-page .quick-history-action {
    min-width: 88px;
  }

  .editor-page .local-save-explanation {
    margin-top: 8px;
    padding: 8px 11px;
    gap: 10px;
  }

  .editor-page .backup-reminder {
    margin: 8px auto 0;
    padding: 9px 12px;
    gap: 10px;
  }

  .editor-page .backup-reminder-icon {
    width: 32px;
    height: 32px;
  }

  .editor-page .backup-reminder-actions {
    gap: 6px;
  }
}

@media (min-width: 901px) and (max-width: 1650px) {
  .editor-page .topbar {
    padding-inline: 14px;
  }

  .editor-page .editor-tools .document-identity {
    width: 165px;
    max-width: 165px;
    flex-basis: 165px;
  }

  .editor-page .editor-tools .save-status {
    width: 145px;
    min-width: 145px;
    max-width: 145px;
    flex-basis: 145px;
  }
}

@media (max-width: 900px) {
  .editor-page .local-save-explanation,
  .editor-page .backup-reminder {
    margin-top: 8px;
  }
}

/*
 * Authenticated editor header refinement.
 *
 * Presentation-only: reuse the existing account control, market switcher,
 * document identity, and editor actions. No auth/session/editor behavior is
 * duplicated or moved into a new runtime component.
 */
.editor-page .topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 8px;
  align-items: center;
  padding-bottom: 10px;
}

/* Flatten only the layout wrapper so its existing children can form a
 * coherent two-level application shell without changing DOM ownership. */
.editor-page .topbar-actions {
  display: contents;
}

.editor-page .topbar > .brand {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

.editor-page .editor-back-nav {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  justify-self: start;
}

.editor-page .market-switcher {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

/* The international editor adds a language menu beside the market switcher. Both sit in one wrapper
 * that takes the market switcher's grid cell. */
.editor-page .editor-switchers {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-page .editor-switchers > .market-switcher {
  grid-column: auto;
  grid-row: auto;
  justify-self: auto;
}

.editor-page .account-control {
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
}

.editor-page .editor-tools {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  padding-top: 8px;
  justify-content: flex-end;
  border-top: 1px solid rgba(242, 239, 230, 0.1);
}

/* The avatar is the compact account affordance in the Editor. The summary
 * keeps its existing aria-label and the existing menu remains unchanged. */
.editor-page .account-menu-label {
  display: none;
}

.editor-page .account-menu-trigger {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 2px;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.055);
}

.editor-page .account-menu-trigger:hover,
.editor-page .account-menu[open] > .account-menu-trigger {
  background: rgba(255, 255, 255, 0.13);
}

.editor-page .account-avatar {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
}

.editor-page .topbar .market-switcher > summary {
  min-height: 36px;
  padding-block: 6px;
}

@media (min-width: 1200px) {
  /* Wide desktop has room for global navigation on row one while row two is
   * reserved for current-document context and work actions. */
  .editor-page .editor-back-nav {
    display: flex;
  }
}

@media (max-width: 900px) {
  .editor-page .topbar {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto auto;
    column-gap: 8px;
    row-gap: 7px;
    padding: 10px 12px 12px;
  }

  .editor-page .topbar > .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .editor-page .market-switcher {
    grid-column: 2;
    grid-row: 1;
  }

  .editor-page .editor-switchers {
    grid-column: 2;
    grid-row: 1;
  }

  .editor-page .editor-switchers > .market-switcher {
    grid-column: auto;
    grid-row: auto;
  }

  .editor-page .account-control {
    grid-column: 3;
    grid-row: 1;
  }

  .editor-page .editor-back-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    padding: 1px 0 3px;
    border-bottom: 1px solid rgba(242, 239, 230, 0.08);
  }

  .editor-page .editor-tools {
    grid-column: 1 / -1;
    grid-row: 3;
    padding-top: 0;
    border-top: 0;
  }

  .editor-page .account-menu-panel {
    right: 0;
    left: auto;
  }
}

@media (max-width: 620px) {
  .editor-page .topbar .market-switcher > summary {
    min-height: 36px;
    padding-inline: 8px;
  }

  .editor-page .topbar .market-switcher-menu {
    right: 0;
    left: auto;
  }

  .editor-page .account-sign-in {
    min-height: 36px;
    padding-inline: 9px;
  }
}

@media (max-width: 360px) {
  .editor-page .topbar .brand-word {
    display: none;
  }

  .editor-page .topbar .market-switcher-current {
    max-width: 62px;
  }
}

/*
 * UX-015 header collapse. On a phone the header was 205px: brand row, a Home/Workspace row, the
 * document chip and a New/More row. The chip, New (icon only) and More now share one row and the
 * Workspace link moves into More (the logo already links Home), leaving about 112px above the form.
 */
@media (max-width: 640px) {
  .editor-page .topbar {
    grid-template-rows: auto auto;
    row-gap: 8px;
  }

  .editor-page .editor-back-nav {
    display: none;
  }

  .editor-page .editor-tools {
    grid-row: 2;
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    align-items: stretch;
  }

  .editor-page .editor-tools .document-identity {
    grid-column: 1;
    min-height: 44px;
  }

  .editor-page .editor-tools .editor-new-action-wrapper {
    grid-column: 2;
  }

  .editor-page .editor-tools .editor-new-action {
    width: 44px;
    min-width: 44px;
    padding-inline: 0;
    justify-content: center;
  }

  .editor-page .editor-tools .editor-new-action > span {
    display: none;
  }

  .editor-page .editor-tools > .dropdown {
    grid-column: 3;
  }

  .editor-page .dropdown-item.mobile-nav-action {
    display: flex;
    color: inherit;
    text-decoration: none;
  }
}
