/* --- root & global styles */
:root {
	font-size: calc(2vh);
}

body {
	color: black;
	font-family: "League Spartan", sans-serif;
	margin: 0;
	-webkit-tap-highlight-color: transparent;
}

/* --- layout containers */

.container {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: auto;
	margin-top: 0.5em;
	max-width: calc(max-content-40px);
}

.inner {
	border: 1px solid #c3d3db;
	display: grid;
	grid-row-gap: 0.6em;
	grid-template-columns: minmax(max-content, 1fr);
	padding: 1em;
}

.grid-container {
	min-width: max-content;
	max-width: max-content;
	height: 45vh;
	display: grid;
	grid-template-rows: repeat(4, minmax(10dvh, 1fr));
	grid-row-gap: 0.8rem;
}

.grid-row {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-column-gap: 0.8rem;
	aspect-ratio: 4 / 1;
}

.ui-container {
	display: grid;
	grid-template-columns: 1fr min-content;
	padding-top: 0.1em;
	padding-bottom: 0.1em;
	padding-right: 0.2em;
}

.controls {
	display: grid;
	grid-template-columns: 1fr;
}

/* --- header component */

header {
}

.header-inner {
	display: flex;
	justify-items: center;
	text-align: center;
	position: relative;
}

h1.title {
	display: block;
	font-variant: small-caps;
	letter-spacing: 0.1em;
	padding: 0;
	margin: auto;
	user-select: none;
}

.help-button {
	position: absolute;
	top: 1cqh;
	right: 1cqw;
	color: #ADADAD;
	transition: color 0.2s ease-in;
	cursor: pointer;
	user-select: none;
	padding: 0.1em;
	padding-left: 0.2em;
	padding-right: 0.2em;
}

/* --- splash component */

.splash {
	margin: auto;
	text-align:center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap:0.2em;
	width:25em;
	max-width:90dvw;
}

.splash > .text {
	font-weight: normal;
	padding: 0;
	user-select: none;
	font-size: 1.3em;
	line-height: 1.1em;
	letter-spacing: 0.02em;
	text-align: center;
	background-color: #f2f2f2;
	padding: 1em;
	border-radius: 10px;
}

.splash > .text > p {
	display: block;
	padding: 0;
	margin: 0;
	user-select: none;
	font-size: 1em;
	color: #4a4a4a;
}

/* --- game components */

.grid-cell {
	background-color: #F8F8F8;
	border: 1px solid #ddd;
	border-radius: 12px;
	color: #2a2a2a;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
	text-align: center;
	transition: all 0.08s ease-in-out;
	display: flex;
	text-align: center;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	aspect-ratio: 1 / 1;
	padding: 0.2em;
	font-variant: small-caps;
	cursor: pointer;
	user-select: none;
}

.grid-cell:hover:not(.selected):not(.solution-found) {
	background-color: #fff;
	border-color: #bbb;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.grid-cell.selected {
	background-color: #eef3f7;
	border-color: #8c9fae;
	color: #2a2a2a;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px #8c9fae;
	transform: translateY(-1px);
	transition: all 0.3s ease-in-out;
}

.grid-row.solution-found {
	animation: fade-in 1.5s ease-in;
	grid-template-columns: minmax(0, 1fr);
	overflow: auto;
}

.grid-cell.solution-found {
	aspect-ratio: auto;
	cursor: default;
	font-variant: normal;
	letter-spacing: normal;
}

.grid-cell.solution-found > div > p {
	margin: 0;
	padding: 0;
}

.grid-cell.solution-found-a {
	background-color: #ffe30f;
}

.grid-cell.solution-found-b {
	background-color: #55d45f;
}

.grid-cell.solution-found-c {
	background-color: #6bc4ff;
}

.grid-cell.solution-found-d {
	background-color: #fc86bf;
}

.grid-cell.solution-found.game-over {
	filter: grayscale(70%);
}



h2 {
	font-weight: normal;
	user-select: none;
	padding: 0;
	margin: 0;
	font-size: 1em;
	color: #2e2e2e;
}

h2.h-box {
	font-weight: normal;
	display: block;
	padding: 0;
	margin: 0;
	user-select: none;
	font-size: 1em;
	text-align: center;
	background-color: #f2f2f2;
	padding: 1em;
	border-radius: 10px;
}

#lives {
	font-size: 1em;
	user-select: none;
	color: #2a2a2a;
}

#message {
	text-align: center;
	font-size: 1em;
	display: block;
	font-weight: 600;
	/* transition: opacity 0.3s ease-in-out; */
	height: 100%;
	color: #9e1515;
	line-height: 150%;
	user-select: none;
}

#message > span {
	min-height: 100%;
	opacity: 0;
}

#refresh {
	color: #ADADAD;
	transition: color 0.2s ease-in;
}

svg.shield > path {
	transition: fill 0.3s ease;
}

/* --- interactive states */

/* Grid cell states */

