/*Max Ehrengruber*/

/*------------------------------------*\
  Fonts
\*------------------------------------*/

@supports (font-variation-settings: normal) {
    @font-face {
        font-family: "Social";
        src:
            url("./fonts/ABCSocialPlusVariableEdu.woff2") format("woff2"),
            url("./fonts/ABCSocialPlusVariableEdu.woff") format("woff");
        font-weight: 100 900;
        font-display: swap;
    }

    @font-face {
        font-family: "Diatype Mono";
        src:
            url("./fonts/ABCDiatypeMonoVariableEdu.woff2") format("woff2"),
            url("./fonts/ABCDiatypeMonoVariableEdu.woff") format("woff");
        font-display: swap;
    }
}

@supports not (font-variation-settings: normal) {
    /* Social: same cuts as the variable settings (Regular, Medium, Extended Black) */
    @font-face {
        font-family: "Social";
        src:
            url("./fonts/ABCSocialEdu-Regular.woff2") format("woff2"),
            url("./fonts/ABCSocialEdu-Regular.woff") format("woff");
        font-weight: 400;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: "Social";
        src:
            url("./fonts/ABCSocialEdu-RegularItalic.woff2") format("woff2"),
            url("./fonts/ABCSocialEdu-RegularItalic.woff") format("woff");
        font-weight: 400;
        font-style: italic;
        font-display: swap;
    }
    @font-face {
        font-family: "Social";
        src:
            url("./fonts/ABCSocialEdu-Medium.woff2") format("woff2"),
            url("./fonts/ABCSocialEdu-Medium.woff") format("woff");
        font-weight: 500;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: "Social";
        src:
            url("./fonts/ABCSocialEdu-MediumItalic.woff2") format("woff2"),
            url("./fonts/ABCSocialEdu-MediumItalic.woff") format("woff");
        font-weight: 500;
        font-style: italic;
        font-display: swap;
    }
    @font-face {
        font-family: "Social";
        src:
            url("./fonts/ABCSocialExtendedEdu-Black.woff2") format("woff2"),
            url("./fonts/ABCSocialExtendedEdu-Black.woff") format("woff");
        font-weight: 800;
        font-style: normal;
        font-display: swap;
    }

    /* Diatype Mono */
    @font-face {
        font-family: "Diatype Mono";
        src:
            url("./fonts/ABCDiatypeMonoEdu-Light.woff2") format("woff2"),
            url("./fonts/ABCDiatypeMonoEdu-Light.woff") format("woff");
        font-weight: 300;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: "Diatype Mono";
        src:
            url("./fonts/ABCDiatypeMonoEdu-LightItalic.woff2") format("woff2"),
            url("./fonts/ABCDiatypeMonoEdu-LightItalic.woff") format("woff");
        font-weight: 300;
        font-style: italic;
        font-display: swap;
    }
    @font-face {
        font-family: "Diatype Mono";
        src:
            url("./fonts/ABCDiatypeMonoEdu-Regular.woff2") format("woff2"),
            url("./fonts/ABCDiatypeMonoEdu-Regular.woff") format("woff");
        font-weight: 400;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: "Diatype Mono";
        src:
            url("./fonts/ABCDiatypeMonoEdu-RegularItalic.woff2") format("woff2"),
            url("./fonts/ABCDiatypeMonoEdu-RegularItalic.woff") format("woff");
        font-weight: 400;
        font-style: italic;
        font-display: swap;
    }
}

/*------------------------------------*\
  Design Tokens
\*------------------------------------*/

