@font-face {
    font-family: cms;
    font-display: swap;
    font-style: normal;
    font-weight: 900;
    src: url(font/cms.woff2) format('woff2');
}

@font-face {
    font-family: titan;
    font-display: swap;
    font-style: normal;
    font-weight: normal;
    src: url('font/titan.woff2') format('woff2');
}

:root {
    --app-color-accent: #1c2e21;
    --app-color-accent-alpha: #1c2e21aa;
    --app-color-accent-text: #fff;
    --app-color-error: #cf5236;
    --app-color-error-alpha: #cf5236aa;
    --app-color-error-text: #fff;
    --app-color-primary: #222;
    --app-color-primary-alpha: #222222aa;
    --app-color-primary-dark: #040301;
    --app-color-primary-dark-alpha: #040301aa;
    --app-color-primary-light: #999691;
    --app-color-primary-light-alpha: #999691aa;
    --app-color-primary-text: #fff;
    --app-color-primary-text-alpha: #ffffffaa;
}

body {
    line-height: 1.5rem;
    padding-bottom: 12rem;
    font-family: sans-serif;
    color: var(--app-color-primary-text);
    background: url('ball.jpg') no-repeat right bottom, url('bg.jpg') repeat;
}

::selection {
    color: var(--app-color-accent-text);
    background: var(--app-color-accent-alpha);
}

:is(article, aside, details, form, fieldset, figure, main, section) > :not(:first-child),
[class|=block] > :not(:first-child),
[data-type=textarea] > :not(:first-child) {
    margin-top: 1.5rem;
}

.desktop { display: none; }

a {
    text-decoration: underline;
    color: var(--app-color-accent);
}

