/* The student app's ivory paper theme and hand-drawn primitives (students/app/src/app/globals.css). */

:root {
	--paper: #f5eedd;
	--paper-deep: #e9dfc8;
	--card: #fbf7ec;
	--card-edge: #e3d8bf;
	--ink: #1c2a4d;
	--ink-soft: #4a5573;
	--ink-faint: #8b8e98;
	--line: rgb(28 42 77 / 0.16);
	--red: #c0402b;
	--green: #2d7a4c;
	--amber: #c4861a;
	--teal: #1d7676;
	--highlight: rgb(247 214 92 / 0.72);
	--shadow: rgb(70 52 22 / 0.16);
	--vignette: rgb(120 92 40 / 0.16);
	--font-hand: "Caveat", "Segoe Print", cursive;
	--font-body: "Kalam", ui-rounded, system-ui, sans-serif;
	--font-mono: "Courier Prime", ui-monospace, monospace;
	--sketch: 255px 18px 225px 18px / 18px 225px 18px 255px;
	color-scheme: light;
}

/* Scripts Caveat and Kalam don't cover get their own faces first, as Sinhala and Tamil do in the app. */
.script-Latn {
	--font-hand: "Caveat", "Segoe Print", cursive;
	--font-body: "Kalam", ui-rounded, system-ui, sans-serif;
	line-height: 1.6;
}
.script-Beng {
	--font-hand: "Atma", "Noto Sans Bengali", "Caveat", cursive;
	--font-body: "Noto Sans Bengali", "Kalam", sans-serif;
}
.script-Cakm {
	--font-hand: "Noto Sans Chakma", "Noto Sans Bengali", "Caveat", cursive;
	--font-body: "Noto Sans Chakma", "Noto Sans Bengali", "Kalam", sans-serif;
	line-height: 1.95;
}
.script-Mymr {
	--font-hand: "Noto Sans Myanmar", "Noto Sans Bengali", "Caveat", cursive;
	--font-body: "Noto Sans Myanmar", "Noto Sans Bengali", "Kalam", sans-serif;
	line-height: 2;
}
.script-Java {
	--font-hand: "Noto Sans Javanese", "Caveat", cursive;
	--font-body: "Noto Sans Javanese", "Kalam", sans-serif;
	line-height: 2.1;
}
.script-Sund {
	--font-hand: "Noto Sans Sundanese", "Caveat", cursive;
	--font-body: "Noto Sans Sundanese", "Kalam", sans-serif;
	line-height: 1.95;
}
.script-Bali {
	--font-hand: "Noto Sans Balinese", "Caveat", cursive;
	--font-body: "Noto Sans Balinese", "Kalam", sans-serif;
	line-height: 2.3;
}
.script-Bugi {
	--font-hand: "Noto Sans Buginese", "Caveat", cursive;
	--font-body: "Noto Sans Buginese", "Kalam", sans-serif;
	line-height: 1.95;
}
.script-Batk {
	--font-hand: "Noto Sans Batak", "Caveat", cursive;
	--font-body: "Noto Sans Batak", "Kalam", sans-serif;
	line-height: 1.95;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html,
body {
	min-height: 100%;
}

body {
	margin: 0;
	background-color: var(--paper);
	color: var(--ink);
	font: 16px / 1.6 var(--font-body);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

::selection {
	background: var(--highlight);
	color: var(--ink);
}

/* Paper: grain + long fibres + a warm vignette, fixed behind everything. */
body::before,
body::after {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	mix-blend-mode: multiply;
}
body::before {
	background-image:
		radial-gradient(ellipse at 50% 40%, transparent 55%, var(--vignette) 100%),
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012 0.32' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.36 0 0 0 0 0.2 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
	background-size:
		100% 100%,
		300px 300px;
	opacity: 0.28;
}
body::after {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.24 0 0 0 0 0.15 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	background-size: 180px 180px;
	opacity: 0.55;
}
body > * {
	position: relative;
	z-index: 1;
}

button,
input {
	font: inherit;
	color: inherit;
}
button {
	cursor: pointer;
}
:focus-visible {
	outline: 2px dashed var(--red);
	outline-offset: 2px;
}

/* Shared labels */
.kicker,
.legend {
	margin: 0;
	font: 0.75rem var(--font-mono);
	letter-spacing: 0.25em;
	text-transform: uppercase;
	color: var(--red);
}
.legend {
	margin-bottom: 0.4rem;
	padding: 0;
	font-size: 0.69rem;
	letter-spacing: 0.2em;
	color: var(--ink-faint);
}
.mono {
	font: 0.75rem var(--font-mono);
	color: var(--ink-faint);
}
.red {
	color: var(--red);
}

/* Top bar with the brand */
.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	max-width: 80rem;
	margin: 0 auto;
	padding: 1rem 1.5rem;
}
.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	color: var(--ink);
	text-decoration: none;
}
.brand svg {
	width: 2rem;
	height: 2rem;
	transition: transform 0.7s;
}
.brand:hover svg {
	transform: rotate(200deg);
}
.brand__name {
	font: 700 1.7rem / 1 var(--font-hand);
	letter-spacing: -0.01em;
}
.tag {
	padding: 0.2rem 0.75rem;
	border: 1.5px dashed var(--line);
	border-radius: 999px;
	font: 0.69rem var(--font-mono);
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--ink-soft);
}

