/* The screen, the tab bar and building blocks shared by several screens; tokens in tokens.css. */
/* All values come from the Claude Design canvas (see LLM/ASSETS.md). */

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

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--ground);
	color: var(--ink);
	font-family: var(--sans);
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
	margin: 0;
}

a {
	color: var(--link);
}

a:hover {
	color: var(--link-hover);
}

button,
input,
textarea {
	font: inherit;
	color: inherit;
}

[hidden] {
	display: none !important;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ---- Screen ---- */

.app {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	background: var(--ground);
}

.screen {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: var(--top) 20px 20px;
	outline: none;
}

.page {
	display: flex;
	flex-direction: column;
	gap: 16px;
	min-height: 100%;
}

/* On a phone: the real safe areas instead of the status bar space from the design.
   The Android app sets --safe-top and --safe-bottom itself (its WebView has no env() insets). */
@media (max-width: 440px) {
	:root {
		--top: max(20px, calc(var(--safe-top, env(safe-area-inset-top)) + 12px));
		--bottom: max(20px, var(--safe-bottom, env(safe-area-inset-bottom)));
	}

	/* Below the app, behind Safari's floating toolbar: the tab bar's colour, so Safari tints its
	   toolbar to match the tab bar instead of showing a beige band under it */
	html:not(.is-app) {
		background: var(--bar);
	}

	/* The app is a fixed screen that scrolls inside (.screen); the page itself never moves, so
	   the tab bar can't be dragged along when you swipe (iOS bounces the whole page otherwise) */
	html:not(.is-app),
	html:not(.is-app) body {
		height: 100%;
		overflow: hidden;
		overscroll-behavior: none;
	}

	.screen {
		overscroll-behavior: contain;
	}
}

/* Installed on the home screen: no browser toolbar, pin the app to the screen like the apps */
@media (max-width: 440px) and (display-mode: standalone) {
	html:not(.is-app) body {
		position: fixed;
		inset: 0;
	}
}

/* The apps are always a phone screen, also on a wide phone */
.is-app {
	--top: max(20px, calc(var(--safe-top, env(safe-area-inset-top)) + 12px));
	--bottom: max(20px, var(--safe-bottom, env(safe-area-inset-bottom)));
}

/* No browser feel in the apps: no text selection or link previews outside fields, no page bounce */
.is-app body {
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
	overscroll-behavior: none;
}

.is-app input,
.is-app textarea {
	-webkit-user-select: text;
	user-select: text;
}

/* Larger screen: the phone screen from the design, centred (not in the apps) */
@media (min-width: 441px) {
	html:not(.is-app) body {
		display: flex;
		align-items: center;
		justify-content: center;
		min-height: 100vh;
		background: var(--desk);
	}

	html:not(.is-app) .app {
		width: var(--screen-width);
		height: min(var(--screen-height), 100vh - 32px);
		border-radius: 44px;
		box-shadow: 0 24px 60px rgba(43, 42, 38, 0.16), 0 2px 8px rgba(43, 42, 38, 0.06);
	}
}

/* ---- Tab bar ---- */

.tabbar {
	flex: none;
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 4px;
	padding: 4px 8px var(--bottom);
	background: var(--bar);
	border-top: 1px solid var(--bar-line);
}

.tabbar__tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	min-height: 72px;
	padding-top: 6px;
	border-radius: 16px;
	color: var(--ink-soft);
	font-size: 12.5px;
	text-decoration: none;
}

.tabbar__tab:hover {
	background: var(--hover);
	color: var(--ink-soft);
}

.tabbar__tab[aria-current="page"] {
	color: var(--link);
	font-weight: 500;
}

.tabbar__icon {
	overflow: visible;
}

.tabbar__icon .bird,
.tabbar__icon .page-flip {
	display: none;
}

.tabbar__tab[aria-current="page"] .tabbar__icon--home,
.tabbar__tab[aria-current="page"] .tabbar__icon--journal {
	fill: var(--accent);
	stroke: var(--accent);
	stroke-width: 1.2;
}

