/**
 * Home "broadest IB subject coverage" section styles — Figma node 2617:3301.
 */

.gh-subjects {
	/* Space between the viewport edge and the 1120 content column. Floored at
	   40px so the full-bleed carousel keeps a comfortable inset (and room for the
	   arrows) on mid widths (e.g. 1024) where the column would otherwise nearly
	   touch the edge. */
	--gh-carousel-gutter: max(40px, calc(50vw - 560px));
	max-width: 1120px;
	margin: 0 auto;
	padding-block: 144px;
	/* .site-content already insets by max(24px, 50vw - 560px); add only the
	   shortfall so the heading/tabs line up with the carousel's gutter. */
	padding-inline: max(0px, calc(40px - max(24px, calc(50vw - 560px))));
}

.gh-subjects__inner {
	display: flex;
	flex-direction: column;
	/* Children stretch to the 1120 column (head/tabs centre their own content);
	   the carousel then hosts edge-aligned arrows and a full-bleed track. */
}
/* ---- Heading ---- */
.gh-subjects__head {
	display: flex;
	flex-direction: column;
	gap: 8px;
	text-align: center;
}

.gh-subjects__title {
	margin: 0;
	font-family: 'schibsted_grotesk_demi', Arial, sans-serif;
	font-weight: normal;
	font-size: 32px;
	line-height: 40px;
	color: var(--gh-text-primary);
}

.gh-subjects__subtitle {
	margin: 0;
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 16px;
	line-height: 28px;
	color: var(--gh-text-secondary);
}

/* ---- Filter tabs ---- */
.gh-subjects__tabs {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
	margin-top: 40px;
}

/* Subject count on the active tab only, e.g. "(6 subjects)" — regular weight
   next to the demi group label. Hidden on inactive tabs. */
.gh-subjects__tab-count {
	display: none;
	font-family: 'avenir_next_worldregular', 'Verdana';
	font-weight: normal;
}

.gh-subjects__tab.is-active .gh-subjects__tab-count {
	display: inline;
}

.gh-subjects__tab {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
	border: 1px solid var(--gh-text-secondary);
	border-radius: 8px;
	background: transparent;
	color: var(--gh-text-primary);
	font-family: 'avenir_next_worlddemi', 'Verdana';
	font-weight: normal;
	font-size: 14px;
	line-height: 20px;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.gh-subjects__tab:hover {
	border-color: var(--gh-text-primary);
}

.gh-subjects__tab.is-active {
	background: #000000;
	border-color: var(--gh-text-primary);
	color: var(--gh-white);
}

/* Empty groups (e.g. Group 2, Core) — shown but disabled. */
.gh-subjects__tab.is-disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

.gh-subjects__tab.is-disabled:hover {
	border-color: var(--gh-text-secondary);
}

/* Mobile-only filter dropdown (replaces the tab row ≤768px). */
.gh-subjects__select-wrap {
	display: none;
}

/* ---- Cards carousel ---- */
/* Wrapper stays at the content column and anchors the arrows to its edges; the
   track inside breaks out to full-bleed. (--gh-carousel-gutter is set on the
   section so its padding and this track share one value.) */
.gh-subjects__carousel {
	position: relative;
	width: 100%;
	margin-top: 48px;
}

/* Circular scroll arrows (Figma) — white disc, soft shadow, centred on the
   content-column edges and vertically over the card body. Hidden by default
   (the `hidden` attribute); subjects.js reveals them only when the track
   overflows and disables the one at whichever end the scroll has reached. */
.gh-subjects__arrow {
	position: absolute;
	top: 38%;
	transform: translateY(-50%);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--gh-white);
	color: var(--gh-text-primary);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
	cursor: pointer;
	transition: opacity 0.15s ease, box-shadow 0.15s ease;
}

/* display:flex above would defeat the [hidden] attribute, so restore it. */
.gh-subjects__arrow[hidden] {
	display: none;
}

.gh-subjects__arrow:hover {
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
}

/* Centre each disc on the content-column edge (28px = half the 56px disc). */
.gh-subjects__arrow--prev {
	left: -28px;
}

