/* language support */
/* render Arabic, Persian, Ottoman, Hebrew and Yiddish as rtl */
[lang = "ar"], [lang = "ota"], [lang = "fa"], [lang = "he"], [lang = "yi"], [lang *="-Arab-AR"]{
    direction: rtl;
    text-align: right;
}
/* render Latin and some other scripts as ltr */
[lang = "en"], [lang = "fr"], [lang = "de"], [lang = "it"], [lang = "ru"], [lang = "pl"], [lang *="ar-Latn-"], [lang *="ota-Latn-"] {
    direction: ltr;
    text-align: left;
}

html {
    font-size: var(--base-font-size);
}

/**
 * Reset some basic elements
 */
body, h1, h2, h3, h4, h5, h6, p, tei-p, blockquote, pre, hr, dl, dd, ol, ul, figure {
    margin: 0;
    padding: 0;
}

/**
 * Basic styling
 */
body {
    font: var(--base-font-weight) var(--base-font-size) var(--base-font-family);
    line-height: var(--base-line-height);
    color: var(--text-color);
    background-color: var(--background-color);
    -webkit-text-size-adjust: 100%;
    -webkit-font-feature-settings: "kern" 1;
    -moz-font-feature-settings: "kern" 1;
    -o-font-feature-settings: "kern" 1;
    font-feature-settings: "kern" 1;
    font-kerning: normal;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    overflow-wrap: break-word;
}

/**
 * Set `margin-bottom` to maintain vertical rhythm
 */
h1, h2, h3, h4, h5, h6, p, blockquote, ul, ol, dl, figure, div.footnotes {
    margin-bottom: var(--spacing-unit-half);
}

hr {
    margin-top: var(--spacing-unit);
    margin-bottom: var(--spacing-unit);
}


/**
 * `main` element
 */
main {
    display: block; /* Default value of `display` of `main` element is 'inline' in IE 11. */
}

/**
 * Images
 */
img {
    max-width: 100%;
    vertical-align: middle;
}

/**
 * Figures
 */
figure > img {
    display: block;
    vertical-align: top;
}

figcaption {
    font-size: var(--small-font-size);
}


figure { /*TEI*/
    display: inline-block;
}

figure > tei-head {
    display: block;
    margin: 1.5em auto 1.5em auto;
    padding: .5em 1.5em 1.5em 1.5em;
    border: 1px solid black;
    border-radius: 15px;
    width: 85%;
    position: relative;
    background: white;
    /* reset text-indent for note with <l> ancestors. */
    text-indent: 0;
    font-family: Georgia, serif;
    font-size: 85%;
    text-align: justify;
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/*Paragraph*/
p, tei-p {
    display: block;
    margin-top: 1em;
    margin-bottom: 1em;
    /*text-align: justify;*/
}

*[rendition~="#center"] tei-p {
    text-align: center;
}


/**
 * Lists
 */
ul, ol {
    margin-left: var(--spacing-unit);
}

li {
    > ul,
    > ol {
        margin-bottom: 0;
    }
}

/*Lists*/
ul, ol, list, listBibl {
    display: block;
}

item, listBibl > bibl {
    display: list-item;
    margin-left: 1em;
    /*text-align: -webkit-match-parent;*/
}

li { > ul, > ol { margin-bottom: 0; }}
item { > list, > listBibl { margin-bottom: 0; }}

/*TEI*/
/*Match only lists that are descendants of text. Otherwise they show up in the header.*/
/*LMD: since I have an HTML/TEI mix, and TEI text element may not be present, I disabled it...*/
list, list[type=simple], list[type=ordered], listBibl {
    list-style-type: none;
}

list[type=bulleted] { list-style-type: disc; }

list[type=ordered] {
    counter-reset: items 0;
}
list[type=ordered] > item:before {
    counter-increment: items 1;
    content: counter(items, decimal) ". ";
}
list[type=ordered] > /*tei|*/item {
    margin-left: 0;
}
item > list[type=ordered] {
    margin-left: 1em;
}
list[type="gloss"] { list-style-type: none; }
list[type="gloss"] > label {
    display: block;
    margin-top: 0.25em;
    margin-bottom: 0.25em;
    font-weight: bold;
}
list[type="gloss"] > item {
    margin-left: 2em;
}
listBibl {
    margin-left: .5em;
    margin-top: .5em;
}
listBibl > /*tei|*/bibl {
    margin-left: .5em;
}

/**
 * Links
 */
a {
    color: var(--link-base-color);
    text-decoration: none;

    &:visited {
        color: var(--link-visited-color);
    }

    &:hover {
        color: var(--link-hover-color);
        text-decoration: underline var(--brand-color);
        text-underline-offset: 3px;
    }

    .social-media-list &:hover {
        text-decoration: none;

        .username {
            text-decoration: underline;
        }
    }
}

/*Names with no references*/
a:not([href]) {
    color: var(--brand-color-light);
}

/*Page links - TODO collector-specific?*/
a[missing="true"][empty="true"] {
    color: orange;
}
a[missing="true"]:not([empty="true"]) {
    color: red;
}

/*Footnotes*/
div.footnotes {
    margin-top: 2em;
    border-top: 1px solid var(--border-color-01);
}
a.footnote-link, a.footnote-backlink {
    color: red;
}
.footnote-link {
    vertical-align: super;
    font-size: smaller;
    line-height: 0; // do not let superscript alter line spacing
}
a.footnote-backlink {
    padding-right: 0.25em;
}
.footnote + .footnote {
    padding-left: 0.5em;
}
/*.footnote {*/
/*  display: inline-block;*/
/*  padding: 0 1em;*/
/*  margin-right: 1em;*/
/*}*/


/**
 * Blockquotes
 */
blockquote {
    color: var(--brand-color);
    border-left: 4px solid var(--border-color-01);
    padding-left: var(--spacing-unit-half);
    font-size: 1.05rem;
    font-style: italic;

    > :last-child {
        margin-bottom: 0;
    }

    i, em {
        font-style: normal;
    }
}

/**
 * Code formatting
 */

pre {
    /* TODO I do not think I want this: padding: 8px 12px;*/
    /*background: var(--code-background-color);*/
    /*background-color: var(--code-background-color);*/

    /*font-family: var(--code-font-family);*/
    border: 1px solid var(--brand-color-light);
    border-radius: 3px;

    margin-block: 5px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--heading-color);
    overflow-x: auto;
}

