:root {
  --ink: #17180f;
  --bone: #f1ead4;
  --paper: #d8ceb1;
  --brass: #d3a95d;
  --amber: #f0c46d;
  --glass: #a8d6c5;
  --shadow: #070806;
  --grid-size: 8;
  --control-font:
    "Michroma", Eurostile, "Microgramma D Extended", "Avenir Next", Futura,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 300px;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--bone);
  font-family: var(--control-font);
  background:
    linear-gradient(
      115deg,
      rgba(31, 138, 124, 0.05),
      transparent 32% 68%,
      rgba(211, 169, 93, 0.06)
    ),
    radial-gradient(
      ellipse at 18% 16%,
      rgba(211, 169, 93, 0.18),
      transparent 36%
    ),
    radial-gradient(
      ellipse at 78% 22%,
      rgba(77, 58, 83, 0.22),
      transparent 42%
    ),
    radial-gradient(
      ellipse at 48% 62%,
      rgba(31, 138, 124, 0.1),
      transparent 48%
    ),
    linear-gradient(150deg, #17180f 0%, #202719 38%, #35402c 64%, #10120d 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 30px;
}

.masthead {
  display: block;
  padding-bottom: 18px;
  animation: rise-in 720ms ease both;
}

.identity {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--glass);
  font-size: 0.82rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  text-align: center;
  color: var(--bone);
  font-size: 2.65rem;
  font-weight: 600;
}

.instrument {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 310px;
  gap: 30px;
  align-items: stretch;
}

.grid-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 560px;
  padding: 28px;
  border: 1px solid rgba(241, 234, 212, 0.18);
  background:
    linear-gradient(
      90deg,
      rgba(211, 169, 93, 0.12),
      transparent 18% 82%,
      rgba(31, 138, 124, 0.11)
    ),
    rgba(7, 8, 6, 0.32);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.36),
    0 34px 70px rgba(0, 0, 0, 0.28);
  animation: rise-in 780ms 90ms ease both;
}

.grid-wrap::before {
  position: absolute;
  content: "";
  pointer-events: none;
  inset: 17px;
  border: 1px solid rgba(168, 214, 197, 0.14);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  gap: 9px;
  width: min(71vmin, 604px);
  max-width: 100%;
  aspect-ratio: 1;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(241, 234, 212, 0.09), transparent 44%),
    rgba(23, 24, 15, 0.44);
  border: 1px solid rgba(241, 234, 212, 0.2);
}

.pad {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  cursor: pointer;
  border: 1px solid rgba(241, 234, 212, 0.38);
  border-radius: 50%;
  background: rgba(23, 24, 15, 0.42);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 -7px 14px rgba(0, 0, 0, 0.26);
  transition:
    background 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    transform 220ms ease,
    opacity 220ms ease;
}

.pad:hover,
.pad:focus-visible {
  border-color: var(--glass);
  outline: none;
  transform: translateY(-1px);
}

.pad::after {
  position: absolute;
  inset: 34%;
  content: "";
  border-radius: 50%;
  background: rgba(241, 234, 212, 0.18);
  opacity: 0;
  transform: scale(0.5);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.pad.is-alive {
  border-color: color-mix(in srgb, var(--amber) 72%, var(--glass));
  background: radial-gradient(
    circle,
    rgba(211, 169, 93, 0.7),
    rgba(201, 95, 67, 0.38) 56%,
    rgba(31, 138, 124, 0.34) 100%
  );
  box-shadow: inset 0 -10px 15px rgba(7, 8, 6, 0.28);
}

.pad.is-alive::after {
  opacity: var(--spark-opacity, 0.38);
  transform: scale(var(--spark-scale, 1));
}

.pad.is-born {
  animation: cell-born 820ms ease both;
}

.pad.is-dying {
  border-color: rgba(168, 214, 197, 0.3);
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(168, 214, 197, 0.26),
      transparent 42%
    ),
    rgba(23, 24, 15, 0.34);
  animation: cell-dust 1200ms ease both;
}

.control-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  padding: 4px 0 4px 24px;
  border-left: 1px solid rgba(241, 234, 212, 0.18);
  animation: rise-in 820ms 170ms ease both;
}

.transport {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.transport .primary {
  grid-column: span 2;
}

.command,
.mode-button,
.utility-button {
  position: relative;
  min-height: 46px;
  border: 1px solid rgba(241, 234, 212, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(241, 234, 212, 0.11), rgba(23, 24, 15, 0.3)),
    rgba(23, 24, 15, 0.52);
  color: var(--bone);
  cursor: pointer;
  font-size: 0.92rem;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.command:hover,
.mode-button:hover,
.utility-button:hover,
.command:focus-visible,
.mode-button:focus-visible,
.utility-button:focus-visible {
  border-color: rgba(168, 214, 197, 0.68);
  outline: none;
}

.command.primary,
.mode-button.is-selected {
  color: var(--shadow);
  background: var(--brass);
}

.mode-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.tuning-bank {
  display: grid;
  gap: 18px;
}

.tuning-control {
  display: grid;
  gap: 9px;
  color: var(--paper);
  font-size: 0.86rem;
}

.tuning-control span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
  cursor: pointer;
}

.utility-row {
  display: block;
}

.utility-row .utility-button {
  width: 100%;
}

.modal {
  width: min(680px, calc(100% - 34px));
  padding: 0;
  color: var(--ink);
  border: 1px solid rgba(241, 234, 212, 0.55);
  background: transparent;
}

.modal::backdrop {
  background: rgba(7, 8, 6, 0.72);
}

.modal-sheet {
  padding: 26px;
  background:
    linear-gradient(135deg, rgba(31, 138, 124, 0.09), transparent 42%),
    var(--paper);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.modal-head h2 {
  margin-bottom: 0;
  font-size: 1.65rem;
}

.modal-head .command {
  min-width: 92px;
  color: var(--bone);
  background: var(--ink);
}

.manual-copy {
  font-size: 1rem;
  line-height: 1.65;

  a {
    color: black;
  }

  p:last-child {
    margin-bottom: 0;
  }
}

body.mode-midi .grid {
  border-color: rgba(168, 214, 197, 0.42);
}

footer {
  padding: 25px 0 50px;
}

footer a {
  display: inherit;
  font-family: "Inter", sans-serif;
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--bone);
  text-align: center;
  text-decoration: none;
}

@media (max-width: 1040px) {
  .shell {
    width: min(720px, calc(100% - 24px));
  }

  .instrument {
    grid-template-columns: 1fr;
  }

  .grid-wrap {
    justify-self: center;
    width: min(100%, 720px);
    aspect-ratio: 1;
    min-height: auto;
    padding: clamp(18px, 3.8vw, 32px);
  }

  .control-panel {
    padding: 0;
    border-left: 0;
  }

  .grid {
    width: min(100%, 604px);
  }
}

@media (max-width: 520px) {
  .shell {
    padding-top: 20px;
  }

  h1 {
    font-size: 2rem;
  }

  .grid {
    gap: 6px;
    padding: 10px;
  }

  .transport,
  .mode-group {
    grid-template-columns: 1fr;
  }

  .transport .primary {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cell-born {
  0% {
    transform: scale(0.7);
  }
  55% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cell-dust {
  from {
    opacity: 0.82;
  }
  to {
    opacity: 0.52;
  }
}
