/*
 * Course curriculum pages - the Week Ledger layout.
 *
 * A sticky index rail beside the modules, with the current one highlighted as the page
 * scrolls. Sections that have a heading but nothing under them render muted rather than
 * being hidden, so a visitor can see the Apex course runs sixteen weeks while only three
 * of them are written.
 *
 * Scoped under .cwtf-lp--curriculum throughout. The prose rules deliberately do NOT reuse
 * .cwtf-legal__body, even though it is the right visual grammar for a long document -
 * coupling them would mean a Terms restyle silently restyling a syllabus.
 *
 * Depends on cwtf-landing.css for the token block on .cwtf-lp, .cwtf-shell, .cwtf-eyebrow
 * and .cwtf-ctaband. A few tokens (--f-mono, --c-faint, --c-warm, the softer line values)
 * are declared on .cwtf and reach here by inheritance; each use carries the theme's own
 * value as a var() fallback so this sheet still renders correctly on its own.
 */

/* ---------------------------------------------------------------- tokens ------- */

.cwtf-lp--curriculum {
	--curr-rail: minmax(13rem, 16rem);
	--curr-line-soft: rgba(129, 204, 194, 0.38);
	--curr-line-hard: rgba(129, 204, 194, 0.7);

	/*
	 * The reading measure, as a single token so the prose and the module head cannot
	 * drift apart - the topic count is right-aligned against this, and if the two
	 * disagreed it would float off on its own at wide viewports.
	 *
	 * A percentage rather than a character count, so it grows with the container: the
	 * shell, the grid and the module all scale up to 3000px, and a fixed cap left the
	 * text frozen at 687px in the middle of all that space. The rem floor keeps a laptop
	 * readable; min(100%, ...) stops the percentage overshooting a narrow container.
	 */
	--curr-measure: min(100%, max(42rem, 80%));
}

/* ------------------------------------------------------------------ head ------- */

.cwtf-lp--curriculum .cwtf-curr-head {
	padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.5rem, 3vw, 2.5rem);
}

.cwtf-curr-head__back {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
	color: var(--c-muted);
	text-decoration: none;
	font-size: 0.94rem;
	letter-spacing: 0.04em;
	transition: color 0.2s var(--ease), gap 0.2s var(--ease);
}

.cwtf-curr-head__back:hover,
.cwtf-curr-head__back:focus-visible {
	color: var(--c-accent-lt);
	gap: 0.8rem;
}

.cwtf-lp--curriculum .cwtf-curr-head__title {
	font-size: clamp(2rem, 1.5rem + 2vw, 3.25rem);
	line-height: 1.1;
	letter-spacing: -0.01em;
	text-wrap: balance;
	max-width: 24ch;
}

.cwtf-curr-head__sub {
	margin-top: 1.1rem;
	max-width: 62ch;
	color: var(--c-muted);
	font-size: 1.05rem;
}

.cwtf-curr-head__facts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem 1.75rem;
	margin: 1.75rem 0 0;
	padding: 0;
	font-family: var(--f-mono, ui-monospace, Consolas, monospace);
	font-size: 0.72rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--c-faint, rgba(244, 244, 244, 0.56));
}

.cwtf-lp--curriculum .cwtf-curr-head__facts li {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
}

.cwtf-lp--curriculum .cwtf-curr-head__facts li::before {
	content: "";
	width: 5px;
	height: 5px;
	background: var(--curr-line-hard);
	transform: rotate(45deg);
	flex: none;
}

/* ----------------------------------------------------------------- shell ------- */

.cwtf-curr {
	padding-bottom: clamp(3rem, 7vw, 5rem);
}

/* The site's rhythm device: a hairline with a small diamond on it. Written here rather
   than shared, because the landing sheet has no such rule of its own. */
.cwtf-curr__rule {
	position: relative;
	border: 0;
	height: 1px;
	background: var(--curr-line-soft);
	margin-block: clamp(1.75rem, 3.5vw, 2.75rem);
}

.cwtf-curr__rule::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 7px;
	height: 7px;
	background: var(--c-ink);
	border: 1px solid var(--curr-line-hard);
	transform: translate(-50%, -50%) rotate(45deg);
}

.cwtf-curr__pending {
	color: var(--c-muted);
	font-size: 1.05rem;
	max-width: 62ch;
	padding-block: clamp(1.5rem, 4vw, 3rem);
}

.cwtf-curr__grid {
	display: grid;
	grid-template-columns: var(--curr-rail) minmax(0, 1fr);
	gap: clamp(2rem, 4vw, 4rem);
	align-items: start;
}

/* ------------------------------------------------------------------ rail ------- */

.cwtf-curr__rail {
	position: sticky;
	top: 1.5rem;
	max-height: calc(100vh - 3rem);
	overflow-y: auto;
	padding-right: 0.5rem;
	scrollbar-width: thin;
}

