:root {
    --bg-main: #fff;
    --bg-light: #f8f9fa;
    --border: #a2a9b1;
    --text-main: #202122;
    --text-muted: #555;
    --font-main: Georgia, "Times New Roman", Times, serif;
    --max-width: 1100px;
    --link-color: #0645ad;
    --link-hover: #0b0080;
    --accent: #0645ad;
    --highlight: #eaf2ff;
    --transition: all 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #121212;
        --bg-light: #1e1e1e;
        --border: #444;
        --text-main: #eee;
        --text-muted: #aaa;
        --link-color: #66aaff;
        --link-hover: #99ccff;
        --highlight: #1f2a3d;
    }
}

/* ============ BASE STYLES ============ */
html {
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-main);
    line-height: 1.7;
    background: var(--bg-main);
    color: var(--text-main);
    overflow-wrap: break-word;
    word-break: normal;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover,
a:focus {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ============ HEADER / FOOTER ============ */
header,
footer {
    background: var(--bg-light);
    padding: 1rem 2rem;
    text-align: center;
}

header {
    border-bottom: 1px solid var(--border);
}

header h1 {
    margin: 0.2rem 0;
    font-size: 2.2rem;
    line-height: 1.3;
}

header p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
}

footer {
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

/* ============ MAIN LAYOUT ============ */
main {
    display: flex;
    gap: 2rem;
    max-width: var(--max-width);
    margin: 2rem auto;
    padding: 0 1rem;
    flex-wrap: wrap;
}

article {
    flex: 3 1 60%;
    min-width: 280px;
}

/* Section Headings (collapsible look) */
article h2 {
    font-size: 1.4rem;
    margin-top: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    font-weight: 600;
}

article h2::after {
    content: '\25BC';
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    transform-origin: center;
}

article h2.active::after {
    transform: rotate(-180deg);
}

/* Collapsible Sections */
article section[role="region"] .content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, opacity 0.5s ease;
    opacity: 0;
}

article section.active .content {
    opacity: 1;
}

article p,
article li {
    font-size: 1rem;
    margin: 0.6rem 0;
}

article ul {
    padding-left: 1.6rem;
}

/* ============ ASIDE INFOBOX ============ */
aside {
    flex: 1 1 30%;
    min-width: 260px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.95rem;
}

aside img {
    width: 100%;
    height: auto;
    display: block;
    border-bottom: 1px solid var(--border);
}

/* Enhanced Table Styling */
aside table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    overflow-x: auto;
    display: block;
}

aside caption {
    caption-side: top;
    text-align: left;
    font-weight: 600;
    padding: 0.6rem;
    color: var(--text-muted);
}

aside table th,
aside table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

aside table th {
    background: var(--highlight);
    font-weight: bold;
    text-align: left;
    color: var(--text-main);
}

aside table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

aside table tr:hover {
    background-color: rgba(100, 100, 100, 0.1);
    transition: background-color 0.2s;
}

/* Sticky Sidebar */
@media (min-width: 900px) {
    aside {
        position: sticky;
        top: 2rem;
    }
}

/* Responsive Layouts */
@media (max-width: 900px) {
    main {
        flex-direction: column;
    }
    aside {
        max-width: 500px;
        margin: 0 auto 1.5rem;
    }
}

@media (max-width: 600px) {
    aside {
        max-width: 400px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    article h2 {
        font-size: 1.2rem;
    }
}

/* ============ PRINT STYLES ============ */
@media print {
    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }
    header, footer {
        background: none;
        border: none;
        padding: 0;
        text-align: left;
    }
    main { display: block; margin: 0; padding: 0; }
    aside {
        float: right;
        margin: 0 0 1rem 1rem;
        width: 40%;
        font-size: 10pt;
    }
    article {
        width: 100%;
    }
    a::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
    }
    .content {
        display: block !important;
        max-height: none !important;
        opacity: 1 !important;
    }
    article h2::after { display: none; }
}

/* Branding */
.branding {
    font-size: small;
    padding: 10px;
    color: grey;
    text-align: center;
}

/* Focus outlines */
h2:focus-visible {
    outline: 2px dashed var(--link-color);
    outline-offset: 4px;
}

/* Last section icon disabled */
article section:last-child h2 {
    cursor: default;
}

/* ============ SEMANTIC ELEMENTS SUPPORT ============ */

/* Definition Lists */
dl { margin: 1rem 0; }
dt { font-weight: 600; margin-top: 0.6rem; color: var(--text-main); }
dd { margin: 0 0 0.6rem 1.4rem; color: var(--text-muted); }

/* Blockquotes */
blockquote {
    margin: 1.2rem 0;
    padding: 0.8rem 1rem;
    border-left: 4px solid var(--accent);
    background: var(--bg-light);
    font-style: italic;
    color: var(--text-muted);
}

/* Figures */
figure { margin: 1.5rem auto; text-align: center; }
figcaption { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.4rem; }

/* Highlight / Mark */
mark {
    background: #fff176;
    color: #000;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

/* Code & Pre */
code {
    font-family: "Courier New", Courier, monospace;
    background: var(--bg-light);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.95em;
}
pre {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.95em;
    line-height: 1.5;
    border: 1px solid var(--border);
}
pre code { background: none; padding: 0; }

/* Keyboard inputs */
kbd {
    font-family: "Courier New", Courier, monospace;
    background: #333;
    color: #fff;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Abbreviation */
abbr[title] {
    border-bottom: 1px dotted var(--border);
    cursor: help;
}

/* Small Text */
small { font-size: 0.85em; color: var(--text-muted); }

/* Address */
address {
    font-style: normal;
    background: var(--bg-light);
    padding: 0.8rem 1rem;
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    color: var(--text-muted);
    margin: 1rem 0;
}

/* Superscript/Subscript */
sup, sub { font-size: 0.8em; line-height: 0; }

/* Horizontal Rule */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Details/Summary */
details {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.5rem 0.8rem;
    margin: 1rem 0;
}
details summary {
    font-weight: 600;
    cursor: pointer;
    color: var(--link-color);
}
details[open] summary {
    color: var(--link-hover);
}

/* Progress & Meter */
progress, meter {
    width: 100%;
    height: 1rem;
    border-radius: 5px;
    overflow: hidden;
    margin: 0.5rem 0;
}
progress::-webkit-progress-bar,
meter::-webkit-meter-bar {
    background: var(--bg-light);
    border: 1px solid var(--border);
}
progress::-webkit-progress-value,
meter::-webkit-meter-optimum-value {
    background: var(--link-color);
}