:root {
    --font-sans: "Social", Helvetica, sans-serif;
    --font-mono: "Diatype Mono", Mono, "Roboto Mono", monospace;
    --text-size: 18px;
    --meta-size: 13px;
    --text-lh: 1.5;
    --max-text-width: calc(var(--text-size) * 32); /* 32em, as linear.latex (124mm at 11pt) */
    --color-ink: #222;
    --color-meta: #6b6b6b; /* grey (#808080) failed WCAG AA at 13px */
    --border: 1px solid var(--color-ink);
    --navbar-height: 5em;
    --page-margin: 4em;
    --bar-pad: calc(var(--text-size) * 0.3); /* overhang of heading bars and menu rules */
    --fv-logotype: "wght" 800, "wdth" 6.6; /* Social Extended Black, as on the letterhead */
    --fv-book: "wght" 400, "wdth" 4.8;              /* Social Regular */
    --fv-book-italic: "wght" 400, "wdth" 4.8, "ital" 12;
    --fv-medium: "wght" 553, "wdth" 4.8;            /* Social Medium (letterhead bold) */
    --fv-medium-italic: "wght" 553, "wdth" 4.8, "ital" 12;
    --fv-mono: "wght" 400, "ital" 0;           /* Diatype Mono Regular, as on the letterhead */
    --fv-mono-italic: "wght" 400, "ital" 12;
    --meta-lh: 1.35;
}

html {
    scroll-padding-top: calc(var(--navbar-height) + 4em);
}

/*------------------------------------*\
  Body & Typography
\*------------------------------------*/

body {
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-variation-settings: var(--fv-book);
    font-feature-settings: "calt", "liga", "rlig", "rvrn", "kern", "rclt";
    margin: 0 var(--page-margin) 1em;
}

body i,
em,
.italic {
    font-variation-settings: var(--fv-book-italic); /* full italic */
    font-style: normal;
}

strong,
b {
    font-weight: 500; /* static fallback; variable fonts use the line below */
    font-variation-settings: var(--fv-medium);
}

strong em,
strong i,
b em,
b i {
    font-variation-settings: var(--fv-medium-italic);
}

h1,
h2,
h3 {
    font-family: var(--font-sans);
    line-height: 1.2;
    font-variation-settings: var(--fv-medium);
    max-width: var(--max-text-width);
}

h1 {
    font-weight: 800; /* picks Extended Black where variable fonts are unsupported */
    font-variation-settings: var(--fv-logotype);
    font-size: var(--text-size); /* letterhead: logotype 10pt on 11pt text */
    line-height: 1;
    margin: calc(var(--text-size) * 2) 0;
}

h2 {
    font-size: calc(var(--text-size) * 1.15);
    margin: 2em 0 1em 0;
}

h3 {
    font-size: var(--text-size);
    margin: 1.5em 0 0.75em;
}

h4,
figcaption {
    font-family: var(--font-mono);
    font-variation-settings: var(--fv-mono);
    font-size: var(--meta-size);
    line-height: var(--meta-lh);
    font-weight: normal;
    color: var(--color-meta);
    letter-spacing: 0;
    margin-top: 0;
}

h4 i,
.italic {
    font-variation-settings: var(--fv-mono-italic);
    font-style: normal;
}

/* Prose (linear.latex): no gap between paragraphs, first lines indented */
p {
    margin: 0;
    max-width: var(--max-text-width);
    font-size: var(--text-size);
    line-height: var(--text-lh);
    letter-spacing: 0.006em;
    font-variant-numeric: oldstyle-nums proportional-nums;
    hyphens: auto;
    text-wrap: pretty;
}
p + p {
    text-indent: 2em;
}

/* Line-based content (lists, contact lines; letterhead): one blank line
   between paragraphs, no indent */
.lines {
    margin: calc(var(--text-size) * var(--text-lh)) 0;
}
.lines p {
    text-indent: 0;
    margin-bottom: calc(var(--text-size) * var(--text-lh));
    font-variant-numeric: lining-nums proportional-nums;
    hyphens: manual;
}
.lines p:last-child {
    margin-bottom: 0;
}

p a {
    color: var(--color-ink);
}

a {
    color: var(--color-meta);
    text-decoration: none;
    transition: all 0.2s ease-in;
}

a:hover {
    color: var(--color-ink);
    text-decoration: line-through;
}

.mail {
    color: var(--color-ink);
}

hr {
    border: 0;
    border-bottom: var(--border);
    margin: 2em calc(var(--bar-pad) * -1);
    /* text width plus the same overhang as the bars, on every page */
    max-width: calc(var(--max-text-width) + var(--bar-pad) * 2);
}

