/* The request form in the control room: the room's own terminal, in the manner of method.log. */

.room-form {
  --ink: #fabdf9;
  position: relative;
  display: grid;
  gap: 18px;
  max-width: 560px;
  padding: clamp(20px, 2.4vw, 34px);
  border: 1px solid rgba(250, 189, 249, 0.3);
  background: rgba(14, 4, 22, 0.66);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  font-family: 'Geist Mono', ui-monospace, monospace;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s 0.2s, transform 0.7s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.room-open .room-form {
  opacity: 1;
  transform: none;
}

/* Corner marks, as on every file in this room. */
.room-form::before,
.room-form::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
  pointer-events: none;
}

.room-form::before {
  left: -1px;
  top: -1px;
  border-right: 0;
  border-bottom: 0;
}

.room-form::after {
  right: -1px;
  bottom: -1px;
  border-left: 0;
  border-top: 0;
}

.rf-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(250, 189, 249, 0.4);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 214, 251, 0.72);
  white-space: nowrap;
}

/* On a phone the count gives way: the file name keeps its one line. */
@media (max-width: 480px) {
  .rf-top span:last-child {
    display: none;
  }
}

.rf-top span:first-child::before {
  content: '';
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.9em;
  background: var(--ink);
  box-shadow: 0 0 8px #ff4dea;
  animation: blink 1s steps(2) infinite;
}

.rf-row {
  display: grid;
  grid-template-columns: 9ch minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(250, 189, 249, 0.22);
  cursor: text;
  transition: border-color 0.2s;
}

.rf-row:focus-within {
  border-bottom-color: var(--ink);
}

.rf-key {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 214, 251, 0.72);
  white-space: nowrap;
}

.rf-key::before {
  content: '> ';
  color: var(--ink);
}

.rf-row input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: clamp(16px, 1.25vw, 19px); /* 16px at least: a phone zooms in on anything smaller */
  color: #fff;
  caret-color: var(--ink);
  caret-shape: block;
}

.rf-row input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.rf-row input:-webkit-autofill {
  -webkit-text-fill-color: #fff;
  transition: background-color 9999s;
}

.rf-row.is-wrong {
  border-bottom-color: #ff7a9c;
}

.rf-row.is-wrong .rf-key {
  color: #ff7a9c;
}

.rf-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* What the terminal prints back. */
.rf-out {
  min-height: 1.5em;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 214, 251, 0.86);
}

.rf-out:not(:empty)::before {
  content: '> ';
  color: var(--ink);
}

.rf-out.is-error {
  color: #ff9db6;
}

.rf-send {
  justify-self: start;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #14061c;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.rf-send:hover,
.rf-send:focus-visible {
  background: transparent;
  color: var(--ink);
  box-shadow: 0 0 18px rgba(255, 77, 234, 0.35);
  outline: 0;
}

.rf-send[disabled] {
  cursor: default;
  opacity: 0.6;
}

.room-form.is-sent .rf-row,
.room-form.is-sent .rf-send {
  display: none;
}

@media (max-width: 860px) {
  .room-form {
    max-width: none;
  }
}

/* A phone held upright: the room sits at the foot of the screen, as every chapter does, so the tower
   stays in sight over it. The sentence is set to be read (sans, unlit), each field takes the full width
   under its key, and the button is a full row under the thumb. */
@media (max-width: 760px) {
  .room {
    padding: 84px 16px calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(4, 2, 8, 0.9) 0%, rgba(4, 2, 8, 0.78) 52%, rgba(4, 2, 8, 0.2) 78%, transparent 92%);
  }

  .room .room-in {
    align-self: end;
    gap: 18px;
  }

  html[data-m='d'] .room h2 {
    max-width: none;
    font-size: clamp(26px, 7.6vw, 34px);
  }

  .room .room-lede {
    max-width: none;
    margin-top: 10px;
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: 0;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: none;
  }

  .room .room-more {
    margin-top: 12px;
    font-size: 14px;
  }

  .room-form {
    gap: 6px;
    padding: 16px 16px 18px;
    background: rgba(14, 4, 22, 0.78);
  }

  .rf-top {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .rf-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 0 9px;
  }

  .rf-key {
    font-size: 10px;
  }

  .rf-out {
    min-height: 0;
    font-size: 12px;
  }

  .rf-out:not(:empty) {
    margin-top: 8px;
  }

  .rf-send {
    justify-self: stretch;
    margin-top: 12px;
    padding: 15px 16px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .room-form {
    transition: opacity 0.3s;
    transform: none;
  }

  .rf-top span:first-child::before {
    animation: none;
  }
}
