/* ═══════════════════════════════════════════
   THE RITUAL — AI Coach  (v3)
═══════════════════════════════════════════ */

/* ── Root ── */
.coach-view {
  display: flex;
  flex-direction: column;
  max-width: 1060px;
  margin: 0 auto;
}

/* ── Two-column layout ── */
.coach-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

.coach-main-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ── Observations sidebar (right column) ── */
.coach-obs-col {
  position: sticky;
  top: 72px;
}

.coach-obs-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 4px;
}

.coach-obs-panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-obs-panel-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coach-obs-refresh-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0.45;
  transition: opacity 0.18s, color 0.18s;
  line-height: 1;
}
.coach-obs-refresh-btn:hover { opacity: 1; color: var(--gold); }

/* Desktop: observations always fully visible, no accordion */
@media (min-width: 769px) {
  .coach-obs-toggle--mobile { display: none !important; }

  .coach-obs-section {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    background: var(--navy-card);
    padding: 20px 20px 8px;
  }

  .coach-obs-body {
    display: block !important;
  }
  .coach-obs-inner {
    overflow: visible !important;
  }
}

/* Memory pill */
.coach-memory-wrap {
  margin-top: 4px;
}

.coach-memory-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  background: rgba(196,164,107,0.07);
  border: 1px solid rgba(196,164,107,0.18);
  border-radius: 20px;
  padding: 5px 14px;
}

.coach-memory-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.75;
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,100% { opacity:0.4; transform:scale(0.85); }
  50%      { opacity:0.9; transform:scale(1.1); }
}

/* ══ CHAT AREA ═══════════════════════════════════════ */

.coach-chat-wrap {
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.015);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 24px;
}

/* Messages — scrollable, fixed height */
.coach-messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: clamp(300px, 44vh, 480px);
  min-height: 0;
  overflow-y: auto;
  padding: 28px 28px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(196,164,107,0.18) transparent;
}

.coach-messages::-webkit-scrollbar { width: 4px; }
.coach-messages::-webkit-scrollbar-track { background: transparent; }
.coach-messages::-webkit-scrollbar-thumb {
  background: rgba(196,164,107,0.18);
  border-radius: 4px;
}
.coach-messages::-webkit-scrollbar-thumb:hover { background: rgba(196,164,107,0.35); }

/* ── Oracle empty state + suggested prompts ── */
.coach-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex: 1;
  padding: 20px 0 10px;
  animation: fadeIn 0.3s ease;
}

.coach-empty-label {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.55;
  letter-spacing: 0.08em;
  margin: 0;
}

.coach-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 14px 28px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.coach-prompt-chip {
  background: rgba(196,164,107,0.06);
  border: 1px solid rgba(196,164,107,0.18);
  border-radius: 20px;
  color: var(--stone);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.02em;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.18s;
  line-height: 1.3;
}

.coach-prompt-chip:hover {
  background: rgba(196,164,107,0.12);
  border-color: rgba(196,164,107,0.4);
  color: var(--gold-bright);
  transform: translateY(-1px);
}

/* Coach message — no bubble, just clean text with gold marker */
.coach-msg--coach {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 16px;
  align-items: start;
}

.coach-msg--coach::before {
  content: '✦';
  font-size: 11px;
  color: var(--gold);
  opacity: 0.55;
  padding-top: 5px;
  flex-shrink: 0;
  line-height: 1;
}

.coach-bubble-text {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--stone);
}

.coach-bubble-text .cp {
  margin: 0 0 12px;
  color: var(--stone);
}
.coach-bubble-text .cp:first-child { color: var(--text); }
.coach-bubble-text .cp:last-child  { margin-bottom: 0; }

.coach-bubble-text strong { color: var(--text); font-weight: 600; }
.coach-bubble-text em     { color: var(--stone); font-style: italic; }

.ch3 {
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin: 10px 0 6px;
}
.ch4 {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.cul {
  padding-left: 18px;
  margin: 8px 0;
}
.cul li {
  margin-bottom: 6px;
  list-style: disc;
  font-size: 15px;
  line-height: 1.65;
  color: var(--stone);
}
.cul li strong { color: var(--text); font-weight: 600; }
.chr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin: 14px 0;
}

/* User message */
.coach-msg--user {
  display: flex;
  justify-content: flex-end;
}

