/*
 * Resource tiles + modals for fayeevans.au/resources/
 * Styling is derived from the site's Elementor global kit (kit-416):
 *   --e-global-color-primary  #415678  slate blue
 *   --e-global-color-text     #B44804  rust
 *   --e-global-color-2cf076e  #F0DCDC  blush (site button background)
 *   --e-global-color-5c2ca37  #A3D4E9C2 sky
 * Fonts: Great Vibes (display), Roboto Slab (headings/buttons), Roboto (body).
 */

.fe-resources {
	--fe-primary: var(--e-global-color-primary, #415678);
	--fe-rust: var(--e-global-color-text, #b44804);
	--fe-blush: var(--e-global-color-2cf076e, #f0dcdc);
	--fe-sky: var(--e-global-color-5c2ca37, #a3d4e9c2);
	--fe-ink: #2f3239;
	--fe-paper: #fffdfd;
	--fe-radius: 14px;
	width: 100%;
}

/* ---------------------------------------------------------------- tiles */

.fe-resource-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 32px 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.fe-tile {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	text-align: center;
	cursor: pointer;
	appearance: none;
	transition: transform 0.25s ease;
}

/* hello-elementor styles bare <button> elements — `button:hover, button:focus`
   sets background-color:#c36 — which flooded each tile with crimson on hover and
   stayed there after a click, since :focus persists. The tile is only a button
   for semantics, so every interactive state has to opt back out.

   Scoped under .fe-resources deliberately: the theme's selector list includes
   `[type=button]:hover`, which scores the same (0,2,0) as a bare `.fe-tile:hover`
   and would be settled purely by stylesheet order. The extra class makes this
   win outright, so a future change to the <head> load order can't bring the
   crimson back. */
.fe-resources .fe-tile,
.fe-resources .fe-tile:hover,
.fe-resources .fe-tile:focus,
.fe-resources .fe-tile:focus-visible,
.fe-resources .fe-tile:active {
	background: none;
}

.fe-tile:hover,
.fe-tile:focus-visible {
	transform: translateY(-4px);
}

.fe-tile:focus-visible {
	outline: 2px solid var(--fe-primary);
	outline-offset: 6px;
	border-radius: var(--fe-radius);
}

/* 7/10 rather than a rounder 2/3: the covers run from 0.639 to 0.773 wide, and
   this sits at the geometric middle of that range, so `cover` below trims at
   most ~4.5% off any one edge instead of ~7% off the widest ones. */
.fe-tile__media {
	position: relative;
	display: block;
	aspect-ratio: 7 / 10;
	overflow: hidden;
	border-radius: var(--fe-radius);
	background: var(--fe-paper);
	box-shadow: 0 10px 26px -18px rgba(65, 86, 120, 0.55);
	transition: box-shadow 0.25s ease;
}

.fe-tile:hover .fe-tile__media,
.fe-tile:focus-visible .fe-tile__media {
	box-shadow: 0 18px 34px -18px rgba(65, 86, 120, 0.7);
}

/* The artwork fills the card edge to edge. `contain` plus padding used to letterbox
   each cover against --fe-paper, which read as a white mount inside the rounded
   frame; `cover` bleeds it into the corners instead. border-radius: inherit is
   belt and braces — overflow: hidden already clips, but Safari has historically
   let a transformed child escape a rounded ancestor. */
.fe-tile__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	border-radius: inherit;
}

/* "Read more" veil, revealed on hover — desktop pointers only */
.fe-tile__veil {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 18px 12px;
	background: linear-gradient(to top, rgba(65, 86, 120, 0.82) 0%, rgba(65, 86, 120, 0) 62%);
	color: #fff;
	font-family: "Roboto Slab", serif;
	font-size: 15px;
	font-weight: 300;
	text-transform: capitalize;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.fe-tile:hover .fe-tile__veil,
.fe-tile:focus-visible .fe-tile__veil {
	opacity: 1;
}

/* The tile is now cover art only — the title and price caption were removed.
   The product name still reaches assistive tech through the image alt, which
   supplies the button's accessible name, and both appear in the modal. */

/* ---------------------------------------------------------------- modal */

.fe-modal[hidden] {
	display: none;
}

.fe-modal {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 5vh 20px;
	box-sizing: border-box;
}

.fe-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(47, 50, 57, 0.55);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	animation: fe-fade 0.25s ease both;
}

.fe-modal__panel {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
	gap: 0;
	width: min(920px, 100%);
	max-height: 90vh;
	overflow: hidden;
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 40px 80px -30px rgba(47, 50, 57, 0.65);
	animation: fe-rise 0.3s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

/* Focus lands here when the dialog opens; the ring would be noise. */
.fe-modal__panel:focus {
	outline: none;
}

.fe-modal__media {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 34px 26px;
	background: linear-gradient(160deg, var(--fe-blush) 0%, #fff 78%);
}

.fe-modal__media img {
	display: block;
	width: 100%;
	max-width: 260px;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 18px 38px -20px rgba(47, 50, 57, 0.75);
}

.fe-modal__content {
	display: flex;
	flex-direction: column;
	padding: 40px 42px 36px;
	overflow-y: auto;
	box-sizing: border-box;
}

/*
 * The site kit styles bare h2/p globally (`.elementor-kit-416 h2` paints them
 * blush, which is unreadable on the modal's white panel), and that selector
 * outranks a single class. Scoping these under .fe-resources takes precedence.
 */
.fe-resources .fe-modal__eyebrow {
	margin: 0 0 2px;
	font-family: "Great Vibes", cursive;
	font-size: 30px;
	font-weight: 400;
	line-height: 1.1;
	color: var(--fe-rust);
}

.fe-resources .fe-modal__title {
	margin: 0 0 18px;
	font-family: "Roboto Slab", serif;
	font-size: 30px;
	font-weight: 300;
	line-height: 1.25;
	letter-spacing: 0;
	text-transform: capitalize;
	color: var(--fe-primary);
}

/* `.elementor hr` forces a transparent background, so this needs two classes. */
.fe-resources .fe-modal__rule {
	width: 54px;
	height: 2px;
	margin: 0 0 20px;
	border: 0;
	background-color: var(--fe-sky);
}

.fe-resources .fe-modal__desc {
	margin: 0 0 28px;
	font-family: "Roboto", sans-serif;
	font-size: 16px;
	font-weight: 300;
	line-height: 1.65;
	color: var(--fe-ink);
}

.fe-resources .fe-modal__desc p {
	margin: 0 0 14px;
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
}

.fe-resources .fe-modal__desc p:last-child {
	margin-bottom: 0;
}

.fe-modal__desc em {
	font-style: italic;
}

.fe-modal__actions {
	display: flex;
	align-items: center;
	gap: 18px;
	flex-wrap: wrap;
	margin-top: auto;
	padding-top: 6px;
}

/* Mirrors the site's .elementor-button treatment */
.fe-modal__button {
	display: inline-block;
	padding: 13px 30px;
	background-color: var(--fe-blush);
	color: var(--fe-rust);
	font-family: "Roboto Slab", serif;
	font-size: 16px;
	font-weight: 300;
	line-height: 18px;
	text-transform: capitalize;
	text-decoration: none;
	transition: filter 0.2s ease, transform 0.2s ease;
}

.fe-modal__button:hover,
.fe-modal__button:focus-visible {
	filter: brightness(0.96);
	transform: translate(0.25vw, 0.25vh); /* matches the header button's hover nudge */
	color: var(--fe-rust);
}

.fe-modal__meta {
	font-family: "Roboto", sans-serif;
	font-size: 14px;
	font-weight: 300;
	color: var(--fe-primary);
	opacity: 0.8;
}

.fe-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.86);
	color: var(--fe-primary);
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.fe-modal__close:hover,
.fe-modal__close:focus-visible {
	background: var(--fe-blush);
	color: var(--fe-rust);
	transform: rotate(90deg);
}

.fe-modal__close:focus-visible,
.fe-modal__button:focus-visible {
	outline: 2px solid var(--fe-primary);
	outline-offset: 3px;
}

.fe-modal__close svg {
	width: 15px;
	height: 15px;
	fill: currentColor;
}

@keyframes fe-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes fe-rise {
	from { opacity: 0; transform: translateY(16px) scale(0.985); }
	to { opacity: 1; transform: none; }
}

/* Applied to <body> while a modal is open */
.fe-modal-open {
	overflow: hidden;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 1024px) {
	.fe-resource-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.fe-modal__content {
		padding: 34px 32px 30px;
	}

	.fe-modal__title {
		font-size: 26px;
	}
}

@media (max-width: 767px) {
	.fe-resource-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 26px 16px;
	}

	.fe-modal {
		padding: 0;
	}

	.fe-modal__panel {
		grid-template-columns: minmax(0, 1fr);
		width: 100%;
		max-height: 100%;
		height: 100%;
		border-radius: 0;
	}

	.fe-modal__media {
		padding: 30px 20px 22px;
	}

	.fe-modal__media img {
		max-width: 170px;
	}

	.fe-modal__content {
		padding: 26px 24px 34px;
	}

	/* Let the CTA follow the copy rather than sinking to the bottom of a
	   full-height panel, which strands it below a large gap on short entries. */
	.fe-modal__actions {
		margin-top: 24px;
	}

	.fe-modal__eyebrow {
		font-size: 26px;
	}

	.fe-modal__title {
		font-size: 24px;
	}
}

/* Touch devices have no hover state — keep the veil out of the way */
@media (hover: none) {
	.fe-tile__veil {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fe-tile,
	.fe-tile__media,
	.fe-modal__button,
	.fe-modal__close,
	.fe-tile__veil {
		transition: none;
	}

	.fe-modal__overlay,
	.fe-modal__panel {
		animation: none;
	}

	.fe-tile:hover,
	.fe-tile:focus-visible,
	.fe-modal__button:hover,
	.fe-modal__button:focus-visible {
		transform: none;
	}

	.fe-modal__close:hover,
	.fe-modal__close:focus-visible {
		transform: none;
	}
}
