:root {
    /* https://github.com/system-fonts/modern-font-stacks#old-style */
    --font-family: SortsMillGoudy, 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;

    font-family: var(--font-family);
    font-weight: normal;
}

@font-face {
    font-family: SortsMillGoudy;
    src: url(/fonts/SortsMillGoudy-Regular.ttf);
}

table [title]:not(a),
ul.descriptive strong[title] {
    cursor: help;
}

button,
select {
    cursor: pointer;
}

button:disabled, select:disabled {
    cursor: not-allowed;
}

main a {
    text-decoration: none;
    color: #DD2211;
}

main a:visited {
    color: #FF9922;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

html {
    min-height: 100vh;
}

body {
    margin: 0;
    min-height: 100vh;
}

.container {
    display: flex;
    width: 100vw;
    flex-direction: column;
    min-height: 100vh;
}

.page-body-wrapper {
    align-self: center;
    display: flex;
    width: 100vw;
    flex-grow: 1;
}

.page-body-wrapper .spacer {
    flex-grow: 1;
}

.page-body-wrapper .spacer:first-child {
    background-size: 48px;
    background-position: top right;
    background-image: url(/images/spirals.svg);
}

section.page-body {
    display: flex;
    flex-direction: column;
}

aside.spine {
    user-select: none;

    writing-mode: vertical-lr;
    padding: 24px;
    letter-spacing: 2px;
    word-spacing: 4px;
    font-size: 18px;
    font-variant: small-caps;
    line-height: 1;

    background-color: black;
    color: white;
}

section.pinning {
    padding: 12px 32px;
    border-bottom: 2px solid black;
    display: flex;
    align-items: center;
}

section.pinning * + * {
    margin-left: 16px;
}

section.pinning label {
    cursor: pointer;
}

button.add-pin,
button.remove-pin {
  all: unset;
  float: right;
  margin-left: -32px;
  color: transparent;
  user-select: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
}

button.add-pin {
  background: url("/images/New Tab.svg") center no-repeat;
}

button.remove-pin {
  background: url("/images/Trash.svg") center no-repeat;
}

button.add-pin:focus,
button.remove-pin:focus {
  outline: revert;
}

section.pinning button.remove-pin {
    float: none;
    margin-left: auto;
}

main {
    flex-grow: 1;
}

main > article {
    padding: 64px 32px 32px 32px;
    max-width: 800px;
}

.container.multi-document .page-body-wrapper {
    flex-direction: column;
}

.container.multi-document .page-body > footer {
    border-top: 2px solid black;
    width: calc(100vw - 64px);
    padding: 12px 32px;
}

.container.multi-document main {
    overflow-x: auto;
    max-width: 100vw;
    display: flex;

    /* For the pinned/copied content. */
    background-color: #EFEFEF;
    background-size: 12px;
    background-position: center;
}
.container.multi-document main > article:first-child {
    background: white;
}


.container.multi-document main > article {
    min-width: 800px;
}

.container.multi-document main > article + article {
    border-left: 1px solid #888;
    padding-left: 32px;
}

.container.multi-document .spacer {
    display: none;
}

.container.multi-document aside.spine {
    display: none;
}

footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    align-self: center;
    width: 800px;
    padding: 32px;
}

address {
    text-align: left;
    font-size: 12px;
    font-style: normal;
    letter-spacing: 0.5px;
    word-spacing: 2px;
    color: black;
    line-height: 2;
    flex-grow: 2;

    background-image: url(/images/ku-logo.svg);
    background-repeat: no-repeat;
    background-position: left;
    background-size: 88px 88px;
    padding-left: 100px;

    margin-right: 24px;
}

fieldset {
    border: 2px solid black;
    border-right-width: 6px;
    padding: 12px;

}

fieldset legend {
    padding: 0 6px;
    font-variant: small-caps;
    font-weight: bold;
    font-size: 24px;
}

label {
    display: flex;
    align-items: center;
    font-size: 18px;
}

input[type="checkbox"] {
    appearance: none;
    border: 2px solid black;
    width: 20px;
    height: 20px;
    background: white;
    margin-right: 8px;
    content: "d";
    cursor: pointer;
}

input[type="checkbox"]:checked::after {
    content: "✓";
    font-size: 14px;
    margin-left: 2px;
}

