:root {
    /* Look into https://harmonizer.evilmartians.com/ , made by the same devs behind oklch.com */
    --bg-color: oklch(0.35 0.1 135);
    --text-color: oklch(0.89 0.14 90); /* Apparently conteast-color() exists? */
    --greyed-out: oklch(0.73 0.06 90); /* Separately defined colour for the sake of contrast; aiming for 4.5 : 1 ratio for large text */
    --default-width: 800px;
    --default-font-size: 1.4rem;
    --default-gap: 1.5rem;
    /* PayNet has its own DuitNow branding guidelines that includes colour details; slightly adjusted to fit the website
       https://paynet.my/attachments/duitnow-qr/DNQR_Brand%20Guidelines_2021.pdf */
    --duitnow-color: oklch(0.67 0.22 10);
    --duitnow-black: oklch(0.1 0 0);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    width: 100dvw;

    display: flex;
    flex-direction: column;
    align-items: center;

    font-family: 'Lexica Ultralegible', sans-serif;
    font-size: var(--default-font-size);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Syne Variable';
    font-weight: 700;
    font-style: normal;
}

p, li {
    line-height: 2rem;
}

header, footer {
    * { margin: 0; }
    padding-top: calc(var(--default-gap) + 1rem);
    padding-bottom: calc(var(--default-gap) + 1rem);
    width: 100dvw;

    display: inherit;
    flex-direction: inherit;
    align-items: center;
    text-align: center;

    *:not(:last-child) { margin-bottom: var(--default-gap); }
}

header > h1 {
    font-size: calc(var(--default-font-size) + 0.6rem);
}

article {
    margin-top: calc(var(--default-gap) + 2.5rem);
    margin-bottom: calc(var(--default-gap) + 1rem);

    * {
        margin: 0;
        margin-bottom: calc(var(--default-gap) * 1.25);
    }

    p {
        /* Only way I can force it to work on homepage
           Makes the whole article look more balanced than it actually is */
        margin-left: 0.3rem!important;
        margin-right: 0.3rem!important;
    }
}

h1 { font-size: calc(var(--default-font-size) + 3.2rem); }
h2 { font-size: calc(var(--default-font-size) + 2.4rem); }
h3 { font-size: calc(var(--default-font-size) + 1.6rem); }
h4, h5, h6 { font-size: calc(var(--default-font-size) + 0.8rem); }
h5, h6 { font-weight: 500; }
h6 { font-style: italic; }

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

a:hover {
    color: var(--bg-color);
    background-color: var(--text-color);
}

li > img {
    display: flex;
    max-width: 300px;
}

iframe {
    display: inherit;
    align-self: center;
}

article a:visited {
    color: var(--greyed-out);
}

/* To make each details look stacked */
details:has(+ details) {
    margin: 0;
}

/* Gotta shorten the width for nested details cause it otherwise looks too non-distinct to my taste */
details > details { margin-left: 2.5rem; }
/* CSS nesting into details { summary{} } completely broke the parent details element, separating them into their own root rules worked */
/* Safari specifically refuses to play well with modifying :marker, so custom :before it is
   https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/summary#browser_compatibility */
details > summary {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0; /* Removing extra top and bottom margins off the since details element already has its own margins */
    cursor: pointer; /* https://css-tricks.com/two-issues-styling-the-details-element-and-how-to-solve-them/ */
    font-weight: bold;
    font-size: calc(var(--default-font-size) + 0.3rem);
    background-color: var(--text-color);
    color: var(--bg-color);

    padding-top: 0.8rem;
    padding-bottom: 0.8rem;

    /* Remove all margins of all elements inside summary element */
    * { margin: 0; }
}

/* Apparently you can use this to apply universal rules for both parent and child: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Nesting_selector */
details > summary:before {
    margin-top: -0.3rem; /* Make text look more centre */
    margin-right: 0.5rem;
    content: "[+]";
}

/* If the summary is a heading, align it with the rest of the headings instead */
details > summary:has(h1, h2, h3, h4, h5, h6):before {
    font-size: calc(var(--default-font-size) + 0.5rem);
    margin-right: 1.1rem; /* Aligning text with other headings */
}
details > summary:has(h1, h2, h3, h4, h5, h6) {
    margin-left: -3.5rem;
    font-weight: unset;
}
details[open] > summary:has(h1, h2, h3, h4, h5, h6) {
    margin-left: -3rem; /* Gives it an appearance of right-aligned text */
}

/* This is a lot messier than it should be: https://stackoverflow.com/a/48815117 */
details[open] > summary:before {
    content: "[-]"; /* fullwidth hyphen-minus doesn't work out, so keyboard hyphen it is */
}

/* Sets borders to make it easily identifiable which one is part of details */
details[open]::details-content {
    border-left: 0.5rem solid var(--text-color);
    padding-left: 1rem;
    padding-top: 1rem;
}
details[open]:has(h1, h2, h3, h4, h5, h6)::details-content {
    border-left: unset;
    padding-left: unset;
}

.container {
    width: var(--default-width);
}

.unavailable {
    color: var(--greyed-out);
}

.unavailable:after {
    margin-left: 1rem;
    font-size: var(--default-font-size);
    vertical-align: super;
    content: "coming soon";
}

/* For step-by-step two-column gallery */
.gallery {
    display: grid;
}

/* Only use .new and .updated for actual major content updates of each section */
.new:after {
    margin-left: 1rem;
    font-size: var(--default-font-size);
    vertical-align: super;
    content: "new";
    color: var(--bg-color);
    background-color: var(--text-color);
}

.updated:after {
    margin-left: 1rem;
    font-size: var(--default-font-size);
    vertical-align: super;
    content: "updated";
    font-style: italic;
}

.inverse-color {
    color: var(--bg-color);
    background-color: var(--text-color);
}

.duitnow, .duitnow:visited {
    color: var(--duitnow-black);
    background-color: var(--duitnow-color);
}

a.duitnow:hover {
    background-color: unset;
    color: var(--duitnow-color);
}

.homepage-section {
    padding-left: 1rem;
    padding-right: 1rem;
}

.homepage-title {
    /* So they could line up with sections properly on homepage */
    margin-left: 3rem;
}

/* https://stackoverflow.com/a/15503444 */
p:has(+ #toc) { margin-bottom: 0; }
#toc {
    margin-top: calc(var(--default-gap) + 1rem);
    margin-bottom: calc(var(--default-gap) + 1rem);
}

@media (width < 960px) {
    :root {
        --default-font-size: 1.3rem;
    }

    header > h1 {
        font-size: calc(var(--default-font-size) + 0.3rem);
    }

    h1 { font-size: calc(var(--default-font-size) + 1.2rem); }
    h2 { font-size: calc(var(--default-font-size) + 0.9rem); }
    h3 { font-size: calc(var(--default-font-size) + 0.6rem); }
    h4, h5, h6 { font-size: calc(var(--default-font-size) + 0.3rem); }

    .container, header > *, footer > * {
        max-width: 90dvw;
    }

    details > details { margin-left: 1.3rem; }
    details > summary:has(h1, h2, h3, h4, h5, h6),
        details[open] > summary:has(h1, h2, h3, h4, h5, h6) { margin-left: unset; }
    details > summary:has(h1, h2, h3, h4, h5, h6):before { margin-right: 0.5rem; }
}
