/*===== HOME SCREEN =====
  Terminal-style home: typed greeting, section boxes, and a robot arm in a
  1-bit window with physics crates. Uses terminal.css. */

.hx-home {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--mono);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(var(--rule) 1px, transparent 1.3px);
  background-size: 22px 22px;
  container: hx-home / inline-size;
}

.hx-home__grid {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  grid-template-areas: "text arm" "menu arm";
  column-gap: clamp(20px, 4cqi, 56px);
  row-gap: clamp(22px, 3.4cqi, 36px);
  align-items: start;
  padding-block: clamp(72px, 8cqi, 96px) clamp(40px, 5cqi, 64px);
  padding-left: max(clamp(16px, 5cqi, 60px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 5cqi, 60px), env(safe-area-inset-right, 0px));
}

.hx-home__text {
  grid-area: text;
  align-self: end;
  min-width: 0;
}

.hx-prompt {
  margin: 0 0 18px;
  font: 400 13px var(--mono);
  color: var(--dim);
}

.hx-prompt b {
  color: var(--ink);
  font-weight: 700;
}

.hx-hello {
  margin: 0;
  min-height: 2.08em;
  font: 800 clamp(30px, 6.2cqi, 66px)/1.04 var(--mono);
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}

.hx-sub {
  margin: 14px 0 0;
  min-height: 1.5em;
  font: 500 clamp(14px, 1.8cqi, 18px)/1.5 var(--mono);
  color: var(--dim);
}

.hx-sub::before {
  content: '// ';
}

.hx-name {
  color: var(--blue);
}

/* with JS on, the greeting stays hidden until it is typed out */
.hx-js .hx-home:not(.is-ready) .hx-hello,
.hx-js .hx-home:not(.is-ready) .hx-sub {
  visibility: hidden;
}

/*===== SECTION BOXES =====*/
.hx-menu {
  grid-area: menu;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.hx-item {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 100px;
  padding: 10px 12px 12px;
  border: 1px solid var(--ink);
  background-color: var(--paper);
  color: var(--ink);
}

.hx-js .hx-item {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .4s ease, transform .4s ease;
}

.hx-js .hx-item.on {
  opacity: 1;
  transform: none;
}

.hx-item__top {
  display: flex;
  justify-content: space-between;
  font: 500 12px var(--mono);
  color: var(--dim);
}

.hx-item__arrow {
  color: var(--blue);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .2s, transform .2s;
}

.hx-item__name {
  font: 700 16px/1.1 var(--mono);
}

.hx-item__desc,
.hx-item__cmd {
  font: 400 12px/1.35 var(--mono);
  color: var(--dim);
}

.hx-item__cmd {
  display: none;
  color: var(--ink);
}

.hx-item::before,
.hx-item::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 0 solid var(--blue);
  opacity: 0;
  transition: top .2s, left .2s, right .2s, bottom .2s, opacity .2s;
}

.hx-item::before {
  top: -2px;
  left: -2px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.hx-item::after {
  bottom: -2px;
  right: -2px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

.hx-item:hover,
.hx-item:focus-visible {
  background-image: repeating-linear-gradient(135deg, var(--rule) 0 1px, transparent 1px 7px);
}

.hx-item:hover::before,
.hx-item:focus-visible::before {
  top: -8px;
  left: -8px;
  opacity: 1;
}

.hx-item:hover::after,
.hx-item:focus-visible::after {
  bottom: -8px;
  right: -8px;
  opacity: 1;
}

.hx-item:hover .hx-item__arrow,
.hx-item:focus-visible .hx-item__arrow {
  opacity: 1;
  transform: none;
}

.hx-item:hover .hx-item__desc,
.hx-item:focus-visible .hx-item__desc {
  display: none;
}

.hx-item:hover .hx-item__cmd,
.hx-item:focus-visible .hx-item__cmd {
  display: block;
}

.hx-item:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

/*===== ARM WINDOW =====*/
.hx-arm {
  grid-area: arm;
  align-self: center;
  justify-self: center;
  width: 100%;
  max-width: 380px;
  background-color: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.hx-arm__bar {
  display: grid;
  grid-template-columns: 22px 1fr 22px;
  align-items: center;
  height: 28px;
  padding: 6px;
  border-bottom: 2px solid var(--ink);
  background: repeating-linear-gradient(var(--ink) 0 1px, transparent 1px 3px) content-box;
  user-select: none;
}

.hx-arm__close {
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  background-color: var(--paper);
}

.hx-arm__title {
  justify-self: center;
  padding: 0 8px;
  background-color: var(--paper);
  font: 700 12px/14px var(--mono);
}

.hx-arm__body {
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  cursor: crosshair;
  touch-action: none;
}

.hx-arm__readout {
  position: absolute;
  top: 10px;
  left: 12px;
  font: 500 11px/1.5 var(--mono);
  color: var(--dim);
  white-space: pre;
  pointer-events: none;
}

.hx-world {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hx-home.c-grab,
.hx-home.c-grab * {
  cursor: grab !important;
}

.hx-home.c-grabbing,
.hx-home.c-grabbing * {
  cursor: grabbing !important;
}

@container hx-home (max-width: 760px) {
  .hx-home__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "text" "menu" "arm";
  }
  .hx-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hx-arm {
    max-width: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hx-js .hx-item,
  .hx-item::before,
  .hx-item::after,
  .hx-item__arrow {
    transition: none;
  }
}
