/* Base styles: reset, type, layout helpers and the small component set every page shares.
   Components: .btn (+ --primary --soft --ghost --small), .chip, .card, .field, .notice, .table, .tag-rarity.
   Layout helpers: .wrap, .stack, .cluster, .grid. Headings: .display (Markazi Text), .lead, .muted. */

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }

html {
	overflow-x: clip;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	font-family: var(--font-text);
	font-size: 17px;
	line-height: 1.9;
	color: var(--ink);
	/* The page colour lives on html, not body: a body background is painted above the negative z-index canvases
	   (the colour field and the sky), which would hide both. */
	background: linear-gradient(165deg, var(--paper) 0%, var(--mist-1) 58%, var(--mist-2) 140%) fixed;
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--head-h) + 16px);
}

body {
	margin: 0;
	min-height: 100dvh;
	overflow-x: clip;
}

h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.25em; }
[hidden] { display: none !important; }
::selection { background: var(--lilac); color: var(--ink); }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; border-radius: var(--r-sm); }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

/* Type ----------------------------------------------------------------- */
.display {
	font-family: var(--font-display);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0;
	color: var(--ink);
}
h1.display { font-size: var(--t-3xl); }
h2.display { font-size: var(--t-2xl); }
h3, .h3 { font-size: var(--t-md); font-weight: 700; line-height: 1.6; }
.lead { font-size: var(--t-md); line-height: 2; color: var(--ink-2); max-width: 38em; }
.muted { color: var(--ink-3); }
.small { font-size: var(--t-sm); }
.mono { font-family: var(--font-mono); direction: ltr; unicode-bidi: isolate; letter-spacing: 0.04em; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }

/* Layout --------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.stack > * + * { margin-block-start: var(--stack, var(--s-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--s-3)); }
.grid { display: grid; gap: var(--gap, var(--s-5)); }
main { display: block; padding-block-start: calc(var(--head-h) + var(--s-5)); }
.section { padding-block: var(--s-8); position: relative; }

/* Buttons -------------------------------------------------------------- */
.btn {
	--btn-bg: var(--violet-soft);
	--btn-fg: var(--violet-deep);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.6em;
	min-height: 48px;
	padding: 0.6em 1.5em;
	border: 0;
	border-radius: var(--r-pill);
	background: var(--btn-bg);
	color: var(--btn-fg);
	font-weight: 600;
	font-size: var(--t-base);
	line-height: 1.4;
	text-decoration: none;
	white-space: nowrap;
	transition: transform var(--d-1) var(--ease), background-color var(--d-1) var(--ease), box-shadow var(--d-2) var(--ease), color var(--d-1) var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { --btn-bg: var(--pink); --btn-fg: #fff; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.7); }
.btn--primary:hover { --btn-bg: var(--pink-hover); }
.btn--soft:hover { --btn-bg: var(--mist-3); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--ink-2); }
.btn--ghost:hover { --btn-bg: var(--violet-soft); }
.btn--small { min-height: 36px; padding: 0.3em 1.05em; font-size: var(--t-sm); }
.btn svg { width: 1.15em; height: 1.15em; flex: none; }

/* Chips and rarity ----------------------------------------------------- */
.chip {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	padding: 0.1em 0.8em;
	border-radius: var(--r-pill);
	background: var(--violet-soft);
	color: var(--violet-deep);
	font-size: var(--t-xs);
	font-weight: 600;
	line-height: 1.9;
	white-space: nowrap;
}
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--bad { background: var(--bad-soft); color: var(--bad); }
.chip--pink { background: var(--pink-soft); color: var(--pink-deep); }

.tag-rarity { --c: var(--rarity-common); display: inline-flex; align-items: center; gap: 0.45em; font-size: var(--t-xs); font-weight: 600; color: var(--c); }
.tag-rarity::before { content: ""; width: 0.6em; height: 0.6em; border-radius: 2px; background: var(--c); transform: rotate(45deg); }
.tag-rarity[data-rarity="uncommon"] { --c: var(--rarity-uncommon); }
.tag-rarity[data-rarity="rare"] { --c: var(--rarity-rare); }
.tag-rarity[data-rarity="epic"] { --c: var(--rarity-epic); }
.tag-rarity[data-rarity="legendary"] { --c: var(--rarity-legendary); }

/* Cards ---------------------------------------------------------------- */
.card {
	background: var(--card);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-1);
	padding: var(--s-5);
}

/* Forms ---------------------------------------------------------------- */
.field { display: grid; gap: var(--s-2); }
.field > label, .field > .label { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
	width: 100%;
	min-height: 50px;
	padding: 0.55em 1em;
	border: 0;
	border-radius: var(--r-md);
	background: var(--mist-1);
	color: var(--ink);
	box-shadow: inset 0 0 0 1.5px transparent;
	transition: box-shadow var(--d-1) var(--ease), background-color var(--d-1) var(--ease);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); opacity: 0.8; }
.field input:hover, .field select:hover { background: var(--mist-2); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 0; background: var(--card); box-shadow: inset 0 0 0 2px var(--violet); }
.field .hint { font-size: var(--t-xs); color: var(--ink-3); line-height: 1.8; }
.field .error { font-size: var(--t-xs); color: var(--bad); font-weight: 600; }

.notice { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--violet-soft); color: var(--violet-deep); font-size: var(--t-sm); line-height: 1.9; }
.notice--ok { background: var(--ok-soft); color: var(--ok); }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice--bad { background: var(--bad-soft); color: var(--bad); }

.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { text-align: start; font-weight: 600; color: var(--ink-3); padding: var(--s-2) var(--s-3); }
.table td { padding: var(--s-3); vertical-align: middle; }
.table tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--mist-1) 55%, transparent); }

/* Tilt: the pointer script (tilt.js) sets --rx, --ry and the highlight position on [data-tilt] ----- */
[data-tilt] {
	transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
	transform-style: preserve-3d;
	transition: transform var(--d-3) var(--ease), box-shadow var(--d-2) var(--ease);
	position: relative;
}
[data-tilt].is-tilting { transition: transform 90ms linear, box-shadow var(--d-2) var(--ease); box-shadow: var(--shadow-3); }
[data-tilt]::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	pointer-events: none;
	opacity: 0;
	background: radial-gradient(420px circle at var(--hx, 50%) var(--hy, 0%), rgba(255, 255, 255, 0.13), transparent 55%);
	transition: opacity var(--d-2) var(--ease);
}
[data-tilt].is-tilting::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
	[data-tilt] { transform: none !important; }
}

@media (max-width: 720px) {
	html { font-size: 16px; }
	h1.display { font-size: var(--t-2xl); }
	h2.display { font-size: var(--t-xl); }
	.section { padding-block: var(--s-7); }
}
