/* SAR Editorial Assistant — entry-detail removals.
 *
 * Presentation only. Nothing here changes workflow behavior; every rule hides
 * something the editor does not need on the front-end gravityflow-inbox entry
 * page. Selectors are taken from the rendered markup of entry 951, not guessed.
 *
 * Scoping: .gravityflow_workflow_detail is on Gravity Flow's own wrapper and
 * appears only on the entry-detail view, so it keeps these rules off the inbox
 * list that shares the same WordPress page. No body class needed.
 *
 * Two rules deliberately use :has() to scope on state rather than on position,
 * because position-based selectors break the first time a block is reordered.
 */

/* ---------------------------------------------------------------------------
 * 1. Native Approve / Reject
 *
 * Safe to hide: the panel's Send calls Gravity_Flow_API::send_to_step(), which
 * completes the current step, so these buttons are redundant rather than
 * load-bearing. Hidden with CSS rather than suppressed server-side — killing
 * the section that renders them would take the panel's mount point with it.
 *
 * :has(.gravityflow-step-approval) restricts this to approval steps. The
 * contributor edit page is a User Input step and also renders
 * .gravityflow-action-buttons for its Submit button; that must keep working.
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail:has(.gravityflow-step-approval) .gravityflow-action-buttons {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 2. Workflow Note
 *
 * Not in the wireframe. The editor's reasoning goes into the contributor email,
 * not a parallel internal note. The label sits in .gravityflow-status-box-field-note
 * and the textarea in an unclassed sibling span, so the adjacent-sibling
 * selector is what reaches both.
 *
 * Only safe while the step's Note setting is not required — the rendered
 * <span class="gfield_required"> is empty, confirming it is not.
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail .gravityflow-status-box-field-note,
.gravityflow_workflow_detail .gravityflow-status-box-field-note + .gravityflow-status-box-field-value {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 3. "show empty fields" checkbox
 *
 * Hides the whole table header cell rather than the input and label
 * separately, so no empty 140px column is left behind.
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail .entry-detail-view thead th:has(#gentry_display_empty_fields) {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 4. GP Nested Forms parent-entry box
 *
 * The parent link is preserved in the Admin block (see
 * class-sar-ea-entry-admin.php), which omits the row entirely when there is no
 * parent instead of announcing its absence.
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail .postbox.child-forms {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 5. Admin actions dropdown
 *
 * The box has no class of its own; the select does. Scoping on the select is
 * more durable than nth-child.
 *
 * NOTE: this is send-to-step and cancel-workflow — the same "not useful until
 * it is" escape hatch William wanted the parent link for. Confirm with him
 * before keeping this rule; the Admin block links to wp-admin but does not
 * replace these actions.
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail .postbox:has(#gravityflow-admin-action) {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 6. Print button and its "include timeline" checkbox
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail .detail-view-print {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 7. Page furniture above the inbox block
 *
 * The Poetry/Prose/Art buttons and the Analytics/Editorial Calendar links live
 * in a Columns block in .entry-content, outside Gravity Flow's wrapper, so they
 * need a page-level scope.
 *
 * REQUIRES a class on that Columns block: open the page in the block editor,
 * select the outer Columns block, and add "sar-inbox-nav" under
 * Advanced -> Additional CSS class(es). Targeting it positionally instead would
 * break the first time the block order changes.
 * ------------------------------------------------------------------------- */
