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

html {
	--font-family: -system-ui, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, Helvetica, Arial, apple color emoji, segoe ui emoji, segoe ui symbol, sans-serif;
	font-family: var(--font-family);
	font-size: 16px;
	line-height: 1.5rem;
	-webkit-text-size-adjust: 100%;

	--figure: #000;
	--ground: #eee;

	--color-card: #d4dbe0;
	--color-card-text: #000;

	--color-button: #000;
	--color-button-text: #fff;
	--color-button-hover: #0af;

	--color-error: #f30;
}

body {
	margin: 0;
	min-height: 100vh;
	color: var(--figure);
	background-color: var(--ground);

	display: flex;
	flex-direction: column;
	align-items: center;
}

/* ======================== Basics */

p { margin: 0.5rem 0 1rem 0; }
a { color: inherit; }
h1, h2 {
	font-size: 1.25em;
	letter-spacing: 0.01em;
}
h1 { display: inline-block; }
h2 { margin-bottom: 1rem; }


/* ======================== Form General */

form {
	overflow: hidden;
	position: relative;
}

fieldset {
	border: none;
	padding: 0;
	margin: 0;
	width: 100%;
	transition: translate 200ms ease-out;
}

input,
button,
textarea {
	appearance: none;
	position: relative;
	font: inherit;
	line-height: 2;
	font-weight: inherit;
	color: inherit;
	border: none;
	border-radius: .25rem;
	padding: 0 .5rem;
}

input,
button { height: 2rem; }

select { border: none; }

textarea {
	height: 7rem;
	min-height: 4rem;
	max-height: 23rem;
	resize: vertical;
	line-height: inherit;
	padding: 0.25rem 0.5rem;
}

input::-webkit-input-placeholder {
	color: #ccc;
}

input,
textarea,
.block { flex-grow: 1; }

.button {
	position: relative;
	display: inline-block;
	height: 2rem;
	line-height: 2;
	background-color: var(--color-button);
	color: var(--color-button-text);
	cursor: pointer;
	padding: 0 2rem 0 0.5rem;
	font-weight: bold;
	border-radius: .25rem;
	user-select: none;
	overflow: hidden;
	text-decoration: none;
}
.button:hover {
	background-color: var(--color-button-hover);
}

input:focus,
textarea:focus,
.button:focus,
.button:active {
	box-shadow: inset 0 0 0 2px var(--figure);
	outline: none;
}


/* ======================== SVG */

svg {
	display: inline-block;
	fill-rule: evenodd;
	clip-rule: evenodd;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-miterlimit: 1.5;
}

svg .stroke {
	fill: none;
	stroke: currentColor;
	stroke-width: 2px;
}

p svg {
	transform: translateY(3px);
}

.button svg {
	position: absolute;
    top: 50%;
    right: 0.5rem;
    translate: 0 -50%;
}

#btn-line svg {
	rotate: -45deg;
}
#btn-show-form svg {
	rotate: 90deg;
}


/* ======================== Structure */

main {
	max-width: 60rem;
	padding: 2rem;
}

header {
	position: relative;
	padding: 0 0 2rem 0;
	display: flex;
	flex-direction: row;
	align-items: center;
}

header .text {
	flex-grow: 1;
}

article {
	margin: 0 auto;
	display: flex;
	flex-direction: column;
}

#welcome {
	max-width: 36rem;
	position: relative;
	overflow: hidden;
	margin: 0 0 2rem 0;
}

#cards {
    flex: 50% 1 0;
    padding: 0.5rem 0;
}


/* ======================== Card */

.card {
	background-color: var(--color-card);
	color: var(--color-card-text);
	padding: 1rem;
	margin: 0 0 2rem 0;
	border-radius: 0.5rem;
}

.card h2 {
	margin: 0 0 0.25rem 0;
	font-size: inherit;
}

#card-line {
	display: flex;
	flex-direction: row;
}

#card-line .text {
	align-items: flex-start;
	flex-grow: 1;
	display: flex;
	flex-direction: column;
}

#card-line .text p {
	flex-grow: 1;
}


/* ======================== Head pic */

#head-face {
	overflow: hidden;
	border-radius: 50%;
	width:  5rem;
	height: 5rem;
	background-color: var(--color-card);
	flex: 5rem 0 0;
	margin-left: -0.5rem;
}

#head-face img {
	width: 100%;
	height: 100%;
}

#head-text {
	padding: 0 0 0 1rem;
	flex-grow: 1;
	display: flex;
	flex-direction: row;
}

#head-text h1 {
	flex-grow: 1;
}


/* ======================== Line QR code */

.qrcode {
	display: block;
	width: 10rem;
	height: 10rem;
	flex: 10rem 0 0;
	margin-left: 1rem;
}

.qrcode a {
	display: block;
}

.qrcode svg {
	display: block;
	fill: currentColor;
}

.qrcode:hover {
	color: var(--color-button-hover);
	background-color: #fff;
	outline: 5px solid #fff;
	border-radius: 8px;
}


/* ======================== Form Specific */

.row {
	display: flex;
	flex-direction: row;
	flex-basis: 100%;
}

.block {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
}

form button {
	margin-left: 0.5rem;
}


/* ============ Form MLIST */

#form-mlist {
	min-height: 2.5rem;
}


/* ============ Form EMAIL */

#form-email { /* would like to animate this opening but still a PITA with current CSS */
	position: relative;
	overflow: hidden;
	display: none;
}

