@import url('reset.css');

:root {
    --font-size: 28;         /* unit-less – just tweak it to your liking */
    --side-margin: 2rem;     /* left and right margin of each slide */
    --aspect-ratio: 16 / 9;  /* is usually overridden via js */

    --slide-number-color: #bbb;
    --slide-number-font: inherit;

    --total-slide-number-display: none;
    --slide-progress-display: block;

    --vw: 1vw;  /* these two are set to the viewport size, EXCLUDING the... */
    --vh: 1vh;  /* ...scroll bars, via js in order to fix #23 */
}

@page {
    size: 640px 360px;  /* for a 16:9 aspect ratio; may be overridden via js */
    margin: 0;
}

* {
    -webkit-print-color-adjust: exact;
}

html.draft,
html.presentation.taller {
    font-size: calc(var(--font-size) * (0.1 * var(--vw)));
}
html.presentation.wider {
    font-size: calc(var(--font-size) * (0.1 * var(--vh)) * (var(--aspect-ratio)));
}

body {
    margin: 0;
    padding: 0;
}

.slide {
    --slide-width: calc(100 * var(--vw));
    --slide-height: calc(var(--slide-width) / (var(--aspect-ratio)));
}
.presentation.taller .slide {
    --slide-letterbox-height: calc((100 * var(--vh)) - var(--slide-height));
}
.presentation.wider .slide {
    --slide-height: calc(100 * var(--vh));
    --slide-width: calc(var(--slide-height) * (var(--aspect-ratio)));
    --slide-letterbox-width: calc((100 * var(--vw)) - var(--slide-width));
}

.draft .slide {
    margin-bottom: 0.5rem;
    box-shadow: 0 0.05rem 0.3rem gray,
                0 0.5rem 0 #eee;
    display: inline-block;
}
.presentation .slide {
    display: none;  /* will be overwritten for the currently active slide */
}

.slide-content {
    padding: 0 var(--side-margin);
    box-sizing: content-box;  /* make sure to exclude borders from width/height attribute */
    overflow: hidden;
    border-width: 0;
}

.draft .slide-content {
    width: calc(var(--slide-width) - 2 * var(--side-margin));
    height: var(--slide-height);
}

.presentation .slide-content {
    border-style: solid;
    border-color: black;
}
.presentation.taller .slide-content {
    width: calc(var(--slide-width) - 2 * var(--side-margin));
    height: var(--slide-height);
    border-top-width: calc(var(--slide-letterbox-height) / 2);
    border-bottom-width: calc(var(--slide-letterbox-height) / 2);
}
.presentation.wider .slide-content {
    height: var(--slide-height);
    width: calc(var(--slide-width) - 2 * var(--side-margin));
    border-left-width: calc(var(--slide-letterbox-width) / 2);
    border-right-width: calc(var(--slide-letterbox-width) / 2);
}

.slide-number {
    font-family: var(--slide-number-font);
    font-variant-numeric: tabular-nums lining-nums;  /* doin' a better job than whoever build the macos menu bar clock */
    position: absolute;
    font-weight: normal;
    font-size: 0.8rem;
    margin-top: calc(var(--slide-height) - 1.75rem);
    margin-left: calc(var(--slide-width) - 2.5rem);
    color: var(--slide-number-color);
    height: 0;
    width: 2rem;
    text-align: right;
}
.slide-number-total {
    display: var(--total-slide-number-display);
}

.presentation.taller .slide-number {
    margin-top: calc(var(--slide-height) + var(--slide-letterbox-height) / 2 - 1.75rem);
}
.presentation.wider .slide-number {
    margin-left: calc(var(--slide-width) + var(--slide-letterbox-width) / 2 - 2.5rem);
}

.slide-progress {
    position: absolute;
    /*width: calc(attr(data-progress) * var(--slide-width));*/  /* sadly, attr() outside of "content" is not supported by any browsers even though the spec provides for this use. the width is thus set explicitly using js – which works, but is less flexible */
    margin-top: 0;
    margin-left: 0;
    display: var(--slide-progress-display);
}

.presentation.taller .slide-progress {
    margin-top: calc(var(--slide-letterbox-height) / 2);
}
.presentation.wider .slide-progress {
    margin-left: calc(var(--slide-letterbox-width) / 2);
}

.slide-presenter-notes {
    display: block;
    overflow: hidden;  /* prevent margin collapse */
    font-size: 0.8rem;
    line-height: 1.2em;
    padding: 0 1em;
    color: white;
    background-image: linear-gradient(#111, #282828 0.4rem, #111);
}
.presentation .slide-presenter-notes {
    display: none;  /* will be shown in separate window */
}

/* presenter notes window */
html.presenter-notes {
    font-size: 3vw;  /* it'd be wrong to use var(--vw) here since this is a whole different window */
    min-height: 100%;
}
.presenter-notes body {
    margin: 0;
    background-image: linear-gradient(#222, #111);
    min-height: 100%;
    color: white;
}
.presenter-notes-meta {
    font-family: sans-serif;
    font-size: 1.75rem;
    background-color: #000;
    padding: 0.2em 1rem 0.2em;
    line-height: 1em;
    text-align: center;
    font-variant-numeric: tabular-nums lining-nums;
}
.presenter-notes-meta #timer {
    float: left;
    font-weight: bold;
}
.presenter-notes-meta #clock {
    float: left;
}
.presenter-notes-meta #clock .seconds {
    opacity: 0.5;
}
.presenter-notes-meta #timer:not(:empty) + #clock {
    font-size: 1rem;
    margin-left: 0.75rem;
}
.presenter-notes-meta #timer:not(:empty) + #clock:before {
    content: '(';
}
.presenter-notes-meta #timer:not(:empty) + #clock:after {
    content: ')';
}
.presenter-notes-meta #slide-number {
    float: right;
}
.presenter-notes-meta #slide-number .current {
    font-weight: bold;
}
.presenter-notes-notes {
    margin: 1rem;
}

#black {
    position: fixed;
    z-index: 9001;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: black;
}

.md {
    display: block;  /* its font-size and line-height will otherwise create a white bar at the bottom of the page in presentation mode */
}
#mdContextMenu {
    display: none;  /* display:hidden anyway, but that leaves its height in place, will otherwise create a white bar at the bottom of the page in presentation mode */
}
.markdeepFooter {
    text-align: left;  /* the default right-aligned variant creates a horizontal scrollbar */
}
.presentation .markdeepFooter {
    display: none;  /* sorry morgan */
}

@media print {
    :root {  /* fixes #25 */
        --vw: 1vw !important;
        --vh: 1vh !important;
    }

    .slide {
        --slide-width: 640px;  /* for a 16:9 aspect ratio; may be overridden via js */
        --slide-height: 360px;  /* for a 16:9 aspect ratio; may be overridden via js */
    }
    .slide, .draft .slide, .presentation .slide {
        page-break-before: always;  /* make sure to insert page breaks between slides (might not actually be needed anymore) */
        margin-bottom: 0 !important;
        box-shadow: none !important;
        display: inline-block !important;
    }

    .slide-content, .draft .slide-content, .presentation .slide-content {
        border-width: 0 !important;  /* letterboxing not needed here (shouldn't appear anyway, this just to fix potential weird rounding errors) */
    }

    .slide-presenter-notes {
        display: none;
    }

    .markdeepFooter {
        display: none;  /* again, sorry morgan */
    }
}
