/* =============================================================================
   Page Layout System

   This file owns all flex layout rules for the page editor.
   Consolidated here to avoid conflicts with pages.css.

   Layout hierarchy:
   .page-content
     └── turbo-frame (scroll container)
           └── .content
                 └── turbo-frame (nested)
                       └── [id^="page_"][id$="_content"]
                             └── form
                                   └── .mark-editor-wrapper
                                         ├── .mark-container
                                         └── .empty-state-overlay
   ============================================================================= */

/* Page content - flex column to fill available space */
.page-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Main turbo-frame - scroll container */
.page-content > turbo-frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Content wrapper */
.content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Nested turbo-frames */
.content > turbo-frame,
.page-content .content > turbo-frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

[id^="page_"][id$="_content"] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

[id^="page_"][id$="_content"] > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.mark-editor-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mark-editor-wrapper .mark-container {
  flex: 1;
}

.empty-state-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ntabs-bg-primary, #ffffff);
  z-index: 250;
  cursor: text;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.empty-state-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: text;
}

.empty-state-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  max-width: 22rem;
  text-align: center;
}

/* The invitation, and it is the only thing here. It used to be the small grey
 * line above four template buttons, which made the buttons read as the thing
 * to do on an empty page. */
.empty-state-hint {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 550;
  color: var(--ntabs-text-primary, #374151);
}

.empty-state-sub {
  margin: 0 0 0.9rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ntabs-text-secondary, #9ca3af);
}

.empty-state-shortcut {
  font-size: 0.65rem;
  color: var(--ntabs-text-secondary, #9ca3af);
  margin: 0;
  opacity: 0.6;
}

.empty-state-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-family: inherit;
  font-size: 0.55rem;
  font-weight: 500;
  background: var(--ntabs-bg-tertiary, #f3f4f6);
  border: 1px solid var(--ntabs-border, #e5e7eb);
  border-radius: 3px;
  color: var(--ntabs-text-primary, #374151);
}

/* Dark mode */
.mark-dark .empty-state-overlay,
[data-theme="dark"] .empty-state-overlay {
  background: var(--mark-bg-primary, #0d1117);
}

/* The hint carries the page's own text colours, so it needs no dark rule of
 * its own beyond what the tokens already give it. */
.mark-dark .empty-state-hint,
[data-theme="dark"] .empty-state-hint {
  color: #e5e5e5;
}

.mark-dark .empty-state-shortcut kbd,
[data-theme="dark"] .empty-state-shortcut kbd {
  background: #2d2d3d;
  border-color: #3d3d4d;
  color: #e5e5e5;
}

/* Persistent shortcut hint at bottom of page */
.shortcut-hint-persistent {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--ntabs-text-secondary, #9ca3af);
  z-index: 5;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

/* Hide persistent hint when empty state is visible */
.main-content:has(.empty-state-overlay:not(.hidden)) .shortcut-hint-persistent {
  display: none;
}

.shortcut-hint-persistent:hover {
  opacity: 1;
}

.shortcut-hint-persistent kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-family: inherit;
  font-size: 0.55rem;
  font-weight: 500;
  background: var(--ntabs-bg-tertiary, #f3f4f6);
  border: 1px solid var(--ntabs-border, #e5e7eb);
  border-radius: 3px;
  color: var(--ntabs-text-primary, #374151);
}

[data-theme="dark"] .shortcut-hint-persistent kbd {
  background: #2d2d3d;
  border-color: #3d3d4d;
  color: #e5e5e5;
}

/* A keyboard hint on a device with no keyboard. Pointer type, not viewport
 * width, is what says whether Ctrl+/ can be pressed. */
@media (pointer: coarse) {
  .shortcut-hint-persistent { display: none; }
}

/* A phone has no Ctrl key, so the shortcut line is advice nobody there can
 * take. It also sat directly under the one sentence that matters. */
@media (max-width: 700px) {
  .empty-state-shortcut { display: none; }
  .empty-state-content { max-width: 18rem; }
  .empty-state-sub { margin-bottom: 0; font-size: 0.82rem; }
}

/* One of the two, never both. The pointer decides, not the width. */
.empty-state-sub-touch { display: none; }

@media (pointer: coarse) {
  .empty-state-sub-mouse { display: none; }
  .empty-state-sub-touch { display: inline; }
}