.session {
	display: flex;
	align-items: center;
	gap: 1rem;
}
.session .link {
	font-size: 1.05rem;
}

/* Sign in */
.sign-in {
	display: grid;
	gap: 1rem;
	max-width: 26rem;
	margin: 4rem auto;
	padding: 0 1.5rem;
}
.sign-in .title {
	margin-bottom: 0.5rem;
}
.sign-in .sub {
	margin: 0;
}
.sign-in__form {
	display: grid;
	gap: 1.1rem;
	margin-top: 0.5rem;
}
.sign-in__form label {
	display: grid;
}
.sign-in__form input {
	padding: 0.2rem 0 0.35rem;
	border: 0;
	border-bottom: 2.5px solid color-mix(in oklab, var(--ink) 30%, transparent);
	outline: 0;
	background: transparent;
	font: 1.6rem / 1.3 var(--font-hand);
	color: var(--ink);
	transition: border-color 0.5s;
}
.sign-in__form input:focus {
	border-color: var(--ink);
}
.sign-in__form .ink-button {
	justify-self: start;
}
.sign-in__error {
	margin: 0;
	padding: 0.4rem 1rem;
	border: 2px solid color-mix(in oklab, var(--red) 40%, transparent);
	border-radius: 999px;
	background: var(--card);
	font: 1.15rem var(--font-hand);
	color: var(--red);
}

/* The page */
.page {
	display: grid;
	gap: 1.75rem;
	max-width: 76rem;
	margin: 0 auto;
	padding: 0.5rem 1.5rem 3rem;
}
.page-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1rem 2rem;
}
.title {
	position: relative;
	display: inline-block;
	margin: 0.25rem 0 0;
	font: 700 3.25rem / 1.05 var(--font-hand);
	color: var(--ink);
}
.title .underline {
	position: absolute;
	left: 0;
	bottom: -0.75rem;
	width: 100%;
	height: 1rem;
	color: var(--red);
	pointer-events: none;
}
.sub {
	max-width: 36rem;
	margin: 1.25rem 0 0;
	font-size: 0.94rem;
	color: var(--ink-soft);
}
.note {
	max-width: 22rem;
	margin: 0;
	font-size: 0.85rem;
	color: var(--ink-soft);
}
.hl {
	background-image: linear-gradient(
		100deg,
		transparent 0.5%,
		var(--highlight) 2%,
		var(--highlight) 96%,
		transparent 99%
	);
	background-repeat: no-repeat;
	background-size: 100% 62%;
	background-position: 0 88%;
	padding: 0 0.12em;
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
}