/*------------------------------------*\
  Images & Figures
\*------------------------------------*/

img {
    max-width: 100%;
    box-shadow: var(--shadow-elevation-low);
}

figcaption {
    margin: 2em 0 2em;
}

figcaption strong {
    font-family: var(--font-sans);
    font-size: var(--text-size);
    letter-spacing: 0.006em;
    color: var(--color-ink);
}

figcaption strong::after {
    content: "";
    display: block;
    margin-bottom: 0;
}

/*------------------------------------*\
  Grid Layout
\*------------------------------------*/

.grid {
    max-width: 60em;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-auto-rows: minmax(2em, auto);
    grid-gap: 2em;
}

.full-width {
    grid-column: 1 / -1;
}
.center {
    grid-column: 2 / -2;
}
.left-large {
    grid-column: 1 / -3;
}
.right-large {
    grid-column: 3 / -1;
}
.left-small {
    grid-column: 1 / -5;
}
.right-small {
    grid-column: 5 / -1;
}

.grid figure {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
}

.grid figure img {
    width: 100%;
    height: auto;
    display: block;
}

.grid figure figcaption {
    width: 100%;
}

/*------------------------------------*\
  Navigation
\*------------------------------------*/

.header {
    background-color: #fff;
    position: fixed;
    z-index: 3;
    /* white background spans the page margins, so nothing shows beside it */
    margin: 0 calc(var(--page-margin) * -1) 1em;
    padding: 0 var(--page-margin);
}

.navbar {
    align-items: center;
    background-color: #fff;
}

.sticky {
    position: sticky;
    top: 0;
    z-index: 1;
}

.header ul {
    /* rules overhang like the heading bars; items stay aligned with the text */
    margin: 0 calc(var(--bar-pad) * -1);
    padding: 0 var(--bar-pad);
    list-style: none;
    overflow: hidden;
    border-top: var(--border);
    border-bottom: var(--border);
}

.header li a {
    display: block;
    padding: 2em 2em 2em 0;
    text-decoration: none;
}
.header .logo {
    float: left;
    text-decoration: none;
    color: var(--color-ink);
}

/* Menu */
.menu,
.header .menu {
    font-family: var(--font-mono);
    font-size: var(--meta-size);
    font-variation-settings: var(--fv-mono);
    clear: both;
    max-height: 0;
    transition: max-height 0.2s ease-out;
}

.header .menu a {
    color: var(--color-ink);
}
.header .menu a:hover,
.header .menu .active a {
    text-decoration: line-through;
}

.header .menu-icon {
    cursor: pointer;
    display: inline-block;
    float: right;
    padding: 40px 20px 24px 20px;
    position: relative;
    user-select: none;
}

.header .menu-icon .navicon {
    background: #333;
    display: block;
    height: 2px;
    position: relative;
    transition: background 0.2s ease-out;
    width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
    content: "";
    display: block;
    height: 100%;
    width: 100%;
    position: absolute;
    background: #333;
    transition: all 0.2s ease-out;
}
.header .menu-icon .navicon:before {
    top: 5px;
}
.header .menu-icon .navicon:after {
    top: -5px;
}

.header .menu-btn {
    display: none;
}
.header .menu-btn:checked ~ .menu {
    max-height: 400px;
}
.header .menu-btn:checked ~ .menu-icon .navicon {
    background: transparent;
}
.header .menu-btn:checked ~ .menu-icon .navicon:before {
    transform: rotate(-45deg);
}
.header .menu-btn:checked ~ .menu-icon .navicon:after {
    transform: rotate(45deg);
}
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after {
    top: 0;
}

/*responsive*/

@media only screen and (min-width: 769px) {
    .header li {
        float: left;
    }
    .header li a {
        padding: 1em 2em;
    }
    .header .menu {
        max-height: none;
    }
    .header .menu-icon {
        display: none;
    }
}