.coach-user-bubble {
  background: rgba(196,164,107,0.09);
  border: 1px solid rgba(196,164,107,0.18);
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  max-width: 75%;
  letter-spacing: 0.01em;
}

/* Thinking dots */
.coach-thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 2px;
}
.coach-thinking span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(196,164,107,0.4);
  animation: pulse-dot 1.3s ease-in-out infinite;
}
.coach-thinking span:nth-child(2) { animation-delay: 0.15s; }
.coach-thinking span:nth-child(3) { animation-delay: 0.30s; }

.coach-err { color: var(--danger-text,#d06060); font-size: 15px; }

/* ── Input ── */
.coach-input-wrap {
  border-top: 1px solid rgba(255,255,255,0.05);
  padding: 12px 16px 14px;
}

.coach-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  transition: none;
}

.coach-input-row:focus-within {
  border-color: transparent;
  box-shadow: none;
}

.coach-input {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  outline: none;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.01em;
  padding: 10px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.coach-input:focus {
  border-color: rgba(196,164,107,0.35);
  background: rgba(255,255,255,0.05);
}
.coach-input::placeholder { color: var(--text-muted); opacity: 0.45; }

.coach-send {
  width: 42px; height: 42px;
  background: var(--gold);
  border: none;
  border-radius: 11px;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
}
.coach-send:hover {
  background: #d4a84b;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(196,164,107,0.35);
}
.coach-send:disabled {
  background: rgba(196,164,107,0.16);
  color: rgba(196,164,107,0.3);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ══ OBSERVATIONS DRAWER ════════════════════════════ */

.coach-obs-section {
  /* border handled per breakpoint */
}

.coach-obs-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 20px 0;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-sans);
  transition: color 0.2s;
}
.coach-obs-toggle:hover,
.coach-obs-toggle--open { color: var(--text); }

.coach-obs-toggle-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-obs-toggle-icon {
  font-size: 13px;
  color: var(--gold);
  opacity: 0.6;
}

.coach-obs-toggle-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.coach-obs-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  background: rgba(196,164,107,0.12);
  border-radius: 10px;
  padding: 2px 8px;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.3s;
}
.coach-obs-count:not(:empty) { opacity: 1; }

.coach-obs-toggle-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.coach-obs-refresh {
  font-size: 15px;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
  padding: 4px;
  border-radius: 4px;
}
.coach-obs-refresh:hover { opacity: 1; color: var(--gold); }

.coach-obs-chevron {
  font-size: 16px;
  opacity: 0.4;
  transition: transform 0.3s ease, opacity 0.2s;
  display: inline-block;
  line-height: 1;
}
.coach-obs-toggle--open .coach-obs-chevron { opacity: 0.8; }

/* Drawer */
.coach-obs-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}
.coach-obs-body--open {
  grid-template-rows: 1fr;
}
.coach-obs-inner {
  overflow: hidden;
}

/* Observation cards */
.coach-obs-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
  gap: 0;
  padding: 18px 0;
  border-bottom: 1px solid rgba(255,255,255,0.035);
}
.coach-obs-card:last-child { border-bottom: none; padding-bottom: 28px; }

/* Staggered reveal when observations load */
@keyframes obsReveal {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.coach-obs-card {
  animation: obsReveal 0.35s ease both;
}
.coach-obs-card:nth-child(1) { animation-delay: 0.00s; }
.coach-obs-card:nth-child(2) { animation-delay: 0.09s; }
.coach-obs-card:nth-child(3) { animation-delay: 0.18s; }
.coach-obs-card:nth-child(4) { animation-delay: 0.27s; }
.coach-obs-card:nth-child(5) { animation-delay: 0.36s; }

.coach-obs-num {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
  opacity: 0.4;
  padding-top: 3px;
}
.coach-obs-text {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--stone);
}
.coach-obs-text strong { color: var(--text); font-weight: 600; }

.coach-obs-empty {
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
  padding: 20px 0 28px;
  letter-spacing: 0.03em;
}
.coach-obs-empty a { color: var(--gold); text-decoration: none; }

