/* ============================================================
   INDIVIDUATION — Reading Room (AI dream interpreter)
   Claude-style centered prompt. Built on the "Carbon & Flame" tokens.
   ============================================================ */

:root { --rr-header: 64px; --rr-sidebar: 272px; --rr-col: 46rem; }

.reading-body { overflow: hidden; }              /* the room scrolls internally */

.reading-room {
  margin-top: var(--rr-header);
  height: calc(100svh - var(--rr-header));
  display: grid;
  grid-template-columns: var(--rr-sidebar) 1fr;
  border-top: 1.5px solid var(--line);
  background: var(--bg);
  transition: grid-template-columns 0.28s var(--ease-out);
}
/* collapsed on desktop: sidebar shrinks to a slim icon rail (toggle + new dream) */
@media (min-width: 821px) {
  .reading-room.rr-collapsed { grid-template-columns: 64px 1fr; }
  .reading-room.rr-collapsed .rr-sidebar { padding: 1.1rem 0.55rem; }
  .reading-room.rr-collapsed .rr-side-head { flex-direction: column; align-items: center; }
  .reading-room.rr-collapsed .rr-side-title,
  .reading-room.rr-collapsed .rr-history,
  .reading-room.rr-collapsed .rr-side-foot { display: none; }
}

/* ---- Sidebar ---- */
.rr-sidebar {
  display: flex; flex-direction: column;
  border-right: 1.5px solid var(--line);
  background: var(--bg-2);
  padding: 1.1rem 1rem;
  min-height: 0; min-width: 0; overflow: hidden;
  transition: background 0.45s var(--ease-out);
}
.rr-side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.rr-icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px;
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.rr-icon-btn:hover { color: var(--text); background: var(--surface); }
.rr-icon-btn svg { width: 15px; height: 15px; }

.rr-side-title {
  font-family: var(--font-display); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
  margin: 1.5rem 0 0.6rem;
}
.rr-history {
  list-style: none; margin: 0; padding: 0;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;      /* long titles must never scroll sideways */
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.2rem; align-content: start;
}
.rr-history > li { min-width: 0; }
.rr-history:empty::after {
  content: attr(data-empty);
  display: block; color: var(--muted); font-size: 0.85rem; line-height: 1.5; padding: 0.4rem 0.1rem;
}
.rr-hist-item {
  display: flex; align-items: center; gap: 0.55rem; border-radius: 9px;
  padding: 0.55rem 0.7rem; border: 1px solid transparent;
  color: var(--text-soft); font-size: 0.88rem; cursor: pointer;
  background: transparent; text-align: left; width: 100%;
  font-family: var(--font-body);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap; overflow: hidden;
}
.rr-hist-item:hover { background: var(--surface); color: var(--text); }
.rr-hist-item.active { color: var(--text); background: var(--accent-soft); }
.rr-hist-item span { overflow: hidden; text-overflow: ellipsis; }
.rr-hist-item::before { content: ""; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--accent); }

.rr-side-foot { border-top: 1px solid var(--line); margin-top: 0.8rem; padding-top: 0.9rem; }
.rr-free {
  font-family: var(--font-display); font-weight: 600; font-size: 0.82rem;
  color: var(--text-soft); margin: 0 0 0.6rem;
}
.rr-free.none { color: var(--accent); }
.rr-signin {
  width: 100%; padding: 0.55rem; border: 1px dashed var(--line); border-radius: 9px;
  background: transparent; color: var(--muted);
  font-family: var(--font-display); font-size: 0.74rem; font-weight: 600; cursor: not-allowed;
}

/* ---- Main column (Claude-style) ---- */
.rr-main {
  position: relative;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
/* floating opener — mobile only (desktop keeps the toggle inside the sidebar) */
.rr-side-toggle {
  display: none; position: absolute; top: 0.7rem; left: 0.8rem; z-index: 5;
  width: 40px; height: 40px; place-items: center; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.rr-side-toggle:hover { color: var(--text); border-color: var(--text); }

/* conversation scroll */
.rr-scroll {
  flex: 1 1 auto; overflow-y: auto; min-height: 0;
  padding: clamp(1.4rem, 4vh, 2.6rem) clamp(1rem, 4vw, 2.5rem) 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.rr-scroll::-webkit-scrollbar { width: 9px; }
.rr-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; }

/* the greeting shown on an empty screen */
.rr-greet { max-width: 40rem; margin: 0 auto; text-align: center; padding: 0 1rem; }
.rr-greet .eyebrow { justify-content: center; }
.rr-greet h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin-bottom: 0.7rem; }
.rr-greet p { color: var(--muted); font-size: 0.82rem; line-height: 1.55; max-width: 28rem; margin: 0 auto; }

/* messages — one narrow centered column */
.rr-msg { width: 100%; max-width: var(--rr-col); margin: 0 auto; }
.rr-msg.user {
  align-self: center; display: flex; justify-content: flex-end;
}
.rr-msg.user > .rr-bubble {
  max-width: 85%; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 0.8rem 1.05rem; white-space: pre-wrap;
  color: var(--text); font-size: 0.97rem; line-height: 1.55;
}
.rr-msg.assistant { align-self: center; }

/* AI prose (rendered from Markdown) */
.rr-prose { color: var(--text-soft); font-size: 1rem; line-height: 1.72; }
.rr-prose h4 {
  font-family: var(--font-display); font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--text);
  margin: 1.6rem 0 0.5rem; display: flex; align-items: center; gap: 0.6rem;
}
.rr-prose h4::before { content: ""; width: 12px; height: 2px; background: var(--accent); flex-shrink: 0; }
.rr-prose h4:first-child { margin-top: 0; }
.rr-prose p { margin: 0 0 0.9rem; }
.rr-prose strong { color: var(--text); font-weight: 600; }
.rr-prose em { color: var(--accent); font-style: normal; }
.rr-prose ul { margin: 0 0 0.9rem; padding-left: 1.2rem; }
.rr-prose li { margin-bottom: 0.4rem; }
.rr-prose li::marker { color: var(--accent); }

