@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap');

@font-face {
	font-family: "KanjiStrokeOrders";
	src: url("../fonts/KanjiStrokeOrders-4.005/KanjiStrokeOrders_v4.005.ttf");
}

body {
	font-family: 'Noto Sans', sans-serif;

	&.stroke-order .kanji-character {
		font-family: "KanjiStrokeOrders";
		font-size: 78px;
	}
}

.collection-container {
	padding-bottom: 1rem;
	border-bottom: 1px solid #333;
}

.search {
	display: flex;
	flex-direction: column;
}

#status {
	color: var(--yellow);
	font-size: smaller;
	font-style: italic;
}

input[type="search"] {
	padding: 0.25em;
	font-size: 1.25rem;
	flex: 1;
}

/* options */
.options-wrapper {
	position: relative;

	&.collapsed {
		form {
			height: 0;
			transition: all 0.3s ease-in-out;
		}
	}

	.title {
		position: relative;
	}

	form {
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
		height: auto;
		transition: all 0.3s ease-in-out;
		overflow: hidden;
	}
	
	.display-options,
	.kanji-only-option {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		gap: 0.5rem;
		align-items: center;
	}
	
	.kanji-only-option {
		border-top: 1px solid #aaa;
		padding-top: 1rem;
		flex-direction: column;
	}

	#toggle-options {
		position: absolute;
		right: 0.25rem;
		top: 0;
	}
}

.radio-check {
	font-family: inherit;
	display: grid;
	grid-template-columns: 1em auto;
	gap: 0.5em;
	align-items: center;
	line-height: 1;
}

input[type="checkbox"],
input[type="radio"] {
	position: relative;
	flex: 0 0 auto;
	margin: 8px;
	--webkit-appearance: none;
	appearance: none;
	background-color: white;
	margin: 0;
	font: inherit;
	color: currentColor;
	width: 1.15em;
	height: 1.15em;
	border: 0.15em solid currentColor;
	border-radius: 0.15em;
	transform: translateY(-0.075em);
	display: grid;
	place-content: center;
	
	&::before {
		position: relative;
		content: "";
		width: 0.65em;
		height: 0.65em;
		border-radius: 0.1em;
		transform: scale(0);
		transition: 120ms all ease-in-out;
		box-shadow: inset 1em 1em hotpink;
	}
	
	&:hover::before {
		transform: scale(1);
		opacity: 0.5;
	}
	
	&:checked::before {
		transform: scale(1);
	}
}

input[type="radio"] {
	border-radius: 100%;
	
	&::before {
		border-radius: 100%;
	}
}

/* search styling */
#search {
	padding-top: 1rem;
	margin-bottom: 0.25rem;
	
	.searchbar {
		display: flex;
		background: #777;
		align-items: center;
		padding-left: 0.5rem;
		border-radius: 8px;
	}
	
	input {
		border-radius: 0 8px 8px 0;
		border: 1px solid #333;
		
	}
	
	svg {
		color: white;
		width: 24px;
		height: 24px;
		margin-right: 0.5rem;
	}
}

.ksearch-only {
	display: flex;
	align-items: center;
}

/* Container for the toggle */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
		margin: 0.5rem;
}

/* Hide default checkbox */
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The track */
.slider {
    position: absolute;
    cursor: pointer;
    background-color: blue;
    border-radius: 24px;
    width: 100%;
    height: 100%;
    transition: background-color 0.3s;
}

/* The circular slider */
.slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

/* Toggled state */
.toggle-switch input:checked+.slider {
    background-color: #4caf50;
}

.toggle-switch input:checked+.slider::before {
    transform: translateX(22px);
}

/* entry styling */
.entry {
	background: var(--teal);
	color: var(--indigo);
	border-radius: 8px;
	margin: 0.25rem 0;
	padding: 0.25rem;
	
	.entry-header {
		display: flex;
		flex-wrap: wrap;
		align-items: start;
	}
	
	.entry-header .headword,
	.entry-header .reading {
		font-size: 1.25rem;
		font-weight: bold;
	}
	
	.headword::after {
		content: "・";
	}
	
	.tag {
		background: #333;
		color: white;
		border-radius: 8px;
		padding: 0.15rem 0.5rem;
		margin-left: 0.25rem;
	}
	
	&:hover {
		cursor: pointer;
	}
	&.add:hover,
	&.add:focus { 
		color: white;
		background-color: green; 
	}
	&.remove:hover,
	&.remove:focus { 
		color: white;
		background-color: red; 
	}
}