aside.preferences {
    display: flex;
    justify-content: center;
    margin-top: 24px;

    /* wrap to the next line on overflow. */
    flex-wrap: wrap;
    gap: 12px;
}

aside.preferences * + * {
    margin-left: 12px;
}

section.tei-pages {
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    margin: 0 auto;
}

section.tei-page-controls {
    display: flex;
    padding: 0;
    margin: 0;
    line-height: 1;
    align-self: stretch;
    border: 2px solid black;
    border-right-width: 6px;
    border-bottom: none;
}

section.tei-page-controls > * {
    appearance: none;
}

section.tei-page-controls > * {
    border: none;
    border-left: 0.5px solid white;

    font-variant: small-caps;
    padding: 12px;
    background: black;
    color: white;
    font-size: 16px;
    min-width: max(80px, 25%);
}
section.tei-page-controls > *:disabled {
    /* https://toolcool.org/svg-stripes-maker-react/ */
    background-image: url(/images/stripes.svg);
}

section.tei-page-controls > *:first-child {
    padding-left: 24px;
    border-left: none;
}

section.tei-page-controls > select {
    flex-grow: 1;
    text-align: center;
    border-radius: 0;
    text-align-last: center; /* Needed by Safari. */
}

section.tei-page-controls > *:last-child {
    padding-right: 24px;
}

/* The pages in a TEI document. */
article.tei-page {
    display: flex;
    flex-direction: column;

    border: 2px solid black;
    border-right-width: 6px;
    min-width: fit-content;
    padding: 24px;
    background: white;
}

article.tei-page + article.tei-page {
    margin-top: 24px;
}

article.tei-page header.tei-page-header {
    text-align: right;
    font-size: 18px;
    color: grey;
}

article.tei-page section.tei-page-content {
    align-self: center;
    font-size: 18px;
}

section.tei-free-content {
    font-size: 18px;
}

/* Allows for styling tr. */
table.common {
    border-collapse: collapse;
    width: 100%;

    border-left: none;
    border: 2px solid black;
    border: 2px solid black;
    border-right-width: 6px;

    font-size: 18px;
    font-weight: normal;
    font-variant: normal;
    background: white;
    color: black;
}

tr:not(:last-child) {
    border-bottom: 1px solid #888;
}

table.common table.common {
    margin: 12px 0;
}
/* useful for debugging */
table.common + table.common {
    margin-top: 32px;
}

table.common > tr:nth-child(2) > td {
    border-top: none;
}

table.common > tr:first-child {
    border-bottom: none;
}

table.common > tr > td:first-child {
    text-align: right;
    font-weight: bold;
    font-variant: small-caps;
    border-right: 1px solid #888;
    width: 80px;
}

/* Decorative element for linking tables. */
.continuation {
    margin: 24px 0;
    text-align: center;
    font-weight: bold;
    font-size: 20px;
    line-height: 1;
}

table.common > tr > td:last-child {
    text-align: left;
    font-weight: normal;
    font-variant: normal;
}

table.common td, th {
    padding: 8px 12px;
}

table.common th {
    background: black;
    color: white;
    word-spacing: 6px;
    letter-spacing: 1px;
    text-align: center;
    font-weight: normal;
    height: 26.5px; /* for empty headers */
}

table.common ul {
    margin: 0;
    padding-left: 24px;
    list-style-type: square;
}

table.common ul.descriptive {
    padding-left: 0;
    list-style-type: none;
}

table.common ul.descriptive > li + li {
    margin-top: 12px;
}

details > table.common {
    margin: 12px 0 0 0;
}

details > summary {
    text-align: center;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
}

section.content,
section.list {
    display: grid;
    column-gap: 32px;
    grid-template-columns: minmax(220px, auto) minmax(180px, 40%);
    width: 100%;
}

section.list {
    margin-top: 24px;
}

section.list.single {
    display: flex;
    justify-content: center;
}

section.list.single > * {
    width: 100%;
    max-width: 450px;
}

pre {
    min-width: 50vw;
    max-width: 67vw;
    overflow: scroll;
}

h1, h2, h3, h4, h5, h6 {
    font-variant: small-caps;
    text-align: center;
}

main header h1 {
    margin: 0;
    font-size: 48px;
}

