/* ---------- control deck (site nav) ----------
   A floating CRT dock pinned to the bottom of every page, plus a "/" command bar.
   Shared by every page: <link rel="stylesheet" href="/assets/deck.css"> + /assets/deck.js */

@view-transition {
  navigation: auto;
}

@property --deck-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

body {
  /* room so the dock never covers the footer */
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

.deck {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  width: min(calc(100% - 20px), 520px);
  translate: -50% 0;
  padding: 2px;
  border-radius: 20px;
  background: conic-gradient(from var(--deck-angle), var(--lime), var(--lilac), #2c2f38 35%, #2c2f38 65%, var(--lilac), var(--lime));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 30px rgba(197, 255, 73, 0.12);
  view-transition-name: control-deck;
  animation: deck-spin 6s linear infinite, deck-boot 0.9s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes deck-spin {
  to { --deck-angle: 360deg; }
}

/* CRT power-on: a thin bright line, then the picture opens up */
@keyframes deck-boot {
  0%   { transform: scale(0.02, 0.02); filter: brightness(4); opacity: 0; }
  30%  { transform: scale(1, 0.04); filter: brightness(3); opacity: 1; }
  60%  { transform: scale(1, 1.06); filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}

.deck-inner {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(13, 14, 17, 0.94);
  overflow: hidden;
}

@supports (backdrop-filter: blur(1px)) {
  .deck-inner {
    background: rgba(13, 14, 17, 0.82);
    backdrop-filter: blur(14px) saturate(1.3);
  }
}

/* scanlines + a slow refresh bar inside the screen */
.deck-inner::before,
.deck-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.deck-inner::before {
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 3px);
}

.deck-inner::after {
  background: linear-gradient(to bottom, transparent, rgba(197, 255, 73, 0.10), transparent);
  height: 40%;
  animation: deck-refresh 4.5s linear infinite;
}

@keyframes deck-refresh {
  from { transform: translateY(-100%); }
  to   { transform: translateY(260%); }
}

.deck-cmd,
.deck-link {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--paper);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease, translate 0.18s ease-out;
}

.deck-link {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
}

.deck-cmd {
  flex: none;
  width: 52px;
  background: var(--carbon-3);
  color: var(--lime);
}

.deck-cmd svg,
.deck-link svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.deck-cmd svg {
  width: 26px;
  height: 26px;
}

.deck-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.deck-key {
  display: none;
  font-size: 0.62rem;
  color: var(--paper-dim);
  border: 1px solid #3a3c44;
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.4;
}

@media (hover: hover) and (pointer: fine) {
  .deck-key { display: inline-block; }
  .deck-link { flex-direction: row; gap: 8px; }
}

.deck-link:hover,
.deck-cmd:hover {
  background: var(--carbon-3);
  color: var(--lime);
}

.deck-link[aria-current="page"] {
  background: var(--lime);
  color: var(--carbon);
}

.deck-link[aria-current="page"] .deck-key {
  color: var(--carbon);
  border-color: rgba(16, 17, 20, 0.4);
}

.deck-link:focus-visible,
.deck-cmd:focus-visible {
  outline: 3px solid var(--lilac);
  outline-offset: -3px;
}

/* glitch flicker on items as the deck boots */
.deck-link {
  animation: deck-item 0.5s steps(4, end) both;
}
.deck-link:nth-of-type(2) { animation-delay: 0.45s; }
.deck-link:nth-of-type(3) { animation-delay: 0.55s; }
.deck-link:nth-of-type(4) { animation-delay: 0.65s; }
.deck-link:nth-of-type(1) { animation-delay: 0.35s; }

@keyframes deck-item {
  0%   { opacity: 0; transform: translateX(-6px); text-shadow: 3px 0 var(--lilac); }
  50%  { opacity: 1; transform: translateX(4px); text-shadow: -3px 0 var(--lilac); }
  100% { opacity: 1; transform: none; text-shadow: none; }
}

/* ---------- command bar ---------- */

.cmd {
  width: min(calc(100% - 24px), 560px);
  max-height: 70vh;
  margin: 12vh auto auto;
  padding: 0;
  border: 2px solid var(--lime);
  border-radius: 16px;
  background: #0b0c0f;
  color: var(--paper);
  box-shadow: 0 0 0 1px rgba(181, 154, 255, 0.3), 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 40px rgba(197, 255, 73, 0.15);
  overflow: hidden;
}

.cmd::backdrop {
  background: rgba(8, 9, 11, 0.72);
  backdrop-filter: blur(4px);
}

.cmd[open] {
  animation: cmd-in 0.22s cubic-bezier(.2, .8, .2, 1);
}

@keyframes cmd-in {
  from { transform: translateY(8px) scale(0.98); opacity: 0; filter: brightness(2); }
  to   { transform: none; opacity: 1; filter: none; }
}

.cmd-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--carbon-3);
}

.cmd-prompt {
  font-family: var(--mono);
  font-weight: 800;
  color: var(--lilac);
}

.cmd-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--lime);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 1.1rem;
  caret-color: var(--lime);
}

.cmd-input::placeholder {
  color: #6b6d75;
}

.cmd-esc {
  border: 1px solid #3a3c44;
  border-radius: 6px;
  background: transparent;
  color: var(--paper-dim);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.7rem;
  padding: 6px 8px;
  cursor: pointer;
}

.cmd-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 46vh;
  overflow-y: auto;
}

.cmd-opt {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.cmd-opt mark {
  background: none;
  color: var(--lime);
}

.cmd-opt small {
  margin-left: auto;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--paper-dim);
  text-align: right;
}

.cmd-opt[aria-selected="true"] {
  background: var(--carbon-3);
  box-shadow: inset 3px 0 0 var(--lime);
}

.cmd-say {
  margin: 0;
  padding: 10px 18px 14px;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--lilac);
  min-height: 1.4em;
}

.cmd-say:empty {
  display: none;
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  .deck,
  .deck-link,
  .deck-inner::after,
  .cmd[open] {
    animation: none !important;
  }
}