.tabbar__tab[aria-current="page"] .tabbar__icon--journal {
	stroke-width: 1.3;
}

.tabbar__tab[aria-current="page"] .tabbar__icon--routine {
	stroke: var(--accent);
	stroke-width: 1.6;
}

.tabbar__tab[aria-current="page"] .bird {
	display: inline;
	fill: none;
}

.tabbar__tab[aria-current="page"] .page-flip {
	display: inline;
	fill: var(--sand);
}

.bird--a {
	animation: bird-a 3.2s ease-in-out infinite;
}

.bird--b {
	animation: bird-b 3.6s ease-in-out infinite;
}

.bird__flap {
	animation: flap 0.5s ease-in-out infinite;
}

.bird--a .bird__flap {
	transform-origin: -1px 3px;
}

.bird--b .bird__flap {
	transform-origin: 23.6px 0;
}

.tabbar__tab[aria-current="page"] .rays {
	transform-origin: 12px 12px;
	animation: rays-small 2.4s ease-in-out infinite;
}

.page-flip {
	transform-origin: 12px 12px;
	animation: flip 3.2s ease-in-out infinite;
}

@keyframes bird-a {
	0%, 100% { transform: translate(0, 0); }
	25% { transform: translate(2px, -2px); }
	50% { transform: translate(4px, 0); }
	75% { transform: translate(2px, 1.5px); }
}

@keyframes bird-b {
	0%, 100% { transform: translate(0, 0); }
	25% { transform: translate(-2px, 1.5px); }
	50% { transform: translate(-3px, -1px); }
	75% { transform: translate(-1px, -2px); }
}

@keyframes flap {
	0%, 100% { transform: scaleY(1); }
	50% { transform: scaleY(0.35); }
}

@keyframes rays-small {
	0%, 100% { transform: scale(0.9) rotate(0deg); }
	50% { transform: scale(1.18) rotate(10deg); }
}

@keyframes flip {
	0%, 30% { transform: scaleX(1); opacity: 1; }
	60%, 80% { transform: scaleX(-1); opacity: 1; }
	92% { transform: scaleX(-1); opacity: 0; }
	100% { transform: scaleX(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
	}
}

/* ---- Header with back button ---- */

.topbar {
	display: grid;
	grid-template-columns: 44px 1fr 44px;
	align-items: center;
}

.topbar__title {
	font-family: var(--serif);
	font-size: 21px;
	font-weight: 400;
	text-align: center;
}

.back {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
	color: var(--ink);
	text-decoration: none;
}

.back:hover {
	color: var(--ink);
	background: var(--hover);
}

.icon-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	cursor: pointer;
}

/* ---- Buttons ---- */

.primary-button {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	min-height: 52px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: var(--accent);
	color: var(--on-accent);
	font-family: var(--serif);
	font-size: 15.5px;
	cursor: pointer;
}

a.primary-button {
	text-decoration: none;
}

.primary-button:disabled {
	opacity: 0.6;
	cursor: default;
}

.round-button {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 1px solid var(--line-strong);
	border-radius: 50%;
	background: var(--surface);
	color: var(--ink);
	cursor: pointer;
}

.text-button {
	align-self: center;
	min-height: 44px;
	padding: 0 16px;
	border: 0;
	background: transparent;
	color: var(--link);
	font-size: 14px;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* A destructive action (delete account) */
.danger-button {
	min-height: 52px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: var(--error);
	color: var(--on-accent);
	font-family: var(--serif);
	font-size: 15.5px;
	cursor: pointer;
}

.danger-button:disabled {
	opacity: 0.6;
	cursor: default;
}

/* On/off switch: <input type="checkbox" role="switch" class="switch"> */
.switch {
	appearance: none;
	-webkit-appearance: none;
	flex: none;
	position: relative;
	width: 48px;
	height: 28px;
	margin: 0;
	border-radius: 999px;
	background: var(--line-strong);
	cursor: pointer;
	transition: background 0.2s;
}

.switch::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--surface);
	box-shadow: 0 1px 3px rgba(43, 42, 38, 0.2);
	transition: transform 0.2s;
}

