/* ------------------------------ */
/* CSS Variables (Design Tokens)  */
/* ------------------------------ */

:root {
    /* Colors */
    --color-bg: #ffffff;
    --color-border: #dddddd;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 4rem;

    /* Typography */
    --font-base: system-ui, sans-serif;
    --line-height: 1.6;
    --max-width: 60ch;
}


/* ------------------------------ */
/* Global Reset & Base            */
/* ------------------------------ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-family: var(--font-base);
    font-size: 16px;
    line-height: var(--line-height);
    background: var(--color-bg);
}

body {
    margin: 0;
    padding: 0;
}

main {
    max-width: var(--max-width);
    margin: var(--space-lg) auto;
    padding: 0 var(--space-md);
}


/* ------------------------------ */
/* Typography                     */
/* ------------------------------ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin: var(--space-lg) 0 var(--space-md);
    line-height: 1.25;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4, h5, h6 { font-size: 1rem; }

p, ul, ol {
    margin-bottom: var(--space-md);
}

ul, ol {
    padding-left: var(--space-lg);
}


/* ------------------------------
   Header & Footer
   ------------------------------ */
header, footer {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);

    > div {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-md);
    }

    .current-href {
        font-weight: bold;
    }
}

footer {
    border-top: 1px solid var(--color-border);
    border-bottom: none;
}

header nav {
    display: flex;
    gap: var(--space-md);

    summary {
        cursor: pointer;
        max-width: 20ch;
        overflow-x: clip;
        text-overflow: ellipsis;
    }

    ul {
        position: absolute;
        right: 0px;
        padding: var(--space-sm) var(--space-md);
        background: var(--color-bg);
        border: 1px solid var(--color-border);
        border-radius: var(--space-sm);
        margin: var(--space-xs) var(--space-md);
        list-style: none;
    }
}

/* ------------------------------ */
/* Forms and Buttons              */
/* ------------------------------ */


form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);

    div:not(:last-child) {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
    }

    &:has(input[name="edit"]:not(:checked)) {
        .edit-input-hide {
            visibility: hidden;
        }

        .edit-input {
            display: none;
        }
    }
}

button, input {
    font: inherit;
    padding: var(--space-sm) var(--space-md);
}

fieldset {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}


/* ------------------------------ */
/* Tables                         */
/* ------------------------------ */

table {
    border-collapse: collapse;
    font-family: sans-serif;
}

th, td {
    padding: var(--space-sm);
    border: 1px var(--color-border) solid;
}

tr:nth-child(even) {
    background-color: #f4f4f4;
}


/* ------------------------------ */
/* Classes                        */
/* ------------------------------ */

.hidden {
    visibility hidden;
}


/* ------------------------------ */
/* Print Styles                   */
/* ------------------------------ */

@media print {
    /* Reset background and color for printing */
    body {
        background: #fff !important;
        color: #000 !important;
    }

    header,
    footer,
    nav,
    button {
        display: none !important; /* Hide non-essential UI */
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    a::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #555;
    }
}
