/* /learn — layout, sidebar, lesson components, chat, notes */

/* scroll: global smooth removed from zealphp.css; htmx show: is now instant */

.learn-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 2.5rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 900px) {
  .learn-layout { grid-template-columns: 1fr; padding: 1rem; }
}

/* Sidebar */
.learn-sidebar-toggle-input { display: none; }
.learn-sidebar-toggle-btn {
  display: none; padding: .5rem .8rem; border: 1px solid #d6d3d1; border-radius: 6px;
  font-size: .85rem; cursor: pointer; background: #fff; margin-bottom: .75rem;
}
@media (max-width: 900px) { .learn-sidebar-toggle-btn { display: inline-block; } }

.learn-sidebar { position: sticky; top: 1.5rem; align-self: start; max-height: calc(100vh - 3rem); overflow-y: auto; }
@media (max-width: 900px) {
  .learn-sidebar { display: none; position: static; }
  .learn-sidebar-toggle-input:checked ~ .learn-sidebar { display: block; }
}
.learn-sidebar-inner { padding-right: .5rem; }
.learn-sidebar-group + .learn-sidebar-group { margin-top: 1.25rem; }
.learn-sidebar-group-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #78716c; margin: 0 0 .55rem; font-weight: 700; }
.learn-sidebar-list { list-style: decimal; padding-left: 2.25rem; margin: 0; }
.learn-sidebar-list li { margin: .25rem 0; font-size: .88rem; }
.learn-sidebar-list li a { color: #1c1917; text-decoration: none; display: block; padding: .15rem .3rem; border-radius: 4px; }
.learn-sidebar-list li a:hover { background: #f5f5f4; }
.learn-sidebar-list li.active a { color: var(--accent, #f59e0b); font-weight: 600; background: #fffbeb; }

/* Lesson header */
.lesson-header { margin-bottom: 2rem; }
.lesson-crumb { font-size: .78rem; color: #78716c; margin-bottom: .35rem; }
.lesson-crumb a { color: var(--accent, #f59e0b); text-decoration: none; }
.lesson-title { font-size: 2.25rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin: 0 0 .25rem; }
.lesson-subtitle { color: #57534e; font-size: 1.05rem; margin: 0 0 1rem; }
.lesson-chips { display: flex; gap: .6rem; margin-top: .75rem; }
.lesson-chip { display: inline-block; padding: .35rem .8rem; border: 1px solid #e7e5e4; border-radius: 999px; font-size: .82rem; color: #44403c; text-decoration: none; background: #fff; transition: border-color .15s, color .15s; }
.lesson-chip:hover { border-color: var(--accent, #f59e0b); color: var(--accent, #f59e0b); text-decoration: none; }
.lesson-chip-next { margin-left: auto; }

/* You will learn */
.youwilllearn { background: #fffbeb; border-left: 4px solid var(--accent, #f59e0b); padding: 1rem 1.2rem; border-radius: 0 6px 6px 0; margin: 1.25rem 0; }
.youwilllearn h3 { margin: 0 0 .5rem; font-size: .92rem; text-transform: uppercase; letter-spacing: .05em; color: #92400e; }
.youwilllearn ul { margin: 0; padding-left: 1.25rem; }
.youwilllearn li { margin: .25rem 0; font-size: .92rem; }

/* Callout */
.callout { margin: 1rem 0; padding: .9rem 1.1rem; border-radius: 6px; border-left: 4px solid #e7e5e4; background: #fafaf9; font-size: .92rem; }
.callout-info { border-left-color: #2563eb; background: #eff6ff; }
.callout-warn { border-left-color: #d97706; background: #fffbeb; }
.callout-success { border-left-color: #059669; background: #ecfdf5; }
.callout-deep { border-left-color: #7c3aed; background: #f5f3ff; }
.callout-head { font-weight: 600; margin-bottom: .35rem; }
.callout-icon { margin-right: .3rem; }

/* Deep dive */
.deepdive { margin: 1.25rem 0; border: 1px solid #e7e5e4; border-radius: 6px; padding: .75rem 1rem; background: #fff; }
.deepdive summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: #44403c; user-select: none; }
.deepdive[open] summary { margin-bottom: .65rem; }
.deepdive-icon { margin-right: .35rem; }

/* Try it */
.tryit { margin: 1.25rem 0; border: 2px solid var(--accent, #f59e0b); border-radius: 8px; overflow: hidden; }
.tryit-head { padding: .55rem .9rem; background: #fffbeb; font-weight: 600; font-size: .88rem; color: #92400e; border-bottom: 1px solid #fde68a; }
.tryit-icon { margin-right: .35rem; }
.tryit-body { padding: 1rem; }

/* Lesson body */
.lesson-content { min-width: 0; }
.lesson-content h2 { margin-top: 2.25rem; margin-left: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.lesson-content h3 { margin-top: 1.5rem; margin-left: 0; font-size: 1.15rem; font-weight: 700; }
.lesson-content p { line-height: 1.65; color: #292524; }
.lesson-content ol, .lesson-content ul { padding-left: 1.5rem; margin: 0.75rem 0; }
.lesson-content ol li, .lesson-content ul li { padding-left: 0.25rem; }
.lesson-content code { background: #f5f5f4; padding: .1rem .35rem; border-radius: 3px; font-size: .92em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.lesson-content pre { background: #1c1917; color: #f5f5f4; padding: 1rem; border-radius: 6px; overflow-x: auto; font-size: .85rem; }
.lesson-content pre code { background: transparent; padding: 0; color: inherit; }
.lesson-content pre.mermaid { background: #fff; color: #1c1917; border: 1px solid #e7e5e4; padding: 1.5rem 1rem; text-align: center; cursor: zoom-in; position: relative; }
.lesson-content pre.mermaid:hover { border-color: #f59e0b; }
.lesson-content pre.mermaid::after { content: "Click to expand"; position: absolute; top: .5rem; right: .65rem; font-size: .65rem; color: #a8a29e; background: #fff; padding: .1rem .4rem; border-radius: 3px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.lesson-content pre.mermaid:hover::after { opacity: 1; }

/* Mermaid pop-out viewer */
.mermaid-viewer { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.85); cursor: grab; overflow: hidden; }
.mermaid-viewer:active { cursor: grabbing; }
.mermaid-viewer-inner { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.mermaid-viewer-inner svg { max-width: none !important; max-height: none !important; filter: drop-shadow(0 4px 24px rgba(0,0,0,.3)); }
.mermaid-viewer-close { position: fixed; top: 1rem; right: 1.5rem; z-index: 10000; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); color: #fff; width: 2.5rem; height: 2.5rem; border-radius: 50%; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.mermaid-viewer-close:hover { background: rgba(255,255,255,.3); }
.mermaid-viewer-hint { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 10000; color: rgba(255,255,255,.6); font-size: .75rem; pointer-events: none; }

/* Notes user bar */
.notes-user-bar {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem; margin-bottom: 1rem;
  background: #fafaf9; border: 1px solid #e7e5e4; border-radius: 8px;
}
.notes-user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent, #f59e0b); color: #fff; font-weight: 700; font-size: .85rem;
}
.notes-user-name { font-weight: 600; font-size: .92rem; color: #1c1917; }
.notes-user-logout { margin-left: auto; font-size: .78rem; color: #78716c; text-decoration: none; }
.notes-user-logout:hover { color: #b91c1c; }

/* Notes app */
.notes-app { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.notes-list { display: flex; flex-direction: column; gap: .75rem; }
.note { border: 1px solid #e7e5e4; border-radius: 6px; padding: .85rem 1rem; background: #fff; }
.note-title { margin: 0 0 .35rem; font-size: 1rem; font-weight: 600; }
.note-body { margin: 0; color: #44403c; font-size: .92rem; white-space: pre-wrap; }
.note-meta { font-size: .72rem; color: #78716c; margin-top: .5rem; display: flex; gap: .5rem; align-items: center; }
.note-meta button { background: transparent; border: 1px solid #e7e5e4; color: #b91c1c; padding: .15rem .55rem; border-radius: 4px; font-size: .72rem; cursor: pointer; }
.note-meta button:hover { background: #fef2f2; border-color: #fecaca; }

.note-form { display: grid; gap: .55rem; margin: 0 0 1rem; }
.note-form input, .note-form textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid #d6d3d1; border-radius: 6px; background: #fff;
}
.note-form textarea { min-height: 80px; resize: vertical; }
.note-form button { padding: .55rem 1rem; border: 0; border-radius: 6px; background: var(--accent, #f59e0b); color: #fff; font-weight: 600; cursor: pointer; }

/* Note card animations */
.note-created {
  animation: noteFlashIn .5s ease-out;
  border-color: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, .25);
}
.note-updated {
  animation: noteFlash 3s ease-out;
}
.note-deleting {
  animation: noteFadeOut .35s ease-in forwards;
}
@keyframes noteFlashIn {
  0% { opacity: 0; transform: translateY(-8px); border-color: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, .3); }
  40% { opacity: 1; transform: translateY(0); }
  100% { border-color: #34d399; box-shadow: 0 0 0 2px rgba(52, 211, 153, .25); }
}
@keyframes noteFlash {
  0% { border-color: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, .35); }
  60% { border-color: #34d399; box-shadow: 0 0 0 2px rgba(52, 211, 153, .2); }
  100% { border-color: #e7e5e4; box-shadow: none; }
}
@keyframes noteFadeOut {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.96); max-height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* Auth */
.auth-card { max-width: 420px; margin: 1.5rem 0; padding: 1.5rem; border: 1px solid #e7e5e4; border-radius: 8px; background: #fff; }
.auth-card h2 { margin: 0 0 .25rem; font-size: 1.25rem; }
.auth-card p { color: #78716c; margin: 0 0 1rem; font-size: .9rem; }
.auth-card form { display: grid; gap: .55rem; }
.auth-card input { padding: .55rem .7rem; border: 1px solid #d6d3d1; border-radius: 6px; font: inherit; }
.auth-card button { padding: .55rem 1rem; border: 0; border-radius: 6px; background: var(--accent, #f59e0b); color: #fff; font-weight: 600; cursor: pointer; }
.auth-card .auth-toggle { background: transparent; color: var(--accent, #f59e0b); border: 1px solid var(--accent, #f59e0b); }
.auth-error { color: #b91c1c; font-size: .85rem; margin-top: .5rem; }

/* Chat */
/* Chat widget — two-column: notes left, chat right */
.chat { display: grid; grid-template-columns: 40% 1fr; gap: 1rem; align-items: stretch; }
@media (max-width: 760px) { .chat { grid-template-columns: 1fr; } }

/* The chat box: flex column, viewport-aware height */
.chat-box {
  border: 1px solid #e7e5e4; border-radius: 10px; background: #fff;
  display: flex; flex-direction: column;
  height: clamp(400px, 60vh, 700px);
}

/* Header bar */
.chat-head {
  padding: .6rem 1rem; border-bottom: 1px solid #e7e5e4;
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; font-weight: 600; color: #44403c;
  flex-shrink: 0;
}
.chat-mode { font-size: .68rem; padding: .15rem .55rem; border-radius: 999px; background: #f5f5f4; color: #78716c; font-weight: 500; }
.chat-new { margin-left: auto; font-size: .72rem; padding: .2rem .6rem; border: 1px solid #d6d3d1; background: #fff; border-radius: 4px; cursor: pointer; }
.chat-new:hover { background: #f5f5f4; }

/* Single scrollable conversation stream */
.chat-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: .75rem 1rem;
  display: flex; flex-direction: column; gap: .6rem;
}
.chat-history, .chat-messages { display: flex; flex-direction: column; gap: .6rem; }
.learn-layout .chat-messages { min-height: 0; max-height: none; overflow-y: visible; padding: 0; }
.chat-history:empty { display: none; }
.chat-history:not(:empty) { border-bottom: 1px dashed #d6d3d1; padding-bottom: .6rem; }

/* Bubbles */
.chat-msg { max-width: 85%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-bubble { padding: .6rem .85rem; border-radius: 14px; font-size: .9rem; line-height: 1.55; }
.chat-msg.user .chat-bubble { background: var(--accent, #f59e0b); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: #f5f5f4; color: #1c1917; border-bottom-left-radius: 4px; }
.chat-item { margin: .35rem 0; }
.chat-item.text p { margin: .25rem 0; }
.chat-item.tool { border: 1px solid #e7e5e4; border-radius: 6px; padding: .55rem .7rem; background: #fff; font-size: .82rem; }
.chat-item.tool[data-status="running"] .tool-status::before { content: "…"; animation: chat-pulse 1.2s infinite; }
.chat-item.tool[data-status="ok"] { border-color: #bbf7d0; background: #f0fdf4; }
.chat-item.tool[data-status="error"] { border-color: #fecaca; background: #fef2f2; }
.tool-head { display: flex; align-items: center; gap: .5rem; }
.tool-name { font-family: ui-monospace, monospace; font-weight: 600; }
.tool-status { margin-left: auto; font-size: .7rem; color: #78716c; }
.tool-detail { margin-top: .4rem; }
.tool-detail summary { cursor: pointer; font-size: .72rem; color: #57534e; }
.tool-args, .tool-result { margin: .35rem 0 0; padding: .35rem .55rem; background: #fafaf9; border-radius: 4px; font-size: .72rem; white-space: pre-wrap; word-break: break-all; }

@keyframes chat-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Typing indicator — three bouncing dots */
.chat-typing { display: flex; gap: 4px; padding: .25rem 0; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: #a8a29e; animation: chat-bounce .6s infinite alternate; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-bounce { from { transform: translateY(0); } to { transform: translateY(-5px); } }

.chat-form { display: flex; gap: .5rem; padding: .65rem; border-top: 1px solid #f5f5f4; }
.chat-form input { flex: 1; padding: .55rem .7rem; border: 1px solid #d6d3d1; border-radius: 6px; font: inherit; }
.chat-form button { padding: .55rem 1rem; border: 0; border-radius: 6px; background: var(--accent, #f59e0b); color: #fff; font-weight: 600; cursor: pointer; }
.chat-form button:disabled { opacity: .5; cursor: not-allowed; }

/* Render-method demos */
.render-demo { margin: .75rem 0; padding: .8rem 1rem; background: #fafaf9; border-radius: 6px; border: 1px solid #e7e5e4; }
.render-demo h4 { margin: 0 0 .55rem; font-size: .85rem; }
.render-demo-row { display: flex; gap: .75rem; padding: .4rem .6rem; background: #fff; border-radius: 4px; margin: .35rem 0; font-family: ui-monospace, monospace; font-size: .8rem; align-items: center; }
.render-demo-row strong { font-family: inherit; }
.render-demo-row time { color: #78716c; }

/* Counter button (Lesson 7 try it) */
.counter-btn { padding: .55rem 1rem; border: 1px solid var(--accent, #f59e0b); background: #fff; color: var(--accent, #f59e0b); border-radius: 6px; font-weight: 600; cursor: pointer; font-size: .92rem; }
.counter-btn:hover { background: #fffbeb; }
.counter-btn strong { color: #1c1917; font-size: 1.1em; }

/* Empty states */
.notes-empty, .chat-empty { color: #78716c; font-style: italic; font-size: .9rem; }

/* CTA button */
.lesson-cta { margin: 2rem 0; text-align: center; }
.btn-cta, .btn-cta:link, .btn-cta:visited { display: inline-block; padding: .75rem 1.5rem; background: var(--accent, #f59e0b); color: #fff; border-radius: 8px; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.btn-cta:hover, .btn-cta:focus { filter: brightness(1.1); text-decoration: none; color: #fff; }

/* Concept check — inline quiz */
.concept-check {
  margin: 1.5rem 0; padding: 1.2rem 1.4rem;
  border: 2px solid #c7d2fe; border-radius: 10px; background: #eef2ff;
}
.concept-check-q {
  font-weight: 700; font-size: 1.05rem; margin: 0 0 .85rem; color: #1e1b4b;
  line-height: 1.5;
}
.concept-check-q::before { content: "Quiz: "; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #6366f1; display: block; margin-bottom: .25rem; font-weight: 600; }
.concept-check-form { display: flex; flex-direction: column; gap: .5rem; counter-reset: opt-counter; }
.concept-check-opt {
  text-align: left; padding: .7rem 1rem .7rem .75rem; border: 2px solid #e0e7ff; border-radius: 8px;
  background: #fff; font: inherit; font-size: .9rem; cursor: pointer; color: #334155;
  transition: border-color .15s, background .15s, box-shadow .15s;
  display: flex; align-items: center; gap: .6rem; line-height: 1.4;
}
.concept-check-opt::before {
  content: counter(opt-counter, upper-alpha); counter-increment: opt-counter;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.65rem; height: 1.65rem; flex-shrink: 0;
  border-radius: 50%; background: #e0e7ff; color: #4338ca;
  font-weight: 700; font-size: .78rem;
}
.concept-check-opt:hover {
  border-color: #818cf8; background: #eef2ff; box-shadow: 0 1px 4px rgba(99,102,241,.15);
}
.concept-check-opt:hover::before { background: #818cf8; color: #fff; }
.concept-check-opt:active { transform: scale(.99); }

/* Event log terminal */
.event-log-wrap { margin-top: 1rem; }
.event-log-title {
  margin: 0 0 .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: #78716c; font-weight: 700;
}
.event-log {
  padding: .6rem .75rem; min-height: 60px; max-height: 150px; overflow-y: auto;
  background: #1c1917; color: #d4d4d8; border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .7rem; line-height: 1.7;
}
.event-log:empty::after { content: "Send a message to see events flow\2026"; color: #52525b; font-style: italic; }
.event-log-line { white-space: nowrap; }
.event-log-time { color: #71717a; }
.event-log-tag {
  display: inline-block; padding: 0 .35rem; border-radius: 3px;
  font-size: .62rem; font-weight: 700; letter-spacing: .04em; vertical-align: middle;
}
.event-log-tag-sse { background: #3b82f6; color: #fff; }
.event-log-tag-ws { background: #a855f7; color: #fff; }
.event-log-event { color: #e5e7eb; font-weight: 600; }
.event-log-detail { color: #a1a1aa; }

/* Before / After toggle */
.before-after { margin: 1.25rem 0; border: 1px solid #e7e5e4; border-radius: 8px; overflow: hidden; }
.ba-tabs { display: flex; border-bottom: 1px solid #e7e5e4; background: #fafaf9; }
.ba-tab {
  flex: 1; padding: .55rem 1rem; border: none; background: transparent;
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; color: #78716c;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.ba-tab.active { color: var(--accent, #f59e0b); border-bottom-color: var(--accent, #f59e0b); background: #fff; }
.ba-tab:hover:not(.active) { color: #44403c; }
.ba-panel { padding: 1rem; }
.ba-panel.hidden { display: none; }

/* Key takeaways */
.key-takeaways { margin: 2rem 0 1.5rem; padding: 1rem 1.2rem; border-left: 4px solid #059669; background: #ecfdf5; border-radius: 0 6px 6px 0; }
.key-takeaways h3 { margin: 0 0 .5rem; font-size: .92rem; text-transform: uppercase; letter-spacing: .05em; color: #065f46; }
.key-takeaways ul { margin: 0; padding-left: 1.25rem; }
.key-takeaways li { margin: .25rem 0; font-size: .92rem; color: #064e3b; }

/* Challenge */
.challenge { margin: 1.5rem 0; padding: 1.1rem 1.2rem; border: 2px dashed #d97706; border-radius: 8px; background: #fffbeb; }
.challenge h3 { margin: 0 0 .5rem; font-size: 1rem; color: #92400e; }
.challenge-body { font-size: .92rem; color: #451a03; }
.challenge-body p { margin: .35rem 0; }
.challenge-hint { margin-top: .65rem; }
.challenge-hint summary { cursor: pointer; font-size: .85rem; color: #78716c; font-weight: 500; }
.challenge-hint p { margin: .35rem 0 0; font-size: .85rem; color: #57534e; }
