/* Colors and font from hgrembecki.com (main.css), standalone. Laid out like a text conversation. */
:root {
	color-scheme: light dark;
	--text:         #585858;
	--muted:        #909090;
	--bg:           #ffffff;
	--them-bg:      #ececec;
	--them-text:    #3a3a3a;
	--line:         #d4d4d4;
	--hover:        #e98800;   /* portfolio orange: focus ring */
	--me:           #c46e00;   /* deeper shade of it, so white text stays readable */
	--me-press:     #a85d00;
}

@media (prefers-color-scheme: dark) {
	:root {
		--text:      #e0e0e0;
		--muted:     #a7a7a7;
		--bg:        #1a1a1a;
		--them-bg:   #333333;
		--them-text: #e8e8e8;
		--line:      #444444;
	}
}

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

html, body { margin: 0; }

body {
	background-color: var(--bg);
	color: var(--text);
	font-family: "Source Sans Pro", Helvetica, sans-serif;
	font-size: 14pt;
	font-weight: 300;
	line-height: 1.75;
	-webkit-text-size-adjust: none;
}

@media (max-width: 736px) {
	body { font-size: 12pt; }
}

/* A chat log: each step appears under the last and the page scrolls down to it.
   The message box stays pinned at the bottom. noscript.css shows every step. */
#chat {
	max-width: 36rem;
	min-height: 100vh;
	min-height: 100svh;
	margin: 0 auto;
	padding: max(1.25rem, env(safe-area-inset-top)) 1rem 0;
	display: flex;
	flex-direction: column;
}

/* Every message (picture, bubble, title) is a flex item, so one --gap spaces them all. */
#log {
	--gap: 0.6rem;
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	gap: var(--gap);
	padding-bottom: calc(var(--compose-h, 6rem) + var(--gap));
}

.step { display: none; }
.step.shown, .step:first-child:not(.started) {
	display: flex;
	flex-direction: column;
	gap: var(--gap);
}

.thread { display: contents; }

/* The cat's turn: typing bubble, then the picture, then its words (app.js sets data-phase). */
.step[data-phase="typing"] :is(figure, .msg.them:not(.dots), h1, .soon),
.step[data-phase="picture"] :is(.msg.them:not(.dots), h1, .soon) { display: none; }

/* Typing bubble: three circles that fill in one by one. The outer two sit on the
   centers of the pill's rounded ends; the middle one is centered. */
.msg.dots {
	--h: 2.75rem;
	--dot: 0.6rem;
	height: var(--h);
	width: calc(var(--h) + 2.2rem);
	padding: 0 calc(var(--h) / 2 - var(--dot) / 2);
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.msg.dots span {
	width: var(--dot);
	height: var(--dot);
	border-radius: 50%;
	border: 1.5px solid var(--muted);
	transition: background-color 0.15s;
}

.msg.dots span.on { background-color: var(--muted); }

/* Pictures arrive like messages: on the left, rounded like the bubbles. */
figure {
	margin: 0;
	align-self: flex-start;
	max-width: 80%;
	display: flex;
}

figure img {
	display: block;
	max-width: 100%;
	max-height: 50vh;
	max-height: 50svh;
	width: auto;
	height: auto;
	border-radius: 1.2rem;
	border-bottom-left-radius: 0.35rem;
}

.msg {
	max-width: 80%;
	margin: 0;
	padding: 0.5em 0.9em;
	font-size: 18.8px;   /* average of the message box text (20px) and the old 17.6px */
	line-height: 1.35;
	border-radius: 1.2em;
	overflow-wrap: anywhere;
}

.msg.them {
	align-self: flex-start;
	background-color: var(--them-bg);
	color: var(--them-text);
	font-weight: 400;
	border-bottom-left-radius: 0.35em;
}

.msg.them.big {
	font-weight: 900;
	font-size: 1.6em;   /* 25.6px, unchanged */
	letter-spacing: -0.02em;
}

.msg.me {
	align-self: flex-end;
	background-color: var(--me);
	color: #ffffff;
	font-weight: 400;
	border-bottom-right-radius: 0.35em;
	display: none;
}

.msg.me.sent {
	display: block;
	animation: pop 0.25s ease-out;
}

@keyframes pop {
	from { transform: translateY(0.4em) scale(0.85); }
	to   { transform: none; }
}

/* Last screen */
h1.words {
	text-align: center;
	font-weight: 900;
	font-size: 2.6em;
	letter-spacing: -0.035em;
	line-height: 1.2;
	margin: 0;
	color: var(--text);
	outline: none;
}

.soon {
	text-align: center;
	margin: 0;
	font-weight: 900;
	font-size: 0.8em;
	letter-spacing: 0.35em;
	text-transform: uppercase;
	color: var(--muted);
}

/* Message box with send button */
/* Fixed, not sticky: iPhone Safari didn't paint the sticky box until the first touch.
   app.js keeps --compose-h in sync so the log never hides behind it. */
#compose {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
	padding: 0.5rem max(1rem, calc((100% - 34rem) / 2)) max(1rem, env(safe-area-inset-bottom));
	background-color: var(--bg);
}

#compose.gone { display: none; }

.chips {
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.chips:empty { display: none; }

.chip {
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
	border: 1.5px solid var(--line);
	border-radius: 999px;
	color: var(--text);
	cursor: pointer;
	font: inherit;
	font-weight: 400;
	font-size: 1em;
	line-height: 1.3;
	padding: 0.35em 1.2em;
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.2s, color 0.2s;
}

.chip[aria-pressed="true"] {
	border-color: var(--me);
	color: var(--me);
	font-weight: 700;
}

.bar {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	border: 1.5px solid var(--line);
	border-radius: 999px;
	/* Text starts at the center of the rounded end: half the box height, minus the border. */
	--bar-h: 2.88rem;   /* 80% of the earlier 3.6rem */
	height: var(--bar-h);
	padding: 0.2rem 0.2rem 0.2rem calc(var(--bar-h) / 2 - 1.5px);
}

.field {
	flex: 1;
	min-width: 0;
	font-size: 20px;
	font-weight: 400;
	line-height: 1.35;
	color: var(--them-text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.field:empty::before {
	content: "Message";
	color: var(--muted);
}

.send {
	appearance: none;
	-webkit-appearance: none;
	flex: none;
	width: 2.2rem;
	height: 2.2rem;
	border: 0;
	border-radius: 50%;
	padding: 0;
	background-color: var(--me);
	color: #ffffff;
	cursor: pointer;
	display: grid;
	place-items: center;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.2s, opacity 0.2s, transform 0.1s;
}

.send svg {
	width: 55%;
	height: 55%;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.send:disabled {
	opacity: 0.35;
	cursor: default;
}

@media (hover: hover) {
	.send:not(:disabled):hover { background-color: var(--me-press); }
}

.send:not(:disabled):active {
	background-color: var(--me-press);
	transform: scale(0.92);
}

:is(.send, .chip):focus-visible {
	outline: 2.5px solid var(--hover);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.chip, .send { transition: none; }
	.msg.me.sent { animation: none; }
}
