/* One stylesheet for the whole site: the main page and every project page.
 *
 * Everything takes its colour from the logo: navy for the name, orange for the
 * tag brackets around it. Navy does the steady work (text, links, buttons),
 * orange marks what is active or under your pointer, and pale tints of both
 * fill in the backgrounds. The greys are tinted navy too, so nothing clashes.
 */

:root {
  /* Logo colours */
  --accent: #000092;
  --highlight: #f15a24;

  /* Tints and shades of the two */
  --accent-soft: #e6e7f7;
  --accent-faded: #8c8cd2;
  --accent-dark: #00005c;
  --highlight-soft: #fde8de;
  --highlight-faded: #f8ac90;
  --highlight-dark: #b53c12;

  /* Page */
  --bg: #f4f5fc;
  --card: #ffffff;
  --fg: #15173a;
  --muted: #55587e;
  --border: #d9dbef;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 1200px;
  padding: 2rem 1.25rem 3rem;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
}

::selection {
  background: var(--highlight-soft);
  color: var(--fg);
}

/* ---------- Type ---------- */

h1,
h2,
h3 {
  line-height: 1.25;
  color: var(--accent);
}

/* Page and section titles are written like the logo: <Name /> in a monospace face. */
h1,
h2 {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.6rem;
}

h2 {
  margin: 2.5rem 0 1rem;
  font-size: 1.2rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 650;
}

main > h1::before,
.menu h2::before {
  content: "<";
  margin-right: 0.1em;
  color: var(--highlight);
}

main > h1::after,
.menu h2::after {
  content: " />";
  color: var(--highlight);
}

a {
  color: var(--accent);
  text-decoration-color: var(--highlight-faded);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--highlight-dark);
  text-decoration-color: var(--highlight);
}

b {
  font-weight: 650;
  color: var(--accent);
}

/* ---------- Site header and project menu (drawn by site.js) ---------- */

.site-title {
  display: inline-block;
  /* The logo has some empty space around the letters; pull it in line with the text. */
  margin: -0.5rem 0 0 -0.6rem;
}

.site-title img {
  display: block;
  width: 23rem;
  max-width: 100%;
  height: auto;
}

.site-header p {
  max-width: 65ch;
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

/* A project card: quiet by default, orange edge under the pointer, and solid
   navy for the project that is open, like the name in the logo. */
.card {
  display: block;
  padding: 1rem 1.15rem 1.05rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.card:hover {
  border-color: var(--accent-faded);
  border-left-color: var(--highlight);
}

.card:focus-visible {
  outline: 3px solid var(--highlight);
  outline-offset: 2px;
}

.card.active {
  background: var(--accent);
  border-color: var(--accent);
  border-left-color: var(--highlight);
}

.card h3 {
  margin: 0 0 0.3rem;
  color: var(--accent);
}

.card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.card.active h3 {
  color: #fff;
}

.card.active p {
  color: #c9cbf2;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Project viewer on the main page ---------- */

#viewer {
  position: relative;
}

.viewing #viewer {
  scroll-margin-top: 1rem;
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  /* A short orange stroke at the start of the divider. */
  background: linear-gradient(var(--highlight), var(--highlight)) no-repeat 0 -1px / 3rem 3px;
}

.project-frame {
  display: block;
  width: 100%;
  height: 700px;
  border: none;
}

/* A project that is still loading sits out of sight behind the current one. */
.project-frame.loading {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
}

/* ---------- Project pages (shown inside the viewer) ---------- */

.embedded body {
  max-width: none;
  padding: 0;
}

.intro {
  max-width: 65ch;
  color: var(--muted);
}

.flex-container {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
}

.flex-child {
  line-height: 2.2;
}

/* Number boxes stacked under each other, with their labels lined up on the left. */
.param-fields {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin: 0.5rem 0;
  line-height: 1.5;
}

.hint {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Controls ---------- */

button {
  font: inherit;
  font-weight: 550;
  padding: 0.35rem 0.95rem;
  margin: 0.15rem 0.2rem 0.15rem 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

button:hover {
  background: var(--accent);
  color: #fff;
}

button:active {
  background: var(--highlight);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--highlight-faded);
  outline-offset: 1px;
}

input {
  font: inherit;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
  accent-color: var(--highlight);
  vertical-align: middle;
}

input:hover {
  border-color: var(--accent-faded);
}

input:focus-visible {
  border-color: var(--highlight);
}

input[type="number"] {
  width: 5.5em;
}

input:disabled {
  background: var(--bg);
}

input::placeholder {
  color: var(--accent-faded);
}

canvas {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

/* ---------- Motion and printing ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media print {
  button,
  .no-print {
    display: none !important;
  }

  body {
    max-width: none;
    padding: 0;
    background: white;
  }

  main {
    margin: 0;
    padding: 0;
    border: none;
  }
}
