/*
 * ASEF pages: layout for page content and the asef-site shortcodes.
 * Ported from the staged asef-site plugin change (r1). Loads after style.css
 * and only styles the pieces it names. Colour roles follow style.css:
 * pink = main action, violet = links, yellow = Donate only. Colours come from
 * the theme's variables wherever the theme has one.
 */

/* ---------- On this page (long pages) ----------
 * A plain contents list, not chips (the chips under the title go to other pages).
 * Inline: a quiet bordered panel, two columns where there is room.
 * Side (pages.js, when the screen has room beside the text): it sits next to
 * the text, stays in view and marks the section being read.
 */
.asef-toc {
	margin: 1.25rem 0 2rem;
	padding: 0.85rem 1.25rem 0.7rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 14px;
}
.asef-toc:focus { outline: none; }
.asef-toc__label {
	margin: 0 0 0.2rem;
	color: var(--wp--preset--color--muted);
	font-size: 0.8125rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
.asef-toc ul { columns: 2 14rem; column-gap: 2rem; margin: 0; padding: 0; list-style: none; }
.asef-toc li { margin: 0 !important; break-inside: avoid; }
.asef-toc a {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 40px;
	box-sizing: border-box;
	padding: 0.3rem 0;
	color: var(--asef-link);
	font-weight: 700;
	line-height: 1.3;
	text-decoration: none;
}
.asef-toc a::before { content: "↓" / ""; flex: none; width: 1rem; color: var(--asef-link); font-weight: 800; }
.asef-toc a:hover { text-decoration: underline; }
@media (max-width: 800px) {
	.asef-toc { margin-bottom: 1.5rem; padding: 0.7rem 1rem 0.45rem; }
	.asef-toc a { min-height: 44px; }
}

/* Side list. The theme places a top-level list beside the reading column itself (style.css);
 * a list nested in page content (award winners) gets the same look here: the nav keeps its
 * place in the text but takes no room, and its panel sits in the margin beside the column
 * (pages.js lines its right edge up with the content area's).
 */
@media (min-width: 1200px) {
	.wp-block-post-content > * > .asef-toc {
		position: sticky;
		top: calc(var(--asef-header-h, 64px) + 1.5rem);
		z-index: 2;
		height: 0;
		margin: 0 !important;
		padding: 0;
		border: 0;
		border-radius: 0;
		background: none;
	}
	.wp-block-post-content > * > .asef-toc .asef-toc__panel {
		position: absolute;
		top: 0;
		left: calc(100% + 3.5rem);
		width: min(300px, 15rem);
		max-height: calc(100vh - var(--asef-header-h, 64px) - 3rem);
		overflow-y: auto;
		box-sizing: border-box;
		padding: 0.25rem 0 0.25rem 1.25rem;
		border-left: 2px solid var(--wp--preset--color--line);
	}
	.wp-block-post-content > * > .asef-toc ul { columns: auto; }
	.wp-block-post-content > * > .asef-toc a { min-height: 36px; font-weight: 600; }
	.wp-block-post-content > * > .asef-toc a::before { content: none; }
}
/* The section being read (marked by pages.js while the list is beside the text) */
.asef-toc a[aria-current] { color: var(--wp--preset--color--navy); font-weight: 800; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }

/* The way back to the list once it has scrolled away (narrower screens) */
.asef-toc-back {
	position: fixed;
	right: max(1rem, env(safe-area-inset-right));
	bottom: max(1rem, env(safe-area-inset-bottom));
	z-index: 40;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 44px;
	box-sizing: border-box;
	padding: 0.5rem 1.05rem;
	border-radius: 999px;
	background: var(--wp--preset--color--navy);
	box-shadow: var(--asef-shadow);
	color: #fff !important;
	font-size: 0.9375rem;
	font-weight: 800;
	text-decoration: none !important;
}
.asef-toc-back:hover { background: var(--asef-link); }
.asef-toc-back:focus-visible { outline: 3px solid var(--asef-sun); outline-offset: 2px; }
.asef-toc-back[hidden] { display: none; }
@media print { .asef-toc-back { display: none; } }

/* ---------- Callouts: one component, two kinds ----------
 * Info (default): the plain notice. Warning (--safety, --warning): safety and rules that disqualify.
 * Yellow is kept for Donate, so neither kind is yellow.
 */
.asef-callout,
.asef-note-box {
	box-sizing: border-box;
	padding: 1.1rem 1.4rem;
	background: #f7f4ff;
	border: 0;
	border-left: 4px solid var(--asef-violet);
	border-radius: 0 12px 12px 0;
}
.asef-note-box { margin-top: 1.25rem; padding: 0.85rem 1.15rem; }
.asef-callout.asef-callout--safety,
.asef-callout.asef-callout--warning {
	background: #fff5eb;
	border: 0;
	border-left: 4px solid var(--asef-orange);
}
/* A callout's own heading labels the box, so it stays smaller than the page's section headings */
.asef-callout > .wp-block-heading:first-child { margin-bottom: 0.5rem; font-size: var(--wp--preset--font-size--x-large); }
.asef-callout > p { margin-top: 0.6rem; margin-bottom: 0; }
.asef-callout > :first-child { margin-top: 0; }
.asef-callout > .wp-block-buttons { margin-top: 0.9rem; }
p.asef-callout { margin-top: 2rem; }
.asef-callout--safety .wp-block-image { margin: 1.25rem 0 0.5rem; }
.asef-callout--safety .wp-block-image img { display: block; width: 100%; max-width: 560px; border-radius: 8px; }
@media (max-width: 600px) {
	.asef-callout { padding: 0.9rem 1rem; }
	.asef-callout > .wp-block-heading:first-child { font-size: 1.1875rem; }
}

/* ---------- Lists in page text ---------- */
/* Nested numbered lists read 1. a. i. so a sub-point never looks like a new rule */
.entry-content li > ol { list-style-type: lower-alpha; }
.entry-content li li > ol { list-style-type: lower-roman; }
.entry-content li > :is(ol, ul) { margin-top: 0.4rem; }
@media (max-width: 600px) {
	.entry-content > .wp-block-list:not([class*="asef-"]) { padding-left: 1.5rem; }
	.entry-content li > :is(ol, ul) { padding-left: 1.15rem; }
}

/* PDF links say so (pages.js adds the class when the link text doesn't already) */
.asef-pdf::after {
	content: "PDF";
	display: inline-block;
	margin-left: 0.35rem;
	padding: 0 0.3rem;
	border: 1px solid currentColor;
	border-radius: 4px;
	font-size: 0.6875rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	line-height: 1.45;
	text-decoration: none;
	vertical-align: 0.12em;
}

/* Resource lists (Forms page): each link is a full-width row */
.asef-resources { display: grid; gap: 0.5rem; margin: 1rem 0 1.25rem; padding: 0 !important; list-style: none; }
.asef-resources > li { margin: 0 !important; }
.asef-resources > li:not(.asef-resource) { padding: 0.7rem 1rem; background: #faf8ff; border-radius: 12px; }
.asef-resource > a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	min-height: 52px;
	box-sizing: border-box;
	padding: 0.6rem 1rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 12px;
	color: var(--asef-link);
	font-weight: 700;
	text-decoration: none;
}
.asef-resource > a::after { content: "→" / ""; flex: none; }
.asef-resource > a[target="_blank"]::after { content: "↗" / ""; }
.asef-resource > a:hover { border-color: var(--asef-link); text-decoration: underline; }

/* ---------- Home: entry cards right under the hero ---------- */
.asef-hero + .asef-section { padding-top: clamp(1.5rem, 3vw, 2.25rem); padding-bottom: clamp(1.5rem, 3vw, 2.25rem); }
.asef-path { position: relative; min-height: 5.5rem; box-sizing: border-box; padding-right: 2.75rem; }
.asef-path::after {
	content: "→" / "";
	position: absolute;
	right: 1.1rem;
	bottom: 1rem;
	color: var(--wp--preset--color--navy);
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1;
	transition: transform 0.12s;
}
.asef-path:hover { box-shadow: 0 4px 10px rgb(43 26 107 / 10%), 0 16px 32px rgb(43 26 107 / 12%); }
.asef-path:hover::after { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) {
	.asef-path, .asef-path::after { transition: none; }
	.asef-path:hover, .asef-path:hover::after { transform: none; }
}
/* Tablets: three student cards, then the two adult ones */
@media (min-width: 561px) and (max-width: 800px) {
	.asef-paths--five .asef-path { grid-column: span 2; }
	.asef-paths--five .asef-path--judge, .asef-paths--five .asef-path--mentor { grid-column: span 3; }
}
@media (max-width: 800px) {
	.asef-path { min-height: 0; }
	.asef-path::after { bottom: auto; top: 50%; margin-top: -0.6rem; font-size: 1.125rem; }
}

/* Pathway buttons are the secondary action on each stage card; yellow stays for Donate */
.asef-stage .asef-way-btn--line { width: 100%; }

/* Big numbers stay whole ("$100,000+" never loses its "+") and shrink to fit their box */
.asef-stage .asef-stat { container-type: inline-size; }
.asef-stage .asef-stat b { overflow-wrap: normal; white-space: nowrap; font-size: min(1.6rem, 16cqi); }

/* Sponsor strip on phones: two actions side by side, "See all sponsors" below them */
@media (max-width: 600px) {
	.asef-strip__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
	.asef-strip__actions .asef-way-btn { padding: 0.45rem 0.6rem; font-size: 0.9375rem; white-space: nowrap; line-height: 1.2; }
	.asef-strip__actions .asef-way-btn--line { grid-column: 1 / -1; order: 1; }
}

/* Latest news: date sits right on its title; "All news" is a secondary button */
.asef-news .wp-block-post-template { gap: 1rem 2rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.asef-news .wp-block-post { margin: 0; padding-top: 0.85rem; border-top: 1px solid var(--wp--preset--color--line); }
.asef-news .wp-block-post > * { margin-top: 0; margin-bottom: 0; }
.asef-news .wp-block-post-date { color: var(--wp--preset--color--muted); font-size: var(--wp--preset--font-size--small); font-weight: 700; }
.asef-news .wp-block-post-title { margin-top: 0.25rem; line-height: 1.25; }
.asef-news .wp-block-post-title a { text-decoration: none; }
.asef-news .wp-block-post-title a:hover { text-decoration: underline; }
.asef-more { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; margin-top: 1.5rem; font-size: 0; }
.asef-more a { font-size: 1rem; font-weight: 700; }
.asef-more a:first-child {
	display: inline-flex;
	align-items: center;
	min-height: 48px;
	box-sizing: border-box;
	padding: 0.55rem 1.4rem;
	border: 2px solid var(--asef-link);
	border-radius: 999px;
	color: var(--asef-link);
	text-decoration: none;
}
.asef-more a:first-child:hover { background: var(--asef-link); color: #fff; }

/* ---------- Sponsors: filled tiers are cards, open tiers one compact list ----------
 * One neutral border for every tier; the tier name says which it is.
 */
.asef-tier { border: 1px solid var(--wp--preset--color--line); }
.asef-tier.is-open { background: #fff; border-style: dashed; }
.asef-tiers + .asef-open-tiers { margin-top: 1rem; }
.asef-open-tiers {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: 1.5rem;
	margin: 1.5rem 0 0;
	padding: 0 1.25rem;
	list-style: none;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 16px;
}
.asef-open-tier { grid-column: auto; margin: 0 !important; border-top: 1px solid var(--wp--preset--color--line); }
.asef-open-tier:nth-child(-n+2) { border-top: 0; }
.asef-open-tier a {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 0 1rem;
	align-items: center;
	min-height: 52px;
	height: 100%;
	box-sizing: border-box;
	padding: 0.6rem 0;
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}
.asef-open-tier__name { grid-column: 1; color: var(--wp--preset--color--navy); font-weight: 800; line-height: 1.3; }
.asef-open-tier__amount { grid-column: 1; color: var(--wp--preset--color--muted); font-size: 0.9375rem; line-height: 1.35; }
.asef-open-tier__cta { grid-column: 2; grid-row: 1 / span 2; color: var(--asef-link); font-size: 0.9375rem; font-weight: 800; text-align: right; }
.asef-open-tier a:hover .asef-open-tier__cta { text-decoration: underline; }
@media (max-width: 1000px) {
	.asef-open-tiers { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; }
	.asef-open-tier:nth-child(2) { border-top: 1px solid var(--wp--preset--color--line); }
}
@media (max-width: 480px) {
	.asef-tiers { grid-template-columns: minmax(0, 1fr); }
	.asef-tier { overflow-wrap: break-word; }
	.asef-open-tiers { padding: 0 0.9rem; }
	.asef-open-tier a { padding: 0.5rem 0; }
	.asef-open-tier__cta { font-size: 0.875rem; }
}

/* Past fairs: one quiet list of years, so this year's sponsors lead */
.asef-years {
	display: block;
	margin-top: 1rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 16px;
	overflow: hidden;
}
.asef-years .asef-pane { border: 0; border-top: 1px solid var(--wp--preset--color--line); border-radius: 0; box-shadow: none; }
.asef-years .asef-pane:first-child { border-top: 0; }
.asef-years .asef-pane > summary {
	min-height: 52px;
	padding-top: 0.4rem;
	padding-bottom: 0.4rem;
	border-radius: 0;
	font-size: 1.1875rem;
}
.asef-years .asef-pane > summary:hover { background: #faf8ff; }
.asef-years .asef-pane > summary:focus-visible { outline-offset: -3px; }
@media (max-width: 800px) {
	.asef-years .asef-pane > summary { min-height: 48px; font-size: 1.0625rem; }
}

/* ---------- Students hub: link rows ---------- */
.asef-hub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.asef-hub li { margin: 0 !important; }
.asef-hub a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	height: 100%;
	min-height: 56px;
	box-sizing: border-box;
	padding: 0.75rem 1rem 0.75rem 1.15rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 12px;
	color: var(--wp--preset--color--navy);
	font-weight: 700;
	line-height: 1.3;
	text-decoration: none;
	transition: border-color 0.12s, background-color 0.12s;
}
.asef-hub a::after { content: "→" / ""; flex: none; color: var(--asef-link); }
.asef-hub a:hover { border-color: var(--asef-link); background: #faf8ff; text-decoration: underline; }
@media (max-width: 600px) {
	.asef-hub { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
}

/* ---------- Contact ---------- */
.asef-contact-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.asef-contact-card {
	box-sizing: border-box;
	margin: 0 !important;
	padding: 1.15rem 1.35rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 14px;
}
.asef-contact-card > * { margin-top: 0.6rem; margin-bottom: 0; }
.asef-contact-card > :first-child { margin-top: 0; }
.asef-contact-card--wide { grid-column: 1 / -1; }
.asef-contact-card ul { padding-left: 1.2rem; }
.asef-contact-card a[href^="mailto:"] { font-weight: 700; }
@media (max-width: 700px) {
	.asef-contact-cards { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
	.asef-contact-card { padding: 1rem 1.1rem; }
}

/* ---------- Award winners ---------- */
.asef-search__field { position: relative; display: block; }
.asef-search__field input { padding-right: 3.25rem !important; }
.asef-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.asef-search__clear {
	position: absolute;
	right: 4px;
	bottom: 4px;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	cursor: pointer;
}
.asef-search__clear[hidden] { display: none; }
.asef-search__clear::before,
.asef-search__clear::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 16px;
	height: 2.5px;
	border-radius: 2px;
	background: var(--wp--preset--color--navy);
	transform: translate(-50%, -50%) rotate(45deg);
}
.asef-search__clear::after { transform: translate(-50%, -50%) rotate(-45deg); }
.asef-search__clear:hover { background: #f3edff; }
.asef-search__clear:focus-visible { outline: 3px solid var(--asef-focus); outline-offset: 0; }
/* Room for the result count before pages.js adds it, so nothing below moves */
.asef-search { padding-bottom: calc(0.9375rem * 1.6 + 0.4rem); }
.asef-search:has(.asef-search__count) { padding-bottom: 0; }
.asef-search__count { display: block; line-height: 1.6; min-height: 1.5em; margin-top: 0.4rem; color: var(--wp--preset--color--muted); font-size: 0.9375rem; font-weight: 700; }

.asef-winners .asef-toc { margin-top: 0.5rem; }
.asef-award { container: award / inline-size; padding: 0.85rem 1.15rem; margin: 0.75rem 0; border-width: 1px; }
.asef-award h3 { margin-bottom: 0.35rem; }
.asef-pid { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
/* While searching, the first row still showing has no rule above it */
.asef-award li { border-top: 0; }
.asef-award li:not([hidden]) ~ li { border-top: 1px solid var(--wp--preset--color--line); }
/* ISEF finalists lead the page */
.asef-winners > h2:first-of-type + .asef-award { border: 1px solid var(--asef-violet); border-left-width: 4px; background: #f7f4ff; }
/* Column labels: only on boxes wide enough for one line per winner */
.asef-award__head { display: none; }
@container award (min-width: 540px) {
	.asef-award__head,
	.asef-award li { display: grid; grid-template-columns: 10.5rem 7rem minmax(0, 1fr); column-gap: 1rem; align-items: baseline; }
	.asef-award__head { padding: 0.15rem 0 0.35rem; border-bottom: 1px solid var(--wp--preset--color--line); color: var(--wp--preset--color--muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
	.asef-award li { padding: 0.4rem 0; }
	.asef-award li > strong { grid-column: 1; }
	.asef-award li > .asef-pid { grid-column: 2; margin-left: 0; }
	.asef-award li > .asef-atype { grid-column: 3; }
}
/* Special Awards: many short boxes, two per row where the column is wide enough */
.asef-winners { container: winners / inline-size; }
.asef-award-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; margin: 0.75rem 0; }
.asef-award-grid[hidden] { display: none; }
.asef-award-grid .asef-award { margin: 0; }
@container winners (min-width: 680px) {
	.asef-award-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* ---------- Become a sponsor form ---------- */
.wpcf7-form > p { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 1rem; align-items: end; margin: 0; }
.wpcf7-form > p > br { display: none; }
.wpcf7-form > p > label { margin: 0 !important; }
.wpcf7-form > p > label:has(select),
.wpcf7-form > p > label:has(textarea),
.wpcf7-form > p > label:has(.wpcf7-quiz) { grid-column: 1 / -1; }
/* Resting fields: a 1px border that still meets 3:1; focus adds a second pixel without moving anything */
.wpcf7-form input:not([type=submit]):not([type=checkbox]):not([type=radio]),
.wpcf7-form select,
.wpcf7-form textarea { min-height: 48px; border-width: 1px; padding: 0.7rem 0.9rem; }
.wpcf7-form input:not([type=submit]):focus-visible,
.wpcf7-form select:focus-visible,
.wpcf7-form textarea:focus-visible { border-color: var(--asef-link); box-shadow: inset 0 0 0 1px var(--asef-link); }
.wpcf7-form .wpcf7-quiz { max-width: 12rem; }
/* The quiz repeats its question inside the field label; say it once on screen */
.wpcf7-form .wpcf7-quiz-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Required fields (pages.js adds the mark; the field itself tells screen readers) */
.wpcf7-form .asef-req { margin-left: 0.2rem; color: var(--asef-action); font-weight: 800; }
.wpcf7-form > p > .wpcf7-submit { justify-self: start; min-width: 10rem; margin-top: 0.5rem; }
@media (max-width: 640px) {
	.wpcf7-form > p { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
	.wpcf7-form > p > .wpcf7-submit { justify-self: stretch; width: 100%; }
}
