:root {
  --board: #1a2140;
  --tile: #252e57;
  --tile-edge: #10162e;
  --amber: #f5b841;
  --found: #6fd3a0;
  --text: #e9eaf4;
  --muted: #9298be;
  --danger: #f07a6a;
  --line: #2f3866;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --ui: "Instrument Sans", system-ui, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--board);
  color: var(--text);
  font: 400 1rem/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 68rem;
  margin: 0 auto;
  padding: 3rem 1rem 4rem;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.title {
  margin: 0;
  font: 800 clamp(2.75rem, 8vw, 5.5rem)/0.9 var(--display);
  letter-spacing: 0.01em;
  color: var(--amber);
}
.lede {
  max-width: 38rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.0625rem;
}

/* Messages */
.flash {
  max-width: 44rem;
  margin: 1.5rem 0 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--found);
  background: var(--tile);
  border-radius: 0 4px 4px 0;
}
.flash--err { border-left-color: var(--danger); }

/* Add form: an empty slot on the board */
.add {
  display: flex;
  gap: 0.75rem;
  margin: 2.5rem 0 1.5rem;
}
.add input {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  font: 600 1.375rem/1.2 var(--display);
  letter-spacing: 0.04em;
  color: var(--amber);
  background: var(--tile-edge);
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.add input::placeholder { color: var(--muted); opacity: 0.7; font-family: var(--ui); font-size: 1rem; letter-spacing: 0; }
.add input:focus { outline: 2px solid var(--amber); outline-offset: 2px; border-color: transparent; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.85rem;
  font: 500 0.9375rem/1.2 var(--ui);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn--primary {
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  color: var(--tile-edge);
  background: var(--amber);
  border-color: var(--amber);
}
.btn--primary:hover { background: #ffc95c; border-color: #ffc95c; }
.btn--quiet { border-color: transparent; color: var(--muted); }
.btn--quiet:hover { color: var(--text); border-color: var(--line); }
.btn--danger:hover { color: var(--danger); border-color: var(--danger); }

/* Board */
.board { border-top: 1px solid var(--line); }

.empty {
  padding: 2.5rem 0;
  color: var(--muted);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem;
  grid-template-areas:
    "name   status"
    "meta   meta"
    "actions actions";
  gap: 0.75rem 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

/* Steam cover, pinned to the board like a poster next to the flaps */
.cover {
  grid-area: cover;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 460 / 215;
  object-fit: cover;
  border-radius: 3px;
  background: var(--tile);
  box-shadow: 0 0 0 1px var(--tile-edge);
}
.row:not(.row--found) .cover { filter: saturate(0.55); }

/* Split-flap name */
.flaps {
  grid-area: name;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  margin: 0;
  font: 800 clamp(1.5rem, 4vw, 2.1rem)/1 var(--display);
  text-transform: uppercase;
}
.word { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.flap {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 0.78em;
  height: 1.4em;
  padding: 0 0.08em;
  color: var(--amber);
  background: linear-gradient(var(--tile) 0 50%, #222a51 50% 100%);
  border-radius: 3px;
  box-shadow: inset 0 -2px 0 var(--tile-edge);
  animation: flip 420ms cubic-bezier(.3, .7, .4, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.flap::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: var(--tile-edge);
}
.row--found .flap { color: var(--found); }

@keyframes flip {
  0%   { transform: perspective(300px) rotateX(-90deg); opacity: 0; }
  60%  { transform: perspective(300px) rotateX(12deg); opacity: 1; }
  100% { transform: none; }
}

.status {
  grid-area: status;
  justify-self: end;
  align-self: start;
  margin: 0;
  padding: 0.3rem 0.6rem 0.2rem;
  font: 800 1.5rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  border: 2px solid currentColor;
  border-radius: 3px;
}
.row--found .status { color: var(--found); }

.meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}
.meta .error { color: var(--danger); }
.found-link {
  color: var(--found);
  font-weight: 500;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.found-link:focus-visible { outline: 2px solid var(--found); outline-offset: 2px; }

.actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.actions form, .foot form { margin: 0; }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.row--cover {
  grid-template-areas:
    "cover  cover"
    "name   status"
    "meta   meta"
    "actions actions";
}

@media (min-width: 52rem) {
  .row {
    grid-template-columns: minmax(0, 1fr) auto 6.5rem;
    grid-template-areas:
      "name    actions status"
      "meta    meta    meta";
    align-items: start;
  }
  .actions { justify-content: flex-end; }
  .row--cover {
    grid-template-columns: 13rem minmax(0, 1fr) 6.5rem;
    grid-template-areas:
      "cover name    status"
      "cover meta    meta"
      "cover actions actions";
  }
  .row--cover .actions { justify-content: flex-start; }
}

@media (max-width: 34rem) {
  .wrap { padding-top: 2rem; }
  .add { flex-direction: column; }
  .flaps { gap: 0.4rem 0.6rem; }
  .word { gap: 2px; }
  .status { font-size: 1.2rem; }
}

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