/* RavText V2 layout — stage 1: one slim, document-style header (2026-10-30).
   Owner-approved redesign ("גרסה 2"). Follows the pattern of leading editors
   (Google Docs / Word online): brand + live status on one line, quiet text
   actions, account at the end.
   Scope rules:
   - Every rule requires body.rt-modern-interface (default style; any other
     style in the "סגנון" picker restores the previous header untouched).
   - Screen only; no editor text, stream colours, rendered pages, print or PDF.
   - No DOM is moved: the header row is laid out with CSS grid only. */

@media screen and (min-width: 1100px) {
  /* Brand · status · actions on a single line. The inner row dissolves so its
     two children can share the header grid with the status row. */
  body.rt-modern-interface header.app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 8px;
    padding: 8px 18px;
  }
  body.rt-modern-interface header.app-header > .app-header-row {
    display: contents;
  }
  body.rt-modern-interface header.app-header .app-title-block {
    grid-column: 1;
    grid-row: 1;
  }
  body.rt-modern-interface header.app-header > .rt-header-status-row {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  body.rt-modern-interface header.app-header .app-header-actions {
    grid-column: 3;
    grid-row: 1;
    flex-wrap: nowrap;
  }
  /* One-line status, truncated with an ellipsis; full text stays in the DOM. */
  body.rt-modern-interface header.app-header #status.status-row {
    flex: 1 1 180px;
    min-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* The simple workflow opens as a full panel: give it its own full row. */
  body.rt-modern-interface header.app-header > .rt-header-status-row:has(.ravtext-simple-workflow:not([data-mode="professional"])) {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
  }
}

/* Below 1600px the slim header keeps status and the mode switch on a second line. */
@media screen and (min-width: 1100px) and (max-width: 1599px) {
  body.rt-modern-interface header.app-header > .rt-header-status-row {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media screen and (max-width: 1099px) {
  body.rt-modern-interface header.app-header > .rt-header-status-row,
  body.rt-modern-interface header.app-header #rt-header-utilities,
  body.rt-modern-interface header.app-header #rt-header-utilities .sw-header {
    flex-wrap: wrap;
    row-gap: 6px;
    max-width: 100%;
    min-width: 0;
  }
}

@media screen {
  /* Brand: compact name, decorative tagline hidden (kept for screen readers). */
  body.rt-modern-interface header.app-header .app-title-block h1 {
    font-size: 17px;
    line-height: 1.2;
    margin: 0;
    gap: 8px;
  }
  body.rt-modern-interface header.app-header .app-title-block .app-logo {
    width: 28px;
    height: 28px;
  }
  body.rt-modern-interface header.app-header .app-subtitle {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* Live status reads like "All changes saved" next to the title. */
  body.rt-modern-interface header.app-header #status.status-row {
    margin: 0;
    padding: 4px 10px;
    border: 0;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: none;
  }
  body.rt-modern-interface header.app-header #rt-header-utilities {
    flex: 0 0 auto;
    margin: 0;
  }

  /* Actions: quiet text buttons, like a document app's menu row. */
  body.rt-modern-interface header.app-header .app-header-actions {
    gap: 2px;
  }
  body.rt-modern-interface header.app-header .app-header-actions :is(
    #btn-troubleshooting,
    .rt-tp-btn,
    #rt-prem-icon-faq,
    #rt-prem-icon-settings,
    #rt-prem-icon-downloads,
    #rt-prem-icon-gift,
    #rt-prem-timer,
    .rt-header-help-trigger
  ) {
    min-height: 34px;
    padding: 4px 10px;
    font-size: 13px;
  }
  body.rt-modern-interface header.app-header .app-header-actions #app-version-display {
    font-size: 11px;
    margin: 0 4px;
  }
}

/* Light default theme: borderless actions that only show a surface on hover. */
@media screen {
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) header.app-header .app-header-actions :is(
    #btn-troubleshooting,
    .rt-tp-btn,
    #rt-prem-icon-faq,
    #rt-prem-icon-settings,
    #rt-prem-icon-downloads,
    #rt-prem-icon-gift,
    #rt-prem-timer,
    .rt-header-help-trigger
  ) {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) header.app-header .app-header-actions :is(
    #btn-troubleshooting,
    .rt-tp-btn,
    #rt-prem-icon-faq,
    #rt-prem-icon-settings,
    #rt-prem-icon-downloads,
    #rt-prem-icon-gift,
    #rt-prem-timer,
    .rt-header-help-trigger
  ):hover {
    background: #EEF1F5;
    border-color: #E2E5EA;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) header.app-header #status.status-row {
    color: #4A5466;
    background: transparent;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) header.app-header #app-version-display {
    color: #5B6474;
    opacity: 1;
  }
}

/* ------------------------------------------------------------------------
   Stage 2: the simple-mode panel ("מכאן מתחילים") becomes a welcome hub,
   like the start screens of Word, Docs and Notion: a heading, one search
   box, a primary "continue" action, start tiles and a quiet 3-step guide.
   Same buttons and handlers. Visual order always follows DOM order (header,
   steps, actions, search, footer) so keyboard focus moves predictably.
   ------------------------------------------------------------------------ */
