:root,
html[data-theme='light']{
    --background: #ffffff;
    --text: #000000;
    --dimmed-text: #7b7d82;
    --red: #cf222e;
    --orange: #ffa700;
    --green: #2da44e;
    --blue: #6d9dd5;
    --bluer: #0969da;
    --link: #0969da;
    --link-visited: #9963ff;
    --highlight: #f6f8fa;
    --cell-border: #d0d7de;
    --target-highlight: #c2deef;
    --comment-background: #f0fff0;
    --variant-highlight: #e0e7ff;
    --variant-highlight-alt: #f0f4ff;
    --column-gap: 15px;
    --box-shadow-card: rgba(0, 0, 0, 0.15) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
    --code-background: #f6f8fa;
}

html[data-theme='dark']{
    --background: #0d1117;
    --text:  #eaedf0;
    --dimmed-text: #7b7d82;
    --red: #fd2433;
    --orange: #ffa700;
    --green: #2da44e;
    --blue: #58a6ff;
    --link: #58a6ff;
    --link-visited: #9669ea;
    --highlight: #161b22;
    --cell-border: #c2deef;
    --target-highlight: #58a6ff36;
    --comment-background: #38fd880d;
    --variant-highlight: #6282ff1a;
    --variant-highlight-alt: #6282ff26;
    --box-shadow-card: 0 -3px 12px rgb(0 0 0);
    --code-background: #6e76815e;
}

*{
    box-sizing: border-box;
}

html{
    margin: 0 1em;
    font-family:  ui-sans-serif, sans-serif;
}

body{
    margin: 3em auto;
    max-width: 850px;
    min-width: 544px;
    background-color: var(--background);
    color: var(--text);
}

header{
    margin: 3em 0 5em 0; 
}

header h1{
    margin: 1em 0;
}

.navigation{
    display: flex;
    justify-content: center;
    gap: 1.5em;
}

p,ul {
    line-height: 1.8;
}

code{
    background: var(--code-background);
    font-family: ui-monospace, monospace;
    font-size: 0.85em;
    padding: 3px 5px;
    border-radius: 4px;
}

pre code{
    padding: 0;
    border-radius: 0;
}

h1{
    text-align: center;
}

a,a:hover{
    color: var(--link);
}
a:visited{
    color: var(--link-visited);
}
.navigation a,
.navigation a:hover
.navigation a:visited{
    color: var(--dimmed-text);
    text-decoration: none;
    transition: color 0.2s ease;
}
.navigation a:hover{
    color: var(--color);
}

/*
  Grid
*/
.grid-wrapper{
    margin-bottom: 4em;
    line-height: 1.22;
}
.grid-head,
.grid-body{
    display: grid;
    min-width: min-content;
}
.grid-head{
    font-weight: bold;
    border-bottom: solid 2px var(--cell-border);
    background-color: var(--background);
}
.grid-row{
    display: grid;
    align-items: center;
    grid-gap: var(--column-gap);
    padding: 13px 15px 11px 15px;
}

.grid-schemes .grid-head > .grid-row,
.grid-schemes .grid-body > .grid-row{
    grid-template-columns: minmax(130px, 1fr) minmax(120px, 1fr) 95px 95px 115px 110px;
}

.grid-assumptions .grid-head > .grid-row,
.grid-assumptions .grid-body > .grid-row{
    grid-template-columns: minmax(140px, 1fr) 120px 120px 120px 110px;
}

.grid-attacks .grid-head > .grid-row,
.grid-attacks .grid-body > .grid-row{
    grid-template-columns: minmax(100px, 1fr) minmax(100px, 1fr) minmax(100px, 1fr) minmax(100px, 1fr) 110px;
}


.comment-row{
    display: grid;
    grid-template-columns: 1fr;
}
:not(:target).hidden-row{
    display: none;
}


.grid-row div:first-child{
    padding-left: 26px;
}
.grid-attacks .grid-row div:first-child,
.grid-body.has_variants .grid-row div:first-child{
    padding-left: 0px;
}

.grid-body:nth-child(odd){
    background-color: var(--highlight);
}
/* quintuple (!!!) grid-row so it takes precedence */
.grid-row.grid-row.grid-row.grid-row.grid-row:target {
    background-color: var(--target-highlight);
}
.grid-body.has_variants .grid-row {
    border-left: 3px solid var(--blue);

}
.grid-body:nth-child(odd).has_variants .grid-row {
    border-left: 3px solid var(--bluer);
}
.grid-body.has_variants .variant-row:nth-last-child(2)  {
    border-bottom: solid 3px var(--blue);
}
.grid-body:nth-child(odd).has_variants .variant-row:nth-last-child(2) {
    border-bottom: solid 3px var(--bluer);
}
.grid-row.variant-row div:nth-child(1) {
    text-indent: 36px;
}
.grid-row.variant-row {
    background-color: var(--variant-highlight);
}
.grid-body:nth-child(even) .grid-row.variant-row:nth-child(4n+1),
.grid-body:nth-child(even) .grid-row.variant-row:nth-child(4n+2),
.grid-body:nth-child(odd)  .grid-row.variant-row:nth-child(4n+3),
.grid-body:nth-child(odd)  .grid-row.variant-row:nth-child(4n+4)
{
    background-color: var(--variant-highlight-alt);
}