pre code {
    display: block;
    overflow-x: auto;
    padding: 1em;
}

code {
    font-family: var(--code-font-family);
    background-color: var(--code-background-color);
    /*padding: 3px 5px;*/
    /*border: 1px solid var(--brand-color-light);*/
    /*border-radius: 3px;*/
}

/* LMD I do not have this; Jekyll's Rouge wrapped ... */
div.highlight, figure.highlight {
    margin-bottom: var(--spacing-unit-half);
}

.hljs {
    background-color: var(--code-background-color);
    /*TODO foreground to override Highlight's?*/
}

/* Counter-act Highlights.js styling ;) */
pre code.hljs {
    /* TODO there is some spurious padding/margins around pre > code vertically; display: block; seems to contribute */
    /*display: inline flow-root;*/
    padding: 1em;
}

/**
 * Wrapper
 */
.wrapper {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--spacing-unit);

    @media screen and (max-width: var(--on-medium)) {
        padding-right: var(--spacing-unit-two-thirds);
        padding-left: var(--spacing-unit-two-thirds);
    }
}

.wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/**
 * Icons
 */

.orange {
    color: #f66a0a;
}

.grey {
    color: #828282;
}

.svg-icon {
    width: 1.25em;
    height: 1.25em;
    display: inline-block;
    fill: currentColor;
    vertical-align: text-bottom;
    overflow: visible;
}

/**
 * Tables
 */
table {
    margin-bottom: var(--spacing-unit);
    width: 100%;
    text-align: var(--table-text-align);
    color: var(--table-text-color);
    border-collapse: collapse;
    border: 1px solid var(--table-border-color);
    tr {
        &:nth-child(even) {
            background-color: var(--table-zebra-color);
        }
    }
    th, td {
        padding: var(--spacing-unit-third) var(--spacing-unit-half);
    }
    th {
        background-color: var(--table-header-bg-color);
        border: 1px solid var(--table-header-border);
    }
    td {
        border: 1px solid var(--table-border-color);
        /*vertical-align: text-top;*/
    }
    tei-head {
        text-align: center;
    }
    /*header*/
    th,                         /* HTML */
    tr.row[role=label] td.cell, /* TEI */
    thead td.entry              /* DocBook */
    {
        font-weight: bold;

        /*background-color: lighten($grey-color-light, 3%);*/
        /*border: 1px solid darken($grey-color-light, 4%);*/
        /*border-bottom-color: darken($grey-color-light, 12%);*/

        /* Keep header visible */
        /*position: -webkit-sticky;*/
        position: sticky;
        top: 0;
    }

    @media screen and (max-width: var(--on-laptop)) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
}

table[rendition="borderless"] {
    border: none;
    tr.row {
        /*background-color: $background-color;*/
        td.cell { border: none; }
    }
}


tei-div > tei-head {
    text-indent: -0.5em;
}

listBibl > tei-head {
    font-size: 120%;
    font-weight: bold;
}

/* TEI title */
TEI tei-title {
    display: inline;
}
TEI tei-title[level=a] {
    quotes: "\201c" "\201d" "\2018" "\2019" "\201c" "\201d" "\2018" "\2019" "\201c" "\201d" "\2018" "\2019" "\201c" "\201d";
}
TEI tei-title[level=a]:before {
    content: open-quote;
}
TEI tei-title[level=a]:after {
    content: close-quote;
}
TEI tei-title[level=a][next]:after {
    content: "" !important;
}
TEI tei-title[level=a][prev]:before {
    content: "" !important;
}
tei-title[level=m] {
    font-style: italic;
}

tei-head {
    display: block;
}
