/* ============================================================
   RedLab Markdown Widget — default stylesheet  v1.1.0
   All rules scoped to .redlab-markdown-output to avoid conflicts.
   This file loads LAST in the CSS stack so it can override Prism.
   ============================================================ */

/* -------------------------------------------------------------------------
   Base
   ------------------------------------------------------------------------- */

.redlab-markdown-output {
	font-size: 16px;
	line-height: 1.7;
	color: inherit;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* -------------------------------------------------------------------------
   Headings
   ------------------------------------------------------------------------- */

.redlab-markdown-output h1,
.redlab-markdown-output h2,
.redlab-markdown-output h3,
.redlab-markdown-output h4,
.redlab-markdown-output h5,
.redlab-markdown-output h6 {
	margin-top: 1.5em;
	margin-bottom: 0.5em;
	font-weight: 700;
	line-height: 1.3;
	position: relative; /* needed for anchor hover area */
}

.redlab-markdown-output h1 { font-size: 2.25em; }
.redlab-markdown-output h2 { font-size: 1.75em; }
.redlab-markdown-output h3 { font-size: 1.4em; }
.redlab-markdown-output h4 { font-size: 1.15em; }
.redlab-markdown-output h5 { font-size: 1em; }
.redlab-markdown-output h6 { font-size: 0.875em; color: #666; }

.redlab-markdown-output h1:first-child,
.redlab-markdown-output h2:first-child,
.redlab-markdown-output h3:first-child { margin-top: 0; }

/* -------------------------------------------------------------------------
   Paragraphs
   ------------------------------------------------------------------------- */

.redlab-markdown-output p {
	margin-top: 0;
	margin-bottom: 1em;
}

/* -------------------------------------------------------------------------
   Links
   ------------------------------------------------------------------------- */

.redlab-markdown-output a {
	color: #0073aa;
	text-decoration: underline;
	text-underline-offset: 2px;
	transition: color 0.2s ease;
}

.redlab-markdown-output a:hover { color: #005177; }

/* -------------------------------------------------------------------------
   Strong / em
   ------------------------------------------------------------------------- */

.redlab-markdown-output strong { font-weight: 700; }
.redlab-markdown-output em     { font-style: italic; }

/* -------------------------------------------------------------------------
   Lists
   ------------------------------------------------------------------------- */

.redlab-markdown-output ul,
.redlab-markdown-output ol {
	margin-top: 0;
	margin-bottom: 1em;
	padding-left: 1.75em;
}

.redlab-markdown-output ul { list-style-type: disc; }
.redlab-markdown-output ol { list-style-type: decimal; }

.redlab-markdown-output li { margin-bottom: 0.3em; }

.redlab-markdown-output li > ul,
.redlab-markdown-output li > ol {
	margin-top: 0.3em;
	margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   Inline code
   ------------------------------------------------------------------------- */

.redlab-markdown-output code {
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 0.875em;
	background-color: #f4f4f4;
	border: 1px solid #e1e1e1;
	border-radius: 3px;
	padding: 2px 5px;
	white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Block code — pre + code
   ------------------------------------------------------------------------- */

.redlab-markdown-output pre {
	position: relative; /* required for absolutely-positioned copy btn + label */
	background-color: #1e1e1e;
	color: #d4d4d4;
	border-radius: 6px;
	padding: 1em;
	overflow-x: auto;
	margin-top: 0;
	margin-bottom: 1em;
	line-height: 1.6;
}

.redlab-markdown-output pre code {
	background: none;
	border: none;
	border-radius: 0;
	padding: 0;
	font-size: inherit;
	white-space: pre;
	color: inherit;
}

/* -------------------------------------------------------------------------
   Blockquote
   ------------------------------------------------------------------------- */

.redlab-markdown-output blockquote {
	margin: 0 0 1em 0;
	padding: 0.5em 0 0.5em 1em;
	border-left: 4px solid #e0e0e0;
	color: #666;
	font-style: italic;
}

.redlab-markdown-output blockquote p { margin-bottom: 0; }

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */

.redlab-markdown-output table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1em;
	font-size: 0.95em;
}

.redlab-markdown-output th,
.redlab-markdown-output td {
	border: 1px solid #ddd;
	padding: 0.5em 0.75em;
	text-align: left;
}

.redlab-markdown-output th {
	background-color: #f8f8f8;
	font-weight: 700;
}

.redlab-markdown-output tr:nth-child(even) { background-color: #fafafa; }

/* -------------------------------------------------------------------------
   Horizontal rule
   ------------------------------------------------------------------------- */

.redlab-markdown-output hr {
	border: none;
	border-top: 1px solid #eee;
	margin: 1.5em 0;
}

/* -------------------------------------------------------------------------
   Images
   ------------------------------------------------------------------------- */

.redlab-markdown-output img {
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	display: inline-block;
}

/* -------------------------------------------------------------------------
   GFM task-list checkboxes
   ------------------------------------------------------------------------- */

.redlab-markdown-output input[type="checkbox"] {
	margin-right: 0.4em;
	vertical-align: middle;
}

/* ==========================================================================
   FEATURE 2 — Copy button
   ========================================================================== */

.elemark-copy-btn {
	position: absolute;
	top: 10px;
	right: 10px;
	background: rgba(255, 255, 255, 0.1);
	color: #ccc;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 4px 10px;
	font-size: 12px;
	font-family: "SFMono-Regular", Consolas, monospace;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
	z-index: 10;
	line-height: 1.4;
}

.elemark-copy-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

.elemark-copy-btn.copied {
	background: #27ae60;
	color: #fff;
	border-color: #27ae60;
}

/* ==========================================================================
   FEATURE 3 — Language label
   ========================================================================== */

.elemark-lang-label {
	position: absolute;
	top: 10px;
	left: 14px;
	font-size: 11px;
	font-family: "SFMono-Regular", Consolas, monospace;
	color: #888;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	pointer-events: none;
	user-select: none;
	line-height: 1.4;
}

/* ==========================================================================
   FEATURE 6 — Reading time badge
   ========================================================================== */

.elemark-reading-badge {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 13px;
	color: #888;
	margin-bottom: 16px;
	padding-bottom: 12px;
	border-bottom: 1px solid #eee;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.elemark-reading-badge span {
	display: flex;
	align-items: center;
	gap: 4px;
}

.elemark-word-count {
	color: #aaa;
	font-size: 12px;
}

/* Reading badge at the bottom */
.elemark-reading-badge:last-child {
	margin-bottom: 0;
	margin-top: 16px;
	padding-top: 12px;
	padding-bottom: 0;
	border-bottom: none;
	border-top: 1px solid #eee;
}

/* ==========================================================================
   FEATURE 7 — Anchor links on headings
   ========================================================================== */

.elemark-anchor-link {
	text-decoration: none !important;
	color: inherit !important;
}

.elemark-anchor-icon {
	opacity: 0;
	font-size: 0.7em;
	color: #aaa;
	margin-left: 6px;
	transition: opacity 0.2s ease;
	font-weight: 400;
}

.redlab-markdown-output h1:hover .elemark-anchor-icon,
.redlab-markdown-output h2:hover .elemark-anchor-icon,
.redlab-markdown-output h3:hover .elemark-anchor-icon,
.redlab-markdown-output h4:hover .elemark-anchor-icon,
.redlab-markdown-output h5:hover .elemark-anchor-icon,
.redlab-markdown-output h6:hover .elemark-anchor-icon {
	opacity: 1;
}

/* ==========================================================================
   FEATURE 5 — Theme presets
   Each theme class is applied alongside .redlab-markdown-output on the same
   element, giving the two-class selectors higher specificity than base rules.
   ========================================================================== */

/* ---------- GitHub Light -------------------------------------------------- */

.elemark-theme-github {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.6;
	color: #24292f;
	background: #ffffff;
	padding: 24px;
}

.elemark-theme-github h1,
.elemark-theme-github h2 {
	border-bottom: 1px solid #d0d7de;
	padding-bottom: 8px;
}

.elemark-theme-github h1 { font-size: 2em; }
.elemark-theme-github h2 { font-size: 1.5em; }

.elemark-theme-github a { color: #0969da; }

.elemark-theme-github blockquote {
	border-left: 4px solid #d0d7de;
	color: #57606a;
	padding-left: 16px;
	font-style: normal;
}

.elemark-theme-github code:not(pre code) {
	background: rgba(175, 184, 193, 0.2);
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 85%;
	color: #cf222e;
	border: none;
}

.elemark-theme-github pre {
	background: #f6f8fa !important;
	border: 1px solid #d0d7de;
	border-radius: 6px;
	color: #24292f;
}

.elemark-theme-github table th { background: #f6f8fa; }

.elemark-theme-github .elemark-copy-btn {
	background: rgba(0, 0, 0, 0.05);
	color: #57606a;
	border-color: #d0d7de;
}

.elemark-theme-github .elemark-copy-btn:hover {
	background: rgba(0, 0, 0, 0.1);
	color: #24292f;
}

.elemark-theme-github .elemark-lang-label { color: #57606a; }

/* ---------- Notion Style -------------------------------------------------- */

.elemark-theme-notion {
	font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
	font-size: 16px;
	line-height: 1.75;
	color: #37352f;
	background: #ffffff;
	padding: 20px;
	max-width: 720px;
}

.elemark-theme-notion h1 { font-size: 2.2em; font-weight: 700; margin-bottom: 4px; }
.elemark-theme-notion h2 { font-size: 1.6em; font-weight: 600; margin-top: 2em; }
.elemark-theme-notion h3 { font-size: 1.3em; font-weight: 600; }

.elemark-theme-notion a { color: #0f7b6c; text-decoration: underline; }

.elemark-theme-notion blockquote {
	border-left: 3px solid #37352f;
	padding-left: 14px;
	color: #6b6b6b;
	font-style: normal;
}

.elemark-theme-notion code:not(pre code) {
	background: rgba(135, 131, 120, 0.15);
	padding: 2px 5px;
	border-radius: 3px;
	color: #eb5757;
	font-size: 85%;
	border: none;
}

.elemark-theme-notion pre {
	background: #f7f6f3 !important;
	border-radius: 4px;
	color: #37352f;
}

.elemark-theme-notion .elemark-copy-btn {
	background: rgba(55, 53, 47, 0.06);
	color: #6b6b6b;
	border-color: rgba(55, 53, 47, 0.16);
}

.elemark-theme-notion .elemark-copy-btn:hover { background: rgba(55, 53, 47, 0.12); }
.elemark-theme-notion .elemark-lang-label { color: #9b9a97; }

/* ---------- Medium Article ------------------------------------------------ */

.elemark-theme-medium {
	font-family: "Georgia", "Times New Roman", serif;
	font-size: 21px;
	line-height: 1.58;
	color: #292929;
	background: #ffffff;
	padding: 20px 40px;
	max-width: 740px;
	margin: 0 auto;
}

.elemark-theme-medium h1 {
	font-family: "Georgia", serif;
	font-size: 2em;
	font-weight: 700;
	letter-spacing: -0.5px;
}

.elemark-theme-medium h2 { font-size: 1.5em; font-weight: 700; }
.elemark-theme-medium p  { margin-bottom: 28px; }

.elemark-theme-medium a {
	color: #1a8917;
	text-decoration: none;
	border-bottom: 1px solid #1a8917;
}

.elemark-theme-medium blockquote {
	font-size: 1.3em;
	border-left: 3px solid #292929;
	padding-left: 20px;
	font-style: italic;
	color: #555;
}

.elemark-theme-medium code:not(pre code) {
	font-family: monospace;
	font-size: 0.85em;
	background: #f2f2f2;
	padding: 2px 5px;
	border: none;
	border-radius: 0;
}

.elemark-theme-medium pre { font-size: 14px; line-height: 1.5; }

/* ---------- Dark Mode ----------------------------------------------------- */

.elemark-theme-dark {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 16px;
	line-height: 1.7;
	color: #e6edf3;
	background: #0d1117;
	padding: 24px;
	border-radius: 8px;
}

.elemark-theme-dark h1,
.elemark-theme-dark h2,
.elemark-theme-dark h3 { color: #ffffff; }

.elemark-theme-dark h1,
.elemark-theme-dark h2 {
	border-bottom: 1px solid #21262d;
	padding-bottom: 8px;
}

.elemark-theme-dark a { color: #58a6ff; }
.elemark-theme-dark a:hover { color: #79c0ff; }

.elemark-theme-dark blockquote {
	border-left: 4px solid #3b5070;
	color: #8b949e;
	padding: 8px 16px;
	background: #161b22;
	border-radius: 0 4px 4px 0;
	font-style: normal;
}

.elemark-theme-dark code:not(pre code) {
	background: rgba(110, 118, 129, 0.2);
	color: #ff7b72;
	padding: 2px 6px;
	border-radius: 4px;
	border: none;
}

.elemark-theme-dark pre {
	background: #161b22 !important;
	border: 1px solid #21262d;
}

.elemark-theme-dark table         { color: #e6edf3; }
.elemark-theme-dark table th      { background: #161b22; border-color: #21262d; }
.elemark-theme-dark table td      { border-color: #21262d; }
.elemark-theme-dark hr            { border-color: #21262d; }
.elemark-theme-dark h6            { color: #8b949e; }

.elemark-theme-dark .elemark-reading-badge  { color: #6e7681; border-bottom-color: #21262d; }
.elemark-theme-dark .elemark-word-count     { color: #484f58; }

.elemark-theme-dark .elemark-reading-badge:last-child {
	border-top-color: #21262d;
	border-bottom: none;
}

/* ---------- Minimal Clean ------------------------------------------------- */

.elemark-theme-minimal {
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.8;
	color: #444;
	background: #fff;
	padding: 16px;
}

.elemark-theme-minimal h1,
.elemark-theme-minimal h2,
.elemark-theme-minimal h3 {
	font-weight: 600;
	color: #222;
	margin-top: 1.5em;
}

.elemark-theme-minimal h1 { font-size: 1.8em; }
.elemark-theme-minimal h2 { font-size: 1.4em; }

.elemark-theme-minimal a { color: #333; text-decoration: underline; }

.elemark-theme-minimal blockquote {
	border-left: 2px solid #ddd;
	padding-left: 16px;
	color: #888;
	font-style: normal;
}

.elemark-theme-minimal code:not(pre code) {
	background: #f5f5f5;
	padding: 1px 5px;
	border-radius: 3px;
	font-size: 85%;
	border: none;
}

.elemark-theme-minimal pre {
	background: #f5f5f5 !important;
	border-radius: 4px;
	color: #333;
}

.elemark-theme-minimal hr { border: none; border-top: 1px solid #eee; }

.elemark-theme-minimal .elemark-copy-btn {
	background: rgba(0, 0, 0, 0.05);
	color: #888;
	border-color: #ddd;
}

.elemark-theme-minimal .elemark-copy-btn:hover {
	background: rgba(0, 0, 0, 0.1);
	color: #444;
}

.elemark-theme-minimal .elemark-lang-label { color: #aaa; }
