/* ========================= */
/* == Obsidian: Rich Foot == */
/* ========================= */

/* ------------------------------ */
/* -- General Rich Foot Styles -- */
/* ------------------------------ */
.rich-foot {
    /* Layout optimization */
    contain: layout style;
    min-height: 0;

    /* Spacing */
    margin-top: 30px !important;
    margin-bottom: 20px !important;
    padding-top: 10px !important;

    /* Animation setup */
    opacity: 1;
    transform: translateY(0);
    will-change: opacity, transform;
    transition: opacity 600ms ease-in-out, transform 600ms ease-in-out;
}

.rich-foot--hidden {
    opacity: 0;
    transform: translateY(-2px);
}

/* ---------------------- */
/* -- Backlinks Styles -- */
/* ---------------------- */
.rich-foot--backlinks,
.rich-foot--outlinks,
.rich-foot--links {
    opacity: var(--rich-foot-links-opacity, 1);
}

.rich-foot--backlinks::before { content: 'Backlinks';}
.rich-foot--outlinks::before { content: 'Outlinks';}
.rich-foot--links::before { content: 'Links';}
.rich-foot--backlinks::before,
.rich-foot--outlinks::before,
.rich-foot--links::before {
    text-transform: uppercase;
    filter: brightness(150%);
    position: relative;
    bottom: 0;
    font-size: 0.7em;
    color: var(--rich-foot-link-color, var(--text-accent));
}

.rich-foot--backlinks ul,
.rich-foot--outlinks ul,
.rich-foot--links ul {
    list-style: none;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    margin: 0 !important;
    padding-left: 20px !important;
}

.rich-foot--backlinks ul li,
.rich-foot--outlinks ul li,
.rich-foot--links ul li {
    margin-inline-start: 0 !important;
}

.rich-foot--backlinks ul li a,
.rich-foot--outlinks ul li a,
.rich-foot--links ul li a,
.rich-foot--backlinks ul li .rich-foot--show-more,
.rich-foot--outlinks ul li .rich-foot--show-more,
.rich-foot--links ul li .rich-foot--show-more {
    /* Appearance */
    filter: brightness(120%);
    text-decoration: none !important;
    font-size: 12px;
    padding: 0 8px;
    text-transform: lowercase;
    text-align: center;
    display: inline-block;
    margin: 0 4px;
    cursor: pointer;

    /* Styling */
    border-radius: var(--rich-foot-border-radius, 15px);
    border: 1px solid var(--rich-foot-link-border-color, rgba(255, 255, 255, 0.204));
    color: var(--rich-foot-link-color, var(--link-color));
    background-color: var(--rich-foot-link-background, var(--tag-background));

    /* Performance optimization */
    will-change: filter, border-color;
    transition: 150ms ease-in-out all;
}

.rich-foot--backlinks ul li a::before,
.rich-foot--links ul li a[data-is-backlink="true"]::before {
    content: "⇠ ";
    opacity: .5;
}

.rich-foot--outlinks ul li a::after,
.rich-foot--links ul li a[data-is-outlink="true"]::after {
    content: " ⇢";
    opacity: .5;
}

.rich-foot--backlinks ul li a:hover,
.rich-foot--outlinks ul li a:hover,
.rich-foot--links ul li a:hover,
.rich-foot--backlinks ul li .rich-foot--show-more:hover,
.rich-foot--outlinks ul li .rich-foot--show-more:hover,
.rich-foot--links ul li .rich-foot--show-more:hover {
    filter: brightness(170%);
    border: 1px solid transparent !important;
    text-decoration: none;
}

/* ----------------------------- */
/* -- Show More / Limit Links -- */
/* ----------------------------- */
.rich-foot--backlinks ul li.rich-foot--link-hidden,
.rich-foot--outlinks ul li.rich-foot--link-hidden,
.rich-foot--links ul li.rich-foot--link-hidden {
    display: none !important;
}

.rich-foot--backlinks ul li .rich-foot--show-more,
.rich-foot--outlinks ul li .rich-foot--show-more,
.rich-foot--links ul li .rich-foot--show-more {
    /* The shared pill rule above provides all rich-foot user-setting styling
       (link color, background, border color, radius, padding, font-size) via the
       --rich-foot-* variables, so this control automatically tracks the user's
       visual settings. These declarations only neutralize the native <button>
       chrome so it renders identically to the <a> link pills. */
    font-family: inherit;
    font-weight: inherit;
    font-style: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    vertical-align: baseline;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    /* Obsidian's app stylesheet gives <button> an intrinsic height/vertical
       padding that an <a> doesn't have; collapse it so the pill height matches
       the link pills exactly. */
    height: auto;
    min-height: 0;
    padding: 0 8px;
}

