/* =========================
   Note Viewer — Dark Theme
   Cleaned + merged for index + detail pages
========================= */

/* Uses your main theme variables from styles.css (fallbacks included) */
:root{
  --nv-bg: var(--bg, #0b1118);
  --nv-panel: var(--bg-2, #0c131b);
  --nv-border: var(--border, rgba(255,255,255,0.08));
  --nv-border-2: var(--border-2, rgba(255,255,255,0.12));
  --nv-text: var(--text, rgba(255,255,255,0.88));
  --nv-muted: var(--muted, rgba(255,255,255,0.62));
  --nv-faint: var(--faint, rgba(255,255,255,0.45));
  --nv-accent: var(--accent, #22c1ff);
}

/* =========================
   Shared outer wrappers
========================= */

/* Old detail template layout support */
.layout{
  display:grid;
  grid-template-columns:280px minmax(0,1fr);
  gap:24px;
  align-items:start;
  width:min(1400px, calc(100% - 48px));
  margin:24px auto;
}

/* New landing/index template layout support */
.noteviewer-layout{
  display:grid;
  grid-template-columns:300px minmax(0,1fr);
  gap:24px;
  width:min(1400px, calc(100% - 48px));
  margin:24px auto;
  align-items:start;
}

/* =========================
   Sidebar
========================= */

/* Old detail template sidebar */
.sidebar{
  position:sticky;
  top:88px;
  max-height:calc(100vh - 100px);
  overflow:auto;
  padding:16px;
  border:1px solid rgba(255,255,255,0.08);
  border-radius:16px;
  background:rgba(255,255,255,0.02);
}

/* New landing/index template sidebar */
.noteviewer-sidebar{
  position:sticky;
  top:88px;
  align-self:start;
}

.noteviewer-sidebar-inner{
  max-height:calc(100vh - 100px);
  overflow:auto;
  padding:20px;
  border:1px solid rgba(255,255,255,0.08);
  border-radius:18px;
  background:rgba(255,255,255,0.02);
}

.sidebar-title{
  margin:0 0 16px;
  font-size:1.2rem;
  color:rgba(255,255,255,0.92);
}

/* =========================
   Main content wrappers
========================= */

.note-main,
.noteviewer-main{
  min-width:0;
}

.noteviewer-main-inner{
  padding:28px;
  border-radius:18px;
  background:rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.08);
  box-shadow:0 14px 35px rgba(0,0,0,0.35);
  overflow: hidden;
}

.noteviewer-header{
  margin-bottom:24px;
}

.noteviewer-header h1{
  margin:0 0 10px;
  color:rgba(255,255,255,0.92);
}

.noteviewer-meta{
  color:rgba(255,255,255,0.65);
  font-size:0.95rem;
  line-height:1.5;
}

.noteviewer-body{
  line-height:1.7;
  color:var(--nv-text);
}

/* =========================
   Breadcrumbs
========================= */

.breadcrumbs{
  margin-bottom:18px;
  font-size:0.92rem;
  line-height:1.6;
}

.breadcrumbs a{
  color:var(--nv-accent);
  text-decoration:none;
}

.breadcrumbs a:hover{
  color:#8fe6ff;
  text-decoration:underline;
}

.breadcrumbs span{
  color:var(--nv-muted);
}

.breadcrumb-sep{
  margin:0 6px;
  color:rgba(255,255,255,0.45);
}

/* =========================
   Main readable notes styling
========================= */

/* old detail pages may still use .note-body directly */
.note-body {
  width: min(950px, calc(100% - 48px));
  margin: 24px auto;
  padding: 22px 22px;

  line-height: 1.75;
  font-size: 16px;

  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.02));
  border: 1px solid var(--nv-border);
  border-radius: 18px;
  box-shadow: 0 14px 35px rgba(0,0,0,0.35);

  color: var(--nv-text);
}

/* new landing/index template often renders html inside .noteviewer-body,
   so style both .note-body and content inside .noteviewer-body */
.note-body,
.noteviewer-body{
  font-size:16px;
}

.note-body h1,
.note-body h2,
.note-body h3,
.noteviewer-body h1,
.noteviewer-body h2,
.noteviewer-body h3 {
  color: rgba(255,255,255,0.92);
  letter-spacing: 0.2px;
}

.note-body h1,
.noteviewer-body h1 {
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 14px 0;
}

