@font-face {
    font-family: 'ET Book';
    font-style: normal;
    font-weight: 400;
    src: url('https://cdn.jsdelivr.net/gh/edwardtufte/et-book@gh-pages/et-book/roman-line-figures/ETBook-RomanLF.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/gh/edwardtufte/et-book@gh-pages/et-book/roman-line-figures/ETBook-RomanLF.woff') format('woff');
}

@font-face {
    font-family: 'ET Book';
    font-style: italic;
    font-weight: 400;
    src: url('https://cdn.jsdelivr.net/gh/edwardtufte/et-book@gh-pages/et-book/italic-line-figures/ETBook-ItalicLF.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/gh/edwardtufte/et-book@gh-pages/et-book/italic-line-figures/ETBook-ItalicLF.woff') format('woff');
}

@font-face {
    font-family: 'ET Book';
    font-style: normal;
    font-weight: 700;
    src: url('https://cdn.jsdelivr.net/gh/edwardtufte/et-book@gh-pages/et-book/bold-line-figures/ETBook-BoldLF.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/gh/edwardtufte/et-book@gh-pages/et-book/bold-line-figures/ETBook-BoldLF.woff') format('woff');
}

/* Reset & base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'ET Book', Palatino, 'Palatino Linotype', 'Palatino LT STD',
                 'Book Antiqua', Georgia, serif;
    background-color: #fffff8;
    color: #111;
    counter-reset: sidenote-counter;
}

/* Layout */
article {
    width: 87.5%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 5rem 0;
}

section {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* Typography */
h1, h2, h3 {
    font-weight: 400;
    line-height: 1;
}

h1 {
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    font-size: 3.2rem;
}

h2 {
    font-style: italic;
    font-size: 2.2rem;
    margin-top: 2.1rem;
    margin-bottom: 0.4rem;
}

h3 {
    font-style: italic;
    font-size: 1.7rem;
    margin-top: 2rem;
    margin-bottom: 0.4rem;
}

p, dl, ol, ul {
    font-size: 1.4rem;
    line-height: 2rem;
}

p {
    margin-top: 1.4rem;
    margin-bottom: 1.4rem;
    padding-right: 0;
    vertical-align: baseline;
    width: 55%;
}

ul, ol {
    width: 50%;
    padding-inline-start: 5%;
}

li {
    margin-bottom: 0.5rem;
}

blockquote {
    font-size: 1.4rem;
    width: 55%;
    margin: 1.4rem 0;
    padding: 0 0 0 1rem;
    border-left: 3px solid #ccc;
}

blockquote p {
    width: 100%;
}

/* Links */
a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: #aaa;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-color: #111;
}

/* Navigation */
nav {
    width: 87.5%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 0 0 0;
}

nav a {
    font-size: 1.2rem;
    margin-right: 1.5rem;
    text-decoration: none;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #333;
}

nav a:hover {
    color: #000;
}

/* Sidenotes & margin notes */
.sidenote, .marginnote {
    float: right;
    clear: right;
    margin-right: -60%;
    width: 50%;
    margin-top: 0.3rem;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    vertical-align: baseline;
    position: relative;
}

.sidenote-number {
    counter-increment: sidenote-counter;
}

.sidenote-number::after, .sidenote::before {
    font-size: 1rem;
    position: relative;
    vertical-align: baseline;
}

.sidenote-number::after {
    content: counter(sidenote-counter);
    top: -0.5rem;
    left: 0.1rem;
}

.sidenote::before {
    content: counter(sidenote-counter) " ";
    top: -0.5rem;
}

/* Margin toggle for mobile */
input.margin-toggle {
    display: none;
}

label.sidenote-number {
    display: inline;
}

label.margin-toggle:not(.sidenote-number) {
    display: none;
}

/* Figures */
figure {
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    max-width: 55%;
    margin: 0 0 3rem 0;
}

figcaption {
    float: right;
    clear: right;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.6;
    vertical-align: baseline;
    position: relative;
    max-width: 40%;
}

figure.fullwidth {
    max-width: 90%;
}

/* Code */
code {
    font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 1.125rem;
    line-height: 1.6;
}

pre {
    font-size: 1rem;
    width: 52.5%;
    margin-left: 2.5%;
    overflow-x: auto;
    padding: 1rem;
    background: #f7f7f0;
}

pre code {
    font-size: 0.9rem;
}

/* Horizontal rule */
hr {
    display: block;
    height: 1px;
    width: 55%;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

/* Table */
table {
    border-collapse: collapse;
    font-size: 1.4rem;
    width: 55%;
    margin: 1.4rem 0;
}

th, td {
    padding: 0.4rem 1rem 0.4rem 0;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

th {
    font-weight: 400;
    border-bottom: 2px solid #333;
}

/* Footer */
footer {
    width: 87.5%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 0;
    font-size: 1.1rem;
    color: #666;
}

/* Responsive */
@media (max-width: 760px) {
    body {
        padding: 0 1rem;
    }

    article, nav, footer {
        width: 100%;
    }

    p, ul, ol, blockquote, pre, table, hr, figure {
        width: 100%;
        max-width: 100%;
    }

    .sidenote, .marginnote {
        display: none;
    }

    input.margin-toggle:checked + .sidenote,
    input.margin-toggle:checked + .marginnote {
        display: block;
        float: left;
        left: 1rem;
        clear: both;
        width: 95%;
        margin: 1rem 2.5%;
        vertical-align: baseline;
        position: relative;
    }

    label.margin-toggle:not(.sidenote-number) {
        display: inline;
    }

    label {
        cursor: pointer;
    }
}