.rich-foot--show-more::before,
.rich-foot--show-more::after {
    content: none !important;
}

/* ----------------- */
/* -- Date Styles -- */
/* ----------------- */
.rich-foot--created-date,
.rich-foot--modified-date {
    display: flex;
    flex-direction: row;
    align-items: center;
    list-style: none;
    margin-top: 10px;
    padding-left: 0;
    font-size: .8em;
    filter: brightness(85%);
    color: var(--rich-foot-date-color, var(--text-accent));
    opacity: var(--rich-foot-dates-opacity, 1);
}

.rich-foot--created-date {
    margin-right: 20px;
    margin-left: 20px;
}

.rich-foot--created-date::before,
.rich-foot--modified-date::before {
    font-size: .7em;
    text-transform: uppercase;
    padding: 2px 8px 0 0;
    color: var(--rich-foot-date-color, var(--text-accent));
}

.rich-foot--created-date::before {
    content: "created date";
}

.rich-foot--modified-date::before {
    content: "modified date";
}

/* --------------------------- */
/* -- Theme-specific Styles -- */
/* --------------------------- */
body.theme-light .rich-foot--backlinks::before,
body.theme-light .rich-foot--backlinks ul li a {
    filter: brightness(80%);
}

/* ---------------------------- */
/* -- Editor-specific Styles -- */
/* ---------------------------- */
.cm-sizer {
    width: 100%;
    padding-bottom: 0 !important;
}

.cm-sizer > .rich-foot {
    margin-top: 15px !important;
    max-width: var(--max-width);
    /* Cap at the container width so the footer can never grow wider than the
       editor and force horizontal scrolling on narrow screens (e.g. mobile). */
    width: min(var(--line-width, 100%), 100%);
    margin-inline: var(--content-margin) !important;
}

.cm-sizer .rich-foot--backlinks {
    margin-top: 0;
}

.cm-scroller .cm-contentContainer > .cm-content,
.markdown-source-view .cm-contentContainer > .cm-content {
    padding-top: 0 !important;
    padding-bottom: unset !important;
}

.cm-scroller .rich-foot--backlinks,
.markdown-source-view .rich-foot--backlinks {
    margin-top: 0;
}

.cm-scroller .rich-foot--created-date,
.cm-scroller .rich-foot--modified-date,
.markdown-source-view .rich-foot--created-date,
.markdown-source-view .rich-foot--modified-date,
.cm-sizer .rich-foot--created-date,
.cm-sizer .rich-foot--modified-date {
    display: inline-block;
    margin-right: 20px;
}

/* ---------------------------- */
/* -- Preview-specific Styles -- */
/* ---------------------------- */
.markdown-preview-sizer {
    width: 100%;
    padding-bottom: 0 !important;
}

.markdown-reading-view .markdown-preview-sizer {
    width: 100%;
    /* Use flexbox to push footer to bottom */
    display: flex;
    flex-direction: column;
    min-height: 100% !important;
}

/* Push footer to bottom of visible area */
.markdown-reading-view .markdown-preview-sizer > .rich-foot {
    margin-top: auto !important;
    padding-top: 20px !important;
    padding-bottom: 0 !important;
    margin-bottom: 20px !important;
}

/* ----------------------------------- */
/* -- Footer Width (Readable Length) -- */
/* ----------------------------------- */
/*
 * Issue #78: let users lock the footer to Obsidian's "Readable line length" or
 * to a custom max width, and keep it centered. In every mode the footer is
 * capped at 100% of its container, so it can never grow wider than the note and
 * introduce horizontal scrolling on narrow screens (e.g. mobile).
 *
 * The active mode is set on <body data-rich-foot-width="..."> by the plugin.
 */

/* Readable line length — reading & edit modes */
body[data-rich-foot-width="readable"] .markdown-preview-sizer > .rich-foot,
body[data-rich-foot-width="readable"] .cm-sizer > .rich-foot {
    max-width: min(var(--file-line-width, var(--max-width, 100%)), 100%);
    width: 100%;
    margin-inline: auto !important;
}

/* Custom max width (px) — reading & edit modes */
body[data-rich-foot-width="custom"] .markdown-preview-sizer > .rich-foot,
body[data-rich-foot-width="custom"] .cm-sizer > .rich-foot {
    max-width: min(var(--rich-foot-content-max-width, 700px), 100%);
    width: 100%;
    margin-inline: auto !important;
}

/* ----------- */
/* -- other -- */
/* ----------- */

/* fix note embed height scroll in canvas */
.canvas-node-content.markdown-embed div.cm-sizer,
.canvas-node-content.markdown-embed div.markdown-preview-sizer {
    min-height: unset !important;
}