/* Medium pills: dashed when off, inked in when on */
.languages {
	margin: 0;
	padding: 0;
	border: 0;
}
.pills {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}
.pill {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4rem;
	padding: 0.1rem 0.8rem;
	border: 2px dashed color-mix(in oklab, var(--ink) 20%, transparent);
	border-radius: 999px;
	background: transparent;
	color: var(--ink-soft);
	font: 1.15rem / 1.5 var(--font-hand);
	transition:
		color 0.2s,
		border-color 0.2s,
		background-color 0.2s;
}
.pill:hover {
	border-color: var(--ink);
	color: var(--ink);
}
.pill[aria-pressed="true"] {
	border-style: solid;
	border-color: var(--ink);
	background: var(--ink);
	color: var(--paper);
}
.pill:disabled {
	opacity: 0.4;
	pointer-events: none;
}
.pill__native {
	font-family: var(--font-hand);
	font-size: 1.15rem;
	line-height: 1.5;
}
.pill__name {
	font: 0.62rem var(--font-mono);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	opacity: 0.75;
}
.pill__tag {
	font: 700 0.6rem var(--font-mono);
	letter-spacing: 0.1em;
	color: var(--amber);
}
.pill[aria-pressed="true"] .pill__tag {
	color: var(--highlight);
}
.pill--small {
	padding: 0 0.7rem;
	font-size: 1.05rem;
}

/* The reader: the taped print beside its text */
.reader {
	display: grid;
	grid-template-columns: minmax(17rem, 0.85fr) minmax(0, 1.15fr);
	gap: 2.5rem;
	align-items: start;
}
.print {
	position: sticky;
	top: 1.5rem;
	margin: 0;
	padding: 0.75rem;
	background: var(--card);
	border: 1.5px solid var(--card-edge);
	border-radius: 6px 10px 8px 12px / 10px 6px 12px 8px;
	box-shadow:
		0 1px 0 var(--card-edge),
		0 18px 32px -24px var(--shadow),
		0 2px 6px -3px var(--shadow);
	transform: rotate(-0.5deg);
}
.print img {
	display: block;
	width: 100%;
	border: 1px solid var(--line);
	background: #fff;
}
.print figcaption {
	margin-top: 0.5rem;
	text-align: center;
}
.print__missing {
	margin: 2rem 0;
	text-align: center;
	font: 1.4rem var(--font-hand);
	color: var(--ink-soft);
}
.tape {
	position: absolute;
	top: -0.7rem;
	width: 6rem;
	height: 1.5rem;
	opacity: 0.7;
	background: repeating-linear-gradient(
		45deg,
		color-mix(in oklab, var(--amber) 45%, transparent) 0 6px,
		color-mix(in oklab, var(--amber) 30%, transparent) 6px 12px
	);
	clip-path: polygon(2% 0, 98% 6%, 100% 92%, 0 100%, 3% 50%);
}
.tape--left {
	left: 1.5rem;
	transform: rotate(-4deg);
}
.tape--right {
	right: 1.5rem;
	transform: rotate(5deg);
}

.chapter {
	min-width: 0;
}
.pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	margin-bottom: 1rem;
}
.link {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0;
	border: 0;
	background: none;
	font: 1.15rem var(--font-hand);
	color: var(--ink-soft);
}
.link:hover {
	color: var(--ink);
}
.link:disabled {
	opacity: 0.35;
	pointer-events: none;
}
.pager__label {
	flex: 1;
	text-align: center;
}
.toggles {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	margin-bottom: 1.25rem;
}
.scripts {
	display: flex;
	gap: 0.3rem;
}

