
*, *::before, *::after { box-sizing: border-box }
* { margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent } /* https://stackoverflow.com/a/45050338 */

@font-face {
    font-family: 'Trispace';
    src: url('./fonts/Trispace[wdth,wght].woff2') format('woff2-variations');
    src: url('./fonts/Trispace[wdth,wght].woff2') format('woff2') tech('variations');
    font-weight: 100 800;
    font-stretch: 75% 125%;
    font-style: normal;
}

html {
  font-family: 'Trispace', -system-ui, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, Helvetica, Arial, apple color emoji, segoe ui emoji, segoe ui symbol, sans-serif;
  line-height: 1.5;
  font-weight: 300;
  font-stretch: 95%;

  --figure: 238, 238, 238; /* RGB values to allow opacity of var() colour - Thanks https://stackoverflow.com/a/41265350 */
  --ground: 51, 51, 51;

  --padding: 1.5rem;
  --padding-half: calc(var(--padding) * 0.5);
  --gutter: 2rem;
  --header-height: 8.5rem;
  --footer-height: 4rem;
	
	background: rgb(var(--ground));
}

body {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 0;
	overflow: hidden;
	height: 100dvh;
	background: #eee;
}

body:fullscreen {
	background: rgb(var(--ground));
}

/*///////////////////////////////////////////////////////////*/
/* Generics */

a {
	color: inherit;
	text-decoration: none;
}

sup {
	line-height: 0;
	padding: 0.15rem;
	vertical-align: super;
}

ul {
	padding: 0;
	list-style: none;
}

input {
	font-family: inherit;
	letter-spacing: inherit;
	border: none;
	display: block;
}

input[type='color'] {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	display: inline-block;
  border: none;
  cursor: pointer;
}
input[type='color']::-webkit-color-swatch { display: none }
input[type='color']::-moz-color-swatch { display: none }

button {
	-webkit-appearance: none;
	appearance: none;
	font: inherit;
	border: none;
	display: block;
	position: relative;
	cursor: pointer;
	padding: 0;
	background: transparent;
	color: inherit;
	text-align: inherit;
}

button:focus {
	outline: none;
}

svg {
	display: block;
	clip-rule: evenodd;
	fill-rule: evenodd;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-miterlimit: 1.5;
	vector-effect: non-scaling-stroke;
}

svg .stroke {
	stroke: currentColor;
	stroke-width: 1.5px;
	fill: none;
	vector-effect: non-scaling-stroke;
}

svg .fill {
  fill: currentColor;
}

h1, h2 {
	font-size: inherit;
	font-weight: 400;
}

h1 {
	opacity: 0.5;
	font-weight: 500;
}

h2 span {
	font-weight: 300;
}


/*///////////////////////////////////////////////////////////*/
/* Shared */

.txt-large {
	font-size: 1.25rem; /* 20px @16px */
	line-height: 2;
}

.btn {
	display: inline-flex;
	flex-direction: row;
  align-items: center;
  padding: 0 0.75rem;
  height: 2rem;
  min-width: 4rem;
  flex-shrink: 0;
}

.btn svg {
	width: 2rem;
	height: 2rem;
	flex: 2rem 0 0;
	display: inline-block;
}

.btn.icon {
	width: 2rem;
	height: 2rem;
	min-width: 2rem;
	padding: 0;
	flex: 2rem 0 0;
  box-shadow: none;
}

.btn.text {
	min-width: 4rem;
}

.btn.border {
  border-radius: 0.25rem;
  box-shadow: 0 0 0 1px;
}

.btn.icon.text {
	width: auto;
	flex: auto 0 0;
	padding-right: 0.75rem;
}

.column {
	/* this is backwards - rather than use `max-width` to limit width when page is TOO WIDE, this limits page to 100vw when page is NARROWER than `width` */
	width: 32rem;
	max-width: 100vw;
}


/*///////////////////////////////////////////////////////////*/
/* Structure */

main {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: rgb(var(--ground));
	color: rgb(var(--figure));
	overflow: hidden;
}

