/**
 * Chat experiment (chat.experiments.emilialetizia.com)
 *
 * Editorial and quiet: one column of conversation, a history rail, and
 * nothing that competes with the text. Dark because the whole family
 * of experiment surfaces is.
 *
 * Every interactive affordance is gated on the `.js` class the inline
 * head script sets before first paint, so `.no-js` can retire the
 * composer instead of offering a form that goes nowhere.
 */

:root {
  --bg: #0b0b0d;
  --panel: #141416;
  --panel-2: #1b1d21;
  --ink: #ece9e3;
  --muted: #918c84;
  --line: #26262a;
  --accent: #d8c9a3;
  --warn: #e8b45a;
  --error: #e0907a;
  --bar-h: 3.25rem;
  --side-w: 15rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  background: var(--accent);
  color: #141416;
  padding: .5rem .9rem;
  border-radius: 0 0 .5rem 0;
}
.skip:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ brand bar */

.brandbar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 0 .9rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brandbar__brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
  font-size: .92rem;
}

.brandbar__mark {
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  background: var(--accent);
}

.brandbar__nav {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .8rem;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}
.pill:hover { color: var(--ink); border-color: var(--muted); }

.brandbar__locales {
  display: inline-flex;
  gap: .1rem;
  margin-left: .3rem;
}

.brandbar__loc {
  padding: .2rem .45rem;
  border-radius: .35rem;
  font-size: .74rem;
  letter-spacing: .06em;
  text-decoration: none;
  color: var(--muted);
}
.brandbar__loc:hover { color: var(--ink); }
.brandbar__loc.is-on { color: var(--bg); background: var(--accent); }

/* ---------------------------------------------------------------- shell */

.shell {
  display: flex;
  height: calc(100dvh - var(--bar-h));
  min-height: 0;
}

/* ------------------------------------------------------------- sidebar */

.sidebar {
  flex: 0 0 var(--side-w);
  width: var(--side-w);
  border-right: 1px solid var(--line);
  padding: .9rem .7rem;
  overflow-y: auto;
  min-height: 0;
}

.sidebar__new {
  display: block;
  padding: .55rem .7rem;
  border: 1px dashed var(--line);
  border-radius: .6rem;
  font-size: .85rem;
  text-decoration: none;
  color: var(--ink);
}
.sidebar__new:hover { border-color: var(--muted); }
.sidebar__new.is-on { border-style: solid; border-color: var(--accent); color: var(--accent); }

.sidebar__title {
  margin: 1.4rem 0 .5rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar__list {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.hist {
  display: block;
  padding: .4rem .6rem;
  border-radius: .5rem;
  font-size: .85rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist:hover { background: var(--panel); color: var(--ink); }
.hist.is-on { background: var(--panel); color: var(--ink); }
.hist--empty {
  font-size: .8rem;
  opacity: .75;
  cursor: default;
}

/* ---------------------------------------------------------------- pane */

.pane {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.transcript {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 1.25rem clamp(.9rem, 4vw, 2.5rem);
  scroll-behavior: smooth;
}

.empty {
  margin: auto 0;
  max-width: 34rem;
}
.empty__title {
  margin: 0 0 .5rem;
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 500;
  letter-spacing: -.01em;
}
.empty__body {
  margin: 0;
  color: var(--muted);
}

.msgs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.msg {
  max-width: min(44rem, 100%);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.msg--user { align-self: flex-end; align-items: flex-end; }
.msg--assistant { align-self: flex-start; }

.msg__who {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.msg__body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: .7rem .95rem;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--panel);
}

.msg--user .msg__body {
  background: var(--panel-2);
  border-color: #2e333a;
}

.msg--assistant.is-pending .msg__body::after {
  content: "…";
  display: inline-block;
  animation: chat-blink 1.2s steps(4, end) infinite;
}

@keyframes chat-blink {
  0%   { opacity: .2; }
  50%  { opacity: 1; }
  100% { opacity: .2; }
}

@media (prefers-reduced-motion: reduce) {
  .transcript { scroll-behavior: auto; }
  .msg--assistant.is-pending .msg__body::after { animation: none; opacity: .7; }
}

/* ------------------------------------------------------------ composer */

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: .7rem clamp(.9rem, 4vw, 2.5rem) .9rem;
}

.composer__row {
  display: flex;
  align-items: flex-end;
  gap: .55rem;
}

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2.8rem;
  max-height: 40vh;
  resize: none;
  overflow-y: auto;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  /* Supported in current browsers; the others fall back to a fixed
     one-line box that the JS autosizer takes over. */
  field-sizing: content;
}
.composer__input::placeholder { color: var(--muted); opacity: .8; }
.composer__input:disabled { opacity: .55; }

.composer__send {
  flex: 0 0 auto;
  padding: .7rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: .8rem;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.composer__send:hover:not(:disabled) { background: var(--accent); color: #141416; }
.composer__send:disabled { opacity: .45; cursor: default; }

.composer__status {
  margin: .5rem 0 0;
  min-height: 1.1rem;
  font-size: .8rem;
  color: var(--muted);
}
.composer__status.is-error { color: var(--error); }

.quota {
  display: flex;
  flex-wrap: wrap;
  gap: .1rem .8rem;
  margin: .1rem 0 0;
  font-size: .73rem;
  color: var(--muted);
}
.quota__warn { color: var(--warn); }

.composer__nojs { display: none; margin: 0 0 .7rem; font-size: .85rem; color: var(--warn); }

/* ------------------------------------------------------------- fallback */

.no-js .composer__row,
.no-js .quota,
.no-js .composer__status { display: none; }
.no-js .composer__nojs { display: block; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
  .shell { flex-direction: column; }

  .sidebar {
    flex: 0 0 auto;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: .7rem .8rem;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar__title { display: none; }

  .sidebar__list {
    flex-direction: row;
    gap: .3rem;
    margin-top: .55rem;
  }

  .hist {
    flex: 0 0 auto;
    max-width: 14rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .3rem .7rem;
    font-size: .8rem;
  }
}
