body {
    background-color: white;
    color: black;
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: calc(1vw + 1vh);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
body.dark-mode {
    background-color: black;
    color: white;
}
body.dark-mode nav {
    background-color: black;
}
body.dark-mode .nav-toggle {
    color: white;
}
body.dark-mode nav .left ul li a {
    color: white;
}
body.dark-mode nav .right svg {
    color: white;
}
body.dark-mode #icon-sun {
    display: inline;
}
body.dark-mode #icon-moon {
    display: none;
}
body.dark-mode nav .left .logo {
    filter: brightness(0) invert(1);
}
body.dark-mode nav .left ul li:hover p.link-info {
    opacity: 1;
    visibility: visible;
    display: block;
    color: white;
}
body.dark-mode nav .left ul li a,
body.dark-mode nav .left ul li a:visited {
    color: white;
}
body.dark-mode .grid {
    color: white;
}
body.dark-mode .mobile-caption {
    color: white;
}

nav {
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 300;
    padding: 0.5em 0.5em;
}
nav .left {
    display: flex;
    align-items: center;
}
nav .left .logo {
    display: block;
    width: clamp(20px, 1em, 40px);
    height: clamp(20px, 1em, 40px);
}
nav .left ul {
    list-style: none;
    margin: 0;
    margin-left: 2em;
    padding: 0;
    display: flex;
    gap: 2em;
    font-size: clamp(10px, 0.5em, 40px);
}
nav .left ul li:hover {
    cursor: pointer;
    text-shadow: 0 0 8px silver, 0 0 12px silver;
}
nav .left ul li p.link-info {
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.0s ease;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: absolute;
    color: black;
    padding: 1em;
    margin: 0;
    top: 10%;
    height: 17%;
    left: 50%;
    transform: translate(-50%);
    width: 50%;
    font-size: clamp(0.1px, calc(0.7vw + 0.7vh), 45px);
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    text-shadow: none;
    text-align: center;
    line-height: 1.7;
    cursor: default;
}
nav .left ul li:hover p.link-info {
    opacity: 1;
    visibility: visible;
    display: block;
}
nav .left ul li a {
    color: black;
    text-decoration: none;
}
nav .left ul li a:visited {
    color: black;
}
a#radio_pulsars {
    color: #007aff;
}
a#hz_sky {
    color: rgb(255, 127, 0);
}
a#chickchickgo {
    color: #2aaa00;
}

nav .right {
    display: flex;
    align-items: center;
    gap: 0.5em;
    color: red;
    font-size: clamp(15px, 0.7em, 40px);
    margin-left: auto;
    margin-right: 1em;
}
nav .right .heart,
nav .right .heart:visited,
nav .right .heart:hover,
nav .right .heart:active {
    position: relative;
    text-decoration: none;
    color: red;
}
nav .right .heart::after {
    content: "Buy me a coffee!";
    position: absolute;
    top: 120%;
    right: 50%;
    transform: translateX(50%);
    background: white;
    color: black;
    font-size: 0.65em;
    padding: 0.3em 0.6em;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
body.dark-mode nav .right .heart::after {
    background: black;
    color: white;
    text-shadow: 0 0 8px rgb(255, 149, 149), 0 0 12px rgb(255, 149, 149);
}
@media (hover: hover) {
    nav .right .heart:hover,
    nav .right .heart:hover > * {
        cursor: pointer;
        text-shadow: 0 0 8px red, 0 0 12px red;
    }
    nav .right .heart:hover::after {
        opacity: 1;
    }
}
nav .right .heart.show-hint {
    text-shadow: 0 0 8px red, 0 0 12px red;
}
/* Allow JS to force-show the tooltip */
nav .right .heart.show-hint::after {
    opacity: 1;
}
nav .right button {
    border: none;
    background: transparent;
    cursor: pointer;
}
nav .right svg {
    width: clamp(20px, 1.4vw, 40px);
    height: clamp(20px, 1.4vw, 40px);
    color: black;
}

#icon-sun {
    display: none;
}
#icon-moon {
    display: inline;
}