/*
  Toggle buttons
*/
.toggle-button{
    border: none;
    background-color: inherit;
    font-size: inherit;
    padding: 0;
    cursor: pointer;
    color: var(--text);
    margin: 0;
}
.toggle-button::before{
    content: "▵";
    transform: rotate(90deg);
    transform-origin: center;
    display: inline-block;
    margin-inline-end: 6px;
    transition: transform 0.3s ease;
    box-sizing:border-box;
    color: var(--text);
    width: 12px;
}
.toggle-button[aria-expanded]::before{
    transform: rotate(180deg);
    transform-origin: center;
}

/*
  Variants
*/

.variant-cell{
    line-height: 4px;
    margin-inline-end: calc(0px - var(--column-gap));
    text-align: end;
}
.has_variants :first-child label {
    cursor: pointer;
}

/*
  Comment styling
*/

.comment-cell{
    line-height: 1.6em;
    background-color: var(--comment-background);
    border-left: 3px solid var(--green);
    padding-left: 1.75em;
    -webkit-text-size-adjust: none
}
.comment-cell h4{
    margin: 1rem 0;
}


/*
  Abbr Stuff
*/
abbr[title] {
  position: relative;
  /* ensure consistent styling across browsers */
  text-decoration: underline dotted; 
}

abbr[title=""] {
    text-decoration: none;
}

/*
  Table entries styling
*/

.complexity.exp {
    color: var(--green);
}
.complexity.subexp {
    color: var(--orange);
}
.complexity.poly {
    color: var(--red);
}

.complexity a{
    color: inherit;
    text-underline-position: under;
}

a.reference-link{
    color: var(--link);
}
a.reference-link:visited{
    color: var(--link-visited);
}

/***/

footer {
    margin: 2em 0;
    display: flex;
    justify-content: center;
    gap: 3em;
    align-items: baseline;
}

/* Button Loops like Link */
.btn-theme-toggle{
    border: none;
    background: var(--background);
    font-size: 1em;
    color: var(--link);
    text-decoration: underline;
    cursor: pointer;
}




/* Mobile devices */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 900px) { 

    html{
        margin: 0 10px;
    }
    body{
        min-width: 0;
    }
    h2{
        margin-left: 0.5em;
    }

    abbr[title].touched::after {
        content: attr(title);

        /* position tooltip like the native one */
        position: absolute;
        left: 0;
        top: -40px;
        width: auto;
        white-space: nowrap;

        /* style tooltip */
        background-color: var(--highlight);
        color: var(--text);
        border-radius: 3px;
        box-shadow: 1px 1px 5px 0 rgba(0,0,0,0.2);
        font-size: 15px;
        padding: 3px 5px;
    }

    abbr[title=""] {
        text-decoration: none;
    }

    .grid-head{
        display: none;
    }
    .grid-body{
        margin: 1em 1em 2em calc(1em - 3px)
    }
    .grid-body,
    .has_variants{
        box-shadow: var(--box-shadow-card);
    }
    .grid-body:nth-child(odd){
        background-color: var(--background);
    }
    .grid-row div::before{
        content: attr(data-name) ": " ;
        font-weight: bold;
        color: var(--text);
    }
    .grid-row div.name::before,
    .grid-row div.comment-button-cell::before{
        content:  "";
    }
    .grid-row .name{
        font-weight: bold;
        padding-bottom: 10px;
        border-bottom: solid 2px var(--cell-border);
    }
    .grid-body.has_variants .variant-row:nth-last-child(2)  {
        border-bottom: solid 0px var(--blue);
    }
    .grid-body:nth-child(odd).has_variants .variant-row:nth-last-child(2) {
        border-bottom: solid 0px var(--bluer);
    }
    .grid-row.variant-row div:nth-child(1) {
        text-indent: 0px;
    }
    .grid-row div:first-child{
        padding-left: 0px;
    }
    .grid-schemes .grid-body > .grid-row,
    .grid-attacks .grid-body > .grid-row,
    .grid-assumptions .grid-body > .grid-row{
        grid-template-columns: 1fr
    }

    .comment-cell{
        padding: 0 1em;
    }
    .comment-cell h4{
        margin: 1rem 0;
        display: none;
    }

    .markdown-content h2{
        margin-left: 0;
    }

}
