/*
 * Editorial Theme for Obsidian Publish
 * Warm Sand / Old Newspaper aesthetic
 */

/* ========================================
   FONTS - DM Sans & DM Serif Display
   ======================================== */

@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=DM+Serif+Display:ital@0;1&display=swap");

/* ========================================
   EDITORIAL COLOR PALETTE
   ======================================== */

:root {
    /* Light Mode - Warm Cream/Sand */
    --editorial-bg: #faf8f5;
    --editorial-bg-alt: #f5f2ed;
    --editorial-bg-secondary: #ede9e3;
    --editorial-bg-muted: #e5e0d8;

    --editorial-fg: #2c2825;
    --editorial-fg-secondary: #4a4540;
    --editorial-fg-muted: #6b6560;
    --editorial-fg-faint: #8a847d;

    --editorial-border: #ddd8d0;
    --editorial-border-strong: #c5bfb5;

    /* Accent - subtle forest green for links only */
    --editorial-accent: #4a6741;
    --editorial-accent-hover: #3d5636;

    /* Dark Mode - Deep Warm Brown */
    --editorial-dark-bg: #1e1c1a;
    --editorial-dark-bg-alt: #262321;
    --editorial-dark-bg-secondary: #302c28;
    --editorial-dark-bg-muted: #3a3632;

    --editorial-dark-fg: #e8e4dc;
    --editorial-dark-fg-secondary: #c5c0b8;
    --editorial-dark-fg-muted: #9a958d;
    --editorial-dark-fg-faint: #706b63;

    --editorial-dark-border: rgba(255, 255, 255, 0.1);
    --editorial-dark-border-strong: rgba(255, 255, 255, 0.15);

    --editorial-dark-accent: #7a9a70;
    --editorial-dark-accent-hover: #8fb085;
}

/* ========================================
   DARK THEME (Default)
   ======================================== */

