/* Djot Content Styling - Mobile-First */

/* Base */
.djot-content { font-size: 0.875rem; line-height: 1.65; color: #1f2937; }
.djot-content > :first-child { margin-top: 0; }
.djot-content > :last-child { margin-bottom: 0; }

/* Lists */
.djot-content ol { list-style: decimal; margin: 0.75em 0 0.75em 1.25em; padding-left: 0.25em; }
.djot-content ul { list-style: disc; margin: 0.75em 0 0.75em 1.25em; padding-left: 0.25em; }
.djot-content li { margin: 0.375em 0; line-height: 1.65; }
.djot-content li > ol, .djot-content li > ul { margin: 0.25em 0; }
.djot-content li::marker { color: #6b7280; }

/* Paragraphs & Headings */
.djot-content p { margin: 0.75em 0; line-height: 1.7; }
.djot-content h1, .djot-content h2, .djot-content h3, .djot-content h4, .djot-content h5, .djot-content h6 { margin: 1em 0 0.5em; font-weight: 600; line-height: 1.3; color: #111827; letter-spacing: -0.01em; }
.djot-content p + h1, .djot-content p + h2, .djot-content p + h3, .djot-content p + h4, .djot-content p + h5, .djot-content p + h6 { margin-top: 1.75em; }
.djot-content h1 { font-size: 1.25rem; }
.djot-content h2 { font-size: 1.125rem; }
.djot-content h3 { font-size: 1rem; }
.djot-content h4 { font-size: 0.875rem; font-weight: 700; }
.djot-content h5, .djot-content h6 { font-size: 0.875rem; }

/* Blockquotes */
.djot-content blockquote { border-left: 3px solid #60a5fa; padding: 0.625em 0.875em 0.625em 1em; color: #374151; margin: 1em 0; font-style: italic; background: #f0f9ff; border-radius: 0 0.375rem 0.375rem 0; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.djot-content blockquote > p { color: inherit; margin: 0.5em 0; }
.djot-content blockquote > p:first-child { margin-top: 0; }
.djot-content blockquote > p:last-child { margin-bottom: 0; }

/* Blockquote Captions (figure > blockquote + figcaption) */
.djot-content figure { margin: 1.25em 0; }
.djot-content figure > blockquote { margin: 0; border-radius: 0 0.375rem 0 0; }
.djot-content figure > figcaption { display: block; margin-top: 0.5em; padding-left: 1.5em; font-size: 0.875rem; color: #6b7280; font-style: normal; line-height: 1.5; }
.djot-content figure > figcaption::before { content: '— '; color: #9ca3af; }

/* Code */
.djot-content code { background: #e5e7eb; padding: 0.2em 0.4em; border-radius: 0.25rem; font-family: Consolas, Monaco, 'Courier New', monospace; font-size: 0.875em; color: #1e40af; border: 1px solid #d1d5db; word-break: break-word; }
.djot-content pre { background: #e5e7eb; color: #1f2937; padding: 1em; border-radius: 0.5rem; overflow-x: auto; margin: 1.25em 0; line-height: 1.6; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 1px solid #d1d5db; -webkit-overflow-scrolling: touch; }
.djot-content pre code { background: transparent; padding: 0; color: inherit; font-size: 0.875em; border: none; word-break: normal; }

/* Links & Text */
.djot-content a { color: #2563eb; text-decoration: none; border-bottom: 1px solid #93c5fd; transition: all 0.2s; word-break: break-word; }
.djot-content a:hover { color: #1d4ed8; border-bottom-color: #1d4ed8; background: #eff6ff; }
.djot-content a:focus { outline: 2px solid #3b82f6; outline-offset: 2px; border-radius: 0.125rem; background: #eff6ff; }
.djot-content strong { font-weight: 700; }
.djot-content em { font-style: italic; }

/* Highlight, Insert, Delete */
.djot-content mark { background: #fef9c3; padding: 0.15em 0.35em; border-radius: 0.25rem; color: #854d0e; font-weight: 500; }
.djot-content ins { text-decoration: none; color: #166534; background: #ecfdf5; padding: 0.15em 0.35em; border-radius: 0.25rem; font-weight: 500; border-bottom: 2px solid #22c55e; }
.djot-content del { text-decoration: line-through #ef4444 1.5px; color: #b91c1c; background: #fef2f2; padding: 0.15em 0.35em; border-radius: 0.25rem; }

/* Images */
.djot-content img { max-width: 100%; height: auto; margin: 1.25em auto; display: block; cursor: pointer; transition: opacity 0.2s; }
.djot-content img:hover { opacity: 0.9; }
.djot-content a img:hover { opacity: 1; }

/* Image Lightbox */
.djot-lightbox-overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity 0.2s ease; }
.djot-lightbox-overlay.active { opacity: 1; }
.djot-lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 0.5rem; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); transform: scale(0.92); transition: transform 0.2s ease; }
.djot-lightbox-overlay.active img { transform: scale(1); }

/* Tables */
.djot-content table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1.25em 0; font-size: 0.9375em; display: block; overflow-x: auto; border-radius: 0.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid #e5e7eb; -webkit-overflow-scrolling: touch; }
.djot-content table th, .djot-content table td { border-bottom: 1px solid #e5e7eb; border-right: 1px solid #f3f4f6; padding: 0.5em 0.625em; text-align: left; vertical-align: top; }
.djot-content table th { background: #f9fafb; font-weight: 600; white-space: nowrap; color: #374151; }
.djot-content table th:last-child, .djot-content table td:last-child { border-right: none; }
.djot-content table tr:last-child td, .djot-content table tr:last-child th { border-bottom: none; }
.djot-content table tr:hover td { background: #f9fafb; }

/* Definition Lists */
.djot-content dl { margin: 0.5em 0; }
.djot-content dt { font-weight: 600; margin-top: 0.5em; }
.djot-content dd { margin: 0.25em 0 0.5em 1em; }

/* Horizontal Rules */
.djot-content hr { border: none; height: 1px; background: linear-gradient(to right, transparent, #d1d5db 50%, transparent); margin: 2em 0; }

/* Divs (Note, Warning, Spoiler) */
.djot-content div.note { background: #dbeafe; padding: 0.875em 1em; margin: 1em 0; border-radius: 0 0.5rem 0.5rem 0; border: 1px solid #bfdbfe; border-left: 4px solid #3b82f6; }
.djot-content div.warning { background: #fef3c7; padding: 0.875em 1em; margin: 1em 0; border-radius: 0 0.5rem 0.5rem 0; border: 1px solid #fde68a; border-left: 4px solid #f59e0b; }
.djot-content div.spoiler { background: #f0f9ff; padding: 0.875em 1em; margin: 1em 0; border-radius: 0.5rem; border: 1px solid #e5e7eb; }

/* Spoilers (details/summary) */
.djot-content details { background: #f0f9ff; border: 1px solid #e5e7eb; border-radius: 0.5rem; padding: 0.625em 0.875em; margin: 1em 0; transition: all 0.2s; }
.djot-content details:hover { border-color: #d1d5db; }
.djot-content details summary { font-weight: 600; cursor: pointer; user-select: none; padding: 0.5em 0.75em; margin: -0.25em -0.25em 0; list-style: none; transition: all 0.15s; color: #374151; border-radius: 0.25rem; min-height: 44px; display: flex; align-items: center; }
.djot-content details summary:hover { color: #2563eb; background: rgba(37,99,235,0.05); }
.djot-content details summary:focus { outline: 2px solid #3b82f6; outline-offset: 2px; border-radius: 0.25rem; }
.djot-content details summary::-webkit-details-marker { display: none; }
.djot-content details summary::before { content: '▶'; display: inline-block; margin-right: 0.5em; transition: transform 0.2s; color: #6b7280; font-size: 0.75em; }
.djot-content details[open] summary::before { transform: rotate(90deg); color: #2563eb; }
.djot-content details[open] { padding-bottom: 1em; background: #f0f9ff; border-color: #bfdbfe; }
.djot-content details > *:not(summary) { margin-top: 0.75em; padding-left: 1.5em; }
.djot-content details > :last-child { margin-bottom: 0; }

/* Sub/Superscript */
.djot-content sub, .djot-content sup { font-size: 0.75em; line-height: 0; position: relative; vertical-align: baseline; }
.djot-content sup { top: -0.5em; }
.djot-content sub { bottom: -0.25em; }

/* Figures & Captions */
.djot-content figure { margin: 1em 0; }
.djot-content figure > img { margin: 0; }
.djot-content figcaption, .djot-content caption { font-size: 0.875em; color: #6b7280; font-style: italic; text-align: center; margin-top: 0.5em; }
.djot-content figure > blockquote + figcaption { font-size: 0.875rem; color: #6b7280; font-style: normal; text-align: left; }
.djot-content table caption { margin-bottom: 0.5em; margin-top: 0; }

/* Footnotes */
.djot-content .footnote { font-size: 0.875em; border-top: 1px solid #e5e7eb; padding-top: 0.5em; margin-top: 2em; }
.djot-content .footnote p { margin: 0.25em 0; }
.djot-content sup a { text-decoration: none; font-weight: 600; }

/* Task Lists */
.djot-content ul.task-list { list-style: none; margin-left: 0; padding-left: 0; }
.djot-content ul.task-list input[type="checkbox"] { margin-right: 0.5em; }

/* Sections */
.djot-content section { margin: 2em 0; }
.djot-content section:first-child { margin-top: 0; }

/* Desktop (640px+) */
@media (min-width: 640px) {
    .djot-content ol, .djot-content ul { margin-left: 1.5em; }
    .djot-content p + h1, .djot-content p + h2, .djot-content p + h3 { margin-top: 2em; }
    .djot-content h1 { font-size: 1.5rem; }
    .djot-content h2 { font-size: 1.25rem; }
    .djot-content h3 { font-size: 1.125rem; }
    .djot-content blockquote { padding: 0.75em 1em 0.75em 1.25em; margin: 1.25em 0; }
    .djot-content table { display: table; }
    .djot-content table th, .djot-content table td { padding: 0.625em 0.75em; }
    .djot-content dd { margin-left: 1.5em; }
    .djot-content div.note, .djot-content div.warning, .djot-content div.spoiler { padding: 1em 1.25em; margin: 1.25em 0; }
    .djot-content details { padding: 0.75em 1em; margin: 1.25em 0; }
}