/* The page as clean text, as the app's textbook reader shows it */
.page-text {
	font-size: 1rem;
	line-height: 1.7;
	color: var(--ink);
}
.page-text h2 {
	margin: 1.75rem 0 0.6rem;
	font: 700 1.9rem / 1.15 var(--font-hand);
}
.page-text h2:first-child {
	margin-top: 0;
}
.page-text h2 + h2 {
	margin-top: 0.25rem;
	font-size: 1.5rem;
	color: var(--red);
}
.page-text p {
	margin: 0.6rem 0;
	white-space: pre-line;
}
.box {
	margin: 1rem 0;
	padding: 0.75rem 1rem;
	border: 2px dashed;
	border-radius: 0.5rem;
	white-space: pre-line;
}
.box--speech {
	border-color: color-mix(in oklab, var(--amber) 60%, transparent);
	background: color-mix(in oklab, var(--highlight) 30%, transparent);
}
.box--activity {
	border-color: color-mix(in oklab, var(--teal) 50%, transparent);
	background: color-mix(in oklab, var(--teal) 5%, transparent);
}
.box__label {
	display: block;
	margin-bottom: 0.25rem;
	font: 0.69rem var(--font-mono);
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--ink-faint);
}
.question {
	display: grid;
	grid-template-columns: 2.25rem 1fr;
	gap: 0.25rem;
	margin: 0.9rem 0;
	white-space: pre-line;
}
.question__number {
	font: 700 1.5rem / 1.2 var(--font-hand);
	color: var(--red);
}
.reading {
	display: block;
	font-family: "Noto Sans Bengali", "Kalam", sans-serif;
	font-size: 0.85em;
	line-height: 1.5;
	color: var(--ink-faint);
}
h2 .reading {
	margin-top: 0.1rem;
	font-size: 0.95rem;
	font-weight: 400;
}
.script-Java .reading,
.script-Sund .reading,
.script-Bali .reading,
.script-Bugi .reading,
.script-Batk .reading {
	font-family: "Kalam", sans-serif;
}
.hide-reading .reading {
	display: none;
}
.figure {
	margin: 1.25rem auto 0.5rem;
	max-width: 100%;
	border: 1px solid var(--line);
	border-radius: 0.375rem;
	background-color: #fff;
	background-repeat: no-repeat;
}
.figure-wrap {
	margin: 1.25rem 0;
	text-align: center;
}
.figure-wrap figcaption {
	max-width: 36rem;
	margin: 0 auto;
	font-size: 0.85rem;
	color: var(--ink-soft);
}
.figure-wrap .credit {
	display: block;
	font-size: 0.75rem;
	color: var(--ink-faint);
}
.figure-note {
	font-size: 0.9rem;
	font-style: italic;
	color: var(--ink-soft);
}
.page-text table {
	margin: 1rem 0;
	border-collapse: collapse;
	background: var(--card);
}
.page-text th,
.page-text td {
	padding: 0.35rem 0.7rem;
	border: 1px solid var(--line);
	text-align: left;
}
.page-text th {
	background: var(--paper-deep);
}
.empty {
	font: 1.4rem var(--font-hand);
	color: var(--ink-soft);
}

/* The teacher, as the app's tutor writes */
.teacher {
	margin-top: 2.5rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--line);
}
.teacher__title {
	margin: 0;
	font: 700 1.6rem var(--font-hand);
}
.teacher__sub {
	margin: 0.1rem 0 1rem;
	font-size: 0.9rem;
	color: var(--ink-soft);
}
.turn {
	padding: 1.25rem 0;
	border-bottom: 1px dashed var(--line);
}
.turn:last-child {
	border-bottom: 0;
}
.turn__q {
	position: relative;
	margin: 0 0 0.75rem;
	font: 700 1.75rem / 1.15 var(--font-hand);
}
.turn__q::before {
	content: "Q.";
	position: absolute;
	left: -2.25rem;
	top: 0.35rem;
	font: 0.85rem var(--font-mono);
	color: var(--red);
}
.turn__a {
	font-size: 1.08rem;
	line-height: 1.7;
}
.turn__a p {
	margin: 0.4rem 0;
}
.thinking {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--ink-soft);
}
.thinking span {
	font: 1.25rem var(--font-hand);
	background: linear-gradient(
		90deg,
		var(--ink-faint) 0%,
		var(--ink) 40%,
		var(--ink-faint) 60%,
		var(--ink-faint) 100%
	);
	background-size: 200% 100%;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	animation: shimmer-ink 2.6s linear infinite;
}
.scribble path {
	stroke-dasharray: 100;
	animation: scribble 2.4s ease-in-out infinite;
}

