:root {
    color-scheme: light dark;
    --font: Cambria, Georgia, "Times New Roman", serif;
    --surface1: #e6e6e6;
    --surface-card: #f2f2f2;
    --card-border: rgba(0, 0, 0, 0.08);
    --card-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    --tertiary: #6a4fa3;
    --element1: #111111;
    --focus-color: #6a4fa3;

    /*
     * Breakpoints only override these; the rules consuming them are declared once.
     * min-width only, so no viewport width falls between two queries the way a
     * max-width/min-width pair leaves a gap at fractional widths.
     */
    --avatar: 80px;
    --icon: 26px;
    --gutter: 1.25em;
    --measure: 34rem;
    --h1: xx-large;
    --text-line: 1.35em;
}

/* Paints the OS preference before main.js sets [color-mode], and covers no-JS. */
@media (prefers-color-scheme: dark) {
    :root:not([color-mode="light"]) {
        --surface1: #1e1e1e;
        --surface-card: #282828;
        --card-border: rgba(255, 255, 255, 0.09);
        --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
        --tertiary: #c4a9f7;
        --element1: #eeeeee;
        --focus-color: #c4a9f7;
    }
}

:root[color-mode="dark"] {
    --surface1: #1e1e1e;
    --surface-card: #282828;
    --card-border: rgba(255, 255, 255, 0.09);
    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --tertiary: #c4a9f7;
    --element1: #eeeeee;
    --focus-color: #c4a9f7;
}

/* Small screen laptops / iPad Air / iPad Pro / iPads Mini, Tablets */
@media (min-width: 481px) {
    :root {
        --avatar: 100px;
        --icon: 30px;
        --gutter: 2em;
        --text-line: 1.5em;
    }
}

/* Big laptops / Monitors / Others */
@media (min-width: 1200px) {
    :root {
        --avatar: 120px;
    }
}

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

html {
    font-family: var(--font);
    line-height: 1.5;
    background-color: var(--surface1);
    scroll-behavior: smooth;
    transition: background-color 0.3s ease;
}

body {
    color: var(--element1);
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── Theme toggle ── */

/* Pinned so the toggle stays reachable once the page is long enough to scroll. */
#toggleMode {
    position: fixed;
    top: 1em;
    right: 1em;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
}

.card,
#toggleLabel {
    background-color: var(--surface-card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#toggleLabel {
    display: none;
    position: fixed;
    top: 1.25em;
    right: 1.25em;
    width: 2.75rem;
    height: 2.75rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* The toggle does nothing without scripting, so main.js reveals it. */
:root.js #toggleLabel {
    display: flex;
}

:root:not(.js) #toggleMode {
    display: none;
}

.fa-sun,
.fa-moon {
    width: 1.35rem;
    height: 1.35rem;
    pointer-events: none;
    fill: var(--tertiary);
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.fa-sun {
    display: none;
    fill: none;
    stroke: var(--tertiary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fa-moon {
    display: inline;
}

:root[color-mode="dark"] .fa-sun {
    display: inline;
}

:root[color-mode="dark"] .fa-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([color-mode="light"]) .fa-sun {
        display: inline;
    }

    :root:not([color-mode="light"]) .fa-moon {
        display: none;
    }
}

/* ── Links ── */
a {
    color: var(--element1);
    transition: color 0.2s ease;
}

a:hover {
    color: var(--tertiary);
}

/* Icon links get a minimum touch-target for mobile accessibility. */
nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    transition: color 0.2s ease;
}

a svg {
    display: block;
    width: var(--icon);
    height: var(--icon);
    fill: currentColor;
}

/* ── Focus styles ── */
a:focus-visible,
#toggleMode:focus-visible+#toggleLabel {
    outline: 2px solid var(--focus-color);
    outline-offset: 4px;
    border-radius: 4px;
}

#toggleMode:focus-visible+#toggleLabel {
    border-radius: 12px;
}

/* ── Layout ── */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

main section {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
    padding: 3em var(--gutter);
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.left-col,
.right-col {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.card {
    padding: 1.5em 1.5em;
}

/* ── Identity card ── */
.identity {
    display: flex;
    align-items: center;
    gap: 1.25em;
}

.identity .avatar {
    flex: none;
    border-radius: 50%;
    width: var(--avatar);
    height: var(--avatar);
}

.identity div {
    min-width: 0;
}

main h1 {
    margin: 0;
    font-size: var(--h1);
    line-height: 1.15;
}

.identity p {
    margin: 0.35em 0 0;
}

/* Two columns once there is room */
@media (min-width: 760px) {
    :root {
        --measure: 54rem;
    }

    main section {
        display: grid;
        grid-template-columns: minmax(0, 16.5rem) minmax(0, 1fr);
        align-items: start;
        gap: 1.75em;
    }

    .identity {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .identity .avatar {
        margin-bottom: 0.25em;
    }
}

/* ── Typography ── */
p,
section h2,
section dl,
section .work {
    line-height: var(--text-line);
}

.card h2 {
    margin: 0 0 0.75em 0;
    font-size: 1.15em;
    letter-spacing: 0.02em;
}

/* ── Work list ── */
section .work {
    margin-block: 0;
    padding-left: 1.25em;
}

section .work li+li {
    margin-top: 0.5em;
}

/* ── Tech definition list ── */
section dl {
    margin-block: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55em;
}

section dt,
section dd {
    display: inline;
    margin: 0;
}

/* Padding, not a space in `content`, so HTML/CSS minification cannot drop the gap. */
section dt::after {
    content: ":";
    padding-right: 0.3em;
}

section dt {
    font-weight: bold;
}

/* ── Social nav ── */
section nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 0;
    padding: 0;
}

/* ── Footer ── */
footer {
    background-color: var(--surface1);
    font-size: x-small;
    line-height: 1.4;
    padding: 1em var(--gutter);
    text-align: center;
    transition: color 0.3s ease, background-color 0.3s ease;
}

footer small {
    display: block;
}

/* Matches the section box so the footer text lines up with the content above it. */
footer p {
    max-width: var(--measure);
    margin: 0.25em auto;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
