/* Custom styles layered on top of Tailwind (CDN). */
:root { color-scheme: light; }
.dark { color-scheme: dark; }

html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body { overscroll-behavior-y: none; }

.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* LTR islands inside RTL text */
[dir="ltr"] { unicode-bidi: isolate; }
.ltr { direction: ltr; text-align: left; unicode-bidi: isolate; }

/* Inline code */
.ic {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.4em;
  border-radius: 0.375rem;
  background: rgb(99 102 241 / 0.10);
  color: rgb(67 56 202);
  white-space: break-spaces;
  word-break: break-word;
}
.dark .ic { background: rgb(129 140 248 / 0.14); color: rgb(165 180 252); }

/* Prose generated from lesson markup */
.prose-he { line-height: 1.8; font-size: 1rem; }
.prose-he p { margin: 0 0 0.85em; }
.prose-he p:last-child { margin-bottom: 0; }
.prose-he ul { margin: 0 0 0.85em; padding-inline-start: 1.25rem; list-style: disc; }
.prose-he li { margin: 0.3em 0; }
.prose-he li::marker { color: rgb(99 102 241); }
.prose-he strong { font-weight: 700; }
.dark .prose-he strong { color: #fff; }

/* Code blocks */
.codeblock {
  direction: ltr;
  text-align: left;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
  margin: 0;
  padding: 0.9rem 1rem;
}

/* Accordions */
details.acc > summary { list-style: none; cursor: pointer; user-select: none; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary .chev { transition: transform 0.2s ease; }
details.acc[open] > summary .chev { transform: rotate(-90deg); }
details.acc[open] > .acc-body { animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.25s ease; }

/* Buttons */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; font-size: 1.1rem;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgb(0 0 0 / 0.06); }
.dark .icon-btn:hover { background: rgb(255 255 255 / 0.08); }

.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
  padding: 0.4rem 0.85rem; border-radius: 999px; font-size: 0.85rem; font-weight: 500;
  border: 1px solid rgb(228 228 231); background: #fff; color: rgb(63 63 70);
  transition: all 0.15s;
}
.dark .chip { border-color: rgb(39 39 42); background: rgb(24 24 27); color: rgb(212 212 216); }
.chip[aria-pressed="true"] { background: rgb(79 70 229); border-color: rgb(79 70 229); color: #fff; }

.scroll-x { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { display: none; }

/* Progress bars */
.bar { height: 0.5rem; border-radius: 999px; background: rgb(228 228 231); overflow: hidden; }
.dark .bar { background: rgb(39 39 42); }
.bar > span { display: block; height: 100%; border-radius: inherit; transition: width 0.5s ease; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translate(-50%, 1rem);
  background: rgb(24 24 27); color: #fff; padding: 0.6rem 1.1rem; border-radius: 0.75rem;
  font-size: 0.9rem; width: max-content; max-width: calc(100vw - 2rem); text-align: center; opacity: 0; pointer-events: none; transition: all 0.2s ease; z-index: 50;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.dark .toast { background: rgb(244 244 245); color: rgb(24 24 27); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 768px) { .toast { bottom: 2rem; } }

/* Bottom nav active state */
.bn-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.7rem; color: rgb(113 113 122); }
.bn-item .bn-ico { font-size: 1.3rem; line-height: 1; transition: transform 0.15s; }
.bn-item.active { color: rgb(79 70 229); font-weight: 600; }
.dark .bn-item.active { color: rgb(165 180 252); }
.bn-item.active .bn-ico { transform: translateY(-2px) scale(1.1); }

.tn-item { padding: 0.4rem 0.8rem; border-radius: 0.6rem; font-size: 0.9rem; color: rgb(82 82 91); }
.dark .tn-item { color: rgb(161 161 170); }
.tn-item:hover { background: rgb(0 0 0 / 0.05); }
.dark .tn-item:hover { background: rgb(255 255 255 / 0.06); }
.tn-item.active { color: rgb(79 70 229); background: rgb(99 102 241 / 0.1); font-weight: 600; }
.dark .tn-item.active { color: rgb(165 180 252); }

/* Big custom checkbox */
.check { appearance: none; -webkit-appearance: none; width: 1.6rem; height: 1.6rem; border-radius: 0.5rem;
  border: 2px solid rgb(161 161 170); display: inline-grid; place-content: center; flex-shrink: 0; cursor: pointer; transition: all .15s; }
.check:checked { background: rgb(16 185 129); border-color: rgb(16 185 129); }
.check:checked::after { content: '✓'; color: #fff; font-weight: 800; font-size: 1rem; line-height: 1; }

textarea, input, select { font-size: 16px; } /* prevent iOS zoom */

mark { background: rgb(250 204 21 / 0.4); color: inherit; border-radius: 3px; padding: 0 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