.gh-subjects__arrow--next {
	right: -28px;
}

.gh-subjects__arrow:disabled {
	opacity: 0;
	pointer-events: none;
}

/* Horizontal carousel track — a single non-wrapping row that runs full-bleed
   (100vw) past the 1120 content column so cards fill the screen width like the
   Figma design. The inline padding indents the first card back to the content
   column; cards are a fixed 352px. For groups that overflow, subjects.js builds
   a looped track (cloned card sets on both sides) for seamless infinite scroll;
   groups that fit get `is-centered`. */
.gh-subjects__grid {
	display: flex;
	flex-wrap: nowrap;
	justify-content: flex-start;
	gap: 32px;
	width: 100vw;
	position: relative;
	left: 50%;
	right: 50%;
	margin-left: -50vw;
	margin-right: -50vw;
	padding: 0 var(--gh-carousel-gutter);
	box-sizing: border-box;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	scroll-padding-left: var(--gh-carousel-gutter);
	scrollbar-width: none; /* Firefox */
	-ms-overflow-style: none; /* legacy Edge */
	/* Crossfade when switching groups (subjects.js SWITCH_MS must match 0.2s). */
	transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Groups that fit without scrolling centre their cards. */
.gh-subjects__grid.is-centered {
	justify-content: center;
}

.gh-subjects__grid::-webkit-scrollbar {
	display: none;
}

/* Mid-switch: grid is faded/nudged down while cards are swapped underneath. */
.gh-subjects__grid.is-switching {
	opacity: 0;
	transform: translateY(8px);
}

@media (prefers-reduced-motion: reduce) {
	.gh-subjects__grid {
		transition: none;
	}
}

.gh-subjects__card {
	display: flex;
	flex: 0 0 352px;
	flex-direction: column;
	scroll-snap-align: start;
	border: 1px solid #e6e6e6;
	border-radius: 12px;
	overflow: hidden;
	/* Anchor for the CTA's stretched-link overlay so the whole card is clickable. */
	position: relative;
}

.gh-subjects__card-body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	justify-content: space-between;
	gap: 24px;
	min-height: 280px;
	padding: 40px;
	background: var(--gh-white);
}

/* Draft subjects render as a normal full-colour card; only the CTA differs —
   a non-link "Coming soon" pill replaces the Explore link (Figma 4240:6859). */
.gh-subjects__card-soon {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	padding: 4px 12px;
	border-radius: 4px;
	background: #f5f5f5;
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 12px;
	line-height: 20px;
	color: var(--gh-text-secondary);
}

.gh-subjects__card-text {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.gh-subjects__card-title {
	margin: 0;
	font-family: 'schibsted_grotesk_medium', Arial, sans-serif;
	font-weight: normal;
	font-size: 24px;
	line-height: 32px;
	color: var(--gh-text-primary);
}

.gh-subjects__card-desc {
	margin: 0;
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 14px;
	line-height: 24px;
	color: var(--gh-text-secondary);
}

.gh-subjects__card-cta {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 8px;
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 16px;
	line-height: 28px;
	color: #008392;
	text-decoration: underline;
}

/* Stretched link: the Explore CTA covers the whole card, so a click anywhere on
   a published card follows through to the subject. The visible CTA text stays
   the accessible name (no nested anchors). Draft cards have no CTA, so they stay
   non-clickable. */
.gh-subjects__card-cta::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
}

.gh-subjects__card-cta svg {
	flex-shrink: 0;
	transition: transform 0.15s ease;
}

.gh-subjects__card-cta:hover svg {
	transform: translateX(4px);
}

@media (prefers-reduced-motion: reduce) {
	.gh-subjects__card-cta svg {
		transition: none;
	}
}

.gh-subjects__card-media {
	height: 200px;
	background: #cccccc;
	overflow: hidden;
}

.gh-subjects__card-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Empty-state message — shown only when the active group has no cards. */
.gh-subjects__empty {
	display: none;
	flex-basis: 100%;
	margin: 0;
	padding: 40px 0;
	text-align: center;
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 16px;
	line-height: 28px;
	color: var(--gh-text-secondary);
}

