/* ==========================================================================
   Epipsy chat
   Sibling of the main site: same light surface, same ink, one amber lantern.
   Fraunces (display) + Inter (everything else). No images, no libraries.
   ========================================================================== */

:root {
  --surface: #faf7f1;
  --raised: #efe8db;

  --ink: #211a12;
  --ink-soft: #5c5245;

  --amber: #e8a33d;
  --amber-soft: #f4c877;
  --amber-deep: #8a5410;
  --btn-ink: #1b1206;

  --hairline: rgba(33, 26, 18, 0.14);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --measure: 40rem;
  --pill: 999px;
  --radius: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
}

/* Paper grain, exactly as on the site */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.05;
  background-size: 120px;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.5'/></svg>");
}

h1 {
  font-family: var(--font-display);
  font-weight: 350;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  margin: 0;
}

p {
  margin: 0;
}

::selection {
  background: var(--amber);
  color: var(--btn-ink);
}

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: var(--amber);
  color: var(--btn-ink);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--pill);
}

.skip-link:focus {
  top: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4.5px var(--amber-deep);
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.wm-mark {
  width: 18px;
  height: 18px;
  display: block;
}

.usage {
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Thread
   -------------------------------------------------------------------------- */

main {
  flex: 1;
}

.thread {
  width: min(100%, var(--measure));
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
}

.label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber-deep);
  margin-bottom: 0.75rem;
}

.intro-body {
  margin-top: 0.875rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.chips {
  margin-top: 2rem;
}

.chips-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 0.625rem;
}

.chips-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.chip {
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  text-align: left;
  min-height: 44px;
  padding: 0.625rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: var(--pill);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.chip:hover {
  border-color: var(--amber-deep);
  background: var(--raised);
}

.chips[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin-top: 2rem;
}

.messages:empty {
  margin-top: 0;
}

.msg {
  max-width: 100%;
}

.msg--visitor {
  align-self: flex-end;
  max-width: 85%;
  padding: 0.75rem 1.125rem;
  background: var(--raised);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  font-size: 0.9375rem;
}

.msg--guide {
  align-self: flex-start;
  position: relative;
  padding-left: 1.5rem;
}

/* The lantern ember marks the guide's turn */
.msg--guide::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber-deep);
  box-shadow: 0 0 0 4px rgba(138, 84, 16, 0.12);
}

.msg p {
  margin: 0;
}

.msg p + p {
  margin-top: 0.875rem;
}

.msg a {
  color: var(--amber-deep);
  text-underline-offset: 3px;
}

.msg--guide.is-waiting::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  vertical-align: text-bottom;
  background: var(--ink-soft);
  opacity: 0.55;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .msg--guide.is-waiting::after {
    animation: none;
  }

  * {
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   Composer
   -------------------------------------------------------------------------- */

.composer-wrap {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--surface) 22%);
  padding: 1.25rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
}

.composer {
  width: min(100%, var(--measure));
  margin: 0 auto;
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
  padding: 0.5rem 0.5rem 0.5rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.composer:focus-within {
  border-color: var(--amber-deep);
}

.composer textarea {
  flex: 1;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: transparent;
  border: 0;
  resize: none;
  max-height: 9rem;
  padding: 0.625rem 0;
}

.composer textarea:focus {
  outline: none;
  box-shadow: none;
}

.composer textarea::placeholder {
  color: var(--ink-soft);
  opacity: 0.75;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1.375rem;
  border-radius: var(--pill);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.btn--primary {
  background: var(--amber);
  color: var(--btn-ink);
  border: none;
}

.btn--primary:hover:not(:disabled) {
  background: var(--amber-soft);
}

.btn--primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.notice {
  width: min(100%, var(--measure));
  margin: 0.875rem auto 0;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--raised);
  border-radius: var(--radius);
}

.notice a,
.notice button {
  font-family: inherit;
  font-size: inherit;
  color: var(--amber-deep);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.waitlist {
  width: min(100%, var(--measure));
  margin: 1.5rem auto 0;
  padding: 1.125rem 1.25rem 1rem;
  background: var(--raised);
  border-radius: var(--radius);
}

.waitlist-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  margin: 0 0 0.35rem;
}

.waitlist-body {
  margin: 0 0 0.8rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.waitlist-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.waitlist-form input[type="email"] {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--pill);
}

.waitlist-form input[type="email"]:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.waitlist-error {
  margin: 0.6rem 0 0;
  font-size: 0.8125rem;
  color: var(--amber-deep);
}

.waitlist-confirm {
  margin: 0;
  font-size: 0.9375rem;
}

.waitlist-dismiss {
  margin-top: 0.7rem;
  padding: 0;
  background: none;
  border: 0;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.disclaimer {
  width: min(100%, var(--measure));
  margin: 0.875rem auto 0;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--ink-soft);
  text-align: center;
}

.disclaimer a {
  color: var(--amber-deep);
  text-underline-offset: 3px;
  white-space: nowrap;
}

@media (min-width: 40rem) {
  .thread {
    padding-top: 3rem;
  }

  .chips-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
