/* GLOBAL */
:root {
  --alert: #ef3d36;
  --alert-desat: #ec5f5a;
  --primary: #1d3f5d;
  --secondary: #45a29e;
  --dark: #000;
  --dark2: #191b24;
  --light: #fff;
  --light2: #d8d8da;
}

/* text selection styles */
::selection {
  background-color: var(--secondary);
}
.box.invert ::selection {
  color: var(--dark);
}

/* ELEMENTS */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Avenir, Montserrat, Corbel, "URW Gothic", source-sans-pro,
    sans-serif;
  line-height: 1.6;
}

main {
  padding: 2rem 0;
}

section {
  margin: 0 0 2rem;
}

h1,
h2 {
  padding: 0.75rem 0;
}

p {
  padding: 0.5rem 0;
}

/* UNIFIED LINK STYLING */
a {
  outline: none;
  border: none;
  text-decoration: none;
  transition: all 0.1s ease;
  color: inherit;
  padding-bottom: 0.1rem;
  border-bottom: 2px solid var(--secondary);
}

a:hover,
a:focus {
  color: var(--secondary);
  border-bottom: 2px solid var(--alert);
}

.box.invert a:hover,
.box.invert a:focus {
  border-bottom: 2px solid var(--alert-desat);
}

button {
  outline: none;
  border: none;
  text-decoration: none;
  transition: all 0.1s ease;
}

ul {
  list-style-type: ">  ";
  padding: 0 0 2rem 1.25rem;
}

form {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

button,
input,
textarea {
  font-family: inherit;
  border-radius: 6px;
}

/* UTILITIES */
/**
 * .box inspired by Every Layout: The Box
 * by Heydon Pickering & Andy Bell
 * https://every-layout.dev/layouts/box/
 */
.box {
  position: relative;
  min-height: 100vh;
  padding: 1rem;
  color: var(--dark);
  background-color: var(--light);
}

.box * {
  color: inherit;
}

/* see theme.css for system-level inversions - prefers-color-scheme: dark */
.box.invert {
  color: var(--light2);
  background-color: var(--dark2);
}

.box.invert input,
.box.invert textarea {
  color: var(--dark);
  background-color: var(--light2);
}

@media (min-width: 769px) {
  .box {
    padding: 1rem 10%;
  }
}

/* card */
.card {
  contain: content;
  content-visibility: auto;
  width: 100%;
  margin: 1rem 0;
  padding: 1rem;
  background-clip: border-box;
  border: 2px solid var(--secondary);
  box-shadow: var(--primary) 12px 12px 0px 0px;
  animation: card-lift 0.4s ease;
  border-radius: 6px;
}

.box.invert .card {
  border: 2px solid var(--primary);
  box-shadow: var(--dark) 12px 12px 0px 0px;
  animation: card-lift-invert 0.4s ease;
}

@keyframes card-lift {
  0% {
    box-shadow: none;
    transform: translateX(12px) translateY(12px);
  }
  100% {
    box-shadow: var(--primary) 12px 12px 0px 0px;
    transform: translateX(0px) translateY(0px);
  }
}

@keyframes card-lift-invert {
  0% {
    box-shadow: none;
    transform: translateX(12px) translateY(12px);
  }
  100% {
    box-shadow: var(--dark) 12px 12px 0px 0px;
    transform: translateX(0px) translateY(0px);
  }
}

@media (min-width: 769px) {
  .card {
    margin: 0 0 1rem 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .box.invert .card {
    animation: none;
  }
}

/* HEADER & NAV */
header {
  font-size: 1.25rem;
}

header > div {
  display: flex;
  flex-direction: column;
  align-items: center;
}

header nav,
header p {
  padding: 0 0 0.5rem 0;
  padding: 0.5rem 0;
}

nav ul {
  display: flex;
  justify-content: flex-end;
  list-style: none;
  padding: 0;
}

nav li {
  padding: 0 0.5rem;
}

nav li a {
  border-bottom: 2px solid transparent;
}

nav li a:hover,
nav li a:focus {
  color: var(--secondary);
  border-bottom: 3px solid var(--alert);
}

.box.invert nav li a:hover,
.box.invert nav li a:focus {
  border-bottom: 3px solid var(--alert-desat);
}

nav .current {
  border-bottom: 3px solid var(--secondary);
}

nav li button {
  cursor: pointer;
  font-size: inherit;
  background-color: transparent;
  border-bottom: 3px solid transparent;
  color: inherit;
  border-radius: 0;
}

nav li button:hover,
nav li button:focus {
  outline: none;
  color: var(--secondary);
  border-bottom: 3px solid var(--alert);
}

.box.invert nav li button:hover,
.box.invert nav li button:focus {
  border-bottom: 3px solid var(--alert-desat);
}

@media (min-width: 769px) {
  header > div {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
  }
}

/* FOOTER */
footer {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 4rem;
  text-align: center;
  padding: 1rem;
}

footer a {
  display: inline-block;
  padding-bottom: 0.1rem;
  border-bottom: 2px solid var(--secondary);
  transition: all 0.5s ease;
  color: inherit;
}

footer a:hover,
footer a:focus {
  color: var(--secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--alert);
  margin: 0 0.25rem;
  letter-spacing: 0.08rem;
  animation: wiggle 0.5s linear;
}

.box.invert footer a:hover,
.box.invert footer a:focus {
  border-bottom: 2px solid var(--alert-desat);
}

@keyframes wiggle {
  0%,
  40%,
  100% {
    transform: rotateZ(-2deg);
  }
  20%,
  60%,
  80% {
    transform: rotateZ(2deg);
  }
}

/* dialog */
dialog {
  padding: 0;
  border: none;
  background: transparent;
  width: min(422px, 90%);
  margin: auto;
  display: none; /* Hide by default */
}

dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

/* More specific selector to override card animation */
dialog > .card {
  margin: 0;
  animation: none !important;
  box-shadow: var(--primary) 12px 12px 0px 0px;
  background-color: var(--light);
  width: 100%;
}

.box.invert dialog > .card {
  box-shadow: var(--dark) 12px 12px 0px 0px;
  background-color: var(--dark2);
}

dialog #close-dialog {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background-color: var(--secondary);
  color: var(--light);
  border-radius: 6px;
  cursor: pointer;
}

dialog #close-dialog:hover,
dialog #close-dialog:focus {
  background-color: var(--alert);
}

@media (prefers-reduced-motion: reduce) {
  dialog::backdrop {
    backdrop-filter: none;
  }
}

/* Loading state */
#submit {
  position: relative;
  min-height: 2.5rem;
}

#submit.loading {
  cursor: wait;
}

#submit .button-text {
  display: inline-block;
  transition: opacity 0.2s ease;
}

#submit.loading .button-text {
  opacity: 0;
}

#submit .button-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

#submit.loading .button-loader {
  display: flex;
  gap: 0.5rem;
}

.loader-dot {
  width: 0.5rem;
  height: 0.5rem;
  background-color: currentColor;
  border-radius: 50%;
  animation: loader-bounce 0.6s infinite;
}

.loader-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loader-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader-dot {
    animation: none;
  }
}