.note-body h2,
.noteviewer-body h2 {
  font-size: 24px;
  margin: 28px 0 10px 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.note-body h3,
.noteviewer-body h3 {
  font-size: 18px;
  margin: 18px 0 8px 0;
  color: rgba(255,255,255,0.88);
}

.note-body p,
.noteviewer-body p {
  margin: 10px 0;
  color: var(--nv-text);
}

.note-body ul,
.note-body ol,
.noteviewer-body ul,
.noteviewer-body ol {
  padding-left: 22px;
  margin: 10px 0;
  color: var(--nv-text);
}

.note-body li,
.noteviewer-body li {
  margin: 6px 0;
  color: var(--nv-text);
}

/* Links */
.note-body a,
.noteviewer-body a {
  color: var(--nv-accent);
  text-decoration: none;
  font-weight: 650;
}

.note-body a:hover,
.noteviewer-body a:hover {
  color: #8fe6ff;
  text-decoration: underline;
}

/* Blockquotes */
.note-body blockquote,
.noteviewer-body blockquote {
  margin: 14px 0;
  padding: 12px 14px;

  border-left: 4px solid rgba(34,193,255,0.45);
  background: rgba(255,255,255,0.035);
  border-radius: 12px;

  color: rgba(255,255,255,0.82);
}

/* Images */
.note-body img,
.noteviewer-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 14px auto;
  border-radius: 14px;

  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}

/* Tables */
.note-body table,
.noteviewer-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  overflow: hidden;

  border: 1px solid var(--nv-border);
  border-radius: 14px;
}

.note-body th,
.note-body td,
.noteviewer-body th,
.noteviewer-body td {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 12px 12px;
  text-align: left;
  vertical-align: top;
}

.note-body th,
.noteviewer-body th {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.90);
  font-weight: 800;
}

.note-body td,
.noteviewer-body td {
  color: rgba(255,255,255,0.84);
}

/* Subtle zebra striping */
.note-body tr:nth-child(even) td,
.noteviewer-body tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

/* Horizontal rule */
.note-body hr,
.noteviewer-body hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 18px 0;
}

/* Inline code */
.note-body code,
.noteviewer-body code {
  padding: 3px 7px;
  border-radius: 10px;

  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);

  color: rgba(255,255,255,0.90);
  font-size: 0.95em;
}

/* Code blocks */
.note-body pre,
.noteviewer-body pre {
  padding: 14px 16px;
  border-radius: 14px;
  overflow-x: auto;

  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);

  margin: 14px 0;
}

.note-body pre code,
.noteviewer-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: rgba(255,255,255,0.88);
}

/* Small text / captions */
.note-body small,
.note-body .caption,
.noteviewer-body small,
.noteviewer-body .caption {
  color: var(--nv-muted);
}

/* =========================
   Sidebar tree
========================= */

.sidebar-list,
.sidebar-children{
  list-style:none;
  margin:0;
  padding:0;
}

.sidebar-children{
  margin-left:20px;
  margin-top:6px;
}

.sidebar-item{
  margin-bottom:8px;
}

.sidebar-row{
  display:flex;
  align-items:center;
  gap:8px;
}

.sidebar-toggle{
  width:24px;
  height:24px;
  border:none;
  background:transparent;
  color:inherit;
  cursor:pointer;
  padding:0;
  font-size:14px;
  line-height:1;
  opacity:0.8;
  box-shadow:none;
}

.sidebar-toggle:hover{
  background:transparent;
  border-color:transparent;
  transform:none;
}

.sidebar-toggle-placeholder{
  display:inline-block;
  width:24px;
  height:24px;
}

.sidebar-children.is-collapsed{
  display:none;
}

.sidebar-toggle.is-open{
  transform:rotate(90deg);
}

.sidebar-link{
  text-decoration:none;
  color:inherit;
  line-height:1.4;
  display:inline-block;
  padding:4px 8px;
  border-radius:8px;
}

.sidebar-link:hover{
  text-decoration:none;
  background:rgba(255,255,255,0.06);
}

.sidebar-link.is-active{
  background:rgba(255,255,255,0.12);
  font-weight:700;
}

/* =========================
   Pagination
========================= */

.note-pagination{
  display:flex;
  justify-content:space-between;
  gap:16px;
  margin-top:32px;
  padding-top:24px;
  border-top:1px solid rgba(255,255,255,0.08);
}

.note-pagination-link{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:6px;
  text-decoration:none;
  color:inherit;
  padding:14px 16px;
  border:1px solid rgba(255,255,255,0.08);
  border-radius:14px;
  background:rgba(255,255,255,0.02);
}

.note-pagination-link:hover{
  background:rgba(255,255,255,0.05);
}