.published-container {
    /* Base colors */
    --background-primary: var(--editorial-dark-bg);
    --background-primary-alt: var(--editorial-dark-bg-alt);
    --background-secondary: var(--editorial-dark-bg-secondary);
    --background-secondary-alt: var(--editorial-dark-bg-muted);
    --background-modifier-border: var(--editorial-dark-border);
    --background-modifier-form-field: var(--editorial-dark-bg-secondary);
    --background-modifier-cover: rgba(30, 28, 26, 0.9);

    /* Text colors - monotone */
    --text-normal: var(--editorial-dark-fg);
    --text-muted: var(--editorial-dark-fg-muted);
    --text-faint: var(--editorial-dark-fg-faint);
    --text-accent: var(--editorial-dark-accent);
    --text-accent-hover: var(--editorial-dark-accent-hover);
    --text-on-accent: var(--editorial-dark-bg);

    /* Interactive elements */
    --interactive-normal: var(--editorial-dark-bg-secondary);
    --interactive-hover: var(--editorial-dark-bg-muted);
    --interactive-accent: var(--editorial-dark-accent);
    --interactive-accent-hover: var(--editorial-dark-accent-hover);

    /* Links - subtle accent */
    --link-color: var(--editorial-dark-accent);
    --link-color-hover: var(--editorial-dark-accent-hover);
    --link-external-color: var(--editorial-dark-fg-muted);
    --link-external-color-hover: var(--editorial-dark-fg-secondary);
    --link-unresolved-color: var(--editorial-dark-fg-faint);

    /* Headings - all same warm tone */
    --heading-color: var(--editorial-dark-fg);

    /* Code */
    --code-normal: var(--editorial-dark-fg-secondary);
    --code-background: var(--editorial-dark-bg-secondary);

    /* Page title */
    --page-title-font: "DM Serif Display", serif;
    --page-title-color: var(--editorial-dark-fg);
    --site-name-font: "DM Serif Display", serif;

    /* Site header */
    --site-name-color: var(--editorial-dark-fg);
    --site-name-color-hover: var(--editorial-dark-fg-secondary);
    --site-menu-icon-color: var(--editorial-dark-fg-muted);
    --site-menu-icon-color-hover: var(--editorial-dark-fg);
    --header-height: 60px;

    /* Navigation */
    --nav-collapse-icon-color: var(--editorial-dark-fg-faint);
    --nav-collapse-icon-color-hover: var(--editorial-dark-fg-muted);
    --nav-parent-item-color: var(--editorial-dark-fg-secondary);
    --nav-parent-item-color-active: var(--editorial-dark-fg);
    --nav-item-color: var(--editorial-dark-fg-muted);
    --nav-item-color-hover: var(--editorial-dark-fg-secondary);
    --nav-item-color-active: var(--editorial-dark-fg);
    --nav-item-border-color: var(--editorial-dark-border);
    --nav-item-border-color-hover: var(--editorial-dark-border-strong);
    --nav-item-border-color-active: var(--editorial-dark-fg-faint);

    /* Sidebars */
    --sidebar-left-background: var(--editorial-dark-bg);
    --sidebar-left-border-color: var(--editorial-dark-border);
    --sidebar-right-background: var(--editorial-dark-bg);
    --sidebar-right-border-color: var(--editorial-dark-border);

    /* Components */
    --component-title-color: var(--editorial-dark-fg-muted);

    /* Outline / Table of Contents */
    --outline-heading-color: var(--editorial-dark-fg-muted);
    --outline-heading-color-hover: var(--editorial-dark-fg-secondary);
    --outline-heading-color-active: var(--editorial-dark-fg);

    /* Graph */
    --graph-line: var(--editorial-dark-fg-faint);
    --graph-node: var(--editorial-dark-fg-muted);
    --graph-node-active: var(--editorial-dark-fg);
    --graph-node-focused: var(--editorial-dark-fg);

    /* Inherited app variables — override defaults that clash with the editorial palette
       (the Obsidian defaults pull from --color-purple / accent hue 254, which shows up in
       italics, list markers, tag tints, callout titles, etc.) */

    /* Accent HSL — drives small UI accents (highlights, focus, checkboxes) */
    --accent-h: 109;
    --accent-s: 18%;
    --accent-l: 52%;

    /* Bold / italic — default italic is purple */
    --bold-color: var(--text-normal);
    --italic-color: var(--text-normal);

    /* Headings — keep all monotone */
    --h1-color: var(--heading-color);
    --h2-color: var(--heading-color);
    --h3-color: var(--heading-color);
    --h4-color: var(--heading-color);
    --h5-color: var(--heading-color);
    --h6-color: var(--heading-color);
    --heading-formatting: var(--text-faint);
    --inline-title-color: var(--heading-color);

    /* Blockquote */
    --blockquote-color: var(--text-muted);
    --blockquote-border-color: var(--background-modifier-border);
    --blockquote-background-color: transparent;

    /* Callout */
    --callout-title-color: var(--text-normal);
    --callout-content-background: transparent;

    /* Embed */
    --embed-background: var(--background-secondary);

    /* Horizontal rule */
    --hr-color: var(--background-modifier-border);

    /* Lists */
    --list-marker-color: var(--text-muted);
    --list-marker-color-hover: var(--text-normal);
    --list-marker-color-collapsed: var(--text-faint);

    /* Tables */
    --table-background: transparent;
    --table-border-color: var(--background-modifier-border);
    --table-header-background: var(--background-secondary);
    --table-header-background-hover: var(--background-secondary-alt);
    --table-header-border-color: var(--background-modifier-border);
    --table-header-color: var(--text-normal);
    --table-text-color: var(--text-normal);
    --table-row-alt-background: var(--background-primary-alt);
    --table-row-background-hover: var(--background-secondary);
    --table-row-alt-background-hover: var(--background-secondary);
    --table-selection: var(--background-secondary-alt);
    --table-selection-border-color: var(--editorial-dark-border-strong);

    /* Tags */
    --tag-color: var(--text-muted);
    --tag-color-hover: var(--text-normal);
    --tag-background: var(--background-secondary);
    --tag-background-hover: var(--background-secondary-alt);
    --tag-border-color: transparent;
    --tag-border-color-hover: var(--background-modifier-border);

    /* Link decoration */
    --link-unresolved-decoration-color: var(--text-faint);
}

/* Shared fonts — per Publish docs, font variables go on body */
body {
    --font-text-theme: "DM Sans", sans-serif;
    --font-interface-theme: "DM Sans", sans-serif;
    --font-monospace-theme: "JetBrains Mono", "Fira Code", "SF Mono", monospace;
    --font-text-size: 17px;
}