body:has(.gravityflow_workflow_detail) .sar-inbox-nav {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * 8. Step instructions
 *
 * Now active. The tier definitions have moved into the panel's Editorial
 * Decision Guidelines disclosure, directly above the buttons they describe,
 * so this box in the left column is a duplicate.
 *
 * KEEP the step's Instructions setting populated — the panel reads its copy
 * from there. Emptying it would fall the disclosure back to
 * SAR_EA_Config::GUIDELINES_FALLBACK and lose the ability to reword without a
 * deploy.
 * ------------------------------------------------------------------------- */
.gravityflow_workflow_detail .postbox.gravityflow-instructions {
	display: none !important;
}

/* ===========================================================================
 * LAYOUT — full-width workflow pages
 *
 * Two independent constraints had to come off:
 *
 *   1. The page cap. .sar-main is is-layout-constrained (wide-size 1280px) and
 *      the Post Content block constrains its children to 680px. The theme's
 *      Additional CSS worked around this with `.entry-content { width: 1000px }`
 *      and `.gravityflow_workflow_detail { width: 1000px }` — DELETE BOTH, they
 *      are `width` rather than `max-width` and will fight these rules.
 *
 *   2. The sidebar cap. Gravity Flow reuses wp-admin's postbox layout, which
 *      floats #postbox-container-1 at a fixed ~280px. This is the one that
 *      matters: without it, extra page width goes entirely to the piece and the
 *      review stays a narrow ribbon.
 *
 * Scoped via :has([class*="gravityflow"]) so it catches both the inbox list and
 * the entry detail without needing to know the list block's exact wrapper class,
 * and touches no other page on the site.
 * ======================================================================== */

/* --- 1. Release the page caps ------------------------------------------- */
body:has([class*="gravityflow"]) .sar-main,
body:has([class*="gravityflow"]) .sar-main > .wp-block-group,
.entry-content:has([class*="gravityflow"]),
.entry-content:has([class*="gravityflow"]) > * {
	max-width: none !important;
	width: auto !important;
}

/* Root padding stays — full width, not full bleed. A 24px gutter keeps the
   first character of the piece off the viewport edge. */

/* --- 2. Two real columns ------------------------------------------------- */
/* Replaces the float layout with a grid. minmax(0, …) is load-bearing: grid
   items default to min-width:auto, and the long unbroken review text would
   otherwise blow the column out rather than wrap. */
.gravityflow_workflow_detail #poststuff #post-body.columns-2 {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: var(--wp--preset--spacing--60, 36px);
	align-items: start;
}

.gravityflow_workflow_detail #post-body.columns-2 > #post-body-content,
.gravityflow_workflow_detail #post-body.columns-2 > #postbox-container-1 {
	float: none;
	width: auto;
	min-width: 0;
	margin: 0;
	padding: 0;
}

/* The timeline container is a third region below both columns, not a sidebar
   child. It should span the full grid when present — though with the block's
   Timeline toggle off and the Admin block re-rendering it, it will normally be
   empty. */
.gravityflow_workflow_detail #post-body.columns-2 > #postbox-container-2 {
	grid-column: 1 / -1;
	float: none;
	width: auto;
	min-width: 0;
	margin: 0;
}

/* wp-admin's #poststuff carries min-width: 763px, which forces horizontal
   scroll on phones. */
.gravityflow_workflow_detail #poststuff {
	min-width: 0;
}

/* --- 3. Stack on narrow viewports --------------------------------------- */
@media (max-width: 781px) {
	.gravityflow_workflow_detail #poststuff #post-body.columns-2 {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* --- 2b. Clear the float-layout gutters ---------------------------------
 * Gravity Flow reserves space for the floated sidebar with
 * `#poststuff #post-body.columns-2 { margin-right: 280px }`. Converting to grid
 * above removed the float but left the reserved gutter, so the grid container
 * stopped 280px short of the right edge.
 *
 * SPECIFICITY: that rule is two IDs plus a class. Every selector in sections 2
 * and 2b that targets #post-body must therefore carry #poststuff as well —
 * `.gravityflow_workflow_detail #post-body.columns-2` is one ID plus two
 * classes and loses. The grid properties landed anyway only because Gravity
 * Flow sets no `display` on that rule; the margin did not.
 *
 * .wrap also carries wp-admin's own `margin: 10px 20px 0 2px`, which puts the
 * two columns on a slightly different left edge than the inbox list above it.
 * ---------------------------------------------------------------------- */
.gravityflow_workflow_detail.wrap,
.gravityflow_workflow_detail #poststuff,
.gravityflow_workflow_detail #poststuff #post-body.columns-2 {
	margin-left: 0;
	margin-right: 0;
	padding-left: 0;
	padding-right: 0;
}