.cwtf-curr__rail-title {
	font-family: var(--f-mono, ui-monospace, Consolas, monospace);
	font-size: 0.7rem;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--c-faint, rgba(244, 244, 244, 0.56));
	padding-bottom: 0.9rem;
	margin-bottom: 0.9rem;
	border-bottom: 1px solid var(--curr-line-soft);
}

.cwtf-lp--curriculum .cwtf-curr__rail-list {
	margin: 0;
	padding: 0;
}

.cwtf-curr__rail-link {
	display: grid;
	grid-template-columns: 2.4rem 1fr auto;
	align-items: baseline;
	gap: 0 0.6rem;
	padding: 0.5rem 0.75rem 0.5rem 0.6rem;
	border-left: 2px solid transparent;
	text-decoration: none;
	color: var(--c-muted);
	font-size: 0.94rem;
	transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
		background-color 0.2s var(--ease);
}

.cwtf-curr__rail-link:hover {
	color: var(--c-fg);
	background: rgba(129, 204, 194, 0.05);
}

.cwtf-curr__rail-link.is-current {
	color: var(--c-fg);
	border-left-color: var(--c-accent-lt);
	background: rgba(129, 204, 194, 0.08);
}

.cwtf-curr__rail-no {
	font-family: var(--f-mono, ui-monospace, Consolas, monospace);
	font-size: 0.7rem;
	letter-spacing: 0.08em;
	color: var(--c-accent-lt);
	font-variant-numeric: tabular-nums;
}

.cwtf-curr__rail-meta {
	grid-column: 2;
	display: block;
	margin-top: 0.15rem;
	font-size: 0.78rem;
	line-height: 1.45;
	color: var(--c-faint, rgba(244, 244, 244, 0.56));
}

/* Unwritten sections: present and legible, obviously not yet worth a click. The marker
   sits in its own column so these rows stay the same height as the written ones. */
.cwtf-curr__rail-link.is-empty {
	color: var(--c-faint, rgba(244, 244, 244, 0.56));
}

.cwtf-curr__rail-link.is-empty .cwtf-curr__rail-no {
	color: var(--curr-line-hard);
}

.cwtf-curr__rail-link.is-empty::after {
	content: "\00b7\00b7\00b7";
	grid-column: 3;
	font-family: var(--f-mono, ui-monospace, Consolas, monospace);
	font-size: 0.7rem;
	letter-spacing: 0.24em;
	color: var(--curr-line-hard);
}

/* --------------------------------------------------------------- modules ------- */

.cwtf-curr__mod {
	position: relative;
	padding-block: clamp(1.75rem, 3.5vw, 2.75rem);
	border-top: 1px solid var(--curr-line-soft);
	scroll-margin-top: 1.5rem;
}

.cwtf-curr__mod:first-child {
	border-top: 0;
	padding-top: 0;
}

/* Same measure as the prose below it, so the right-aligned topic count sits at the end of
   the text rather than floating off toward the edge of the page at wide viewports. */
.cwtf-curr__mod-head {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.4rem 1rem;
	margin-bottom: 1.4rem;
	max-width: var(--curr-measure);
}

/* Set large and low-contrast: it indexes the page without competing with the heading. */
.cwtf-curr__mod-no {
	font-family: var(--f-display);
	font-size: clamp(2.4rem, 1.8rem + 2.4vw, 3.6rem);
	font-weight: 500;
	line-height: 0.85;
	font-variant-numeric: tabular-nums;
	color: transparent;
	background: linear-gradient(120deg, var(--c-fg) 5%, var(--c-accent-lt) 95%);
	-webkit-background-clip: text;
	background-clip: text;
	opacity: 0.42;
	flex: none;
}

.cwtf-curr__mod-titles {
	min-width: 0;
}

.cwtf-lp--curriculum .cwtf-curr__mod-title {
	font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.85rem);
	line-height: 1.2;
	letter-spacing: -0.005em;
}

.cwtf-curr__mod-meta {
	margin-top: 0.3rem;
	font-family: var(--f-display);
	font-size: 0.775rem;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--c-accent-lt);
}

.cwtf-curr__mod-count {
	margin-left: auto;
	font-family: var(--f-mono, ui-monospace, Consolas, monospace);
	font-size: 0.7rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--c-faint, rgba(244, 244, 244, 0.56));
	white-space: nowrap;
}

.cwtf-curr__mod--empty {
	padding-block: clamp(1.1rem, 2vw, 1.5rem);
}

.cwtf-curr__mod--empty .cwtf-curr__mod-no {
	opacity: 0.16;
	font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem);
}

.cwtf-lp--curriculum .cwtf-curr__mod--empty .cwtf-curr__mod-title {
	font-size: 1.1rem;
	font-weight: 400;
	color: var(--c-muted);
}