#form-email input {
	margin-bottom: 0.5rem;
	width: 100%; /* oh screw you - https://stackoverflow.com/a/42421490 */
}

#form-email button {
	float: right;
	margin: 0.5rem 0 0 0.5rem;
}

#form-email label {
	flex: 5.5rem 0 0;
	line-height: 2;
	margin-bottom: .5rem;
}

#form-email .block label {
	flex-basis: 5rem;
}


/* ======================== Cloudflare Turnstile iframe */

.ts {
    max-width: 300px;
    height: 65px;
    background-color: #fafafa;
	display: none;
	margin-top: 0.5rem;
	overflow: hidden; /* just in case screen is narrower than the iframe added by cloudflare */
}

#form-email .ts {
	margin-left: 5.5rem;
}

/* ======================== Form EXTRAS */


.thanks {
	position: absolute;
	top: 0;
	right: 100%;
	width: 100%;
	max-height: 100%;
	transition: all 200ms 0ms ease-out;
	
	background: #c8ffc8;
	padding: 0.5rem 0.75rem;
	border-radius: 5px;
}

.thanks p {
	margin: 0;
}

.error {
	color: var(--color-error);
	overflow: hidden;
	display: none;
	margin: 0.5rem 0 0 0;
}

#form-email .error {
/*	margin: 0 0 0.5rem 5.5rem;*/
	margin-left: 5.5rem;
}

/* ======================== Form STATES */
/* ready | waiting | thanks | error | ts-pending | ts-error | ts-interactive */

.show-form #form-email {
	display: block;
}

.show-form #btn-show-form {
	height: 0;
}

button::after { /* to become either spinning circle or sliding dot */
	content: '';
	position: absolute;
	top: 50%; left: 50%;
	border-radius: 50%;
	display: block;
}


/* ============ STATE: Ready */

/* default */


/* ============ STATE: Cloudflare Turnstile pending */

form[data-state='ts-pending'] button {
	pointer-events: none;
	touch-action: none;
}

form[data-state='ts-pending'] button svg,
form[data-state='ts-pending'] button span {
	opacity: 0;
}


/*//// button - sliding dot */
form[data-state='ts-pending'] button::after {
	width:  6px;
	height: 6px;
	background-color: currentColor;
	animation: slide 500ms infinite ease-in-out alternate;
}


/* ============ STATE: Cloudflare Turnstile Interactive challenge */

form[data-state='ts-interactive'] button {
	pointer-events: none;
	touch-action: none;
}

form[data-state='ts-error'] .ts,
form[data-state='ts-interactive'] .ts {
	display: block;
}


/* ============ STATE: Cloudflare Turnstile Error */

form[data-state='ts-error'] .ts
	display: block;
}


/* ============ STATE: Waiting & Thanks */

form[data-state='waiting'] {}

form[data-state='waiting'] button svg,
form[data-state='waiting'] button span {
	opacity: 0;
}

/*//// button - spinning circle */
form[data-state='waiting'] button::after,
form[data-state='thanks'] button::after {
	width:  1rem;
	height: 1rem;
	border: 2px solid;
	border-top-color: transparent;
	translate: -50% -50%;
	animation: spin 700ms infinite linear;
}

form[data-state='waiting'] fieldset,
form[data-state='thanks'] fieldset {
	opacity: 0.5;
	resize: none;
	pointer-events: none;
	touch-action: none;
	user-select: none;
}


/* ============ STATE: Thanks */

form[data-state='thanks'] fieldset {
    translate: 120% 0;
}
form[data-state='thanks'] .thanks {
	translate: 100% 0;
}


/* ============ STATE: Error */

form[data-state='error'] {}

form[data-state='error'] .error {
	display: block;
}


/* ======================== Language switcher */

#lang {
	position: relative;
	line-height: 2;
	cursor: pointer;
}

select#lang-select {
	opacity: 0;
	position: absolute;
	width: 100%;
	height: 100%;
	z-index: 1;
	cursor: pointer;
}

#lang-text {
	pointer-events: none;
}

#lang-text::after {
	content: '';
	border: 6px solid transparent;
	border-top-color: currentcolor;
	margin: 0 0 0 0.3rem;
	transform: translateY(4px);
	display: inline-block;
	width: 0;
	height: 0;
}


/* ======================== Language elements on page */

.ja,
.en .ja {
	font-family: 'M PLUS 1p', hiragino sans, ヒラギノ角ゴ pro w4, ヒラギノ角ゴ pro w3, hiragino kaku gothic pro, Osaka, メイリオ, Meiryo, ＭＳ Ｐゴシック, ms pgothic, sans-serif;
	font-weight: inherit;
	line-height: 1.6;
}
.ja .en {
	font-family: var(--font-family);
}
[lang='en'] .ja:not(.perm),
[lang='ja'] .en:not(.perm) { display: none; }



/* ======================== Animations */

@keyframes slide {
	0%   { translate:-200% -50% }
	100% { translate:150% -50% }
}

@keyframes spin {
	0%   { rotate: 0deg }
	100% { rotate: 360deg }
}

/* ======================== Media queries */

@media (min-width: 800px) {
	header {
		padding: 1rem 0 2rem 0;
	}
	article {
		flex-direction: row;
	}
	#welcome {
		padding: 0 2rem 0 0;
	}
}
@media (min-width: 900px) {
	
	#welcome {
		padding: 0 2rem 0 5.5rem;
	}
}