/* Help button states */
.help-button:hover {
	color: #505050;
}

/* Refresh button states */
#refresh[data-active="true"] {
	cursor: pointer;
}

#refresh[data-active="true"]:hover {
	color: #505050;
}

/* Component visibility states */
.game-component:not([data-active="true"]) {
	display: none;
}

.come-back-later:not([data-active="true"]) {
	display: none;
}

.splash:not([data-active="true"]) {
	display: none;
}

/* --- solution states */

svg.shield.filled > path {
	fill: #9BB49B;
}

svg.shield.empty > path {
	fill: none;
}

/* --- button styles */

/* Base button styles (shared between splash and controls) */
.splash > button,
.controls > button {
	font-size: 1.2em;
	font-weight: bold;
	letter-spacing: 0.05em;
	color: #333;
	text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
	border-radius: 10px;
	padding: 1rem 0.5rem;
	cursor: pointer;
	user-select: none;
	transition: all 0.15s ease-out;
	border: 1px solid #7C9F68;
	box-shadow: 0 2px 0 0 #7C9F68, 0 5px 10px rgba(0, 0, 0, 0.2);
	background-image: linear-gradient(to bottom, #C0E8A7 0%, #A9D18E 100%);
}

/* Splash button specific styles */
.splash > button {
	width: 100%;
	display: block;
	margin: auto;
}

/* Controls button specific styles */
#shuffle {
	background-image: linear-gradient(to bottom, #F0F0F0 0%, #DCDCDC 100%);
	border: 1px solid #B0B0B0;
	box-shadow: 0 2px 0 0 #B0B0B0, 0 5px 10px rgba(0, 0, 0, 0.15);
}

/* Button hover states */
.splash > button:hover,
.controls > button:hover {
	transform: translateY(-1px);
	background-image: linear-gradient(to bottom, #D0F8B7 0%, #B9E09E 100%);
	box-shadow: 0 3px 0 0 #7C9F68, 0 8px 15px rgba(0, 0, 0, 0.25);
}

#shuffle:hover {
	background-image: linear-gradient(to bottom, #FFFFFF 0%, #EDEDED 100%);
	box-shadow: 0 2px 0 0 #7C9F68, 0 5px 10px rgba(0, 0, 0, 0.2);
}

/* Button active states */
.splash > button:active,
.controls > button:active {
	background-image: linear-gradient(to bottom, #9BD97D 0%, #83C667 100%);
	box-shadow: 0 1px 0 0 #7C9F68, 0 2px 5px rgba(0, 0, 0, 0.15);
	transform: translateY(2px);
	transition: all 0.05s ease-out;
}

#shuffle:active {
	background-image: linear-gradient(to bottom, #CDCDCD 0%, #B6B6B6 100%);
	box-shadow: 0 1px 0 0 #B0B0B0, 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Button disabled states */
.splash > button:disabled,
.controls > button:disabled {
	filter: grayscale(100%);
	background-image: linear-gradient(to bottom, #E0E0E0 0%, #D0D0D0 100%);
	border-color: #A0A0A0;
	color: #A0A0A0;
	text-shadow: none;
	box-shadow: none;
	transform: none;
	cursor: not-allowed;
	opacity: 0.7;
}

.splash > button:disabled:hover,
.splash > button:disabled:active,
.controls > button:disabled:hover,
.controls > button:disabled:active {
	background-image: linear-gradient(to bottom, #E0E0E0 0%, #D0D0D0 100%);
	box-shadow: none;
	transform: none;
	transition: none;
}

/* --- animations */

.fade-in-out {
	animation: 5s fade-in-out ease-in-out;
}

@keyframes fade-in-out {
	0% { opacity: 0}
	40% { opacity: 1}
	100% {opacity : 0}
}

@keyframes fade-in {
	0% { opacity: 0; }
	100% { opacity: 1; }
}

/* --- utility classes */

.message-container {}

.language-controls {
	position:absolute;
	right:0.2em;
	color: #4a4a4a;
	display:none;
	user-select: none;
}

.language-controls[data-active="true"] {
	display:block;
}

.switch {
  position: relative;
  display: inline-block;
  width: 1.5em;
  height: 0.85em;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: transform .4s,background-color .4s;
  transition: transform .4s,background-color .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 0.65em;
  width: 0.65em;
  left: 0.1em;
  bottom: 0.1em;
  background-color: white;
  -webkit-transition: .4s, background-color .4s;
  transition: transform .4s,background-color .4s;
}

input:checked + .slider {
  background-color: #808080;
}

input:focus + .slider {
  box-shadow: 0 0 1px #808080;
}

input:checked + .slider:before {
  -webkit-transform: translateX(0.65em);
  -ms-transform: translateX(0.65em);
  transform: translateX(0.65em);
}

/* Rounded sliders */
.slider.round {
  border-radius: 0.85em;
}

.slider.round:before {
  border-radius: 50%;
}