.note-pagination-link.next{
  text-align:right;
}

/* =========================
   Compatibility with pages content card
========================= */

.content {
  background: rgba(255,255,255,0.02) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
}

/* =========================
   Responsive
========================= */

@media (max-width: 980px){
  .noteviewer-layout,
  .layout{
    grid-template-columns:1fr;
  }

  .noteviewer-sidebar,
  .sidebar{
    position:static;
    max-height:none;
  }
}

@media (max-width: 700px){
  .note-pagination{
    flex-direction:column;
  }

  .note-pagination-link.next{
    text-align:left;
  }
}

@media (max-width: 520px){
  .note-body{
    width: calc(100% - 28px);
    padding: 16px 14px;
    font-size: 15px;
  }

  .noteviewer-main-inner{
    padding:20px 16px;
  }

  .note-body h1,
  .noteviewer-body h1{
    font-size:28px;
  }

  .note-body h2,
  .noteviewer-body h2{
    font-size:22px;
  }
}

.flashcard-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
}

.flashcard-counter {
  font-size: 0.9rem;
  color: var(--nv-muted);
}

.flashcard-scene {
  width: 100%;
  max-width: 560px;
  height: 260px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.flashcard.is-flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 14px;
  border: 1px solid var(--nv-border);
  background: rgba(255,255,255,0.04);
  color: var(--nv-text);
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.6;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: rgba(255,255,255,0.07);
}

.flashcard-controls {
  display: flex;
  gap: 0.75rem;
}

.flashcard-controls button {
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--nv-border);
  background: transparent;
  color: var(--nv-text);
  cursor: pointer;
  font-size: 0.9rem;
}

.flashcard-controls button:hover {
  background: rgba(255,255,255,0.06);
}

/* =========================
   Question Cards
========================= */

.question-card {
  padding: 20px 24px;
  margin-bottom: 16px;
  border: 1px solid var(--nv-border);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
}

.question-text {
  margin: 0 0 14px;
  font-size: 1rem;
  color: var(--nv-text);
  font-weight: 600;
  line-height: 1.6;
}

.question-answer {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border-left: 3px solid var(--nv-accent);
  color: var(--nv-text);
  line-height: 1.7;
  font-size: 0.97rem;
}

.btn-reveal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--nv-border-2);
  background: transparent;
  color: var(--nv-accent);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-reveal:hover {
  background: rgba(255,255,255,0.06);
}

.empty-message {
  color: var(--nv-muted);
  font-size: 0.95rem;
}

/* =========================
   Paywall Overlay
========================= */

.paywall-overlay {
  position: relative;
  margin-top: -6rem;
}

.paywall-overlay__fade {
  height: 6rem;
  background: linear-gradient(to bottom, transparent, #0b1118);
}

.paywall-overlay__cta {
  background: #0b1118;
  text-align: center;
  padding: 1.5rem 1rem 2rem;
}

.paywall-overlay__message {
  color: rgba(255,255,255,0.75);
  font-size: 1rem;
  margin: 0 0 1rem;
}

.paywall-overlay__btn {
  display: inline-block;
  padding: 0.6rem 1.75rem;
  background: var(--nv-accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.paywall-overlay__btn:hover {
  background: #8fe6ff;
  color: #000;
}

/* =========================
   Billing Status Pages
========================= */

.billing-status-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
}

.billing-status-card {
  text-align: center;
  max-width: 480px;
  width: 100%;
}

.billing-status-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 auto 1.5rem;
}

.billing-status-icon--success {
  background: #166534;
  color: #bbf7d0;
}

.billing-status-icon--cancel {
  background: #1e293b;
  color: #94a3b8;
}

.billing-status-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  margin: 0 0 0.75rem;
}

.billing-status-body {
  color: var(--nv-muted);
  font-size: 1rem;
  margin: 0 0 2rem;
  line-height: 1.6;
}

.billing-status-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.billing-status-btn {
  display: inline-block;
  padding: 0.65rem 2rem;
  background: var(--nv-accent);
  color: #000;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.billing-status-btn:hover {
  background: #8fe6ff;
}

.billing-status-btn--secondary {
  background: rgba(255,255,255,0.06);
  color: var(--nv-text);
  border: 1px solid var(--nv-border);
}

.billing-status-btn--secondary:hover {
  background: rgba(255,255,255,0.10);
}


/* =========================
   Video Player
========================= */

.video-embed-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 ratio */
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.video-embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
}

.noteviewer-empty-message {
  color: var(--nv-muted);
  font-size: 0.95rem;
}