/* =========================================================
   PolicyTrade Subscribe — CTA in nav + modal styling

   Two surfaces:
     1. The .pt-subscribe-btn rendered into the primary nav as a CTA
     2. The .pt-subscribe-modal <dialog> rendered into wp_footer

   Brand colour: #496d5f (the POM green used across
   the masthead lockup, the Official News rail eyebrow, and the
   footer accent). Hover ramps to #375247 (the lighter-maroon used
   on link hovers throughout the site).
   ========================================================= */

/* ----- CTA in masthead (top-right) -----
   Injected via newspack_header_before_mobile_toggle into the flex
   .middle-header-contain .wrapper row. margin-left:auto pushes it past
   the logo/search block to the right edge; the row's align-items:center
   vertically centres it with the logo lockup. */

.pt-masthead-cta {
	margin-left: auto;
	margin-right: 1.25rem;
	display: flex;
	align-items: center;
}

/* ----- Three-zone masthead (desktop) -----
   Rebalances the centred-logo masthead into three flanks:
       [search]        [logo lockup]        [Subscribe]
   The Newspack header row (.middle-header-contain .wrapper) ships as a
   flex/space-between row whose children are an empty social-nav (left),
   the logo, the search-bearing .nav-wrapper, and our .pt-masthead-cta —
   which clusters search + subscribe on the right and orphans the left
   flank. A 1fr/auto/1fr grid keeps the logo dead-centre regardless of
   flank width and lets us place search left and Subscribe right.

   Scoped to >=783px: that's where Newspack shows .nav-wrapper (search)
   and the .bottom-header-contain primary-nav row, so the redundant
   mobile hamburger can be hidden here without losing menu access. Below
   783px the row keeps Newspack's default flex layout (logo · Subscribe ·
   hamburger), and the hamburger stays the menu trigger. */
@media (min-width: 783px) {
	.middle-header-contain .wrapper {
		display: grid;
		grid-template-columns: 1fr auto 1fr;
		align-items: center;
	}

	.middle-header-contain .wrapper > .nav-wrapper {
		grid-column: 1;
		grid-row: 1;
		justify-self: start;
	}

	.middle-header-contain .wrapper > .site-branding {
		grid-column: 2;
		grid-row: 1;
		justify-self: center;
	}

	.middle-header-contain .wrapper > .pt-masthead-cta {
		grid-column: 3;
		grid-row: 1;
		justify-self: end;
		margin: 0;          /* grid placement handles alignment; drop the flex-era auto margins */
	}

	/* Empty header social-nav (social lives in the footer) and the
	   redundant hamburger would otherwise add stray grid cells. */
	.middle-header-contain .wrapper > #social-nav-contain,
	.middle-header-contain .wrapper > .mobile-menu-toggle {
		display: none;
	}
}

.pt-subscribe-btn {
	background: #496d5f;
	color: #fff;
	font-family: Inter, sans-serif;
	font-weight: 600;
	font-size: 0.8125rem;
	text-transform: none;
	letter-spacing: 0;
	padding: 0.5rem 1.25rem;
	border: none;
	border-radius: 2px;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.pt-subscribe-btn:hover,
.pt-subscribe-btn:focus-visible {
	background: #375247;
}

.pt-subscribe-btn:focus-visible {
	outline: 2px solid #375247;
	outline-offset: 2px;
}

/* ----- Modal ----- */

.pt-subscribe-modal {
	max-width: 480px;
	width: 90vw;
	padding: 2.5rem 2rem 2rem;
	border: 1px solid #ddd;
	border-radius: 4px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	font-family: Inter, sans-serif;
}

.pt-subscribe-modal::backdrop {
	background: rgba(0, 0, 0, 0.5);
}

.pt-subscribe-close {
	position: absolute;
	top: 0.5rem;
	right: 0.75rem;
	background: transparent;
	border: none;
	font-size: 1.75rem;
	line-height: 1;
	color: #666;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
}

.pt-subscribe-close:hover {
	color: #000;
}

.pt-subscribe-modal h2 {
	font-family: Fraunces, Georgia, serif;
	font-size: 1.5rem;
	font-weight: 500;
	margin: 0 0 0.5rem;
	color: #1a1a1a;
}

.pt-subscribe-intro {
	color: #555;
	font-size: 0.95rem;
	margin: 0 0 1.5rem;
}

.pt-subscribe-form {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.pt-subscribe-form input[type="email"] {
	padding: 0.75rem 1rem;
	border: 1px solid #ccc;
	border-radius: 2px;
	font-size: 1rem;
	font-family: inherit;
}

.pt-subscribe-form input[type="email"]:focus {
	outline: none;
	border-color: #496d5f;
	box-shadow: 0 0 0 2px rgba(138, 47, 47, 0.15);
}

.pt-subscribe-submit {
	background: #496d5f;
	color: #fff;
	border: none;
	padding: 0.75rem 1rem;
	font-family: Inter, sans-serif;
	font-weight: 600;
	font-size: 0.95rem;
	cursor: pointer;
	border-radius: 2px;
	transition: background-color 0.15s ease;
}

.pt-subscribe-submit:hover,
.pt-subscribe-submit:focus-visible {
	background: #375247;
}

.pt-subscribe-disclaimer {
	margin: 1.25rem 0 0;
	font-size: 0.8rem;
	color: #888;
	line-height: 1.5;
}

/* ----- Screen-reader-only utility -----
   Newspack already ships a .screen-reader-text rule; this is
   defensive in case the modal renders on a page where the parent's
   stylesheet hasn't loaded yet. Same offscreen-1px-square pattern. */
.pt-subscribe-modal .screen-reader-text {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ----- Mobile ----- */

@media (max-width: 640px) {
	.pt-masthead-cta {
		margin-right: 0.5rem;
	}

	.pt-subscribe-btn {
		padding: 0.4rem 0.85rem;
		font-size: 0.8125rem;
	}

	.pt-subscribe-modal {
		padding: 2.5rem 1.25rem 1.5rem;
	}
}
