@import url("https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,100..900;1,100..900&family=Raleway:ital,wght@0,100..900;1,100..900&display=swap");

:root {
    --max-content-width: 1200px;
}

:root,
[data-theme="light"] {
    --color-bg: #ffffff;

    --color-text: #666666;
    --color-text-label: #333333;
    --color-text-nav: #cccccc;
    --color-text-nav-highlight: #ffffff;
    --color-heading: brown;

    --color-title: #eee;
    --color-bg-subtle: #f9f9f9;
    --color-bg-subtle2: #eeeeee;
    --color-bg-tooltip: #cccccc;

    --table-row-border: #d6d6d6;
}

[data-theme="dark"] {
    --color-bg: #1a1a1a;
    --color-text: #aaaaaa;
    --color-text-label: #cccccc;
    --color-heading: darkorange;

    --color-bg-subtle: #2a2a2a;
    --color-bg-subtle2: #222222;
    --color-bg-tooltip: #333333;

    --table-row-border: #6d6d6d;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --color-bg: #1a1a1a;
        --color-text: #aaaaaa;
        --color-text-label: #cccccc;
        --color-heading: darkorange;

        --color-bg-subtle: #2a2a2a;
        --color-bg-subtle2: #222222;
        --color-bg-tooltip: #333333;

        --table-row-border: #6d6d6d;
    }
}

html {
    background-color: var(--color-bg);
}

body {
    font-family: "Raleway", Arial, Helvetica, sans-serif;
    color: var(--color-text);
    margin: 0;
}

nav {
    color: var(--color-text-nav);
    margin-left: auto;
    margin-right: auto;
    max-width: var(max-content-width);
}

nav select {
    text-align: right;
    float: right;
    margin: 0 1em;
}

#menu {
    text-align: left;
    float: left;
    display: inline-block;
}
#menu ul {
    display: flex;
    justify-content: space-around;
    list-style-type: none;
    margin: 0;
    padding: 0;
}
#menu li {
    margin: 0 1em;
}
#menu li a {
    color: var(--color-text-nav);
    text-decoration: none;
    &:hover {
        color: var(--color-text-nav-highlight);
    }
    &:active {
        color: var(--color-text-nav-highlight);
    }
}

header {
    grid-area: header;
    width: 100%;
    background-image: url("./banner.jpg");
    background-size: cover;
    background-repeat: no-repeat;
    padding: 2ex 0;
}

main {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "introduction"
        "introduction-star"
        "introduction-binary"
        "controls"
        "graph"
        "data-section"
        "program-log";

    padding-left: 2rem;
    padding-right: 2rem;
}

@media (min-width: 700px) {
    main {
        grid-template-columns: 300px 1fr;
        grid-template-areas:
            "introduction introduction"
	        "introduction-star introduction-star"
	        "introduction-binary introduction-binary"
            "controls graph"
            "data-section data-section"
            "program-log program-log";
    }
}

#banner {
    text-align: center;
}

#introduction {
    grid-area: introduction;
    justify-self: start;
    max-width: var(--max-content-width);
}

#introduction-star {
    grid-area: introduction-star;
    justify-self: start;
    max-width: var(--max-content-width);
}

#introduction-binary {
    grid-area: introduction-binary;
    justify-self: start;
    max-width: var(--max-content-width);
}

#controls {
    grid-area: controls;
    align-self: start;
    min-width: 300px;
}

#graph {
    grid-area: graph;
    align-self: end;

    min-width: 700px;

    overflow: visible;
}

#data-section {
    grid-area: data-section;
    overflow-x: auto;
    overflow-y: hidden;
}

#program-log {
    grid-area: program-log;
    justify-self: start;
}

h1 {
    color: var(--color-title);
    font-size: 4rem;
    font-weight: lighter;
}

h2 {
    margin-bottom: 0;
    padding: 0.5rem;
    color: var(--color-heading);
    font-size: x-large;
    font-weight: normal;
}

details summary {
    margin-bottom: 1rem;
    padding: 0.5rem;
    color: var(--color-heading);
    font-size: x-large;
}

