/* markdown-reader.css — Fullscreen markdown reader with reading settings */

/* ─── VaultSerif Font ─── */

@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-RegularItalic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-MediumItalic.woff2') format('woff2'); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-Semibold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-SemiboldItalic.woff2') format('woff2'); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'VaultSerif'; src: url('../fonts/VaultSerif-BoldItalic.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }

/* ─── Reader overlay ─── */

.markdown-reader {
  position: fixed;
  inset: 0;
  z-index: 280;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  --md-base-size: 16px;
  --md-heading-scale: 1.25;
  --md-line-height: 1.6;
  --md-font-weight: 400;
  --md-heading-weight: 700;
  --md-text-opacity: 1;
}

body.reader-open { overflow: hidden; }

/* ─── Header ─── */

.markdown-reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.markdown-reader-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.markdown-reader-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.markdown-reader-close:hover { color: var(--text-primary); }

/* ─── Content ─── */

.markdown-reader-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  -webkit-overflow-scrolling: touch;
}

/* ─── Markdown body ─── */

.markdown-body {
  max-width: 680px;
  margin: 0 auto;
  font-size: var(--md-base-size);
  line-height: var(--md-line-height);
  font-weight: var(--md-font-weight);
  opacity: var(--md-text-opacity);
  color: var(--text-primary);
  word-wrap: break-word;
}

.markdown-body.font-serif {
  font-family: 'VaultSerif', Georgia, 'Times New Roman', serif;
}

/* Headings */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-weight: var(--md-heading-weight);
  color: var(--text-primary);
  margin-top: 16px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.markdown-body h1 { font-size: calc(var(--md-base-size) * var(--md-heading-scale) * var(--md-heading-scale) * var(--md-heading-scale)); }
.markdown-body h2 { font-size: calc(var(--md-base-size) * var(--md-heading-scale) * var(--md-heading-scale)); }
.markdown-body h3 { font-size: calc(var(--md-base-size) * var(--md-heading-scale)); }
.markdown-body h4 { font-size: calc(var(--md-base-size) * 1.1); }

/* Paragraphs & lists */
.markdown-body p { margin-bottom: 8px; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1.25em; padding-left: 16px; }
.markdown-body li { margin-bottom: 4px; }

/* Links */
.markdown-body a {
  color: var(--primary-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.markdown-body a:hover { color: var(--link-hover); }

/* Blockquotes */
.markdown-body blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 12px;
  padding-top: 0.5em;
  padding-right: 1em;
  padding-bottom: 0.5em;
  margin: 8px 0;
  color: var(--text-muted);
}

/* Code */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--hover-bg);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--primary-color);
}

.markdown-body pre {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25em;
  font-size: 0.9em;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-color);
  padding: 0.5em 0.75em;
  text-align: left;
}

.markdown-body th {
  font-weight: 600;
  background: var(--hover-bg);
}

/* Images */
.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 0.5em 0;
}

/* Horizontal rule */
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

/* Checkboxes */
.markdown-body input[type="checkbox"] {
  margin-right: 0.5em;
}

/* ─── Floating settings button ─── */

.reading-action-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--panel-bg);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 281;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.reading-action-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

/* ─── Settings panel ─── */

.reading-settings {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100%;
  background: var(--panel-bg);
  border-left: 1px solid var(--border-color);
  z-index: 282;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
  overflow-y: auto;
}

.reading-settings.open {
  right: 0;
}

.reading-settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 281;
  display: none;
}

.reading-settings-overlay.open {
  display: block;
}

.reading-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.reading-settings-header h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.reading-settings-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.reading-settings-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Setting groups ─── */

.rs-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rs-group label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
}

.rs-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.rs-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
}

.rs-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--text-primary);
  cursor: pointer;
}

.rs-val {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Theme buttons */
.rs-theme-btns {
  display: flex;
  gap: 8px;
}

.rs-theme-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.rs-theme-btn:hover { color: var(--text-primary); }

.rs-theme-btn.active {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Typography select */
.rs-typo-select {
  background: var(--bg-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-size: var(--text-sm);
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* ─── Mobile ─── */

@media (max-width: 768px) {
  .reading-settings {
    width: 60%;
    right: -60%;
  }

  .markdown-reader-scroll {
    padding: 1.5rem 1rem;
  }

  .reading-action-btn {
    bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
}
