/*
 * GATO — visual system per NOIR's STYLEGUIDE.md.
 *
 * Tokens, type stacks, easing, layering, atmosphere, and the button, field and
 * panel vocabulary (§13) are the apps' own, unchanged. The 8-bit world lives
 * inside the screen, a canvas with its own palette (web/pixels.js): the one
 * place the dark blue is spent. Around it the page is NOIR.
 *
 * --signal is spent once, as §14's beacon, on the chat field — the next action
 * — until you have said something, and then never again.
 */

:root {
  color-scheme: dark;

  /* --- guide tokens, verbatim --- */
  --bg: #000000;
  --fg: #ffffff;
  --fg-dim: rgba(255, 255, 255, 0.58);
  --fg-faint: rgba(255, 255, 255, 0.14);
  --fg-body: rgba(255, 255, 255, 0.72);
  --fg-punct: rgba(255, 255, 255, 0.38);

  --signal: #a7e6ec;
  --signal-soft: rgba(167, 230, 236, 0.55);
  --signal-faint: rgba(167, 230, 236, 0.14);

  --font-display: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --mx: 50%;
  --my: 26%;

  --rule: 1px solid var(--fg-faint);
  --pad: clamp(1rem, 3vw, 1.8rem);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ---------------------------------------------------------- atmosphere -- */

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    58vmax 58vmax at var(--mx) var(--my),
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02) 34%,
    transparent 68%
  );
  opacity: 0;
  animation: rise-in 2.4s var(--ease) 0.1s forwards;
}

.grain {
  position: fixed;
  inset: -150%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 700ms steps(1) infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(135% 100% at 50% 34%, transparent 54%, rgba(0, 0, 0, 0.66) 100%);
}

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

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 3%); }
  40%  { transform: translate(4%, -5%); }
  60%  { transform: translate(-3%, -2%); }
  80%  { transform: translate(5%, 4%); }
  100% { transform: translate(0, 0); }
}

/* --------------------------------------------------------------- header -- */

.bar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(var(--pad) * 0.8) var(--pad);
  border-bottom: var(--rule);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.14em;
  line-height: 1;
  text-decoration: none;
}

.brand__name {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.9vw, 1.42rem);
  font-weight: 900;
  letter-spacing: 0.17em;
  margin-right: -0.17em;
  color: var(--fg);
}

.brand__by {
  font-family: var(--font-mono);
  font-size: clamp(0.56rem, 0.85vw, 0.68rem);
  letter-spacing: 0.19em;
  margin-right: -0.19em;
  color: var(--fg-dim);
}

.brand:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }

.privacy {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 0 auto;
  padding: 0.4em 0.75em;
  border: var(--rule);
  font-size: clamp(0.56rem, 0.8vw, 0.66rem);
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  white-space: nowrap;
}

.privacy__label { margin-right: -0.2em; }

.privacy__dot {
  width: 5px;
  height: 5px;
  background: var(--fg);
  border-radius: 50%;
  flex: 0 0 auto;
}

/* -------------------------------------------------------------- controls -- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  padding: 0.6em 0.95em;
  border: var(--rule);
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: clamp(0.58rem, 0.82vw, 0.68rem);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.btn:hover, .btn:focus-visible { color: var(--fg); border-color: var(--fg-dim); outline: none; }
.btn:focus-visible { border-color: var(--fg); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:disabled:hover { color: var(--fg-dim); border-color: var(--fg-faint); }
.btn--ghost { border-color: transparent; }
.btn--ghost:hover, .btn--ghost:focus-visible { border-color: var(--fg-faint); }
.btn--ghost:disabled:hover { border-color: transparent; }

.field {
  width: 100%;
  min-width: 0;
  padding: 0.7em 0.85em;
  border: var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: max(16px, clamp(0.72rem, 1vw, 0.82rem)); /* 16px: phones zoom into anything smaller */
  letter-spacing: 0.04em;
}

.field::placeholder { color: var(--fg-dim); letter-spacing: 0.14em; }
.field:focus-visible { outline: none; border-color: var(--fg); }
.field:disabled { opacity: 0.35; }

/* §14: the one beacon, on the chat field, until you have said something. */
.field.is-beacon {
  border-color: var(--signal-soft);
  animation: beacon 2.8s var(--ease) infinite;
}

.field.is-beacon:focus-visible { border-color: var(--signal); }

@keyframes beacon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 230, 236, 0); border-color: var(--signal-faint); }
  50%      { box-shadow: 0 0 22px -2px rgba(167, 230, 236, 0.28); border-color: var(--signal-soft); }
}

/* ------------------------------------------------------------------- room -- */

.room {
  position: relative;
  z-index: 4;
  flex: 1;
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(1.2rem, 3.5vh, 2.4rem) var(--pad) clamp(2rem, 6vh, 3.6rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.6rem, 3vw, 2.4rem);
  animation: rise-in 0.8s var(--ease) 0.15s both;
}

/* ----------------------------------------------------------------- stage -- */

.stage { min-width: 0; }

/* screen.js sizes the canvas to a whole number of device pixels per screen
   pixel, as wide as this box allows; the black around it is the page's own. */