/* ---- Progressive enhancement ---- */
/* With JS, subjects.js rebuilds the track with only the active group's cards
   (plus clones for the loop), so there is no per-card hiding here. Without JS,
   every card stays visible (no filtering). */
.gh-subjects--js.gh-subjects--empty .gh-subjects__empty {
	display: block;
}

/* Tablet band (769–1199px): the content column can't hold a whole number of
   352px cards, so the left-anchored track piles all the slack on the right
   (the asymmetry seen at 1024/iPad Pro). Re-pad the *looping* track so its
   resting pair sits centred: subjects.js still rests at scrollLeft = loopWidth,
   which lands card 0's left edge on padding-left, so a padding of half the
   leftover space centres the two-card block — no JS change. scroll-padding-left
   matches so every snapped card centres the pair too. Result: two cards centred
   with equal peeks of the previous/next card on both sides. Groups that fit keep
   .is-centered (excluded here) and stay balanced via justify-content:center. */
@media (min-width: 769px) and (max-width: 1199px) {
	.gh-subjects__grid:not(.is-centered) {
		/* (100vw − 736px two-card block) / 2, floored at the 40px gutter for safety. */
		padding-inline: max(40px, calc(50vw - 368px));
		scroll-padding-left: max(40px, calc(50vw - 368px));
	}
}

/* From ~1000px up the peeks are wide enough (~112px at 1024) to seat the arrows
   inside them, so pull them off the edge. Below 1000px (iPad Air / iPad Pro 11
   portrait) the two cards nearly fill the width, so the arrows keep their default
   edge overlay over the outer card corners. */
@media (min-width: 1000px) and (max-width: 1199px) {
	.gh-subjects__arrow--prev {
		left: 60px;
	}

	.gh-subjects__arrow--next {
		right: 60px;
	}
}

/* ---- Responsive (Figma is desktop-only; breakpoints match cta/features) ---- */
@media (max-width: 1023px) {
	.gh-subjects {
		padding-block: 64px;
	}

	.gh-subjects__carousel {
		margin-top: 56px;
	}

	.gh-subjects__tabs {
		margin-top: 40px;
	}
}

/* Mobile — Figma nodes 3173:14059 (heading), 3173:14063 (tabs), 3173:14067
   (cards). Heading left-aligns; the filter tabs scroll horizontally instead of
   wrapping; cards collapse to a single tight-stacked column with the accent
   background and no media (per the mobile design). Section sits inside
   .site-content's 16px gutter, so horizontal padding is 0 here (Figma 16px). */