/* Override accent HSL globally so anything outside .published-container
   (sidebars, header, any cascade fallback) also picks up the editorial green instead of
   Obsidian's default purple (h:258, s:88%, l:66%). Set on both .theme-X and the body
   inside it so the override holds whether the theme class lives on <html> or <body>. */
.theme-dark,
.theme-dark body {
    --accent-h: 109;
    --accent-s: 18%;
    --accent-l: 52%;
}

.theme-light,
.theme-light body {
    --accent-h: 108;
    --accent-s: 22%;
    --accent-l: 33%;
}

/* ========================================
   LIGHT THEME
   ======================================== */

.theme-light .published-container {
    /* Base colors */
    --background-primary: var(--editorial-bg);
    --background-primary-alt: var(--editorial-bg-alt);
    --background-secondary: var(--editorial-bg-secondary);
    --background-secondary-alt: var(--editorial-bg-muted);
    --background-modifier-border: var(--editorial-border);
    --background-modifier-form-field: var(--editorial-bg-secondary);
    --background-modifier-cover: rgba(250, 248, 245, 0.9);

    /* Text colors - monotone */
    --text-normal: var(--editorial-fg);
    --text-muted: var(--editorial-fg-muted);
    --text-faint: var(--editorial-fg-faint);
    --text-accent: var(--editorial-accent);
    --text-accent-hover: var(--editorial-accent-hover);
    --text-on-accent: var(--editorial-bg);

    /* Interactive elements */
    --interactive-normal: var(--editorial-bg-secondary);
    --interactive-hover: var(--editorial-bg-muted);
    --interactive-accent: var(--editorial-accent);
    --interactive-accent-hover: var(--editorial-accent-hover);

    /* Links - subtle accent */
    --link-color: var(--editorial-accent);
    --link-color-hover: var(--editorial-accent-hover);
    --link-external-color: var(--editorial-fg-muted);
    --link-external-color-hover: var(--editorial-fg-secondary);
    --link-unresolved-color: var(--editorial-fg-faint);

    /* Headings - all same warm tone */
    --heading-color: var(--editorial-fg);

    /* Code */
    --code-normal: var(--editorial-fg-secondary);
    --code-background: var(--editorial-bg-secondary);

    /* Page title */
    --page-title-color: var(--editorial-fg);

    /* Site header */
    --site-name-color: var(--editorial-fg);
    --site-name-color-hover: var(--editorial-fg-secondary);
    --site-menu-icon-color: var(--editorial-fg-muted);
    --site-menu-icon-color-hover: var(--editorial-fg);

    /* Navigation */
    --nav-collapse-icon-color: var(--editorial-fg-faint);
    --nav-collapse-icon-color-hover: var(--editorial-fg-muted);
    --nav-parent-item-color: var(--editorial-fg-secondary);
    --nav-parent-item-color-active: var(--editorial-fg);
    --nav-item-color: var(--editorial-fg-muted);
    --nav-item-color-hover: var(--editorial-fg-secondary);
    --nav-item-color-active: var(--editorial-fg);
    --nav-item-border-color: var(--editorial-border);
    --nav-item-border-color-hover: var(--editorial-border-strong);
    --nav-item-border-color-active: var(--editorial-fg-faint);

    /* Sidebars */
    --sidebar-left-background: var(--editorial-bg-alt);
    --sidebar-left-border-color: var(--editorial-border);
    --sidebar-right-background: var(--editorial-bg);
    --sidebar-right-border-color: var(--editorial-border);

    /* Components */
    --component-title-color: var(--editorial-fg-muted);

    /* Outline / Table of Contents */
    --outline-heading-color: var(--editorial-fg-muted);
    --outline-heading-color-hover: var(--editorial-fg-secondary);
    --outline-heading-color-active: var(--editorial-fg);

    /* Graph */
    --graph-line: var(--editorial-fg-faint);
    --graph-node: var(--editorial-fg-muted);
    --graph-node-active: var(--editorial-fg);
    --graph-node-focused: var(--editorial-fg);

    /* Inherited app variables — override defaults that clash with the editorial palette */
    --accent-h: 108;
    --accent-s: 22%;
    --accent-l: 33%;

    --bold-color: var(--text-normal);
    --italic-color: var(--text-normal);

    --h1-color: var(--heading-color);
    --h2-color: var(--heading-color);
    --h3-color: var(--heading-color);
    --h4-color: var(--heading-color);
    --h5-color: var(--heading-color);
    --h6-color: var(--heading-color);
    --heading-formatting: var(--text-faint);
    --inline-title-color: var(--heading-color);

    --blockquote-color: var(--text-muted);
    --blockquote-border-color: var(--background-modifier-border);
    --blockquote-background-color: transparent;

    --callout-title-color: var(--text-normal);
    --callout-content-background: transparent;

    --embed-background: var(--background-secondary);

    --hr-color: var(--background-modifier-border);

    --list-marker-color: var(--text-muted);
    --list-marker-color-hover: var(--text-normal);
    --list-marker-color-collapsed: var(--text-faint);

    --table-background: transparent;
    --table-border-color: var(--background-modifier-border);
    --table-header-background: var(--background-secondary);
    --table-header-background-hover: var(--background-secondary-alt);
    --table-header-border-color: var(--background-modifier-border);
    --table-header-color: var(--text-normal);
    --table-text-color: var(--text-normal);
    --table-row-alt-background: var(--background-primary-alt);
    --table-row-background-hover: var(--background-secondary);
    --table-row-alt-background-hover: var(--background-secondary);
    --table-selection: var(--background-secondary-alt);
    --table-selection-border-color: var(--editorial-border-strong);

    --tag-color: var(--text-muted);
    --tag-color-hover: var(--text-normal);
    --tag-background: var(--background-secondary);
    --tag-background-hover: var(--background-secondary-alt);
    --tag-border-color: transparent;
    --tag-border-color-hover: var(--background-modifier-border);

    --link-unresolved-decoration-color: var(--text-faint);
}