@media only screen and (max-width: 768px) {
    :root {
        --page-margin: 1em;
    }

    .navbar {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
    }

    .header .logo {
        flex: 1;
    }

    .header .menu-icon {
        float: none;
        padding: 1.5em 0;
    }

    .header .menu {
        flex-basis: calc(100% + var(--bar-pad) * 2);
        border-bottom: 0; /* collapsed: a single line, not two stacked ones */
    }
    .header .menu-btn:checked ~ .menu {
        border-bottom: var(--border);
    }

    .full-width {
        grid-column: 1 / -1;
    }

    .center {
        grid-column: 1 / -1;
    }

    .left-large {
        grid-column: 1 / -1;
    }

    .right-large {
        grid-column: 1 / -1;
    }

    .left-small {
        grid-column: 1 / -1;
    }

    .right-small {
        grid-column: 1 / -1;
    }
}

/*------------------------------------*\
  Texts
  Corporate design from the letterhead (letter.latex):
  logotype cut for titles, inverted bar for sections, ruled bar
  for subsections, Diatype Mono for info.
  Reading rules from linear.latex: ~32em measure, first-line
  indents instead of paragraph gaps, small quotes indented both
  sides, footnote numbers hanging, lining figures in notes.
\*------------------------------------*/

.text,
.texts-list {
    --note-size: calc(var(--text-size) * 0.83);
}

/* Running text beyond paragraphs (abstracts: same breaks on both pages) */
.text > ol,
.text > ul,
.text blockquote,
.text-header .text-abstract,
.text-entry .text-abstract {
    font-variation-settings: var(--fv-book);
    letter-spacing: 0.006em;
    font-variant-numeric: oldstyle-nums proportional-nums;
    hyphens: auto;
    text-wrap: pretty;
}
/* Header: back link, title in the logotype cut, date, abstract */
.text-header {
    max-width: var(--max-text-width);
    margin-bottom: 3em;
}
.back-link,
.text-header .date,
.text-entry .text-meta {
    display: block;
    font-family: var(--font-mono);
    font-variation-settings: var(--fv-mono);
    font-size: var(--meta-size);
    line-height: var(--meta-lh);
    color: var(--color-meta);
    margin: 0;
}
.back-link {
    margin-bottom: calc(var(--text-size) * 2);
}
.back-link a {
    color: var(--color-ink); /* mono links are ink (like the menu), mono info is grey */
}
/* Titles (text page and texts list): text cut on an inverted bar,
   like the letterhead's title bar */
.text-header .title,
.text-entry .text-title {
    font-weight: normal;
    font-variation-settings: var(--fv-book);
    letter-spacing: 0.006em;
    line-height: 1.3;
    background: var(--color-ink);
    color: #fff;
    padding: 0.15em var(--bar-pad);
    margin-left: calc(var(--bar-pad) * -1);
    margin-right: calc(var(--bar-pad) * -1);
}
.text-header .title,
.text-entry .text-title {
    font-size: var(--text-size);
    margin-top: 0;
    margin-bottom: calc(var(--text-size) * 0.5);
}
.text-header .text-abstract,
.text-entry .text-abstract {
    margin: calc(var(--text-size) * 0.75) 0 0;
    text-indent: 0; /* header lines, not prose */
}

/* Sections: inverted bar; subsections: ruled bar (both at text size) */
.text > h2,
.text > h3 {
    font-variation-settings: var(--fv-book);
    font-size: var(--text-size);
    line-height: 1.3;
    letter-spacing: 0.006em;
    padding: 0.15em var(--bar-pad);
    margin-left: calc(var(--bar-pad) * -1);
    margin-right: calc(var(--bar-pad) * -1);
}
.text > h2 {
    background: var(--color-ink);
    color: #fff;
    margin-top: 2.5em;
    margin-bottom: 1em;
}
.text > h3 {
    border-top: var(--border);
    border-bottom: var(--border);
    margin-top: 2em;
    margin-bottom: 1em;
}
.text > h2 + h3 {
    margin-top: 1em;
}
.text > h4 {
    font-family: var(--font-sans);
    font-variation-settings: var(--fv-medium);
    font-size: var(--text-size);
    color: var(--color-ink);
    margin: 1.5em 0 0.25em;
}