.ink-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	margin: 0.5rem 0 1.25rem;
	padding: 0.65rem 1.25rem;
	border: 2px solid var(--ink);
	border-radius: var(--sketch);
	background: var(--ink);
	color: var(--paper);
	font: 700 1.2rem / 1 var(--font-hand);
	letter-spacing: 0.025em;
	box-shadow: 3px 4px 0 0 var(--red);
	transition:
		transform 0.2s ease-out,
		box-shadow 0.2s ease-out;
}
.ink-button:hover {
	transform: translate(-1px, -1px);
	box-shadow: 5px 6px 0 0 var(--red);
}
.ink-button:active {
	transform: translate(2px, 2px);
	box-shadow: none;
}
.ink-button:disabled {
	opacity: 0.4;
	pointer-events: none;
}

/* The tutor's input: a ruled line and a round ink button */
.dock {
	display: flex;
	align-items: flex-end;
	gap: 0.75rem;
	padding-bottom: 0.5rem;
	border-bottom: 2.5px solid color-mix(in oklab, var(--ink) 30%, transparent);
	transition: border-color 0.5s;
}
.dock:focus-within {
	border-color: var(--ink);
}
.dock input {
	flex: 1;
	min-width: 0;
	padding: 0;
	border: 0;
	outline: 0;
	background: transparent;
	font: 1.6rem / 1.3 var(--font-hand);
	color: var(--ink);
}
.dock input::placeholder {
	color: var(--ink-faint);
}
.send {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 2.75rem;
	height: 2.75rem;
	margin-bottom: 0.25rem;
	border: 2px solid var(--ink);
	border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%;
	background: var(--ink);
	color: var(--paper);
	box-shadow: 2px 3px 0 0 var(--red);
	transition:
		transform 0.3s,
		box-shadow 0.3s;
}
.send:hover {
	transform: translateY(-2px);
	box-shadow: 3px 5px 0 0 var(--red);
}
.send:disabled {
	opacity: 0.3;
	pointer-events: none;
}

.footer {
	padding-top: 1rem;
	border-top: 1px solid var(--line);
	font-size: 0.75rem;
	color: var(--ink-faint);
}
.footer a {
	color: var(--ink-soft);
}

/* Motion */
.ink-draw {
	stroke-dasharray: var(--len, 1000);
	animation: ink-draw var(--dur, 1.1s) cubic-bezier(0.6, 0.1, 0.3, 1)
		var(--delay, 0s) both;
}
.page-in {
	animation: page-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.rise-in {
	animation: rise-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes ink-draw {
	from {
		stroke-dashoffset: var(--len, 1000);
	}
	to {
		stroke-dashoffset: 0;
	}
}
@keyframes page-in {
	from {
		opacity: 0;
		transform: translate3d(36px, 6px, 0) rotate(0.8deg);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
@keyframes rise-in {
	from {
		opacity: 0;
		transform: translate3d(0, 14px, 0);
		filter: blur(3px);
	}
	to {
		opacity: 1;
		transform: none;
		filter: none;
	}
}
@keyframes shimmer-ink {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}
@keyframes scribble {
	0% {
		stroke-dashoffset: 100;
	}
	55% {
		stroke-dashoffset: 0;
	}
	100% {
		stroke-dashoffset: -100;
	}
}
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-delay: 0ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

@media (min-width: 768px) {
	.title {
		font-size: 3.75rem;
	}
}
@media (max-width: 900px) {
	.reader {
		grid-template-columns: 1fr;
	}
	.print {
		position: static;
	}
	.turn__q::before {
		display: none;
	}
}