main h2 {
    margin: 24px 0;
    font-size: 32px;
}

main section + section {
    margin-top: 48px;
}

hgroup {
    margin: 0 auto;
}

hgroup p {
    margin-top: 0;
    text-align: center;
    font-variant: small-caps;
}

/* TODO: experimental, figure out best method for achieving this across display sizes */
h1.brutalist {
    font-size: 72px;
    letter-spacing: 8px;
    line-height: 1.2;
    text-align: center;
    margin: 0 auto;
    width: fit-content;
}

.big {
    font-size: 150%;
}

.red {
    color: #DD2211;
}

.yellow {
    color: #FF9922;
}

.grey {
    color: #888;
}

.black {
     color: black;
 }

table.dimensions, table.dimensions tr,  table.dimensions td {
    border: none;
    width: fit-content;
    text-align: center;
    padding: 0;
    margin: 0 0 12px 0;
    line-height: 1;
    font-weight: normal;
}

table.dimensions td.dimensions-height {
    padding-right: 8px;
}

table.dimensions td.dimensions-width {
    padding-bottom: 8px;
}

table.skiplinks {
    background: black;
    background-image: url(/images/stripes.svg);
}

table.skiplinks td {
    border: 1px solid #888;
    text-align: center;
    font-weight: bold;
    background: white;
}

table.skiplinks td.empty {
    border: none;
    background: none;
}

/* Undo table.common styles. '*/
table.skiplinks > tr > td:first-child,
table.skiplinks > tr > td:last-child {
    text-align: center;
    width: auto;
}

.dimensions-model {
    border: 2px solid black;
    background: black;
    background-image: url(/images/stripes.svg);
}

ul.descriptive {
    list-style-type: none;
    margin: 16px 0;
    padding-left: 24px;
}

ul.descriptive > li {
    padding-left: 4px;
}

ul.descriptive > li + li {
    margin-top: 4px;
}

p,
header > ul.descriptive > li {
    font-size: 18px;
    line-height: 1.8;
    letter-spacing: 1px;
    word-spacing: 2px;
    margin: 0;
}

ul.descriptive > li > strong {
    text-transform: uppercase;
}

* + p {
    margin-top: 16px;
}

header.top {
    border-bottom: 6px solid black;
    /*position: sticky;
    top: 0; /* required for sticky */
}

nav {
    display: flex;
    align-items: stretch;
    max-width: 1200px;
    margin: 0 auto;
    background: white;
}

nav a {
    color: black;
    text-decoration: none;
    font-variant: small-caps;
}

nav a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
}

