/*! GineCSS MIT-License https://ginacss.sippo.work/ */
/*! v0.0.1 beta */

@layer base, special;
@layer base {
    @media (prefers-color-scheme: light) {
        :root {
            color-scheme: light;
            --color-body-bg: #fdfdfd;
            --color-body-fg: #333;
            --color-link-fg: #007095;
        }
    }

    @media (prefers-color-scheme: dark) {
        :root {
            color-scheme: dark;
            --color-body-bg: #111;
            --color-body-fg: #ddd;
            --color-link-fg: #65a8c1;
        }
    }

    * {
        word-break: break-all;
        font-size: 1rem; /* 暫定 */
    }

    *, *::before, *::after {
        box-sizing: border-box;
    }

    *:not(pre, code) {
        font-family: sans-serif;
    }

    body {
        background-color: var(--color-body-bg);
        color: var(--color-body-fg);
        width: 95%;
        min-width: 180px;
        max-width: 720px;
        margin: 32px auto 4px auto;
    }

    blockquote,
    hr,
    iframe,
    img,
    ol:not(ol > ol, ul > ol),
    p,
    pre,
    ul:not(ul > ul, ol > ul),
    table,
    textarea,
    video {
        margin: 8px 0 24px 0;
    }

    blockquote {
        padding-left: 4px;
        border-left: solid 6px var(--color-link-fg);
    }
    
    footer {
        margin-top: 48px;
    }

    h1,h2,h3,h4,h5,h6 {
        margin: 24px 0 4px 0;
    }

    h1 {
        font-size: 2rem;
    }

    h1 + h2,
    h2 + h3,
    h3 + h4,
    h4 + h5,
    h5 + h6 {
        margin: 0 0 4px 0;
    }

    h2 {
        font-size: 1.6rem;
    }

    h3 {
        font-size: 1.4rem;
    }

    h4 {
        font-size: 1.2rem;
    }

    h5 {
        font-size: 1.1rem;
    }

    h6 {
        font-size: 1rem;
    }

    hr {
        background-color: var(--color-link-fg);
        width: 100%;
        height: 0;
        margin: 32px 0;
        padding: 1px 0;
        border: none;
        border-radius: 2px;
    }

    iframe,img,video {
        width: 100%;
        border-radius: 4px;
    }

    /* list */
    :root {
        --color-list-dot: var(--color-body-fg);
    }

    ul, ol {
        position: relative;
        padding-left: 0px;
        list-style: none;
    }

    ul > ul, ol > ol {
        padding-left: 1.5em;
    }

    ul > li{
        position: relative;
        padding-left: 12px;
    }

    ul > li::before {
        position: absolute;
        content: "";
        top: 0.5lh;
        left: 0;
        background-color: var(--color-list-dot);
        width: 6px;
        height: 6px;
        border-radius: 50%;
        transform: translateY(-3px);
    }

    ol {
        counter-reset: olcount;
    }

    ol > li::before {
        content: counter(olcount) ". ";
        position: relative;
        top: 0;
        left: 0;
        font-size: 1em;
    }

    ol > li{
    position: relative;
    padding-left: 0; /*delete?*/
    counter-increment: olcount;
    }

    li {
        min-height: 1lh;
    }

    li+li {
        margin-top: 4px;
    }
    /* end list */

    nav {
        display: flex;
        gap: 4px;
    }

    nav > a {
        flex-shrink: 1;
        padding: 2px 4px;
        font-size: 1.2rem;
        font-weight: bold;
        text-decoration: none;
    }

    p {
        margin: 4px 0;
    }

    table:not(.table-scroll) {
        width: 100%;
        border-collapse: separate;
        border-radius: 4px;
        border-spacing: 0;
        overflow: hidden;
    }

    table:not(.table-scroll) th, table:not(.table-scroll) td {
        border: solid 1px;
        padding: 4px;
        text-align: center;
        font-size: clamp(12px, 2vw, 1rem);
        vertical-align: top;
    }

    /* table: border-radius - border */
    thead tr:first-child th:first-child,
    thead tr:first-child td:first-child,
    tbody:not(thead+tbody) tr:first-child th:first-child,
    tbody:not(thead+tbody) tr:first-child td:first-child {
        border-top-left-radius: 4px;
    }

    thead tr:first-child th:last-child,
    thead tr:first-child td:last-child,
    tbody:not(thead+tbody) tr:first-child th:last-child,
    tbody:not(thead+tbody) tr:first-child td:last-child {
        border-top-right-radius: 4px;
    }

    tbody tr:last-child th:first-child,
    tbody tr:last-child td:first-child {
        border-bottom-left-radius: 4px;
    }

    tbody tr:last-child th:last-child,
    tbody tr:last-child td:last-child {
        border-bottom-right-radius: 4px;
    }

    table thead tr th,
    table thead tr td,
    table tr:not(tr:last-child) th,
    table tr:not(tr:last-child) td {
        border-bottom: none;
    }

    table tr th:not(:last-child),
    table tr td:not(:last-child) {
        border-right: none;
    }

    table th > span,
    table td > span {
        display: inline-block;
        text-align: left;
    }

    table.table-scroll {
        display: block;
        border-radius: 4px;
        overflow-x: auto;
        border-collapse: separate;
        border-spacing: 0;
    }

    table.table-scroll th, table.table-scroll td {
        min-width: 128px;
        border: solid 1px;
        padding: 4px;
        text-align: center;
        vertical-align: top;
        /*white-space: nowrap;*/
    }

    a {
        color: var(--color-link-fg);
    }

    button,
    input[type="button"],
    input[type="reset"],
    input[type="submit"] {
        background-color: var(--color-link-fg);
        color: var(--color-body-bg);
        margin: 0 4px;
        padding: 2px 8px;
        border: 0;
        border-radius: 4px;
        font-size: 1rem;
        cursor: pointer;
    }

    button:hover,
    input[type="button"]:hover,
    input[type="reset"]:hover,
    input[type="submit"]:hover {
        mix-blend-mode: luminosity;
    }

    button:active,
    input[type="button"]:active,
    input[type="reset"]:active,
    input[type="submit"]:active {
        opacity: 0.6;
    }
}

@layer special {
    header > * {
        margin: 4px 0;
    }
}