/* collection-specific styling */
#collection {
	.headword:after, .reading, .tag, .gloss { display: none; }
	
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

/* sheet-specific styling */
.drill-row-container {
	position: relative;

	.drill-row-header {
		border-bottom: 1px solid #ccc;
		border-top: 3px solid #333;
		margin-bottom: 0.5rem;
		display: flex;
		flex-wrap: wrap;
		padding-top: 0.75rem;
		
		.en-glosses-container,
		.example-sentence,
		.related-words {
			display: none;
		}
	
		h3 {
			grid-area: rowTitle;
			padding-bottom: 0.25rem;
			margin-bottom: 0.25rem;
			width: 47%;
		}
		
		.example-related-cont {
			width: 47%;
			margin-bottom: 0.5rem;
			display: flex;
			flex-direction: column-reverse;
		}
	}
	
	&:is(.has-example, .has-related) {
		.example-related-cont .related-words {
			border: 1px solid #ccc;
			border-radius: 8px;
			padding: 0.25rem;
			margin-top: 0.5rem;
		}
	}
	
	.example-sentence p,
	.related-words p {
		display: flex;
		flex-wrap: wrap;
		
		span:first-child {
			display: inline-block;
			min-width: 7ch;
		}
	}
	
	.related-words {
		position: relative;
		
		&:before {
			content: "関連語";
			position: absolute;
			top: -1rem;
			left: 0.25rem;
			padding: 0 0.5rem;
			font-weight: bold;
			font-size: larger;
			background: white;
		}
		
		p {
			margin: 0.5rem 0 0 1rem;
		}
	}
	
	&.has-gloss .en-glosses-container {
		display: block;
		grid-area: gloss;
		margin-bottom: 0.5rem;
	}
	
	&.has-related .related-words {
		display: block;
		grid-area: related;
	}

	&.has-example .example-sentence {
		display: block;
		grid-area: example;
		padding-bottom: 0.25rem;
	}

	.stroke-count {
		background: #ccc;
		padding: 0 0.25em;
		margin-left: 1rem;
		border-radius: 8px;
		font-size: smaller;
		font-weight: normal;
		white-space: pre;
	}

	.jlpt-tag {
		position: absolute;
		top: -0.5rem;
		right: 1rem;
		background: white;
		padding: 0 0.25rem;
	}

	.headword {
		font-size: 2rem;
	}

	.readings {
		display: inline-block;
		margin-left: 0.5rem;
		padding-left: 0.5rem;
		font-size: 1rem;
		font-weight: normal;
		margin-top: 0.5rem;
		
		span + span {
			margin-left: 1rem;
		}
	}
}

.block-container {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25em;
	padding-bottom: 1rem;
}

.kanji-block {
	width: 80px;
	height: 80px;
	border: 1px solid black;
	position: relative;
	
	.grid &::before {
		position: absolute;
		top: 0;
		content: "";
		width: 80px;
		height: 40px;
		border-bottom: 1px dashed #777;
	}
	
	.grid &::after {
		position: absolute;
		top: 0;
		left: 0;
		content: "";
		width: 40px;
		height: 80px;
		border-right: 1px dashed #777;
	}
	
	&.kanji-character {
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 64px;
		
		span { opacity: 0.25; }
		
		&.first span { opacity: 0.75; }
		&.second span { opacity: 0.5; }
	}
}

@media (min-width: 768px) {
	#options .kanji-only-option {
		border-top: 0;
	}
}

@media print {
	.site-header,
	.site-sidebar,
	.site-footer,
	.options-wrapper {
		display: none;
	}
	
	.page-wrapper {
		display: block;
	}
	
	.drill-row-container {
    break-inside: avoid;
    page-break-inside: avoid;   /* older-browser fallback */
  }
	
	.drill-row-header {
    break-after: avoid;
    page-break-after: avoid;
  }
}