.stage__screen {
  display: flex;
  justify-content: center;
  max-width: 34rem; /* stacked, the chat stays in reach below it */
  margin: 0 auto;
}

.screen {
  display: block;
  outline: 1px solid var(--fg-faint);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

.status,
.meal,
.rules {
  margin: 0;
  text-align: center;
  font-family: var(--font-mono);
}

.status {
  margin-top: 1rem;
  font-size: clamp(0.72rem, 1vw, 0.8rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--fg);
}

/* Your meals, said out loud: showing up and talking are what feed it. */
.meal {
  min-height: 1.9em;
  margin-top: 0.45rem;
  font-size: clamp(0.68rem, 0.95vw, 0.76rem);
  line-height: 1.9;
  letter-spacing: 0.14em;
  color: var(--fg-body);
}

.rules {
  margin-top: 0.35rem;
  font-size: clamp(0.62rem, 0.85vw, 0.68rem);
  line-height: 1.8;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
}

/* ------------------------------------------------------------------ chat -- */

.chat {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: var(--rule);
}

.label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 0.95vw, 0.74rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--fg);
}

.chat__here {
  font-size: clamp(0.68rem, 0.9vw, 0.72rem);
  letter-spacing: 0.18em;
  color: var(--fg-dim);
}

.log {
  height: clamp(12rem, 34vh, 20rem);
  margin: 0;
  padding: 0.7rem 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-faint) transparent;
}

.line {
  padding: 0.24rem 0;
  font-size: clamp(0.72rem, 1vw, 0.8rem);
  line-height: 1.65;
  letter-spacing: 0.03em;
  color: var(--fg-body);
  overflow-wrap: anywhere;
}

.line__name {
  margin-right: 0.8em;
  font-size: 0.92em;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
}

.line--mine .line__name { color: var(--fg); }

/* The cat speaks in full white, and signs in the display face: it is the
   only name here that is somebody's identity. */
.line--cat .line__name {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.17em;
  color: var(--fg);
}

.line--cat .line__text { color: var(--fg); }

.line--visit,
.line--rename {
  font-size: clamp(0.66rem, 0.88vw, 0.72rem);
  letter-spacing: 0.14em;
  color: var(--fg-dim);
}

.line__food {
  margin-left: 0.7em;
  letter-spacing: 0.08em;
  color: var(--fg);
}

.say {
  display: flex;
  gap: 0.4rem;
  padding-top: 0.9rem;
  border-top: var(--rule);
}

.note {
  min-height: 1.9em;
  margin: 0.5rem 0 0;
  font-size: clamp(0.66rem, 0.9vw, 0.72rem);
  line-height: 1.9;
  letter-spacing: 0.16em;
  color: var(--fg);
}

.me {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.7rem;
  margin: 0.2rem 0 0;
  font-size: clamp(0.66rem, 0.9vw, 0.72rem);
  letter-spacing: 0.16em;
  color: var(--fg-dim);
}

.me strong { font-weight: 500; color: var(--fg); letter-spacing: 0.12em; }
.me .btn { padding: 0.45em 0.7em; }

/* Side by side once the screen can be big and the chat still readable. */
@media (min-width: 60rem) {
  .room {
    grid-template-columns: minmax(0, 40rem) minmax(18rem, 1fr);
    align-items: start;
  }

  .stage__screen { max-width: none; }

  .log { height: clamp(18rem, 48vh, 26rem); }
}

/* ------------------------------------------------------------------ foot -- */

.foot {
  position: relative;
  z-index: 4;
  padding: var(--pad);
  border-top: var(--rule);
  text-align: center;
}

.foot p {
  margin: 0 0 0.6rem;
  font-size: clamp(0.55rem, 0.8vw, 0.64rem);
  letter-spacing: 0.14em;
  line-height: 1.9;
  color: var(--fg-punct);
}

/* ------------------------------------------------------------- utilities -- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 0.6em 1em;
  background: var(--bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
}

.skip-link:focus { left: 0.5rem; top: 0.5rem; }

[hidden] { display: none !important; }

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

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

  .glow, .room {
    animation-duration: 0.01ms;
    animation-delay: 0s;
  }

  .field.is-beacon {
    animation: none;
    border-color: var(--signal-soft);
  }

  * { transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------- site nav -- */

/*
 * The same map of noirapps.io that closes every page of the site — apps, site,
 * legal, contact — so every page reaches every other. Groups wrap as units.
 * Links are root-relative because the app lives one directory down.
 * STYLEGUIDE §6, "Footer".
 */
.sitenav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem clamp(1.6rem, 3vw, 2.6rem);
}

.sitenav__group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem clamp(0.9rem, 1.6vw, 1.3rem);
}

.sitenav a {
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 0.9vw, 0.72rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-decoration: none;
  text-underline-offset: 0.45em;
  transition: color 0.45s var(--ease);
}

.sitenav a:hover,
.sitenav a:focus-visible {
  color: var(--fg);
  text-decoration: underline;
  outline: none;
}

.sitenav a[aria-current="page"] { color: var(--fg); }

/* An address is data, not a label: barely tracked. */
.sitenav .sitenav__mail { letter-spacing: 0.06em; }

.foot .sitenav { margin-top: 1rem; }