nav a:not([href]) {
    color: #DD2211;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

nav a:not([href]):hover {
}

nav ul {
    display: flex;
    border-right: 2px solid black;
    margin: 0 auto 0 0;
    padding: 32px 8px 8px 16px;
}

nav ul li {
    display: inline-block;
    margin-right: 16px;
    font-size: 24px;
}

nav form {
    flex-grow: 1;
    display: flex;
}

nav input[type=search] {
   flex-grow: 1;
   width: 0;
   font-size: 24px;
   padding: 32px 8px 8px 16px;
   background: white; /* Safari on iPhone needs this. */
   border: none;
   align-self: stretch;
   font-family: var(--font-family);
   line-height: 1;
}

nav input[type=search]:not(:focus),
nav input[type=search]::placeholder
{
    color: #00000033;
}

ul.links {
    columns: 2;
    column-gap: 0;

    flex-grow: 1;
    justify-content: center;

    text-align: right;
    list-style-type: none;
    font-size: 18px;
    margin: 0;
    padding: 0;
    line-height: 1.4;
    border: 2px solid black;
    border-right-width: 6px;
}

ul.links li {
    padding: 8px;
    margin: 0;
    text-align: center;
}

ul.links li:nth-child(1), ul.links li:nth-child(2) {
    border-right: 1px solid #888;
}

ul.links li:nth-child(1), ul.links li:nth-child(3) {
    border-bottom: 1px solid #888;
}

ul.links a {
    color: black;
    text-decoration: none;
    font-variant: small-caps;
}

ul.links a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

dl.index {
     margin: 0;
}
dl.index dt {
    background: black;
    color: white;
    padding: 8px 12px;
    font-size: 18px;

    /* Match table.common border styles. */
    border: 2px solid black;
    border-right-width: 6px;
    border-bottom-width: 0.5px;
}
dl.index.table-like dt {
    text-align: center;
}
dl.index dd {
    margin: 0;
}
dl.index ul {
    list-style-type: none;
    padding: 0;
    margin: 0; /* Chrome needs this. */
    border: 2px solid black;
    border-top: none;
    border-right-width: 6px;
}
dl.index dd + dt {
    margin-top: 24px;
}
dl.index li {
    padding: 8px 12px;
    font-size: 18px;
}
dl.index li + li {
    border-top: 1px solid #888;
}

span.disambiguate {
    font-size: 14px;
    margin-left: 8px;
    opacity: 0.8;
}

ruby.disambiguate {
    ruby-position: under;
    ruby-align: center;
    margin: 0;
}

ruby.disambiguate rt {
    opacity: 0.8;
    font-size: 12px;
    margin: 0;
}

ruby.token {
    ruby-position: under;
    ruby-align: center;
    margin: 0;
}

ruby.token rt {
    font-size: 10px;
}

ruby.token rt.lemma {
    color: #888;
}

ruby.token rt.pos {
    color: #DD2211;
    margin-bottom: 24px;
}

ruby.token:nth-child(even) rt.pos {
    color: #FF9922;
}

.tei-free-content rt,
.no-token-metadata rt {
    display: none;
}

.tei-free-content tei-p > *:last-child::after,
.no-paragraph-marks tei-p > *:last-child::after {
    content: "";
}

.tei-free-content tei-lb::after,
.no-lb-marks tei-lb::after {
    content: "";
}

/* TODO: improve styles */
dialog.error pre {
    width: 70vw;
    height: 70vh;
    overflow: scroll;
}

hr {
    border: none;
    border-top: 1px solid black;
    margin: 36px 0;
}

dl {
    font-size: 18px;
}

dt {
    font-weight: bold;
    font-variant: small-caps;
    font-size: 24px;
}

dd {
    margin-left: 24px;
}

dd + dt {
    margin-top: 24px;
}

dt + dd {
}


@media (width <= 932px) {
    .page-body-wrapper {
        flex-direction: column;
    }
    aside.spine {
        writing-mode: horizontal-tb;
        padding: 16px 8px;
        text-align: center;
    }
    .spacer {
        display: none;
    }
    .page-body {
        flex-grow: 1;
    }
    .page-body-wrapper {
        justify-content: center;
    }
    aside.spine {
    }
    main {
        width: auto;
        flex-grow: 1;
    }
    footer {
        width: auto;
        align-self: stretch;
    }
}

@media (width <= 824px) {
    .container.multi-document main > article {
        min-width: 420px;
        width: auto;
    }
    section.content {
        display: flex;
        flex-direction: column;
    }
    section.list {
        display: flex;
        flex-direction: column-reverse;
    }
    section.tei-pages {
        max-width: 450px;
    }
    footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    address {
        margin-top: 24px;
    }
}

@media (width <= 600px) {
    main > article, footer {
        padding: 24px;
    }
    section.pinning {
        padding: 12px 24px;
    }
    section.pinning * + * {
         margin-left: 8px;
    }
    nav ul {
        padding: 16px 8px 8px 8px;
    }
    nav ul li {
        display: inline-block;
        margin-right: 12px;
    }
    nav input[type=search] {
       flex-grow: 1;
       font-size: 18px;
       padding: 16px 8px 8px 8px;
    }
    h1.brutalist {
        font-size: 52px;
        margin-top: 24px;
    }
    ul.descriptive {
        padding-left: 12px;
    }
}

@media (width <= 480px) {
    main > article {
        padding: 12px;
    }
    section.pinning {
        padding: 8px 12px;
    }
    section.pinning p {
        font-size: 16px;
    }
    section.pinning * + * {
         margin-left: 6px;
    }
    footer {
        padding: 24px 12px;
    }
    nav ul {
        padding: 12px 6px 6px 6px
    }
    nav ul li {
        font-size: 16px;
    }
    nav ul li {
        margin-right: 8px;
    }
    nav input[type=search] {
       font-size: 16px;
       padding: 12px 6px 6px 6px
    }
    aside.spine {
        font-size: 16px;
        padding: 12px 6px;
    }
}
