/* DragonWriter — public stylesheet */
/* Uses Tailwind CDN for utilities; this file handles custom components */

/* ── Rating badges ───────────────────────────────────────────────────────── */

.story-tile { position: relative; }

.rating-badge {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  line-height: 1;
  cursor: default;
  user-select: none;
}

.rating-badge--large {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.7rem;
}

label .rating-badge { position: static; }

.rating-unstated { background: #94a3b8; }
.rating-general  { background: #059669; }
.rating-teens    { background: #2563eb; }
.rating-mature   { background: #ea580c; }
.rating-explicit { background: #dc2626; }

/* ── Prose / description box ─────────────────────────────────────────────── */

.prose-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.dark .prose-box {
  background: #1f2937;
  border-color: #374151;
}

/* ── Story page spacing ───────────────────────────────────────────────────── */

.story-title       { margin-bottom: 0.5rem; }
.story-meta-line   { margin-bottom: 0.75rem; }
.story-tags        { margin-top: 1rem; margin-bottom: 1rem; }
.story-chapters    { margin-top: 0; padding-top: 1rem; }
.story-chapter-label  { margin-bottom: 1rem; }
.story-chapter-select { margin-bottom: 2rem; }
.chapter-title     { margin-top: 1.5rem; margin-bottom: 1.25rem; }
.chapter-content   { margin-top: 1.5rem; max-width: none; }

/* ── Prose markdown content ──────────────────────────────────────────────── */

.prose {
  color: #334155;
  line-height: 1.75;
  max-width: 65ch;
}

.dark .prose { color: #cbd5e1; }

.prose p  { margin-bottom: 1em; }
.prose h1, .prose h2, .prose h3 { font-weight: 600; margin: 1.5em 0 0.75em; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }
.prose a  { color: #059669; text-decoration: underline; }
.prose em { font-style: italic; }
.prose strong { font-weight: 700; }
.prose ul { list-style: disc; padding-left: 1.5em; margin-bottom: 1em; }
.prose ol { list-style: decimal; padding-left: 1.5em; margin-bottom: 1em; }
.prose li { margin-bottom: 0.25em; }
.prose blockquote {
  border-left: 4px solid #e2e8f0;
  padding-left: 1em;
  color: #64748b;
  font-style: italic;
  margin: 1em 0;
}
.dark .prose blockquote { border-color: #374151; color: #94a3b8; }
.prose code {
  font-family: monospace;
  background: #f1f5f9;
  padding: 0.1em 0.3em;
  border-radius: 0.2em;
  font-size: 0.875em;
}
.dark .prose code { background: #1e293b; }
.prose pre { background: #1e293b; color: #e2e8f0; padding: 1em; border-radius: 0.5em; overflow-x: auto; margin-bottom: 1em; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 1px solid #e2e8f0; margin: 1.5rem 0; }
.dark .prose hr { border-color: #374151; }
.chapter-content { max-width: none; }
.prose-box .prose  { max-width: none; }
.chapter-content hr { border: 1px solid currentColor; margin: 1.5rem 0; }

/* ── Disclaimer overlay ───────────────────────────────────────────────────── */

.disclaimer-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  padding: 1.5rem;
}

.disclaimer-box {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 2rem;
  max-width: 36rem;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.dark .disclaimer-box { background: #1f2937; }

.disclaimer-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #1e293b;
}

.dark .disclaimer-title { color: #f1f5f9; }

.disclaimer-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #475569;
  margin-bottom: 1.5rem;
}

.dark .disclaimer-text { color: #94a3b8; }

.disclaimer-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 400px) {
  .disclaimer-buttons { flex-direction: row; justify-content: flex-end; }
}

.disclaimer-btn-back {
  padding: 0.5rem 1.25rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: transparent;
  color: #475569;
}

.dark .disclaimer-btn-back { border-color: #4b5563; color: #94a3b8; }
.disclaimer-btn-back:hover { background: #f1f5f9; }
.dark .disclaimer-btn-back:hover { background: #374151; }

.disclaimer-btn-continue {
  padding: 0.5rem 1.25rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: #059669;
  color: #ffffff;
}

.disclaimer-btn-continue:hover { background: #047857; }

/* ── Series navigation bar (fixed bottom) ────────────────────────────────── */

.story-series-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background-color: white;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

.dark .story-series-nav {
  background-color: #1f2937;
  border-top-color: #374151;
}

.story-series-nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.story-series-nav-prev,
.story-series-nav-next {
  flex: 1;
  color: #334155;
  display: flex;
  flex-direction: column;
}

.dark .story-series-nav-prev,
.dark .story-series-nav-next { color: #cbd5e1; }

.story-series-nav-next { align-items: flex-end; }

.story-series-nav-label {
  font-size: 0.75rem;
  color: #94a3b8;
}

.story-series-nav-title {
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}

.story-series-nav-center {
  flex: none;
  margin: 0 1rem;
  text-align: center;
}

.story-series-nav-series {
  font-size: 0.75rem;
  color: #64748b;
}

.dark .story-series-nav-series { color: #94a3b8; }
.story-series-nav a:hover { color: #059669; }
.story-series-nav-label--mobile { display: block; }
.story-series-nav-label--desktop { display: none; }

@media (min-width: 640px) {
  .story-series-nav-label--mobile { display: none; }
  .story-series-nav-label--desktop { display: block; }
  .story-series-nav-title { display: block; }
}

/* ── Correction floating button ──────────────────────────────────────────── */

.correction-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  z-index: 900;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: #059669;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: background 0.15s, transform 0.15s;
}

.correction-btn:hover { background: #047857; transform: scale(1.08); }
.correction-btn svg { width: 1.1rem; height: 1.1rem; }

.correction-btn-tooltip {
  position: absolute;
  right: 3.25rem;
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.correction-btn:hover .correction-btn-tooltip { opacity: 1; }

/* ── Correction modal ────────────────────────────────────────────────────── */

.correction-modal {
  display: none;
  position: fixed;
  right: 1.25rem;
  z-index: 9999;
  width: min(360px, calc(100vw - 2rem));
  background: #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  padding: 1.25rem 1.25rem 1rem;
}
.dark .correction-modal {
  background: #1e293b;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.correction-modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  font-family: inherit;
}
.correction-modal-close:hover { color: #0f172a; }
.dark .correction-modal-close { color: #94a3b8; }
.dark .correction-modal-close:hover { color: #f1f5f9; }

.correction-modal-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: #1e293b;
}
.dark .correction-modal-title { color: #f1f5f9; }

.correction-modal-sub {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0 0 0.75rem;
}
.dark .correction-modal-sub { color: #94a3b8; }

.correction-modal-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #1e293b;
  background: #ffffff;
}
.dark .correction-modal-textarea {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.correction-modal-textarea::placeholder { color: #94a3b8; }

.correction-modal-btn {
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.correction-modal-btn:hover { background: #059669; }

.correction-modal-error {
  display: none;
  font-size: 0.78rem;
  color: #dc2626;
  margin-top: 0.4rem;
}
.dark .correction-modal-error { color: #fca5a5; }

/* ── Filter panel ────────────────────────────────────────────────────────── */

.filter-sections { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 0.75rem; }
.filter-option-list { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }

/* ── Author avatar ────────────────────────────────────────────────────────── */

.author-avatar {
  width: 8rem;
  height: 8rem;
  min-width: 8rem;
  border-radius: 0.5rem;
  object-fit: cover;
  object-position: center;
  margin-right: 1.25rem;
}

/* ── Like button ─────────────────────────────────────────────────────────── */

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  border: 2px solid #e2e8f0;
  background: transparent;
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.like-btn:hover { border-color: #dc2626; color: #dc2626; }
.like-btn.liked { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.dark .like-btn { border-color: #374151; color: #94a3b8; }
.dark .like-btn:hover { border-color: #dc2626; color: #fca5a5; }
.dark .like-btn.liked { background: #450a0a; border-color: #dc2626; color: #fca5a5; }

/* ── Comments ───────────────────────────────────────────────────────────── */

.comment {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #ffffff;
}

.dark .comment { background: #1f2937; border-color: #374151; }

.comment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.comment-author { font-weight: 600; color: #1e293b; }
.dark .comment-author { color: #f1f5f9; }
.comment-date { color: #94a3b8; font-size: 0.75rem; }
.comment-body { color: #475569; font-size: 0.9rem; line-height: 1.6; }
.dark .comment-body { color: #94a3b8; }

.comment-reply { margin-left: 2rem; border-left: 2px solid #059669; padding-left: 1rem; }

.comment-admin-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #059669;
  color: #fff;
  border-radius: 9999px;
  padding: 0.1rem 0.4rem;
  margin-right: 0.25rem;
}

.reply-form {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
}
.dark .reply-form { background: #111827; border-color: #374151; }

.comment-form textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 6rem;
  background: #ffffff;
  color: #334155;
}

.dark .comment-form textarea { background: #1f2937; border-color: #374151; color: #e2e8f0; }

/* ── Docs ─────────────────────────────────────────────────────────────────── */

.docs-topic-heading {
  font-size: 24px;
  font-weight: 400;
  line-height: 1.43;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px)  { .docs-topic-heading { font-size: 28px; } }
@media (min-width: 1280px) { .docs-topic-heading { font-size: 33px; } }

/* ── Admin panel ──────────────────────────────────────────────────────────── */

.admin-nav {
  background: #1e293b;
  color: #e2e8f0;
  min-height: 100vh;
  width: 14rem;
  flex-shrink: 0;
  padding: 1rem 0;
}

@media (max-width: 767px) {
  .admin-nav { width: 100%; min-height: auto; }
}

.admin-nav a {
  display: block;
  padding: 0.6rem 1.25rem;
  color: #94a3b8;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.admin-nav a:hover { color: #f1f5f9; background: #334155; }
.admin-nav a.active { color: #34d399; background: #1f2937; border-left: 3px solid #34d399; }
.admin-nav-heading {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 0.75rem 1.25rem 0.25rem;
  margin-top: 0.5rem;
}

.admin-content { flex: 1; padding: 1.5rem; max-width: 960px; }

.admin-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  color: #e2e8f0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid #e2e8f0;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}

.admin-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ── Admin markdown editor ────────────────────────────────────────────────── */

.md-editor-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: stretch;
}

.md-input-pane {
  display: flex;
  flex-direction: column;
  max-height: 65vh;
}

.md-input-pane .form-textarea {
  flex: 1;
  resize: vertical;
  overflow-y: auto;
}

@media (max-width: 767px) {
  .md-editor-wrap { grid-template-columns: 1fr; }
  .md-preview-pane { display: none; }
  .md-preview-pane.active { display: block; }
  .md-input-pane.hidden { display: none; }
}

.md-preview-pane {
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  overflow-y: auto;
  min-height: 300px;
  max-height: 65vh;
  background: #fafafa;
}

.dark .md-preview-pane { background: #0f172a; border-color: #334155; color: #e2e8f0; }

/* ── Admin dark mode ────────────────────────────────────────────────────── */

/* Table */
.dark .admin-table th { color: #94a3b8; border-color: #334155; }
.dark .admin-table td { color: #e2e8f0; border-color: #334155; }
.dark .admin-table tr:hover td { background: #334155; }

/* Tailwind slate text overrides inside dark cards */
.dark .admin-card .text-slate-400,
.dark .admin-card .text-slate-500 { color: #94a3b8; }
.dark .admin-card .text-slate-600,
.dark .admin-card .text-slate-700,
.dark .admin-card .text-slate-800 { color: #cbd5e1; }
.dark .admin-card h2 { color: #e2e8f0; }

/* Borders inside dark cards */
.dark .admin-card .border-slate-200,
.dark .admin-card .border-slate-300 { border-color: #475569; }

/* Form labels */
.dark .form-label { color: #94a3b8; }

/* Form inputs */
.dark .form-input, .dark .form-select, .dark .form-textarea {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}
.dark .form-input:focus, .dark .form-select:focus, .dark .form-textarea:focus {
  border-color: #059669;
}
.dark .form-input::placeholder, .dark .form-textarea::placeholder { color: #64748b; }

/* Buttons */
.dark .btn-secondary { background: #334155; color: #cbd5e1; border-color: #475569; }
.dark .btn-secondary:hover { background: #475569; }

/* Badges */
.dark .badge-green  { background: #064e3b; color: #6ee7b7; }
.dark .badge-yellow { background: #78350f; color: #fcd34d; }
.dark .badge-red    { background: #7f1d1d; color: #fca5a5; }
.dark .badge-gray   { background: #334155; color: #94a3b8; }

/* ── Form controls shared ────────────────────────────────────────────────── */

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.35rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: #ffffff;
  color: #1e293b;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5,150,105,0.15);
}

.form-textarea { resize: vertical; min-height: 8rem; font-family: monospace; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn-primary   { background: #059669; color: #ffffff; }
.btn-primary:hover { background: #047857; }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger    { background: #dc2626; color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.75rem; }

/* ── Reader dashboard ────────────────────────────────────────────────────── */

.reader-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin: 1.5rem 0 0.75rem;
}

.dark .reader-section-title { color: #f1f5f9; }

/* ── Searchable filter widget (fss) ──────────────────────────────────────── */

.fss-widget { position: relative; }

.fss-input {
  width: 100%;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  background: #ffffff;
  color: #1e293b;
  outline: none;
  box-sizing: border-box;
}
.fss-input:focus { border-color: #059669; box-shadow: 0 0 0 1px #059669; }
.dark .fss-input { background: #1e293b; border-color: #475569; color: #e2e8f0; }
.dark .fss-input:focus { border-color: #059669; box-shadow: 0 0 0 1px #059669; }
.fss-input::placeholder { color: #94a3b8; }

.fss-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  background: #ffffff;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  margin-top: 2px;
}
.dark .fss-dropdown { background: #1e293b; border-color: #475569; }

.fss-option {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  color: #1e293b;
  cursor: pointer;
}
.fss-option:hover { background: #f0fdf4; color: #059669; }
.dark .fss-option { color: #e2e8f0; }
.dark .fss-option:hover { background: #134e4a; color: #6ee7b7; }

.fss-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.fss-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 9999px;
  font-size: 0.75rem;
  background: #d1fae5;
  color: #065f46;
  white-space: nowrap;
}
.dark .fss-chip { background: #064e3b; color: #6ee7b7; }

.fss-chip-x {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1;
  color: #059669;
  cursor: pointer;
  opacity: 0.7;
}
.fss-chip-x:hover { opacity: 1; }
