/*
 * Famouskai Editor - Local-First PWA IDE
 * Copyright (C) 2026 Denys Poulat (https://github.com/denys-digital)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 *
 * -------------------------------------------------------------------------
 * COMMERCIAL LICENSE
 * For commercial integration without the AGPLv3 strict open-source 
 * restrictions, please contact the author to acquire a commercial license.
 * -------------------------------------------------------------------------
 */

/* ﹥ MARKDOWN - Editable Markdown Preview Style */

/* Oswald headings font, self-hosted in vendor/ (zero-CDN) */
@font-face {
    font-family: 'Oswald';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('vendor/fontsource-oswald/files/oswald-latin-500-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'Oswald';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('vendor/fontsource-oswald/files/oswald-latin-700-normal.woff2') format('woff2');
}

.markdown-body {
    background-color: #ffffff;
    color: #333333;
    padding: 28px;
    font-family: 'Tahoma', 'Segoe UI', Geneva, Verdana, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    text-align: left;
}

/* ==========================================================================
   ﹥ Print Engine (PDF Export)
   ========================================================================== */
@media print {

    /* 1. Force the browser to drop its default Headers/Footers (URL, Date) */
    @page {
        margin: 0;
        size: A4 portrait;
        /* Standardize format */
    }

    .markdown-body {
        -webkit-print-color-adjust: exact;
        width: 100%;
        font-size: 14px;

        /* 2. Recreate physical margins inside the document 
              since @page margin is now 0 */
        padding: 1cm 1cm !important;

        /* Force black text for perfect print contrast */
        color: #000000 !important;
    }

    /* Hide interactive UI extensions like table filter panels in print/PDF output */
    .markdown-body .famous-up-filter-panel {
        display: none !important;
    }

    /* Page break utility for Magic Snippet (/pb) */
    .page-break {
        page-break-after: always;
        break-after: page;
    }
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #111827;
    /* Near black for sharp contrast */
}

.markdown-body h1 {
    margin-top: 0;
    font-size: 2.8em;
    margin-bottom: 30px;
    padding-bottom: 5px;
}

.markdown-body h1+p {
    margin-top: 1em;
}

.markdown-body h2 {
    margin-top: 1.6em;
    font-size: 2.1em;
}

.markdown-body h2+h3,
.markdown-body h2+p {
    margin-top: 1em;
}

.markdown-body h3 {
    margin-top: 1.6em;
    font-size: 1.6em;
}

.markdown-body h3+h4,
.markdown-body h3+p {
    margin-top: 1em;
}

.markdown-body h4 {
    margin-top: 1.6em;
    font-size: 1.3em;
}

.markdown-body h4+h5,
.markdown-body h4+p {
    margin-top: 1em;
}

.markdown-body h5 {
    margin-top: 1.6em;
    font-size: 1.1em;
}

.markdown-body h5+h6,
.markdown-body h5+p {
    margin-top: 1em;
}

.markdown-body h6 {
    margin-top: 1.6em;
    font-size: 1.0em;
}

.markdown-body strong {
    font-weight: 600;
}

.markdown-body div {
    margin-bottom: 1.2em;
}

.markdown-body p {
    margin: .6em 0;
    text-align: justify;
}

.markdown-body a {
    color: #0473bc;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body svg {
    display: inline-flex;
    align-self: center;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 0;
}

.markdown-body img {
    max-width: calc(100% - 2.6em);
    margin: 1.3em;
    min-height: 23px;
}

.markdown-body input[type="text"],
.markdown-body input[type="number"] {
    padding: .3em;
    font-family: 'consolas';
    border: solid 1px #ccc;
    border-radius: 2px;
}

.markdown-body input[type="radio"] {
    display: inline-block;
    height: 1em;
    line-height: 1em;
    vertical-align: top;
}

.markdown-body textarea {
    font-family: consolas;
}

.markdown-body ul,
.markdown-body ol {
    margin: 1em 0 1em 1.6em;
    position: relative;
}

.markdown-body ul {
    margin-left: 1.8em;
    list-style-type: circle;
}

.markdown-body li {
    margin-bottom: .6em;
    word-wrap: break-word;
}

.markdown-body li>ul,
.markdown-body li>ol {
    margin: .6em 0 .6em 1.6em;
}

.markdown-body li ul>li {
    list-style-type: disc;
}

.markdown-body li li ul>li:not([class]) {
    list-style-type: none;
}

.markdown-body li li ul>li:not([class]):before {
    content: "\2212";
    position: absolute;
    left: -1.2em;
}

.markdown-body li img {
    margin: .6em auto;
}

.markdown-body button {
    padding: .2em .4em;
}

.markdown-body button>svg {
    vertical-align: top;
}

.markdown-body blockquote {
    margin: 1.6em 0;
    padding: 1em 1.6em;
    border-left: 8px solid #eaeaea;
    background-color: #f7f7f7;
}

.markdown-body blockquote blockquote {
    border-left: 8px solid #e3e3e3;
    background-color: #f0f0f0;
}

.markdown-body blockquote blockquote blockquote {
    border-left: 8px solid #dbdbdb;
    background-color: #e8e8e8;
}

.markdown-body blockquote blockquote blockquote blockquote {
    border-left: 8px solid #d4d4d4;
    background-color: #e0e0e0;
}

.markdown-body blockquote blockquote blockquote blockquote blockquote {
    border-left: 8px solid #ccc;
    background-color: #d9d9d9;
}

.markdown-body blockquote>*:first-child {
    margin-top: 0;
}

.markdown-body blockquote>*:last-child {
    margin-bottom: 0;
}

.markdown-body pre {
    margin: 1em 0;
    padding: 1em !important;
    overflow-x: auto;
    font-size: .9em;
    line-height: 1.2;
    background-color: #f0f0f0; 
    border: 1px solid #ddd; 
    border-radius: 3px;
}
/* Force Highlight.js to inherit the gray background from our <pre> block */
.markdown-body .hljs {
    background: transparent !important;
    padding: 0;
}

.markdown-body code {
    font-family: monospace;
    word-break: keep-all;
    word-wrap: break-word;
    line-height: 1.2;
}

.markdown-body pre>code table {
    margin: 0;
    border: 0;
}

.markdown-body pre>code table td {
    padding: 0;
    border: 0;
}

.markdown-body pre>code table td>pre {
    padding: 0 1em;
}

.markdown-body *:not(pre)>code {
    display: inline-block;
    margin: 0;
    padding: .2em .4em;
    font-size: .875em;
    background: #f0f0f0;
    border-radius: 3px;
}

.markdown-body blockquote *:not(pre)>code {
    background: #e8e8e8;
}

.markdown-body blockquote blockquote *:not(pre)>code {
    background: #e0e0e0;
}

.markdown-body blockquote blockquote blockquote *:not(pre)>code {
    background: #d9d9d9;
}

.markdown-body blockquote blockquote blockquote blockquote *:not(pre)>code {
    background: #d1d1d1;
}

.markdown-body blockquote blockquote blockquote blockquote blockquote *:not(pre)>code {
    background: #c9c9c9;
}

.markdown-body .highlight pre {
    tab-size: 4;
}

.markdown-body .seq-diagram,
.markdown-body .flow-diagram {
    text-align: center;
    overflow: auto;
}

.markdown-body table {
    margin: 1.6em 0;
    width: 100%;
    text-align: left;
    color: #3f3f3f;
    border-collapse: collapse;
    border: 1px solid #e8e8e8;
    font-size: 15px;
}

.markdown-body table tr:nth-child(odd) {
    background: #fafafa;
}

.markdown-body table tr:nth-child(even) {
    background: #f7f7f7;
}

.markdown-body table th,
.markdown-body td {
    padding: .5em .8em;
}

.markdown-body table th {
    background: #f0f0f0;
    border: 1px solid #dedede;
    border-bottom-width: 2px;
}

.markdown-body table td {
    border: 1px solid #e8e8e8;
}

.markdown-body table td>p:first-child {
    margin-top: 0;
}

.markdown-body table td>p:last-child {
    margin-bottom: 0;
}

/* ﹥ FAMOUS-UP EXTENSION - Table Filtering */
.markdown-body tr.famous-up-row-hidden {
    display: none !important;
}

.markdown-body .famous-up-filter-panel {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px 14px;
    margin: 12px 0;
    font-family: sans-serif;
    font-size: 13px;
}

.markdown-body .famous-up-filter-title {
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.markdown-body .famous-up-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.markdown-body .famous-up-filter-label {
    color: #333;
    font-weight: bold;
    margin-right: 4px;
}

.markdown-body .famous-up-filter-pill {
    background: #F0F0F0;
    color: #555;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: normal;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.markdown-body .famous-up-filter-pill:hover {
    background: #e8e8e8;
    color: #111;
}

.markdown-body .famous-up-filter-pill.active {
    background: #ffffff;
    color: #555;
    border: 1px solid #ccc;
    font-weight: bold;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.markdown-body .famous-up-pill-all {
    text-transform: uppercase;
    font-size: 12px;
}

.markdown-body hr {
    margin: 3.6em 0;
    width: 100%;
    border-top: none;
    border-bottom: 1px solid #ddd;
}

.markdown-body .t1,
.markdown-body .t2,
.markdown-body .t3 {
    margin: 3.6em 0;
    padding: 2em;
    width: 100%;
    border: 1px solid #ddd;
}

.markdown-body .t1 h1,
.markdown-body .t2 h2,
.markdown-body .t3 h3 {
    margin: 0;
}

.markdown-body figure {
    display: inline-block;
    text-align: center;
}

.markdown-body caption,
.markdown-body figcaption {
    display: block;
    margin: 0 0 1.6em 0;
    color: #888;
    font-size: .875em;
    text-align: center;
}

.markdown-body caption,
.markdown-body figcaption>strong {
    user-select: none;
    margin-right: .5em;
}

.markdown-body highlight {
    font-weight: 600;
    box-shadow: inset 0 -6px 0 #ffee58;
}


/* ﹥ DIFF2HTML - Diff2Html Preview Coloration */

:root {
    --d2h-dark-color:			                var(--color-text-primary);
    --d2h-dark-bg-color:			            var(--color-bg-app);
    --d2h-dark-border-color:			        var(--color-border);
    --d2h-dark-dim-color:			            var(--color-text-secondary);
    --d2h-dark-line-border-color:			    var(--color-border-subtle);
    --d2h-dark-file-header-bg-color:			var(--color-bg-panel);
    --d2h-dark-file-header-border-color:		var(--color-border-subtle);
    --d2h-dark-empty-placeholder-bg-color: hsla(215, 8%, 47%, .1);
    --d2h-dark-empty-placeholder-border-color:	var(--color-bg-panel);
    --d2h-dark-selected-color: rgba(56, 139, 253, .1);
    --d2h-dark-ins-bg-color: rgba(46, 160, 67, .15);
    --d2h-dark-ins-border-color: rgba(46, 160, 67, .4);
    --d2h-dark-ins-highlight-bg-color: rgba(46, 160, 67, .4);
    --d2h-dark-ins-label-color:			        var(--fm-green);
    --d2h-dark-del-bg-color: rgba(248, 81, 73, .1);
    --d2h-dark-del-border-color: rgba(248, 81, 73, .4);
    --d2h-dark-del-highlight-bg-color: rgba(248, 81, 73, .4);
    --d2h-dark-del-label-color:			        var(--fm-red);
    --d2h-dark-change-del-color: rgba(210, 153, 34, .2);
    --d2h-dark-change-ins-color: rgba(46, 160, 67, .25);
    --d2h-dark-info-bg-color: rgba(56, 139, 253, .1);
    --d2h-dark-info-border-color: rgba(56, 139, 253, .4);
    --d2h-dark-change-label-color:			    var(--fm-orange);
    --d2h-dark-moved-label-color:			    var(--fm-cyan);
    --d2h-moved-label-color:                    var(--fm-sky); /* for <a> */
}

/* Diff2Html container: avoid inheriting markdown-body font/spacing rules,
   keep it visually consistent with the dark editor theme. */
.d2h-body {
  padding: 0;
  font-family: var(--font-mono);
  background-color: transparent;
}

.d2h-body .d2h-file-wrapper { border-radius: 4px; }