header {
	display: flex;
	flex-direction: row;
	justify-content: center;
	padding: 2.25rem var(--padding) 1.25rem var(--padding);
	box-shadow: inset 0 -1px 0 0;
	flex: var(--header-height) 0 0;
}

article {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	overflow: hidden;
	user-select: none;
	position: relative; /* JS scrollTo() requires this */
}

footer {
	display: flex;
	flex-direction: row;
	justify-content: space-around;
	padding: 1rem 1.25rem;
	position: relative;
	background: rgb(var(--ground));
	box-shadow: inset 0 1px 0 0;
	z-index: 2;
	flex: var(--footer-height) 0 0;
}



/*///////////////////////////////////////////////////////////*/
/* Loader */

#loader {
	position: absolute;
	top: 0; right: 0; bottom: 0; left: 0;
	
	display: flex;
	flex-direction: column;
	align-items: center;
  justify-content: center;

	background: rgb(var(--ground));
	opacity: 0;
	transition: opacity 300ms ease-in;
	z-index: 3;
	pointer-events: none;
}

.loading #loader {
	opacity: 1;
	pointer-events: all;
}

#spinner {
	width:  3rem;
	height: 3rem;
	border-radius: 2rem;
	border: 1px solid;
	border-left-color: transparent;
}

/*///////////////////////////////////////////////////////////*/
/* within header */

.value {
	position: relative;
}

.value input {
	width: 100%;
	height: 2.5rem;
	border-radius: 0.25rem;
	padding: 0 0 0 var(--padding-half);

	background: rgb(var(--figure));
	color: rgb(var(--ground));
	font-feature-settings: 'tnum';
	letter-spacing: -0.03em;
}

.value input:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgb(var(--ground)), 0 0 0 4px rgb(var(--figure));
}

.value .label {
	margin: var(--padding-half) 0 0 0;
	padding: 0 var(--padding-half);
	font-weight: 400;

	overflow: hidden;
	white-space: nowrap;
  text-overflow: ellipsis;

  position: absolute;
  width: 100%;
}

#center {
	width: var(--gutter);
	height: 2.5rem;
	flex-shrink: 0;

	display: flex;
	flex-direction: row;
  align-items: center;
  justify-content: center;

  transition: rotate 200ms ease-in-out;
}

#center svg {
	width: 1rem;
	height: 1rem;
}

header[data-active='left'] #center {
	rotate: 0deg;
}

header[data-active='right'] #center {
	rotate: 180deg;
}

/*///////////////////////////////////////////////////////////*/
/* within article */

#unitlist {
	overflow: hidden scroll;
  scrollbar-color: rgb(var(--figure)) transparent;
}


/*///////////////////////////////////////////////////////////*/
/* Unit Lists */

.group {
	position: relative;
	display: flex;
	flex-direction: row;
	justify-content: center;
	gap: var(--gutter);
	padding: var(--padding);
}

.group::after {
	content: '';
	display: block;
	position: absolute;
	left:  2.25rem;
	right: 2.25rem;
	bottom: 0;
	border-bottom: 1px dashed;
	opacity: 0.5;
}

.group:last-of-type::after {
	content: none;
}

.group ul {
	flex: 50% 1 1;
	overflow: hidden;
}

.group li {
	cursor: pointer;
	border-radius: 0.25rem;

	display: block;
	line-height: 2;
	padding-left: var(--padding-half);

	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.group.selected li.selected {
	background: rgb(var(--figure));
	color: rgb(var(--ground));
	translate: 0 0;
	font-weight: 400;
}


/*///////////////////////////////////////////////////////////*/
/* Panes */

#panes {
	position: absolute;
	top: 0;
	bottom: var(--footer-height);
	left: 0;
	right: 0;

	/* background: rgba(var(--ground), 0.3); */ /* dont dim main area as colours hard to judge when changing settings */
	pointer-events: all;
	transition: background 200ms ease-out;
	z-index: 1;

	user-select: none;
}


