/* ==================================================================
   PI Exam Dates — [exam_dates] shortcode

   Cards on a cream background. Each card has text on the left and a
   desk calendar on the right, with a "days left" line under it.

   The calendar is part of the card layout (CSS grid), not absolutely
   positioned, so the text and the calendar can never overlap.

   Contents
    1. Variables (colors and fonts)
    2. Section and heading
    3. Card grid
    4. Card and card text
    5. Calendar: base styles
    6. Calendar: page parts (header, day, weekday)
    7. Calendar: days-left line
    8. Page layout by screen width
    9. Calendar layout by screen width
   10. Calendar: page-turn animation
   11. Reduced motion
   ================================================================== */


/* ------------------------------------------------------------------
   1. VARIABLES
   Change a color or font here and it updates everywhere.
   ------------------------------------------------------------------ */
.pi-exam {
	--pi-navy: #0A2447;
	--pi-blue: #2563a8;
	--pi-muted: #5d6b85;
	--pi-border: #dfe3ea;
	--pi-cream: #f5f0e6;
	--pi-white: #fff;

	--pi-font-body: "Plus Jakarta Sans", sans-serif;
	--pi-font-heading: "Baloo 2", sans-serif;
}


/* ------------------------------------------------------------------
   2. SECTION AND HEADING
   ------------------------------------------------------------------ */
.pi-exam {
	padding: 50px 0;
	background: var(--pi-cream);
	color: var(--pi-navy);
	font-family: var(--pi-font-body);
}

.pi-exam__inner {
	width: min(1200px, 100% - 48px);
	margin: 0 auto;
}

.pi-exam__head {
	margin: 0 0 28px;
}

.pi-exam__title {
	margin: 0 0 4px;
	color: var(--pi-navy);
	font-family: var(--pi-font-heading);
	font-size: 26px;
	font-weight: 700;
	line-height: 1.3;
}

.pi-exam__sub {
	margin: 0;
	color: var(--pi-muted);
	font-size: 14px;
	line-height: 1.4;
}


/* ------------------------------------------------------------------
   3. CARD GRID  (3 columns on desktop)
   ------------------------------------------------------------------ */
.pi-exam__list {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 20px;
	width: 90%;
	margin: 0;
	padding: 0;
	list-style: none;
}


/* ------------------------------------------------------------------
   4. CARD AND CARD TEXT

   Each card is a small grid with two columns:

       | category |          |
       | name     | calendar |
       | chip     |          |

   Column 1 holds the text, column 2 holds the calendar.
   ------------------------------------------------------------------ */
.pi-exam__item {
	display: flex;
	justify-content: space-between;
	column-gap: 12px;
	align-items: start;
	min-width: 0;
	min-height: 160px;
	margin: 0;
	padding: 20px;
	background: var(--pi-white);
	border: 1px solid var(--pi-border);
	border-radius: 12px;
	text-align: left;
}

/* Where each part sits in the card grid */
.pi-exam__category {
	grid-column: 1;
	grid-row: 1;
}

.pi-exam__top {
	grid-column: 1;
	grid-row: 2;
}

.pi-exam__cal {
	grid-column: 2;
	grid-row: 1 / span 2;
}

/* Small label above the exam name */
.pi-exam__category {
	display: block;
	margin-bottom: 8px;
	color: var(--pi-blue);
	font-size: 12px;
	font-weight: 700;
	line-height: 1.3;
}