/* Typewriter cursor in greeting bubble */
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.coach-cursor {
  display: inline-block;
  width: 1.5px;
  height: 0.85em;
  background: var(--gold);
  margin-left: 1px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: cursorBlink 0.6s step-end infinite;
}
.coach-obs-retry-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 14px;
  background: var(--gold-dim);
  border: 1px solid var(--gold-line);
  border-radius: 6px;
  color: var(--gold);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}
.coach-obs-retry-btn:hover { background: rgba(196,164,107,0.2); }

/* Loading */
.coach-loading-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 24px 0;
}
.coach-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.2;
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.coach-dot:nth-child(2) { animation-delay: 0.2s; }
.coach-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Memory Panel ──────────────────────────────────── */
.coach-mem-section {
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  overflow: hidden;
  background: var(--navy-card);
}

.coach-mem-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-sans);
  transition: background 0.2s;
}
.coach-mem-toggle:hover,
.coach-mem-toggle--open { background: rgba(255,255,255,0.03); }

.coach-mem-toggle-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-mem-toggle-icon {
  font-size: 14px;
  color: rgba(196,164,107,0.6);
}

.coach-mem-toggle-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.coach-mem-count {
  font-size: 12px;
  background: rgba(196,164,107,0.15);
  color: var(--gold);
  border-radius: 10px;
  padding: 1px 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.coach-mem-chevron {
  font-size: 16px;
  color: var(--text-muted);
  opacity: 0.4;
  transition: transform 0.2s;
}

.coach-mem-body {
  display: none;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.coach-mem-body--open { display: block; }

.coach-mem-inner { padding: 0; }

.coach-mem-list {
  display: flex;
  flex-direction: column;
}

.coach-mem-row {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.coach-mem-row:last-child { border-bottom: none; }
.coach-mem-row:hover { background: rgba(255,255,255,0.02); }

.coach-mem-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.coach-mem-type {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
}
.mem-type-insight  { background: rgba(196,164,107,0.12); color: var(--gold); }
.mem-type-pattern  { background: rgba(109,186,133,0.12); color: #6dba85; }
.mem-type-milestone { background: rgba(147,112,219,0.12); color: #9370db; }
.mem-type-weekly   { background: rgba(100,149,237,0.12); color: #6495ed; }
.mem-type-chat     { background: rgba(110,128,153,0.12); color: #8ea4bc; }

.coach-mem-date {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.5;
  flex: 1;
  letter-spacing: 0.04em;
}

.coach-mem-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.15s;
  font-family: var(--font-sans);
}
.coach-mem-row:hover .coach-mem-delete { opacity: 0.4; }
.coach-mem-delete:hover { opacity: 1 !important; color: #c97070; background: rgba(201,112,112,0.1); }

.coach-mem-content {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
  letter-spacing: 0.02em;
}

.coach-mem-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.01);
}

.coach-mem-clear-btn {
  background: none;
  border: 1px solid rgba(201,112,112,0.25);
  border-radius: 5px;
  padding: 5px 12px;
  color: #c97070;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.7;
}
.coach-mem-clear-btn:hover { opacity: 1; background: rgba(201,112,112,0.08); }

.coach-mem-footer-note {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.4;
  letter-spacing: 0.04em;
}

.coach-mem-empty {
  padding: 20px 18px;
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0.6;
  font-style: italic;
  text-align: center;
  margin: 0;
}

/* ══ RESPONSIVE ══════════════════════════════════════ */

@media (max-width: 768px) {
  .coach-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .coach-obs-col {
    position: static;
    margin-top: 24px;
  }

  /* On mobile, show the accordion toggle and hide the desktop header */
  .coach-obs-panel-header { display: none; }
  .coach-obs-toggle--mobile {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 18px 0;
    cursor: pointer;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .coach-messages      { height: clamp(260px, 48vh, 400px); padding: 18px 16px 14px; }
  .coach-input-wrap    { padding: 10px 12px 12px; }
  .coach-bubble-text   { font-size: 15px; }
  .coach-user-bubble   { max-width: 88%; font-size: 15px; }

  /* Memory panel mobile */
  .coach-mem-section   { margin-top: 12px; }
  .coach-mem-toggle    { padding: 12px 14px; }
  .coach-mem-row       { padding: 10px 14px; }
  .coach-mem-footer    { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .coach-mem-footer-note { width: 100%; order: -1; }
  .coach-mem-delete    { opacity: 0.35; }
}