.switch:checked {
	background: var(--accent);
}

.switch:checked::after {
	transform: translateX(20px);
}

.switch:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ---- Segmented control (Morning/Evening, language) ---- */

.segmented {
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: column;
	gap: 4px;
	padding: 4px;
	background: var(--track);
	border-radius: 999px;
}

.segmented__option {
	min-height: 40px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-size: 13.5px;
	font-weight: 500;
	cursor: pointer;
}

.segmented__option[aria-pressed="true"] {
	background: var(--bar);
	color: var(--ink);
}

.segmented--small {
	align-self: center;
	width: 220px;
}

/* ---- Forms ---- */

.form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.field__label {
	font-size: 13px;
	color: var(--muted);
}

.field__input {
	min-height: 48px;
	padding: 0 16px;
	border: 1px solid var(--line-strong);
	border-radius: 14px;
	background: var(--surface);
	font-size: 15px;
}

.field__input:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.field__hint {
	font-size: 12px;
	font-weight: 300;
	color: var(--muted);
}

.form-error {
	font-size: 13.5px;
	color: var(--error);
}

.form-done {
	font-size: 13.5px;
	color: var(--accent-ink);
}

.section-title {
	font-family: var(--serif);
	font-size: 17px;
	font-weight: 400;
}

.section-title small {
	font-family: var(--sans);
	font-size: 12px;
	font-weight: 300;
	color: var(--muted);
}

/* A journal entry; also used for the completed challenge */
.entry {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 14px 10px 10px;
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--surface);
	color: var(--ink);
	text-decoration: none;
}

.entry:hover {
	color: var(--ink);
	background: var(--hover);
}

.entry__date {
	flex: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	width: 58px;
	padding: 8px 0;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--ground);
	font-size: 11.5px;
	letter-spacing: 0.4px;
}

.entry__day {
	font-size: 22px;
	line-height: 1.1;
	letter-spacing: 0;
}

.entry__badge {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 74px;
	border-radius: 12px;
	background: var(--accent);
	color: var(--on-accent);
}

.entry__body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.entry__title {
	font-family: var(--serif);
	font-size: 14.5px;
	color: var(--accent-ink);
}

.entry__text {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	font-size: 13px;
	font-weight: 300;
	line-height: 1.45;
}

/* ---- Avatar: the profile photo, or the first letter of the name (Home, Settings) ---- */

.avatar {
	flex: none;
	display: flex;
	width: 64px;
	height: 64px;
	padding: 2px;
	border: 2px solid var(--ring);
	border-radius: 50%;
}

.avatar__initial,
.avatar__photo {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	border-radius: 50%;
}

.avatar__initial {
	background: var(--sand);
	color: var(--accent-ink);
	font-family: var(--serif);
	font-size: 24px;
}

.avatar__photo {
	object-fit: cover;
}

.avatar--link {
	color: inherit;
	text-decoration: none;
}

.avatar--large {
	width: 96px;
	height: 96px;
}

.avatar--large .avatar__initial {
	font-size: 36px;
}

/* ---- Time picker (reminders): hours and minutes with up/down ---- */

.time-picker {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
}

.time-picker.is-disabled {
	opacity: 0.4;
}

.time-picker__unit {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
}

.time-picker__step {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: transparent;
	color: var(--accent-ink);
	cursor: pointer;
}

.time-picker__step:disabled {
	cursor: default;
}

.time-picker__value {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 56px;
	padding: 0;
	border: 1px solid var(--line-strong);
	border-radius: 16px;
	background: var(--surface);
	color: var(--ink);
	font-family: var(--serif);
	font-size: 30px;
	line-height: 1;
	text-align: center;
}

.time-picker__value--button {
	cursor: pointer;
	text-decoration: underline dotted var(--line-strong);
	text-underline-offset: 6px;
}

.time-picker__input:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.time-picker__colon {
	font-family: var(--serif);
	font-size: 30px;
	color: var(--muted);
}