label {
    display: inline-block;
    margin: 0.5em 0.5ex;
    font-size: smaller;
    color: var(--color-text-label);
}

/* Hide the stepper controls in the number input fields */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* Using `textfield` does not work in Safari, but is the solution for Firefox */
input[type="number"] {
    appearance: textfield;
    text-align: right;
    margin: 0.2rem;
    border-radius: 10px;
    padding: 3px 5px;
    border: 2px solid #cccccc;
    width: 50px;
}
input[type="range"] {
    cursor: pointer;
}

#program-log output {
    display: block;
    font-family: monospace;
    white-space: pre-wrap;
    border: 1px solid #cccccc;
    padding: 8px;
    overflow-y: auto;
    line-height: 1.2rem;
    min-height: calc(1.2rem * 20); /* approx. 20 lines visible */
    max-height: 400px;
    background: var(--color-bg-subtle);
}

#data-table {
    border-collapse: collapse;
    width: 100%;
    max-width: 600px;
}
#data-table,
th,
td {
    border-left: none;
    border-right: none;
    padding: 4px 8px;
    text-align: left;
    font-family: monospace;
}
#data-table thead tr {
    background-color: var(--color-bg-subtle2);
}
/* Add a little bit of spacing between the header and the body */
#data-table tbody:before {
    content: "@";
    display: block;
    visibility: hidden;
    line-height: 10px;
}
#data-table tbody td {
    border-bottom: 1px solid var(--table-row-border);
}
#data-table tbody tr:nth-child(odd) {
    background-color: var(--color-bg-subtle);
}
#data-table tbody tr:nth-child(even) {
    background-color: var(--color-bg-subtle2);
}

.tooltip {
    position: relative;
    display: inline-block;
    margin-left: 0.5rem;
}
.tooltiptext {
    visibility: hidden; /* Hidden by default */
    width: 260px;
    background-color: var(--color-bg-tooltip);
    color: var(--color-text-label);
    text-align: center;
    text-wrap: balance;
    padding: 5px 0;
    border-radius: 6px;
    position: absolute;
    z-index: 1; /* Ensure tooltip is displayed above content */
}
/* Show the tooltip text on hover */
.tooltip:hover .tooltiptext {
    visibility: visible;
}

#start-button {
    font-size: 1rem;
    font-weight: bold;
}

#status {
    margin-left: 10px;
    font-size: 0.9rem;
    font-style: italic;
    color: #555555;
}

button {
    display: block;
    padding: 0.3rem 1.3rem;
    margin: 0.2rem;
    border-radius: 1rem;
    border: 3px solid #0077ff;
    background: #eeeeee;
    box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.6);
    font-size: 0.8rem;

    &:hover:not(:disabled) {
        cursor: pointer;
        background: #cccccc;
    }
    &:active:not(:disabled) {
        box-shadow: none;
    }
    &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control {
    background-color: var(--color-bg-subtle2);
    margin: 1em 3ex 1em 1ex;
    padding: 0.2em 0.5ex;
}

/* Hide the (drop-down) arrows and style the <select> element as
   minimally as possible */
#lang-switch,
#theme-switch {
    /* <select> doesn't automatically inherit font-size, since the element
   is usually taken from the OS */
    display: inline-block;
    font-size: large;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: none;
    border: none;
    padding: 0;
    color: var(--color-text-nav);

    &::-ms-expand {
        /* IE and Edge */
        display: none;
    }
}

#graph-options {
    display: flex;
    align-items: flex-start;
}

.visible {
    display: block;
}

.invisible {
    display: none;
}

#star-size {
    anchor-name: --star-size-anchor;
    margin: 0 1em;
    padding: 0 1em;
    border-left: 2px solid #ddd;
    min-height: 5em;
}

#star-size-graph {
    z-index: -1;
    pointer-events: none; /* Clicks pass through the SVG to elements below */
    overflow: visible; /* Allows drawing at negative coordinates */
}

svg {
    font-size: 0.8rem;
}