mark {
    padding: 0.125rem 0.25rem;
    color: var(--app-color-accent-text);
    background: var(--app-color-accent-alpha);
    border-radius: 0.125rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
ol, ul { padding-left: 2rem; }

nav {
    a { text-decoration: none; }

    ul {
        padding-left: 0;
        list-style: none;
    }
}

details {
    padding: 0.6875rem 0.3125rem;
    color: var(--app-color-primary-text);
    background: var(--app-color-primary-dark-alpha);
    border: 0.0625rem solid var(--app-color-primary-dark);

    &[open] {
        color: var(--app-color-accent-text);
        background: var(--app-color-accent-alpha);

        summary {
            padding-bottom: 0.6875rem;
            border-bottom: 0.0625rem solid var(--app-color-primary-dark);
        }
    }

    a:not(.button) { color: var(--app-color-primary-dark); }
}

figure {
    &.left {
        max-width: 50%;
        margin: 0 0.75rem 0.75rem 0;
        float: left;
        shape-outside: inset(0 0 0 0);
        shape-margin: 0.75rem;
    }

    &.center {
        max-width: 80%;
        margin-left: auto;
        margin-right: auto;
    }

    &.right {
        max-width: 50%;
        margin: 0 0 0.75rem 0.75rem;
        float: right;
        shape-outside: inset(0 0 0 0);
        shape-margin: 0.75rem;
    }
}

figcaption { font-size: 0.875rem; }

img {
    max-width: 15rem;
    max-height: 15rem;
    object-fit: contain;
}

table {
    width: 100%;
    font-size: 0.875rem;
}

tfoot { font-weight: bold; }

td, th {
    padding: 0.5rem 0.375rem;
    border-bottom: 0.0625rem dotted;
}

th[scope=row] { font-weight: normal; }

table.stat,
[class|=fixture] {
    a { color: inherit; }

    input:is([type=datetime-local], [type=number]) {
        height: 1.375rem;
        padding: 0;
        color: var(--app-color-primary-text);
        background: var(--app-color-primary-dark-alpha);
        border: 0;
    }

    input[type=number] {
        width: 3rem;
        text-align: center;
    }

    input[type=checkbox] { margin: 0; }

    .date, .team { text-align: left; }

    .team-home {
        text-align: right;

        a.team-link {
            padding: 0 2.25rem 0 0;

            img {
                left: initial;
                right: 0;
            }
        }
    }

    .result {
        text-align: center;

        a {
            text-decoration: none;
            color: inherit;
        }

        time { font-size: 0.75rem; }
    }
}

table.stat {
    thead {
        position: sticky;
        top: 3rem;
        z-index: 1;
        font-weight: bold;
        color: var(--app-color-primary-text);
        background: var(--app-color-primary-dark-alpha);
        border-bottom-style: solid;
    }

    td, th {
        white-space: nowrap;
        text-align: center;

        &.min { width: 1%; }
        &.team { width: 50%; }
    }
}

[class|=fixture] {
    font-size: 0.875rem;
    text-wrap: nowrap;

    & > * { padding: 0.5rem 0.375rem; }
    & > :not(:first-child) { margin-top: 0; }

    .weekday {
        font-weight: bold;
        border-bottom: 0.0625rem solid;
    }

    .item {
        display: grid;
        grid-template-columns: 10fr 1fr 10fr;
        gap: 0.75rem;
    }
}

.fixture-day .item {
    grid-template-rows: 1fr 1fr;
    grid-template-columns: repeat(3, 1fr);

    & > .date { grid-area: 1 / 1 / 2 / 3; }

    & > .counted {
        grid-area: 1 / 3 / 2 / 4;

        label {
            display: inline-block;
            margin-right: 0.75rem;
            font-size: 0.75rem;
            color: var(--app-color-accent);
        }
    }
}

.block-daily table.stat thead .result a.team-link {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;

    img { position: static; }

    span { display: none; }
}

:root[data-id='league:view'] .block-league table.stat tbody tr:is(
    :nth-of-type(4),
    :nth-of-type(5),
    :nth-of-type(6),
    :nth-of-type(15),
    :nth-of-type(16)
) td,
:root[data-id='betleague:view:1']:not([data-season='2010']) .block-league table.stat tbody tr:nth-of-type(15) td,
:root[data-id='betleague:view:1'][data-season='2010'] .block-league table.stat tbody tr:nth-of-type(14) td,
:root[data-id='betleague:view:2']:not([data-season='2010']) .block-league table.stat tbody tr:is(:nth-of-type(3), :nth-of-type(15)) td,
:root[data-id='betleague:view:2'][data-season='2010'] .block-league table.stat tbody tr:nth-of-type(4) td,
:root[data-id='betleague:view:3'] .block-league table.stat tbody tr:nth-of-type(3) td,
:is(.block-daily, .block-overall, .block-stat) table.stat tbody tr:nth-of-type(10n):not(:last-child) td {
    border-bottom-style: dashed;
}

[role=alert] {
    padding: 0.75rem;
    color: var(--app-color-accent-text);
    background: var(--app-color-accent-alpha);

    p:not(:first-child) { margin-top: 0; }
}

::file-selector-button {
    height: 1.5rem;
    padding: 0.25rem;
    color: var(--app-color-primary-text);
    background: var(--app-color-primary-dark-alpha);
    border: 0;
}

::placeholder { color: var(--app-color-primary-light); }

input:is(
    [type=date],
    [type=datetime-local],
    [type=email],
    [type=number],
    [type=password],
    [type=search],
    [type=tel],
    [type=text],
    [type=time],
    [type=url]
),
legend,
select,
textarea {
    padding: 0.71875rem 0;
    border-bottom: 0.0625rem solid var(--app-color-primary-dark);
}

fieldset input:is(
    [type=date],
    [type=datetime-local],
    [type=email],
    [type=number],
    [type=password],
    [type=search],
    [type=tel],
    [type=text],
    [type=time],
    [type=url]
),
fieldset select {
    width: 100%;
    max-width: 30rem;
}

button, input:is([type=button], [type=submit]) {
    padding: 0.75rem;
    color: var(--app-color-primary-text);
    background: var(--app-color-primary-dark-alpha);
}

a.button, input[type=reset] {
    padding: 0.75rem;
    text-decoration: none;
    color: var(--app-color-primary-text);
    background: var(--app-color-primary-light-alpha);
}

input[type=file] { font-size: 0.75rem; }
.file-current, .file-delete { font-size: 0.875rem; }
legend, textarea { width: 100%; }
label { display: block; }
select[multiple], textarea { height: 15rem; }
select { background: none; }

input:is([type=checkbox], [type=radio]) {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0.125rem 0;
    padding: 0.5625rem 0;
    border: 0.0625rem solid var(--app-color-primary-dark);
    appearance: none;

    &:checked {
        color: var(--app-color-accent-text);
        background: var(--app-color-accent-alpha);
    }

    & + label {
        display: inline-block;
        margin: 0 0.5rem 0 0.25rem;
    }

    &[disabled] + label { opacity: 0.2; }
}

input[type=radio] { border-radius: 1rem; }

div:has([required]) > label:first-child::after { content: '*'; }

form:invalid [type=submit] {
    color: var(--app-color-error-text);
    background: var(--app-color-error-alpha);
}

div:has(:user-invalid, .error) {
    color: var(--app-color-error);

    :user-invalid {
        color: var(--app-color-error-text);
        background: var(--app-color-error-alpha);
        border-bottom: 0.0625rem solid var(--app-color-error);
    }
}

.error {
    margin: 0;
    font-size: 0.875rem;
    font-weight: bold;
    color: var(--app-color-error);
}

a[data-action] {
    display: inline-block;
    line-height: 1;
    font-family: cms;
    font-size: 0;
    text-decoration: none;

    &::before { font-size: 1rem; }
}

a[data-action=add]::before { content: '\e804'; }
a[data-action=edit]::before { content: '\e805'; }
a[data-action=delete]::before { content: '\e806'; }
a[data-action=view]::before { content: '\e807'; }

a.team-link {
    display: inline-block;
    position: relative;
    padding: 0 0 0 2.25rem;
    text-decoration: none;
    color: inherit;

    img {
        position: absolute;
        left: 0;
        top: calc(50% - 0.75rem);
        width: 1.5rem;
        height: 1.5rem;
        object-fit: contain;
    }

    span { display: block; }
    span.team-name { display: none; }
}

.block-fixtureview {
    & > * { text-align: center; }
    .result { font-size: 3rem; }
    .date { font-size: 1.25rem; }

    .info {
        margin-top: 0;
        font-size: 0.875rem;
        font-weight: bold;
    }

    a.team-link {
        padding: 0;
        text-align: center;
    }

    a.team-link img {
        position: static;
        display: block;
        width: 7.5rem;
        height: 7.5rem;
        margin: 0 auto;
    }
}

.links {
    font-size: 0.875rem;

    a {
        text-decoration: none;
        color: var(--app-color-primary-text);

        &:not(:first-child) { margin-left: 0.5rem; }
        &[aria-current] { font-weight: bold; }
    }

    select {
        width: 100%;
        padding: 0 0.375rem;
        color: var(--app-color-primary);
        background: var(--app-color-primary-text-alpha);
        border: 0;
    }
}

[data-change] {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;

    &::after {
        font-family: cms;
        font-size: 1.25rem;
        content: '\e801';
    }
}

[data-change='']::after { content: '\e800'; }
[data-change='0']::after { content: '\e802'; }
[data-change^='-']::after { content: '\e803'; }

[data-points] {
    display: inline-block;
    white-space: nowrap;

    &::after {
        display: inline-block;
        vertical-align: super;
        line-height: 1;
        margin-left: 0.0625rem;
        font-size: 0.75rem;
        color: var(--app-color-error);
        content: attr(data-points);
    }
}

[data-points='0']::after { visibility: hidden; }

#toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-areas: "icon shortcut day" "toolbar toolbar toolbar";
    grid-template-columns: minmax(max-content, 1.5rem) minmax(min-content, 1fr) minmax(min-content, 6rem);
    column-gap: 0.75rem;
    padding: 0.75rem;
    color: var(--app-color-primary-text);
    background: var(--app-color-primary-dark-alpha);

    &[data-open] { position: relative; }

    a {
        display: inline-block;
        color: inherit;
    }

    &::before,
    a[aria-haspopup=true]::after {
        line-height: 1;
        font-family: cms;
        cursor: pointer;
    }

    &::before {
        font-size: 1.5rem;
        content: '\e809';
    }

    &[data-open]::before { content: '\e808'; }

    a[aria-haspopup=true]::after {
        margin-left: 0.375rem;
        content: '\e802';
    }

    a[aria-haspopup=true][aria-expanded=true]::after {
        margin-left: 0.375rem;
        content: '\e803';
    }

    a:is([aria-current], .current-path) { font-weight: bold; }

    &[data-open] > ul, a[aria-expanded=true] + ul { display: block; }

    ul {
        display: none;
        margin-left: 1.5rem;
    }

    &[data-open] ul { display: block; }

    & > ul {
        grid-area: toolbar;
        margin: 1.5rem 0 0;
    }

    div.shortcut {
        grid-area: shortcut;
        display: flex;
        gap: 0.75rem;
    }

    .block-day {
        grid-area: day;
        justify-self: end;
    }

    .block-day > :not(:first-child), .block-day > div > :not(:first-child) { margin-top: 0; }

    .block-day, .block-day > :is(.season, .day), &[data-open] .block-day > .season {
        display: flex;
        column-gap: 0.375rem;
    }

    &[data-open] div.shortcut, .block-day > .season { display: none; }

    .block-day label { display: inline-block; }

    .block-day select {
        padding: 0 0.375rem;
        color: var(--app-color-primary-text);
        background: var(--app-color-primary-alpha);
        border: 0;
    }
}