.cwtf-curr__mod--empty .cwtf-curr__mod-head {
	margin-bottom: 0.4rem;
}

.cwtf-curr__soon {
	font-size: 0.92rem;
	color: var(--c-faint, rgba(244, 244, 244, 0.56));
	font-style: italic;
}

/* ------------------------------------------------------------- the prose ------- */

.cwtf-curr .cwtf-md {
	color: var(--c-fg-2);
	max-width: var(--curr-measure);
}

/* The intro sits directly in the shell with no rail beside it, so it has more room to
   give away and keeps a little more of it as margin. */
.cwtf-curr .cwtf-curr__intro {
	max-width: min(100%, max(46rem, 62%));
}

.cwtf-curr .cwtf-md > * + * {
	margin-top: 1.05em;
}

.cwtf-lp--curriculum .cwtf-md p {
	line-height: 1.75;
}

.cwtf-lp--curriculum .cwtf-md strong {
	color: var(--c-fg);
	font-weight: 600;
}

.cwtf-lp--curriculum .cwtf-md a {
	color: var(--c-accent-lt);
	text-decoration: underline;
	text-underline-offset: 0.18em;
	text-decoration-color: var(--c-line-strong);
}

.cwtf-lp--curriculum .cwtf-md a:hover {
	text-decoration-color: var(--c-accent-lt);
}

.cwtf-lp--curriculum .cwtf-md code {
	font-family: var(--f-mono, ui-monospace, Consolas, monospace);
	font-size: 0.9em;
	padding: 0.1em 0.35em;
	border-radius: 4px;
	background: rgba(129, 204, 194, 0.1);
	color: var(--c-fg);
}

/*
 * The plugin's base rules strip list markers everywhere under .cwtf-lp. Here the numbers
 * are content, not decoration - Matt wrote "1)" through "15)" - so they come back, and
 * the marker takes the accent.
 */
.cwtf-lp--curriculum .cwtf-md ul,
.cwtf-lp--curriculum .cwtf-md ol {
	margin: 0;
	padding-left: 1.6em;
}

.cwtf-lp--curriculum .cwtf-md ol > li {
	list-style: decimal;
}

.cwtf-lp--curriculum .cwtf-md ul > li {
	list-style: disc;
}

.cwtf-lp--curriculum .cwtf-md li {
	margin-bottom: 0.55em;
	line-height: 1.7;
}

.cwtf-lp--curriculum .cwtf-md li:last-child {
	margin-bottom: 0;
}

.cwtf-lp--curriculum .cwtf-md li::marker {
	color: var(--c-accent);
}

/* A paragraph opening with **Label:** keeps its lead-in inline with the prose. */
.cwtf-lp--curriculum .cwtf-md__lead strong {
	color: var(--c-accent-lt);
}

/* **Weekly Projects:** alone on a line labels the list beneath it, so it is tightened
   against what follows instead of floating between two blocks. */
.cwtf-lp--curriculum .cwtf-md__label {
	margin-top: 1.8em;
	font-family: var(--f-display);
	font-size: 0.8rem;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--c-warm, #e2b04a);
}

.cwtf-curr .cwtf-md .cwtf-md__label + * {
	margin-top: 0.7em;
}

.cwtf-lp--curriculum .cwtf-md__sub {
	margin-top: 1.6em;
	font-size: 1.1rem;
	color: var(--c-accent-lt);
}

/* ------------------------------------------------------------ narrow ------- */

@media (max-width: 68rem) {
	.cwtf-curr__grid {
		grid-template-columns: 1fr;
	}

	.cwtf-curr__rail {
		position: static;
		max-height: none;
		overflow: visible;
		padding: 0 0 1.5rem;
		border-bottom: 1px solid var(--curr-line-soft);
		margin-bottom: 1.5rem;
	}

	/* Two columns all the way down, so seventeen links are not a 700px wall above the
	   content on a phone. The sub-labels are hidden below, which keeps the rows short
	   enough that two columns still fit at 390px. */
	.cwtf-lp--curriculum .cwtf-curr__rail-list {
		columns: 2;
		column-gap: clamp(0.75rem, 3vw, 1.5rem);
	}

	.cwtf-lp--curriculum .cwtf-curr__rail-list li {
		break-inside: avoid;
	}

	.cwtf-curr__rail-meta {
		display: none;
	}
}

@media (max-width: 34rem) {
	.cwtf-curr__rail-link {
		grid-template-columns: 1.9rem 1fr auto;
		padding-inline: 0.4rem 0.3rem;
		font-size: 0.88rem;
	}

	/* The count sits after the heading rather than pushed to the far right, where at this
	   width it would be alone on a line with the module number. */
	.cwtf-curr__mod-count {
		margin-left: 0;
		flex-basis: 100%;
	}
}