/* ========================================
   TYPOGRAPHY & ELEMENTS
   ======================================== */

/* Body background - adapts to theme */
body,
.publish-renderer {
    background-color: var(--editorial-dark-bg);
}

.theme-light body,
.theme-light .publish-renderer {
    background-color: var(--editorial-bg);
}

/* Headings - all monotone, serif for h1-h2, sans for rest */
.published-container h1,
.published-container h2,
.published-container h3,
.published-container h4,
.published-container h5,
.published-container h6 {
    color: var(--heading-color);
}

.published-container h1 {
    font-family: "DM Serif Display", serif;
    font-weight: 400;
    font-size: 2.25em;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

.published-container h2 {
    font-family: "DM Serif Display", serif;
    font-weight: 400;
    font-size: 1.75em;
    line-height: 1.25;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--background-modifier-border);
}

.published-container h3 {
    font-family: "DM Sans", sans-serif;
    font-weight: 600;
    font-size: 1.35em;
    line-height: 1.3;
    margin-top: 1.25em;
}

.published-container h4 {
    font-family: "DM Sans", sans-serif;
    font-weight: 600;
    font-size: 1.15em;
    line-height: 1.4;
}

.published-container h5,
.published-container h6 {
    font-family: "DM Sans", sans-serif;
    font-weight: 500;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Links - subtle, editorial style */
.published-container a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.published-container a:hover {
    color: var(--link-color-hover);
}

/* External links */
.published-container a.external-link {
    color: var(--link-external-color);
}

.published-container a.external-link:hover {
    color: var(--link-external-color-hover);
}

/* Code blocks */
.published-container pre {
    background-color: var(--code-background);
    border: 1px solid var(--background-modifier-border);
    border-radius: 4px;
    padding: 1em;
    font-size: 0.9em;
    overflow-x: auto;
}

.published-container code {
    color: var(--code-normal);
    background-color: var(--code-background);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.published-container pre code {
    padding: 0;
    background: none;
}

/* Syntax highlighting - monotone with subtle variation */
.published-container .token.comment,
.published-container .token.prolog,
.published-container .token.doctype,
.published-container .token.cdata {
    color: var(--text-faint);
    font-style: italic;
}

.published-container .token.punctuation {
    color: var(--text-muted);
}

.published-container .token.property,
.published-container .token.tag,
.published-container .token.boolean,
.published-container .token.number,
.published-container .token.constant,
.published-container .token.symbol {
    color: var(--text-normal);
}

.published-container .token.selector,
.published-container .token.attr-name,
.published-container .token.string,
.published-container .token.char,
.published-container .token.builtin {
    color: var(--text-muted);
}

.published-container .token.operator,
.published-container .token.entity,
.published-container .token.url {
    color: var(--text-muted);
}

.published-container .token.atrule,
.published-container .token.attr-value,
.published-container .token.keyword {
    color: var(--text-normal);
    font-weight: 500;
}

.published-container .token.function,
.published-container .token.class-name {
    color: var(--text-normal);
}

.published-container .token.regex,
.published-container .token.important,
.published-container .token.variable {
    color: var(--text-muted);
}

/* Blockquotes - editorial style */
.published-container blockquote {
    border-left: 3px solid var(--background-modifier-border);
    background-color: transparent;
    padding: 0.25em 0 0.25em 1.5em;
    margin: 1.5em 0;
    color: var(--text-muted);
    font-style: italic;
}

.published-container blockquote p {
    margin: 0.5em 0;
}

/* Tables */
.published-container table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
}

.published-container th,
.published-container td {
    border: 1px solid var(--background-modifier-border);
    padding: 0.6em 1em;
    text-align: left;
}

.published-container th {
    background-color: var(--background-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.03em;
}

.published-container tr:nth-child(even) {
    background-color: var(--background-primary-alt);
}

/* Horizontal rules - editorial divider */
.published-container hr {
    border: none;
    border-top: 1px solid var(--background-modifier-border);
    margin: 2.5em 0;
}

/* Lists */
.published-container ul,
.published-container ol {
    padding-left: 1.5em;
    margin: 1em 0;
}

.published-container li {
    margin: 0.35em 0;
}

.published-container li::marker {
    color: var(--text-muted);
}

/* Bold and italic - subtle emphasis */
.published-container strong {
    font-weight: 600;
    color: var(--text-normal);
}

.published-container em {
    font-style: italic;
}

/* Images */
.published-container img {
    border-radius: 4px;
    max-width: 100%;
}

/* Image captions */
.published-container img + em,
.published-container figure figcaption {
    display: block;
    text-align: center;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 0.75em;
    font-style: italic;
}

/* Selection */
.published-container ::selection {
    background-color: var(--editorial-dark-bg-muted);
    color: var(--editorial-dark-fg);
}

.theme-light .published-container ::selection {
    background-color: var(--editorial-bg-muted);
    color: var(--editorial-fg);
}

/* Scrollbar */
.published-container ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.published-container ::-webkit-scrollbar-track {
    background: transparent;
}

/* Right column wrapper — keep transparent so the scrollbar doesn't sit on a tinted band behind the graph */
.published-container .site-body-right-column {
    background: transparent;
}

.published-container ::-webkit-scrollbar-thumb {
    background: var(--text-faint);
    border-radius: 4px;
}

.published-container ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* MathJax */
.published-container .MathJax {
    color: var(--text-normal);
}

/* Callouts - subtle, monotone */
.published-container .callout {
    border-radius: 4px;
    padding: 1em;
    margin: 1.5em 0;
    background-color: var(--background-secondary);
    border-left: 3px solid var(--background-modifier-border);
}

.published-container .callout-title {
    font-weight: 600;
    margin-bottom: 0.5em;
}

/* Tags - subtle */
.published-container .tag {
    background-color: var(--background-secondary);
    color: var(--text-muted);
    padding: 0.15em 0.5em;
    border-radius: 3px;
    font-size: 0.85em;
}

.published-container .tag:hover {
    background-color: var(--background-secondary-alt);
    color: var(--text-normal);
}

/* Page width for readability */
.published-container {
    --page-width: 720px;
    --page-padding: 2rem;
}

/* Drop cap for first paragraph (newspaper style) - optional */
.published-container .markdown-preview-sizer > p:first-of-type::first-letter {
    float: left;
    font-family: "DM Serif Display", serif;
    font-size: 3.5em;
    line-height: 0.8;
    padding-right: 0.1em;
    margin-top: 0.05em;
    color: var(--text-normal);
}