/* Exam name and status chip, stacked */
.pi-exam__top {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.pi-exam__name {
	font-size: 24px;
	font-weight: 600;
	line-height: 1.3;
	font-family: "Baloo 2", sans-serif;
}

/* Status chip: "Upcoming", "Soon" or "Today" */
.pi-exam__chip {
	display: inline-block;
	padding: 3px 10px;
	border: 1px solid var(--pi-navy);
	border-radius: 999px;
	color: var(--pi-navy);
	font-size: 12px;
	font-weight: 700;
	line-height: 1.4;
}

/* "Soon" and "Today" chips are filled */
.pi-exam__item--soon .pi-exam__chip,
.pi-exam__item--today .pi-exam__chip {
	background: var(--pi-navy);
	color: var(--pi-white);
}


/* ------------------------------------------------------------------
   5. CALENDAR: BASE STYLES

   The size variables below are the "dials" for the calendar.
   Section 9 changes them for each screen size.
   ------------------------------------------------------------------ */
.pi-exam__cal {
	--cal-w: 92px;            /* calendar width */
	--cal-h: 95px;            /* calendar height */
	--cal-r: 10px;            /* corner radius */
	--cal-head: 24px;         /* header bar height */
	--cal-head-fs: 11px;      /* header text size */
	--cal-day-fs: 36px;       /* big day number size */
	--cal-sub-fs: 11px;       /* weekday / year text size */
	--cal-perspective: 320px; /* depth of the page-turn effect */

	width: var(--cal-w);
	color: var(--pi-navy);
	pointer-events: none;
}

/* The paper pad. Page edges peek out below it via box-shadow. */
.pi-exam__cal-body {
	position: relative;
	width: 100%;
	height: var(--cal-h);
	background: var(--pi-white);
	border-radius: var(--cal-r);
	box-shadow:
		0 2px 0 -1px #fff,
		0 2px 0 0 var(--pi-border),
		0 4px 0 -2px #fff,
		0 4px 0 -1px var(--pi-border),
		0 12px 18px -12px rgba(10, 36, 71, 0.45);
	perspective: var(--cal-perspective);
	perspective-origin: 50% 0;
}

/* The two binder rings on top */
.pi-exam__cal-body::before,
.pi-exam__cal-body::after {
	content: "";
	position: absolute;
	top: -4px;
	z-index: 4;
	width: 4px;
	height: 9px;
	background: var(--pi-navy);
	border-radius: 2px;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.pi-exam__cal-body::before {
	left: 26%;
}

.pi-exam__cal-body::after {
	right: 26%;
}


/* ------------------------------------------------------------------
   6. CALENDAR: PAGE PARTS
   ------------------------------------------------------------------ */
.pi-exam__cal-page {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	overflow: hidden;
	background: var(--pi-white);
	border: 1px solid var(--pi-border);
	border-radius: var(--cal-r);
	text-align: center;
}

/* Header bar: month and year */
.pi-exam__cal-head {
	display: flex;
	align-items: center;
	justify-content: center;
	align-self: stretch;
	gap: 4px;
	height: var(--cal-head);
	background: var(--pi-navy);
	color: var(--pi-white);
	font-size: var(--cal-head-fs);
	font-weight: 700;
	line-height: 1;
	font-family: "Plus Jakarta Sans", sans-serif;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.pi-exam__cal-year {
	color: rgba(255, 255, 255, 0.72);
	font-weight: 600;
}

/* Big day number */
.pi-exam__cal-day {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	font-family: var(--pi-font-heading);
	font-size: var(--cal-day-fs);
	font-weight: 700;
	line-height: 1;
	font-family: "Baloo 2", sans-serif;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}

.pi-exam__cal-weekday {
	padding-bottom: 8px;
	color: var(--pi-muted);
	font-size: var(--cal-sub-fs);
	font-weight: 600;
	line-height: 1;
	font-family: "Plus Jakarta Sans", sans-serif;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}


/* ------------------------------------------------------------------
   7. CALENDAR: DAYS-LEFT LINE
   Sits under the calendar and is centered on it. "flex" keeps it
   centered even when the text is wider than the calendar.
   ------------------------------------------------------------------ */
.pi-exam__cal .pi-exam__countdown {
	display: flex;
	justify-content: center;
	gap: 0.25em; /* space between the number and "days left" */
	margin-top: 12px;
	color: var(--pi-muted);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
}

.pi-exam__num {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}


/* ------------------------------------------------------------------
   8. PAGE LAYOUT BY SCREEN WIDTH
   Desktop is the default. These rules only change the page around
   the cards (padding, columns, gaps).

     Screen width     Cards per row
     ---------------  -------------
     768px and up     3  (list is 90% wide)
     381px to 767px   2
     380px and below  1
   ------------------------------------------------------------------ */

/* Phones (767px and below) */
@media (max-width: 767px) {
	.pi-exam {
		padding: 36px 0;
	}

	.pi-exam__inner {
		width: calc(100% - 32px);
	}

	.pi-exam__list {
		grid-template-columns: repeat(2, 1fr);
		gap: 12px;
		width: 100%;
	}

	.pi-exam__item {
		min-height: 148px;
		padding: 16px;
	}
}

/* 2-column phones: slightly taller cards */
@media (min-width: 381px) and (max-width: 767px) {
	.pi-exam__item {
		min-height: 156px;
	}
}

/* Very small phones: 1 column */
@media (max-width: 380px) {
	.pi-exam__list {
		grid-template-columns: 1fr;
	}
}

/* Roomier gap between cards in these two width ranges */
@media (min-width: 366px) and (max-width: 380px),
       (min-width: 712px) and (max-width: 767px) {
	.pi-exam__list {
		gap: 15px;
	}
}


/* ------------------------------------------------------------------
   9. CALENDAR LAYOUT BY SCREEN WIDTH

   The calendar is always on the RIGHT side of the card. Its size
   changes with the screen width:

     Screen width            Calendar
     ----------------------  ----------------------------------------
     1114px and up           Large, right side           (9A, default)
     768px to 1113px         Small tile, right side      (9B)
     712-767px, 366-380px    Medium, right side          (9D)
     381-711px, up to 365px  Small tile, bottom-right    (9E)

   Order matters: each block overrides the one above it.
   ------------------------------------------------------------------ */

/* 9A. Large screens: default sizes from section 5, nothing to add. */


/* 9B. Medium screens: small tile */
@media (min-width: 768px) and (max-width: 1113px) {
	.pi-exam__cal {
		--cal-w: 80px;
		--cal-h: 70px;
		--cal-r: 7px;
		--cal-head: 17px;
		--cal-head-fs: 10px;
		--cal-day-fs: 24px;
		--cal-sub-fs: 10px;
		--cal-perspective: 220px;
	}

	.pi-exam__cal .pi-exam__countdown {
		margin-top: 10px;
		font-size: 12px;
	}

    .pi-exam__item{
		min-height: 140px;
		padding: 15px;	
	}

	.pi-exam__list{
		width: 95%;
		gap: 15px;
	}

	.pi-exam__name{
		font-size: 16px;
	}
	
	.pi-exam__cal-year {
		padding-bottom: 6px;
	}
}


/* 9C. Small tile design (shared by 9B and 9E):
   month-only header, weekday hidden, year moved under the day */
@media (min-width: 768px) and (max-width: 1113px),
       (max-width: 365px),
       (min-width: 381px) and (max-width: 711px) {

	.pi-exam__cal-head {
		display: contents;
	}

	.pi-exam__cal-month {
		display: flex;
		align-items: center;
		justify-content: center;
		align-self: stretch;
		height: var(--cal-head);
		background: var(--pi-navy);
	}

	/* Order inside the tile: month, day, year */
	.pi-exam__cal-day {
		order: 1;
	}

	.pi-exam__cal-year {
		order: 2;
		color: var(--pi-muted);
		font-size: var(--cal-sub-fs);
		letter-spacing: 0.04em;
	}

	.pi-exam__cal-weekday {
		display: none;
	}
}


/* 9D. Phones, medium calendar
   (366-380px = 1 column, 712-767px = 2 columns) */
@media (min-width: 366px) and (max-width: 380px),
       (min-width: 712px) and (max-width: 767px) {

	.pi-exam__cal {
		--cal-w: 78px;
		--cal-h: 86px;
		--cal-r: 8px;
		--cal-head: 20px;
		--cal-head-fs: 10px;
		--cal-day-fs: 30px;
		--cal-sub-fs: 10px;
	}

	.pi-exam__cal-weekday {
		padding-bottom: 7px;
	}
}


@media (max-width: 365px),
       (min-width: 381px) and (max-width: 711px) {

	.pi-exam__cal {
		--cal-w: 80px;
		--cal-h: 70px;
		--cal-r: 6px;
		--cal-head: 16px;
		--cal-head-fs: 10px;
		--cal-day-fs: 22px;
		--cal-sub-fs: 9px;
		--cal-perspective: 200px;
	}

	.pi-exam__cal-year {
		padding-bottom: 5px;
	}

	/* Card grid: 3 rows */
	.pi-exam__item {
		display: flex;
        flex-direction: column;
        align-items: center;
		row-gap: 10px;
	}

	/* "display: contents" lets the name and chip sit directly in the card grid */
	.pi-exam__top {
		display: block;
	}

	.pi-exam__category {
		grid-column: 1 / -1;
		grid-row: 1;
		margin-bottom: 5px;
	}

	.pi-exam__name {
		grid-column: 1 / -1;
		grid-row: 2;
	}

	.pi-exam__chip {
		grid-column: 1;
		grid-row: 3;
		justify-self: start;
	}

	.pi-exam__cal {
		grid-column: 2;
		grid-row: 3;
		align-self: end;
	}
}


/* Days-left line: same on every phone card */
@media (max-width: 767px) {
	.pi-exam__cal .pi-exam__countdown {
		margin-top: 10px;
		font-size: 12px;
	}

	.pi-exam__name{
		font-size: 18px;
		margin-right: 5px;
	}
}

.pi-exam__cal-sheet {
	position: absolute;
	inset: 0;
	z-index: 3;
	transform-origin: 50% 0;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	animation: pi-exam-cal-turn var(--cal-turn-ms, 700ms) cubic-bezier(0.4, 0.05, 0.3, 1) forwards;
	will-change: transform, opacity;
}

/* Shadow on the old page as it bends away from the light */
.pi-exam__cal-sheet::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: var(--cal-r);
	background: linear-gradient(to bottom, rgba(10, 36, 71, 0) 25%, rgba(10, 36, 71, 0.3));
	opacity: 0;
	animation: pi-exam-cal-shade var(--cal-turn-ms, 700ms) ease-in forwards;
}

/* The new page underneath starts in shadow, then brightens */
.pi-exam__cal.is-turning .pi-exam__cal-body > .pi-exam__cal-page::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to bottom, rgba(10, 36, 71, 0.2), rgba(10, 36, 71, 0) 75%);
	animation: pi-exam-cal-reveal 700ms ease-out forwards;
}

@keyframes pi-exam-cal-turn {
	0% {
		transform: rotateX(0deg) rotateZ(0deg);
		opacity: 1;
	}
	15% {
		transform: rotateX(10deg) rotateZ(-1deg);
	}
	65% {
		transform: rotateX(74deg) rotateZ(-3deg) translateY(-2px);
		opacity: 1;
	}
	100% {
		transform: rotateX(100deg) rotateZ(-4deg) translateY(-6px);
		opacity: 0;
	}
}

@keyframes pi-exam-cal-shade {
	to {
		opacity: 1;
	}
}

@keyframes pi-exam-cal-reveal {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}


/* ------------------------------------------------------------------
   11. REDUCED MOTION
   Visitors who prefer less motion see no page-turn animation.
   ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
	.pi-exam__cal-sheet {
		display: none;
		animation: none;
	}

	.pi-exam__cal.is-turning .pi-exam__cal-body > .pi-exam__cal-page::after {
		content: none;
		animation: none;
	}
}