/* typing indicator */
.rr-typing { display: inline-flex; gap: 5px; padding: 0.4rem 0; }
.rr-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: rrpulse 1s var(--ease-out) infinite; }
.rr-typing span:nth-child(2) { animation-delay: 0.15s; }
.rr-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rrpulse { 0%,100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* streaming cursor */
.rr-cursor::after { content: "▍"; color: var(--accent); animation: rrblink 1s steps(1) infinite; }
@keyframes rrblink { 50% { opacity: 0; } }

/* Go deeper */
.rr-deeper-wrap { width: 100%; max-width: var(--rr-col); margin: 0.1rem auto 0; }
.rr-deeper {
  display: inline-flex; align-items: center; gap: 0.5rem; border-radius: 999px;
  padding: 0.5rem 1.15rem; border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  font-family: var(--font-display); font-weight: 600; font-size: 0.82rem; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.rr-deeper:hover { border-color: var(--accent); color: var(--accent); }
.rr-deeper svg { transition: transform 0.25s var(--ease-out); }
.rr-deeper:hover svg { transform: translateX(3px); }

.rr-err { color: var(--accent); font-size: 0.92rem; width: 100%; max-width: var(--rr-col); margin: 0 auto; }

/* ---- Composer (rounded Claude-style box) ---- */
.rr-composer-wrap { flex: 0 0 auto; padding: 0.6rem 1rem 1rem; }
.rr-composer { width: 100%; max-width: var(--rr-col); margin: 0 auto; }
.rr-inputbox {
  display: flex; align-items: flex-end; gap: 0.5rem;
  border: 1.5px solid var(--line); border-radius: 20px;
  background: var(--surface); padding: 0.55rem 0.55rem 0.55rem 1.1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.rr-inputbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rr-inputbox textarea {
  flex: 1 1 auto; resize: none; max-height: 220px; min-height: 24px;
  border: none; outline: none; background: transparent; color: var(--text);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.55; padding: 0.5rem 0;
}
.rr-inputbox textarea::placeholder { color: var(--muted); }
.rr-send {
  flex-shrink: 0; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  border: none; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  transition: transform 0.12s var(--ease-out), opacity 0.2s, background 0.2s;
}
.rr-send:hover { background: var(--text); color: var(--bg); }
.rr-send:active { transform: scale(0.92); }
.rr-send:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.rr-disclaimer {
  text-align: center; color: var(--muted); font-size: 0.73rem;
  padding: 0.6rem 1rem 0; margin: 0; max-width: var(--rr-col); margin: 0.6rem auto 0;
}

/* ---- Empty state: center greeting + prompt in the middle (Claude landing) ---- */
.rr-main.empty { justify-content: center; }
.rr-main.empty .rr-scroll { flex: 0 0 auto; overflow: visible; padding-bottom: 0.6rem; }
.rr-main.empty .rr-composer-wrap { padding-top: 0; }

/* ---- Free-limit modal ---- */
.rr-modal {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(0,0,0,0.6); padding: 1.5rem;
  animation: rrfade 0.25s var(--ease-out);
}
.rr-modal[hidden] { display: none; }
@keyframes rrfade { from { opacity: 0; } to { opacity: 1; } }
.rr-modal-card {
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  max-width: 30rem; width: 100%; padding: 2rem;
  animation: fadeUp 0.4s var(--ease-out);
}
.rr-modal-card h3 { margin-bottom: 0.8rem; }
.rr-modal-card p { color: var(--text-soft); margin-bottom: 1.6rem; }
.rr-modal-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.rr-modal-actions .btn { padding: 0.7rem 1.3rem; font-size: 0.78rem; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .rr-side-toggle { display: grid; }
  .reading-room,
  .reading-room.rr-collapsed { grid-template-columns: 1fr; }
  .rr-scroll { padding-top: 3.6rem; }
  .rr-main.empty .rr-scroll { padding-top: 3.6rem; }
  .rr-sidebar {
    position: fixed; top: var(--rr-header); bottom: 0; left: 0; z-index: 90;
    width: min(84vw, var(--rr-sidebar));
    transform: translateX(-105%); transition: transform 0.3s var(--ease-out);
    box-shadow: 8px 0 30px rgba(0,0,0,0.35);
  }
  .rr-sidebar.open { transform: translateX(0); }
}
