/*
 * Shared shell: the phone-shaped frame, the palette, type, buttons and the
 * bits every scene uses. Scene-specific rules live in menu.css and game.css.
 */

@font-face {
	font-family: 'Bonveno';
	src: url('../assets/fonts/BonvenoCF-Light.otf') format('opentype');
	font-weight: 300;
	font-display: swap;
}

:root {
	--orange: #fbaf3f;
	--orange-dark: #e89a29;
	--ink: #1a1a1a;
	--ink-muted: #9a9a9a;
	--paper: #ffffff;
	--panel: #f1f1f2;
	--panel-line: #e4e4e6;

	--frame-width: 480px;
	--radius: 4px;
	--gutter: 16px;
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
}

body {
	background: var(--panel);
	color: var(--ink);
	font-family: 'Bonveno', 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
	font-weight: 300;
	letter-spacing: 0.14em;
	-webkit-font-smoothing: antialiased;
}

/* The play area. Capped so it keeps phone proportions on a desktop. */
#app {
	position: relative;
	width: 100%;
	max-width: var(--frame-width);
	height: 100%;
	margin: 0 auto;
	background: var(--paper);
	overflow: hidden;
	box-shadow: 0 0 60px rgba(0, 0, 0, 0.08);
}

.scene {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	padding: env(safe-area-inset-top) var(--gutter) env(safe-area-inset-bottom);
	animation: scene-in 0.25s ease both;
}

.scene-additive {
	background: rgba(255, 255, 255, 0.94);
	backdrop-filter: blur(2px);
}

@keyframes scene-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ type */

h1, h2 {
	margin: 0;
	font-weight: 300;
}

.logo-word {
	font-size: 34px;
	letter-spacing: 0.34em;
	text-indent: 0.34em;
	margin: 0;
}

.logo-word.small {
	font-size: 22px;
}

.muted { color: var(--ink-muted); }

/* --------------------------------------------------------------- buttons */

.cr-button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 18px 12px;
	border: none;
	border-bottom: 1px solid var(--panel-line);
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-size: 17px;
	letter-spacing: 0.22em;
	text-indent: 0.22em;
	cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}

.cr-button:last-child { border-bottom: none; }

.cr-button:active,
.cr-button:hover {
	background: var(--orange);
	color: var(--paper);
}

.cr-button.primary {
	background: var(--orange);
	color: var(--paper);
}

.cr-button.primary:active,
.cr-button.primary:hover {
	background: var(--orange-dark);
}

.cr-button.ghost {
	color: var(--ink-muted);
	font-size: 14px;
	padding: 16px 12px;
	border-top: 1px solid var(--panel-line);
	border-bottom: none;
}

.cr-button.ghost:active,
.cr-button.ghost:hover {
	background: var(--panel);
	color: var(--ink);
}

.button-icon {
	width: 22px;
	height: 22px;
	object-fit: contain;
}

.sound-button {
	border: none;
	background: transparent;
	padding: 8px;
	cursor: pointer;
	line-height: 0;
}

.sound-icon {
	width: 26px;
	height: 26px;
	object-fit: contain;
	opacity: 0.8;
}

/* ----------------------------------------------------------------- toast */

.toast-layer {
	position: fixed;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	width: 100%;
	max-width: var(--frame-width);
	z-index: 50;
	pointer-events: none;
	padding: 0 var(--gutter);
}

.achievement-toast {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: calc(12px + env(safe-area-inset-top));
	padding: 12px 16px;
	background: var(--ink);
	color: var(--paper);
	border-radius: var(--radius);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	animation: toast-in 0.3s ease both;
}

.achievement-toast.leaving {
	animation: toast-out 0.4s ease both;
}

.achievement-toast img {
	width: 34px;
	height: 34px;
	object-fit: contain;
}

.toast-kicker {
	font-size: 10px;
	letter-spacing: 0.2em;
	color: var(--orange);
}

.toast-title {
	font-size: 15px;
	letter-spacing: 0.16em;
}

@keyframes toast-in {
	from { opacity: 0; transform: translateY(-20px); }
	to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
	from { opacity: 1; transform: none; }
	to   { opacity: 0; transform: translateY(-20px); }
}

.toast {
	position: absolute;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	padding: 10px 18px;
	background: var(--ink);
	color: var(--paper);
	font-size: 12px;
	border-radius: var(--radius);
	animation: toast-in 0.2s ease both;
}

/* Hook for updating a button's text in place (the sound toggle). */
.button-label { display: inline-block; }

/* ------------------------------------------------------------------- hud */

/*
 * The trophy/coin strip. Shared by the menu and the game, which place it
 * identically: icons 78px tall on a 1179px-wide screen, sitting 6% in from
 * each edge, with the value tucked under each one.
 */
.game-hud {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	width: 100%;
	padding: 0 6%;
}

.hud-stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	/* The value's own leading supplies the gap under the icon. */
	gap: 0;
	min-width: 7.4cqw;
}

.hud-icon {
	width: 7.4cqw;
	height: 6.6cqw;
	object-fit: contain;
}

.hud-value {
	font-size: 6.2cqw;
	letter-spacing: 0.02em;
	line-height: 1;
	color: var(--ink);
}

/* ------------------------------------------------------------- wordmark */

/*
 * CROWNER with the crown centred over it. The original nudges the crown 15.5%
 * of the word's width to the left so it sits over the O; centred is a
 * deliberate departure.
 */
.hud-logo,
.menu-logo {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.logo-crown-mark {
	object-fit: contain;
	/* Lifted off the word by a fraction of its own height, so the gap holds
	   whatever size the crown is drawn at. */
	transform: translateY(-60%);
}

.logo-word-mark {
	line-height: 1.05;
	white-space: nowrap;
}

/* Small, inline between the two stats. */
.hud-logo { padding-top: 0.4cqw; }
.hud-logo .logo-crown-mark { width: 6.8cqw; }
.hud-logo .logo-word-mark { font-size: 5.6cqw; letter-spacing: 0.3em; text-indent: 0.3em; }

/* Large, under the stats on the menu. */
.menu-logo { margin-top: 11.6%; }
.menu-logo .logo-crown-mark { width: 12.1cqw; }
.menu-logo .logo-word-mark { font-size: 12.2cqw; letter-spacing: 0.22em; text-indent: 0.22em; }

/* The menu shows the website's logo image (crown + wordmark in one) instead. */
.menu-logo-image {
	display: block;
	width: 70cqw;
	max-width: 100%;
	height: auto;
	margin: 11.6% auto 0;
}