@media screen {
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) {
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
    width: min(1180px, calc(100% - 24px));
    margin: 12px auto 6px;
    padding: 20px clamp(14px, 3vw, 28px) 14px;
    border-radius: 16px;
  }
  /* Heading block, centered; mode and tour buttons sit quietly beneath. */
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    text-align: center;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-heading {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-title {
    font-family: "Frank Ruhl Libre", "David Libre", serif;
    font-size: clamp(22px, 2.4vw, 28px);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-subtitle {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    max-width: 560px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) :is(#sw-mode, #sw-tour-launch) {
    min-height: 36px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
  }

  /* One prominent search box directly under the heading. */
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-search {
    display: flex;
    justify-content: center;
    position: relative;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-search-input {
    box-sizing: border-box;
    width: min(580px, 100%);
    min-height: 48px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 15px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-results {
    width: min(580px, 100%);
  }

  /* Start actions as tiles; the primary "continue" spans the full row. */
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-stage {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
    padding: 0;
    border: 0;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-stage-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 auto;
    text-align: start;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-stage-title {
    font-size: 16px;
    font-weight: 700;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-stage-description {
    margin: 0;
    font-size: 14px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    flex: 0 0 auto;
    width: 100%;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions .sw-action {
    box-sizing: border-box;
    min-height: 52px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    text-align: start;
    display: flex;
    align-items: flex-end;
    white-space: normal;
    transition: border-color .15s ease, box-shadow .15s ease;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions .sw-action.sw-primary {
    grid-column: 1 / -1;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px;
  }

  /* The three steps become a quiet progress guide. */
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-steps .sw-step {
    min-height: 40px;
    border-radius: 10px;
    font-size: 14px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-footer {
    font-size: 12px;
  }
}
/* Wide screens: two columns so the hub stays short and the editor below
   keeps its height (the app is a fixed-viewport layout). */
@media screen and (min-width: 900px) {
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    grid-template-areas:
      "head   stage"
      "steps  stage"
      "search foot"
      "tour   tour";
    align-items: end;
    column-gap: 28px;
    row-gap: 14px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-header { grid-area: head; }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-search { grid-area: search; }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-steps { grid-area: steps; }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-stage { grid-area: stage; }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-tour-panel { grid-area: tour; }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-footer { grid-area: foot; }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-search-input {
    width: 100%;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-steps .sw-step {
    min-height: 34px;
    font-size: 13px;
  }  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions .sw-action {
    min-height: 48px;
    font-size: 14px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) .sw-footer .sw-document-states {
    flex: 1 1 auto;
  }
  body.rt-modern-interface .ravtext-simple-workflow:not([data-mode="professional"]) #sw-subtitle {
    font-size: 14px;
  }
}
@media screen and (prefers-reduced-motion: reduce) {
  body.rt-modern-interface .ravtext-simple-workflow #sw-actions .sw-action {
    transition: none;
  }
}

/* Stage 2 colours (default light theme only). */
@media screen {
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) .ravtext-simple-workflow:not([data-mode="professional"]) {
    background: #FFFFFF;
    border: 1px solid #E2E5EA;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 32px rgba(16, 24, 40, .06);
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) .ravtext-simple-workflow:not([data-mode="professional"]) :is(#sw-subtitle, #sw-stage-description, .sw-footer) {
    color: #4A5466;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) .ravtext-simple-workflow:not([data-mode="professional"]) #sw-search-input {
    border-color: #D5DAE1;
    background: #FFFFFF;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions .sw-action:not(.sw-primary) {
    background: #FFFFFF;
    border-color: #E2E5EA;
    color: #1A2233;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) .ravtext-simple-workflow:not([data-mode="professional"]) #sw-actions .sw-action:not(.sw-primary):hover {
    border-color: #B7C2D2;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .08);
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) .ravtext-simple-workflow:not([data-mode="professional"]) .sw-steps .sw-step:not([aria-selected="true"]) {
    background: #F7F8FA;
    border-color: #E2E5EA;
    color: #4A5466;
  }
}

/* ------------------------------------------------------------------------
   Stage 3: workspace. Word/Docs pattern — a tighter frame, the ribbon flush
   with its panel, and the editing panes as white sheets on a quiet canvas.
   Chrome only: pane contents, editor text and rendered pages are untouched.
   ------------------------------------------------------------------------ */
@media screen {
  /* More room for work: slimmer outer margins between the two panels. */
  body.rt-modern-interface main.main {
    padding: 12px 14px 40px;
    gap: 14px;
  }
  body.rt-modern-interface main.main > .panel {
    border-radius: 12px;
  }
  /* Ribbon reads as one bar with an underline, not a box inside a box. */
  body.rt-modern-interface main.main #ribbon-tabs.ribbon-tabs {
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
  }
  body.rt-modern-interface main.main #rt-home-quickbar {
    border-radius: 8px;
    box-shadow: none;
  }
  body.rt-modern-interface main.main #nested-notes-row {
    min-height: 0;
    font-size: 13px;
  }
  body.rt-modern-interface main.main #stream-menu-ribbon-open-btn {
    border-radius: 8px;
    font-size: 13px;
  }
  /* Panes: sheets on a canvas. */
  /* Gaps stay on the user's configurable stream-gap variables: the
     side-by-side control sizes panes from them (pane_side_by_side_controls). */
  body.rt-modern-interface main.main #panes-container {
    border-radius: 10px;
    padding: 10px;
  }
  body.rt-modern-interface main.main #panes-container .pane {
    border-radius: 10px;
  }
  /* Preview: a document viewer. */
  body.rt-modern-interface main.main .preview-pane > h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
  }
  body.rt-modern-interface main.main .preview-pane #pdf-toolbar {
    border-radius: 8px;
  }
}

/* Stage 3 colours (default light theme only). */
@media screen {
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) main.main #panes-container {
    background: #EEF0F3;
    border-color: #E2E5EA;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) main.main #panes-container .pane {
    border-color: #E2E5EA;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .04);
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) main.main #stream-menu-ribbon-open-btn {
    border-color: #D5DAE1;
    background: #FFFFFF;
    color: #1A2233;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) main.main #stream-menu-ribbon-open-btn:hover {
    background: #EEF1F5;
  }
  body.rt-modern-interface.light-theme:not([data-theme]:not([data-theme="light"])) main.main #nested-notes-row {
    color: #4A5466;
  }
}