/* Quotes and lists */
.text blockquote {
    margin: 1.25em 2em;
    max-width: calc(var(--max-text-width) - 4em);
}
.text blockquote p {
    font-size: calc(var(--text-size) * 0.9);
    line-height: 1.45;
    margin: 0;
}
.text > ol,
.text > ul {
    padding-left: 2em;
    margin: 1em 0;
    max-width: calc(var(--max-text-width) - 2em);
}
.text > ol li p,
.text > ul li p {
    margin: 0 0 0.5em;
}

/* Footnote markers in the text: small lining figures */
.footnote-ref sup {
    font-family: var(--font-sans);
    font-variation-settings: var(--fv-book);
    font-variant-numeric: lining-nums tabular-nums;
    font-size: 0.65em;
    line-height: 0;
    color: var(--color-ink);
    padding-left: 0.1em;
}
sup {
    vertical-align: baseline;
    position: relative;
    top: -0.55em;
}

/* Footnotes: full rule, numbers hanging (letterhead), text font */
.text .footnotes {
    border-top: var(--border);
    margin: 3em calc(var(--bar-pad) * -1) 0;
    padding: 1.25em var(--bar-pad) 0;
    max-width: var(--max-text-width); /* rule ends where the bars end */
}
.text .footnotes > hr {
    display: none;
}
.text .footnotes ol {
    list-style: none;
    counter-reset: fn;
    margin: 0;
    font-size: var(--note-size); /* so 2.25em matches the hanging numbers */
    padding-left: 2.25em;
    max-width: none;
}
.text .footnotes li,
.text .footnotes li p,
.text #refs .csl-entry {
    font-family: var(--font-sans);
    font-variation-settings: var(--fv-book);
    font-size: var(--note-size);
    line-height: 1.4;
    letter-spacing: 0.006em;
    color: var(--color-ink);
    hyphens: auto;
}
.text .footnotes li {
    counter-increment: fn;
    position: relative;
    max-width: none;
    margin: 0 0 0.5em;
}
.text .footnotes li p {
    margin: 0;
}
.text .footnotes li::before {
    content: counter(fn);
    position: absolute;
    left: -2.25em;
    font-variant-numeric: lining-nums tabular-nums;
}
.text .footnotes li em,
.text #refs .csl-entry em {
    font-variation-settings: var(--fv-book-italic);
    font-style: normal;
}
.footnote-back {
    font-family: var(--font-mono);
    font-variation-settings: var(--fv-mono);
    font-size: var(--meta-size);
    color: var(--color-ink);
    text-decoration: none;
    margin-left: 0.25em;
}

/* Bibliography: hanging indent 1.5em (linear.latex) */
.text #refs {
    margin: 1em 0 0;
    max-width: var(--max-text-width);
}
.text #refs .csl-entry {
    max-width: none;
    margin: 0 0 0.5em;
    padding-left: 1.5em;
    text-indent: -1.5em;
}

/* Texts index: title (logotype cut), date, abstract (body text) */
.texts-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: var(--max-text-width);
}
.text-entry {
    /* no rule between entries: the title bar separates them; 2 lines of space */
    margin: 0 0 calc(var(--text-size) * var(--text-lh) * 2);
}
.text-entry .text-title a,
.text-entry .text-title a:hover {
    display: block;
    color: #fff;
}
.text-entry .text-abstract {
    font-size: var(--text-size);
    line-height: var(--text-lh);
}
.text-entry .text-abstract em {
    font-variation-settings: var(--fv-book-italic);
    font-style: normal;
}

@media only screen and (max-width: 768px) {
    .text blockquote {
        margin-left: 1em;
        margin-right: 0;
    }
}

@keyframes footnote-li-flash {
    0% {
        background-color: var(--color-ink);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes footnote-ref-bg-flash {
    0% {
        background-color: var(--color-ink);
    }
    100% {
        background-color: transparent;
    }
}

.footnotes li:target {
    animation: footnote-li-flash 1.5s ease-in forwards;
}

.footnote-ref:target {
    animation: footnote-ref-bg-flash 1.5s ease-in forwards;
}