#panes[data-show='none'] {
	pointer-events: none;
	background: transparent;
}

.pane {
	width: 100%;
	min-height: 40vh;
	max-height: calc(100vh - 8rem - 4rem); /* header = 8rem, footer = 4rem */
	position: absolute;
	top: 100%;

	translate: 0 0;
	transition: translate 150ms ease-out;
	background: rgb(var(--ground));
	box-shadow: inset 0 1px 0 0 currentColor;

	padding: var(--padding);
	padding-bottom: var(--padding-half);

	display: flex;
  flex-direction: column;
}

.fav {
	background: rgb(var(--figure));
	color: rgb(var(--ground));
	line-height: 2rem;
	padding: 0 0.5rem;

	margin: 0 0.75rem 0.75rem 0;
	border-radius: 0.25rem;
	display: inline-block;
	overflow: hidden;
	position: relative;

	transition: background 200ms ease-in;
}

.fav-delete {
	color: rgb(var(--figure));

	width: 2rem;
	height: 2rem;

	position: absolute;
	top: 0;
	right: -2rem;
	opacity: 0;

	font-size: 2.5rem;
	font-weight: 300;
	text-align: center;
	line-height: 1.9rem;
	border-radius: 2rem;

	pointer-events: none;

	transition: right 200ms ease-out;
}

.pane[data-mode='edit'] .fav {
	background: rgba(var(--figure), 0.4);
	pointer-events: none;
}
.pane[data-mode='edit'] .fav-delete {
	opacity: 1;
	right: 0;
	pointer-events: all;
}
.pane[data-mode='edit'] #btn-favs-add {
	opacity: 0.5;
	pointer-events: none;
}


section h2 {
	flex-grow: 1;
	line-height: 2rem;
}

.pane-head,
.pane-foot {
	display: flex;
	flex-direction: row;
  justify-content: space-between;
}

.pane-head {
	margin-bottom: var(--padding);
}

.pane-foot {
  margin: 2rem 0 0.75rem;
}

.pane-content {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
}

.pane-content p {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
  align-items: center;

	min-height: 3rem;
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
  gap: 0.5rem;
}

section.pane-bottom {
	display: flex;
	flex-direction: row;
	margin-top: 2.5rem;
}

.pane-close {
	translate: 0 -0.25rem;
}

#panes[data-show='settings'] #pane-settings,
#panes[data-show='favs'] #pane-favs {
	translate: 0 -100%;
}

#fav-num {
	display: inline-block;
}


/*///////////////////////////*/
/* LocalStorage info in Settings pane */

#ls-info {}

#ls-clear {
	margin-left: 1rem;
}

#ls-info.empty #ls-info-text {
	opacity: 0.5;
}

#ls-info.empty #ls-clear {
	display: none;
}
#ls-info-text {
	white-space: nowrap;
}


/*///////////////////////////*/
/* Hide install prompt when running as PWA */
body.mode-twa #pwa-install-prompt,
body.mode-standalone #pwa-install-prompt {
	display: none;
}



/*///////////////////////////*/
/* Color inputs */

#colorpickers {
	display: inline-flex;
	flex-direction: row;
	gap: 0.25rem;
}

input.colorpicker {
  width:  2rem;
	height: 2rem;

  border-radius: 50%;
  margin: 0;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit
}

#color1 {
	background: rgb(var(--ground));
}

#color2 {
	background: rgb(var(--figure));
}



/*///////////////////////////////////////////////////////////*/
/* Animations */

.bounce {
	transform-origin: center;
  animation: bounce 200ms ease-out 1;
}

.shake {
  animation: shake 400ms ease-in-out 1;
}

.spin {
	animation: spin 1s linear infinite;
}


@keyframes shake {
  20% { translate: 0.25em 0; }
  40% { translate: -0.25em 0; }
  60% { translate: 0.25em 0; }
  80% { translate: -0.25em 0; }
}

@keyframes bounce {
  40% { scale: 110% }
}

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