/* =============================================================
   A Conversation with Luke Burgis
   Editorial / literary UI. Paper, ink, amber.
   ============================================================= */

:root {
  --paper:        #faf9f5;
  --paper-warm:   #f3eee1;
  --ink:          #1c1c1c;
  --ink-soft:     #3a3733;
  --ink-mute:     #7a736b;
  --rule:         #d9d2c2;
  --amber:        #a85d1f;
  --amber-soft:   #c4863c;
  --sepia:        #8a6a3b;
  --serif:        "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --display:      "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --sans:         "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --max:          720px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle paper grain overlay — pure CSS noise via SVG data URI */
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a {
  color: var(--amber);
  text-decoration: none;
  border-bottom: 1px solid rgba(168, 93, 31, 0.3);
  transition: border-color 0.2s ease;
}
a:hover { border-bottom-color: var(--amber); }

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

/* =============================================================
   GATE
   ============================================================= */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 28px;
  position: relative;
}

.gate-inner {
  max-width: 520px;
  width: 100%;
  text-align: center;
  position: relative;
}

.gate-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 36px;
  opacity: 0.85;
}

.gate-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.3rem, 6vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin-bottom: 28px;
}
.gate-title .amp {
  font-style: italic;
  color: var(--ink-mute);
  font-weight: 400;
}

.gate-blurb {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 380px;
  margin: 0 auto 44px;
}
.gate-blurb em { color: var(--ink); font-style: italic; }

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 320px;
  margin: 0 auto;
}

#code {
  font-family: var(--serif);
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  text-align: center;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease;
}
#code::placeholder {
  color: var(--ink-mute);
  opacity: 0.45;
  letter-spacing: 0.18em;
}
#code:focus { border-bottom-color: var(--amber); }

#gate-submit {
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 14px 28px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.05s ease;
}
#gate-submit:hover { background: #000; }
#gate-submit:active { transform: translateY(1px); }
#gate-submit:disabled { background: var(--ink-mute); cursor: progress; }
.btn-loading { letter-spacing: 0.4em; }

.gate-error {
  margin-top: 18px;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--amber);
  font-style: italic;
}

.gate-foot {
  margin-top: 56px;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
}
.gate-foot a {
  color: var(--ink);
  border-bottom-color: var(--ink-mute);
}
.gate-foot a:hover { color: var(--amber); border-bottom-color: var(--amber); }

/* =============================================================
   CHAT — the reading room
   ============================================================= */
.chat {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--sans);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-name {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.signout {
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s ease;
}
.signout:hover { color: var(--amber); }

/* Reading room */
.reading-room {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px 28px 200px; /* room for sticky composer */
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 44px;
}

/* User entry: italic, right-aligned, with a leading mark */
.entry.user {
  align-self: flex-end;
  max-width: 92%;
  text-align: right;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--ink-soft);
  line-height: 1.55;
  padding-right: 18px;
  border-right: 1px solid var(--amber);
}

/* Luke's response: full-width essay set in serif */
.entry.luke {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.75;
  color: var(--ink);
}
.entry.luke p { margin-bottom: 1em; }
.entry.luke p:last-child { margin-bottom: 0; }
.entry.luke em { font-style: italic; color: var(--ink-soft); }
.entry.luke strong { font-weight: 600; }

/* Footnote-style sources */
.sources {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-mute);
  line-height: 1.6;
}
.sources-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  color: var(--sepia);
  margin-right: 8px;
}
.sources cite {
  font-style: italic;
  color: var(--ink-soft);
}
.sources .sep { color: var(--rule); margin: 0 6px; }

/* Loading: typographic ellipsis */
.entry.loading {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--ink-mute);
  letter-spacing: 0.3em;
}
.entry.loading .dots span {
  display: inline-block;
  animation: pulse 1.4s infinite ease-in-out;
}
.entry.loading .dots span:nth-child(2) { animation-delay: 0.2s; }
.entry.loading .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* Composer */
.composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9;
  background: linear-gradient(
    to top,
    var(--paper) 0%,
    var(--paper) 70%,
    rgba(250, 249, 245, 0) 100%
  );
  padding: 36px 28px 28px;
}

.composer-form {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 10px;
}

#composer {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--ink);
  resize: none;
  line-height: 1.5;
  padding: 6px 0;
  max-height: 200px;
  overflow-y: auto;
}
#composer::placeholder {
  color: var(--ink-mute);
  opacity: 0.5;
  font-style: italic;
}

#send {
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.1s ease;
}
#send:hover { color: var(--amber); }
#send:active { transform: translateX(2px); }
#send:disabled { color: var(--ink-mute); cursor: not-allowed; opacity: 0.4; }

/* =============================================================
   Mobile
   ============================================================= */
@media (max-width: 640px) {
  html, body { font-size: 17px; }
  .gate { padding: 40px 22px; }
  .gate-title { margin-bottom: 22px; }
  .gate-blurb { margin-bottom: 36px; }
  .reading-room { padding: 32px 22px 180px; }
  .chat-header { padding: 12px 22px; }
  .composer { padding: 28px 22px 22px; }
  .entry.luke { font-size: 1.05rem; }
}

/* Print/reader nicety */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