#header {
    display: block;
    max-width: 100rem;
    height: 24rem;
    margin: 0 auto;
    padding: 0.75rem;
    text-align: right;

    h1 {
        line-height: 1;
        font-family: titan;
        color: var(--app-color-primary-dark-alpha);
    }
}

main {
    max-width: 100rem;
    margin: 24rem auto 0;
}

#header ~ main { margin-top: 0; }

#content {
    & > * {
        padding: 0.75rem;
        color: var(--app-color-primary-text);
        background: var(--app-color-primary-alpha);

        &.links {
            background: var(--app-color-accent-alpha);
        }
    }
}

@media screen and (min-width: 721px) {
    .desktop { display: revert; }
    .mobile { display: none; }

    .fixture-day .item {
        grid-template-rows: 1fr;
        grid-template-columns: 3fr 8fr 3fr 8fr 1fr;

        & > :is(.date, .counted) { grid-area: auto; }
        & > .counted label { display: none; }
    }

    a.team-link {
        span.team-shortname { display: none; }
        span.team-name { display: block; }
    }

    .block-fixtureview {
        display: flex;
        flex-wrap: wrap;
        place-items: center;

        & > :not(:first-child) { margin-top: 0; }
        .date, .info { width: 100%; }
        .team { width: 40%; }
        .team-home { text-align: right; }
        .team-away { text-align: left; }
        .result { width: 20%; }
    }

    #header h1 {
        line-height: 6rem;
        font-size: 4.5rem;
    }
}

@media screen and (min-width: 1041px) {
    #toolbar {
        grid-template-areas: "toolbar day";
        grid-template-columns: minmax(min-content, 1fr) minmax(max-content, 12rem);
        font-size: 0.875rem;

        &::before, a:not([aria-expanded=true]) + ul { display: none; }

        & > ul {
            display: block;
            margin-top: 0;

            & > li {
                display: inline-block;
                margin-right: 0.625rem;
            }
        }

        ul { margin-left: 0; }

        li {
            ul {
                position: absolute;
                background: var(--app-color-primary-dark-alpha);
            }

            li {
                position: relative;
                display: block;
                padding: 0.375rem;

                ul {
                    top: 0;
                    left: 100%;
                }
            }
        }

        .block-day > .season { display: flex; }
        div.shortcut { display: none; }
    }
}