.rich-foot > .rich-foot--dashed-line {
    border-top-width: var(--rich-foot-border-width, 1px);
    border-top-style: var(--rich-foot-border-style, dashed);
    border-top-color: var(--rich-foot-border-color, var(--text-accent));
    opacity: var(--rich-foot-border-opacity, 1);
}

.rich-foot > .rich-foot--dates-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    color: var(--rich-foot-date-color);
}

/* Settings styles */
.rich-foot-settings input[type='text'],
.rich-foot-settings input[type='number'] {
    text-align: right;
}

/* --------------------- */
/* -- Settings Styles -- */
/* --------------------- */
.rich-foot-settings {
    display: flex;
    flex-direction: column;
}

.rich-foot-settings .rich-foot-info {
    margin-bottom: 10px;
    padding: 15px 20px;
    background-color: var(--background-secondary);
    color: var(--text-accent-hover);
    border-radius: 10px;
}

.rich-foot-settings .rich-foot-example-title {
    margin-top: 60px;
    margin-bottom: 10px;
    border-top: 1px solid var(--text-accent);
    padding-top: 30px;
}

.rich-foot-settings .rich-foot-example {
    margin-top: 20px;
    margin-bottom: 20px;
}

.rich-foot-settings .rich-foot-example img {
    max-width: 100%;
    height: auto;
}

.rich-foot-settings .setting-item {
    border: none;
    background-color: var(--background-secondary);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.rich-foot-settings .setting-item-name {
    font-weight: bold;
}

.rich-foot-settings .setting-item-description {
    font-size: 0.9em;
    opacity: 0.8;
}

.rich-foot-settings textarea {
    background-color: var(--background-primary-alt);
    border: 1px solid var(--background-modifier-border);
    border-radius: 5px;
    padding: 10px;
    font-family: var(--font-monospace);
    width: 400px !important;
    height: 250px !important;
    resize: vertical;
}

.excluded-folders-container {
    margin-bottom: 24px;
}

.excluded-folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    margin: 4px 0;
    background-color: var(--background-secondary);
    border-radius: 4px;
}

.excluded-folder-delete {
    padding: 4px 8px;
    color: var(--text-error);
    background-color: transparent;
    border: 1px solid var(--text-error);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 150ms ease, color 150ms ease;
}

.excluded-folder-delete:hover {
    background-color: var(--text-error);
    color: var(--text-on-accent);
}

/* Release Notes Modal */
.release-notes-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    background-color: var(--background-secondary);
}

.release-notes-container img {
    max-width: 100%;
}

.release-notes-instructions {
    font-size: 0.75em;
    font-weight: 300;
    letter-spacing: 2px;
}

.release-notes-section {
    margin: 10px 0;
}

.release-notes-section h4 {
    margin: 15px 0 5px 0;
    color: var(--text-accent-hover);
}

.release-notes-container > ul {
    padding-left: 25px;
}
.release-notes-container ul:not(:last-of-type) {
    padding-bottom: 20px;
}

.release-notes-section ul {
    margin: 0;
    padding-left: 20px;
}

.release-notes-container li,
.release-notes-section li {
    margin: 5px 0;
}

.release-notes-spacer {
    margin: 10px 0;
    height: 20px;
}

.release-notes-promotional-links {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

/* Inline error feedback for invalid CSS selector input in settings */
.rich-foot-input-error {
    color: var(--text-error);
}

/* Color Swatches Grid */
.color-swatches-container {
    margin: 12px 0;
    padding: 12px;
    background-color: var(--background-secondary);
    border-radius: 10px;
}

.color-swatches-container h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
}

.color-swatches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 150ms ease;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: var(--text-accent);
    transform: scale(1.2);
}

/* Slider Styles */
.rich-foot-settings .setting-item input[type="range"] {
    width: 150px;
}

/* Reset Buttons */
.rich-foot-settings .setting-item button {
    font-size: 12px;
    padding: 4px 8px;
    margin-left: 8px;
    transition: opacity 150ms ease;
}

/* Excluded selectors */
.excluded-selectors-container {
    margin-bottom: 24px;
}

.excluded-selector-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    margin: 4px 0;
    background-color: var(--background-secondary);
    border-radius: 4px;
    font-family: var(--font-monospace);
    font-size: 0.9em;
}

.excluded-selector-delete {
    padding: 4px 8px;
    color: var(--text-error);
    background-color: transparent;
    border: 1px solid var(--text-error);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 150ms ease, color 150ms ease;
}

.excluded-selector-delete:hover {
    background-color: var(--text-error);
    color: var(--text-on-accent);
}