/* Hamburger menu for narrow screens */
.nav-toggle {
    display: none;
    position: relative;
    left: 10%;
    width: 16px;
    height: 12px;
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 0.3em;
    color: black;
}
.nav-toggle span {
    position: absolute;
    width: 100%;
    height: 2px;
    background: currentColor;
    transition: transform 0.3s ease, top 0.3s ease; opacity: 0.3s ease;
}
.nav-toggle span:nth-child(1) {
    top: 0;
}
.nav-toggle span:nth-child(2) {
    top: 6px;
}
.nav-toggle span:nth-child(3) {
    top: 12px;
}
nav.open .nav-toggle span:nth-child(1) {
    top: 9px;
    transform: rotate(45deg);
}
nav.open .nav-toggle span:nth-child(2) {
    opacity: 0;
}
nav.open .nav-toggle span:nth-child(3) {
    top: 9px;
    transform: rotate(-45deg)
}

.canvas-container {
    flex: 1; /* take remaining space */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* flex-start; */ /* push toward up */
    padding-top: 0; /* was 27vh */
    min-height: 60vh;
    padding-bottom: 1em;
    box-sizing: border-box;
}

.grid-wrapper {
    position: relative;
    width: 17vw;
    height: 8vw;
}

.grid {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    color: black;
}

.grid line {
    stroke: currentColor;
    stroke-width: 1;
}

.grid-horizontal {
    display: none;
}

.grid-vertical {
    display: block;
}

.canvases {
    display: flex;
    gap: 1vw;
    justify-content: center;
}

.canvases #canvas1 {
    display: block;
    width: 8vw;
    height: 8vw;
}

.canvases #canvas2 {
    display: block;
    width: 8vw;
    height: 8vw;
}

.caption {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    font-size: clamp(10px, 0.7em, 45px);
    font-weight: 300;
    text-align: center;
    margin-top: 1em;
    min-height: 2em;
}

.caption .caption-pulsars {
    color: #007aff;
}

.caption .caption-temperatures {
    color: rgb(255, 127, 0);
}

/* Narrow screen */
@media (max-width: 700px) {
    nav {
        flex-wrap: wrap;
        position: relative;
    }

    nav .left .logo {
        width: 3.5em;
        height: 3.5em;
        margin-left: 1em;
    }

    .nav-toggle {
        display: block;
    }

    nav .left ul {
        flex-direction: column;
        gap: 1rem;
        width: 20%;
        max-height: 0;
        background: transparent;
        background-color: rgba(0, 0, 0, 0);
        border-radius: 0 0 0 0;
        backdrop-filter: blur(6px);
        padding: 1rem 0;
        padding-left: 1.2rem;
        box-sizing: border-box;
        font-size: 1em;
        position: absolute;
        top: 3.8rem; /* sit right below nav */
        left: 0;
        margin-left: 7.5%;
        opacity: 0;
        transition: max-height 0.5s ease, opacity 0.5s ease;
    }

    /* Show menu when nav is toggled */
    nav.open .left ul {
        max-height: 300px;
        padding: 1rem 0 1rem 1.1rem;
        opacity: 1;
    }

    nav .left ul li a {
        display: block;
        padding: 0rem 0rem;
    }

    nav .left ul li p.link-info {
        top: 40%;
        left: 215%;
        width: 150%;
        height: auto;
        font-size: clamp(0.1px, calc(1vw + 1vh), 35px);
    }

    nav .right {
        font-size: 1.9em;
        margin: 0.3em;
    }

    nav .right svg {
        width: 7vw;
        height: 7vw;
    }

    .canvases {
        flex-direction: column;
        align-items: center;
        gap: 2vh;
    }

    .grid-wrapper {
        width: 25vw;
        height: auto;
    }

    .grid-horizontal {
        display: block;
    }

    .grid-vertical {
        display: none;
    }

    .canvases #canvas1 {
        width: 25vw;
        height: 25vw;
    }

    .canvases #canvas2 {
        width: 25vw;
        height: 25vw;
    }

    .caption {
        font-size: 1.3em;
    }
}

/* Narrow screens on desktop (hover available) */
@media (max-width: 700px) and (hover: hover) and (pointer: fine) {
    .canvas-container {
        padding-top: 50vh;
    }
}

.mobile-caption {
    display: none;
    position: static;
    margin-top: 1em;
    bottom: auto;
    left: auto;
    transform: none;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    font-size: 1.4em;
    font-weight: 300;
    color: black;
    text-align: center;
}

@media (hover: none) and (pointer: coarse) {
    .mobile-caption {
        display: block;
    }

    nav .right .heart::after {
        content: "Double tap to Buy me a coffee!";
        right: 30%;
        transform: translateX(30%);
        font-size: 0.55em;
    }
}