@media (max-width: 768px) {
	.gh-subjects {
		padding-block: 48px;
		padding-inline: 0;
	}

	.gh-subjects__head {
		align-items: flex-start;
		text-align: left;
	}

	/* Scale the heading down from the 40px desktop size on small screens. */
	.gh-subjects__title {
		font-size: 28px;
		line-height: 36px;
	}

	/* Tabs give way to a single full-width dropdown (Figma node 3173:14063). */
	.gh-subjects__tabs {
		display: none;
	}

	/* Sticks below the site header while the subjects section is in view (its
	   containing block is the section, so it releases once the section scrolls
	   past). --gh-header-h is published by mega-menu.js. The white background
	   keeps the cards from showing behind the trigger's rounded corners. */
	.gh-subjects__select-wrap {
		display: block;
		position: sticky;
		top: var(--gh-header-h, 48px);
		z-index: 20;
		width: 100%;
		margin-top: 40px;
		background: var(--gh-white);
	}

	/* Custom dropdown trigger button */
	.gh-subjects__select-trigger {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		padding: 8px 12px;
		border: 1px solid var(--gh-text-secondary);
		border-radius: 8px;
		background-color: var(--gh-white);
		font-size: 14px;
		line-height: 20px;
		color: var(--gh-text-primary);
		cursor: pointer;
		transition: border-color 0.15s ease;
	}

	.gh-subjects__select-trigger:hover {
		border-color: var(--gh-text-primary);
	}

	.gh-subjects__select-trigger:focus-visible {
		outline: none;
		border-color: var(--gh-text-primary);
	}

	.gh-subjects__select-trigger[aria-expanded="true"] {
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;
		border-color: var(--gh-text-primary);
	}

	/* Visible label: group name (demi) + count (regular) */
	.gh-subjects__select-display {
		display: flex;
		align-items: center;
		gap: 4px;
	}

	.gh-subjects__select-group {
		font-family: 'avenir_next_worlddemi', 'Verdana';
		font-weight: normal;
	}

	.gh-subjects__select-count {
		font-family: 'avenir_next_worldregular', 'Verdana';
		font-weight: normal;
	}

	/* Arrow icon in trigger */
	.gh-subjects__select-arrow {
		flex-shrink: 0;
		transition: transform 0.2s ease;
	}

	.gh-subjects__select-trigger[aria-expanded="true"] .gh-subjects__select-arrow {
		transform: rotate(180deg);
	}

	/* Custom dropdown panel */
	.gh-subjects__select-dropdown {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		margin-top: 0;
		border: 1px solid var(--gh-text-secondary);
		border-radius: 0 0 8px 8px;
		background-color: var(--gh-white);
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
		z-index: 1000;
		overflow: hidden;
	}

	/* Dropdown options */
	.gh-subjects__select-option {
		display: flex;
		align-items: center;
		width: 100%;
		padding: 12px;
		border: none;
		background-color: var(--gh-white);
		text-align: left;
		font-size: 14px;
		line-height: 20px;
		color: var(--gh-text-primary);
		font-family: 'avenir_next_worldmedium', 'Verdana';
		cursor: pointer;
		transition: background-color 0.15s ease, color 0.15s ease;
		gap: 4px;
	}

	.gh-subjects__select-option:hover {
		background-color: #f5f5f5;
	}

	.gh-subjects__select-option.is-active {
		background-color: #f5f5f5;
		font-family: 'avenir_next_worlddemi', 'Verdana';
	}

	.gh-subjects__select-option.is-disabled {
		opacity: 0.4;
		cursor: not-allowed;
		pointer-events: none;
	}

	.gh-subjects__select-option-label {
		font-family: 'avenir_next_worlddemi', 'Verdana';
		font-weight: normal;
	}

	.gh-subjects__select-option-count {
		font-family: 'avenir_next_worldregular', 'Verdana';
		font-weight: normal;
	}

	/* Carousel collapses to a plain vertical stack; the arrows are hidden. */
	.gh-subjects__carousel {
		margin-top: 32px;
	}

	.gh-subjects__arrow {
		display: none;
	}

	/* Undo the full-bleed breakout and stack within the content column. */
	.gh-subjects__grid,
	.gh-subjects__grid.is-centered {
		flex-direction: column;
		justify-content: flex-start;
		overflow-x: visible;
		gap: 8px;
		width: auto;
		left: auto;
		right: auto;
		margin-left: 0;
		margin-right: 0;
		padding: 0;
	}

	/* Single full-width column. */
	.gh-subjects__card {
		flex: 0 0 auto;
		width: 100%;
	}

	/* Cards become flat accent panels (no border, no media) per the mobile node. */
	.gh-subjects__card {
		border: none;
		border-radius: 16px;
		background: var(--gh-accent);
	}

	.gh-subjects__card-body {
		gap: 8px;
		min-height: 0;
		padding: 24px;
		background: transparent;
	}

	.gh-subjects__card-title {
		font-size: 20px;
		line-height: 24px;
	}

	.gh-subjects__card-desc {
		display: none;
	}

	.gh-subjects__card-cta {
		font-size: 14px;
		line-height: 24px;
	}

	.gh-subjects__card-media {
		display: none;
	}
	.gh-subjects__select:focus-visible {
		outline: none;
	}
}

@media (min-width: 1025px) {
	.gh-subjects__title {
		font-size: 40px;
		line-height: 48px;
	}
}
