@font-face { font-family: "Amiri"; src: url("fonts/Amiri-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("fonts/Amiri-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
	--bg: #f5f0e6;
	--ink: #17171a;
	--muted: #a39d91;
	--soft: #6d685f;
	--accent: #0b7a5a;
	--accent-soft: #0b7a5a1f;
	--text-size: clamp(26px, 3.4vw, 36px);
	--line: 1.95;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: "Amiri", serif; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }
button { font: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 28px clamp(20px, 5vw, 56px); }
.brand { display: flex; align-items: baseline; gap: 10px; font-family: -apple-system, "SF Pro Display", "Helvetica Neue", Arial, sans-serif; }
.brand b { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.brand .ar { font-family: "Amiri", serif; font-weight: 700; font-size: 33px; color: var(--accent); }

.status { display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 20px; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
.status.ready .dot { background: var(--accent); animation: none; }
.status.failed .dot { background: #d64545; animation: none; }
@keyframes pulse { 50% { opacity: .25; } }

.page { width: min(860px, 100% - 40px); margin: clamp(24px, 9vh, 110px) auto 0; flex: 1; }

.editor { position: relative; }
.editor textarea, .backdrop {
	font-family: "Amiri", serif;
	font-size: var(--text-size);
	line-height: var(--line);
	direction: rtl;
	text-align: right;
	white-space: pre-wrap;
	overflow-wrap: break-word;
	word-break: normal;
	padding: 0;
	margin: 0;
	border: 0;
	letter-spacing: 0;
	width: 100%;
}
.backdrop { position: absolute; inset: 0; color: var(--ink); pointer-events: none; }
.editor textarea {
	position: relative;
	display: block;
	min-height: calc(var(--text-size) * var(--line) * 4);
	resize: none;
	overflow: hidden;
	background: transparent;
	color: transparent;
	caret-color: var(--accent);
	outline: none;
}
.editor textarea::placeholder { color: var(--muted); }
.editor textarea::selection { background: #0b7a5a33; color: transparent; }

mark.fix {
	position: relative;
	color: inherit;
	background: linear-gradient(var(--accent), var(--accent)) no-repeat right bottom 0.18em / 100% 3px;
	border-radius: 2px;
}
mark.fix.fresh { animation: underline .55s cubic-bezier(.22, .9, .3, 1) both, glow 1.4s ease-out both; animation-delay: calc(var(--age) * -1ms); }
mark.fix.fresh::before {
	content: attr(data-original);
	position: absolute;
	right: 0;
	top: 0;
	color: var(--muted);
	white-space: nowrap;
	animation: float-away .6s cubic-bezier(.3, .7, .3, 1) both;
	animation-delay: calc(var(--age) * -1ms);
}
@keyframes underline { from { background-size: 0 3px; } to { background-size: 100% 3px; } }
@keyframes glow { from { box-shadow: 0 0 0 .18em var(--accent-soft); background-color: var(--accent-soft); } to { box-shadow: 0 0 0 .18em transparent; background-color: transparent; } }
@keyframes float-away { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-1.1em); } }

.popover {
	position: absolute;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 8px 10px 8px 16px;
	background: var(--ink);
	color: #f5f0e6;
	border-radius: 12px;
	font-size: 21px;
	box-shadow: 0 10px 30px #17171a33;
	transform: translate(-50%, calc(-100% - 10px));
	animation: pop .18s ease-out;
}
.popover[hidden] { display: none; }
.popover b { color: #f3d9a4; font-weight: 700; }
.popover button { border: 0; border-radius: 8px; padding: 2px 12px 4px; background: #ffffff1f; color: inherit; cursor: pointer; }
.popover button:hover { background: #ffffff33; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, calc(-100% - 4px)); } }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 28px; padding-top: 18px; border-top: 1px solid #17171a14; }
.chip, .count { white-space: nowrap; }
.chip { border: 0; border-radius: 999px; padding: 6px 18px 9px; font-size: 21px; background: var(--accent-soft); color: var(--accent); cursor: pointer; transition: background .15s, transform .1s; }
.chip:hover { background: #0b7a5a2e; }
.chip:active { transform: scale(.97); }
.chip.ghost { background: transparent; color: var(--soft); }
.chip.ghost:hover { background: #17171a0d; }
.chip:disabled { opacity: .4; cursor: default; }
.sound { margin-inline-start: auto; }
.sound[aria-pressed="false"] { text-decoration: line-through; }
.count { color: var(--soft); font-size: 21px; }

.note { text-align: center; color: var(--muted); font-size: 19px; margin: 40px 20px 120px; }
canvas#dots { position: fixed; left: 0; bottom: 0; width: 100%; height: 120px; pointer-events: none; z-index: 0; }
.top, .page, .note { position: relative; z-index: 1; }
