/* Shared by every app (moved here from their css/style.css). Each app's own css/style.css
   comes after this file and only adds what is its own. */

body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--serif);
}

h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: normal;
  letter-spacing: 0.02em;
}

/* ---- The pages, as tabs standing on a rule: 2D, 3D, 4D ---- */

.page_tabs {
  display: flex;
  flex-wrap: wrap;          /* many tabs: a second row rather than out of the panel */
  row-gap: 3px;
  margin: 0 0 10px;
  padding-left: 4px;
  border-bottom: 1px solid var(--ink);
}

.page_tabs a {
  position: relative;
  bottom: -1px;            /* the current tab covers the rule below it */
  margin-right: 2px;
  padding: 2px 7px 1px;
  border: 1px solid var(--rule);
  border-bottom-color: var(--ink);
  background: var(--tab);
  color: var(--tab-ink);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.page_tabs a:hover {
  background: var(--tab-hover);
  color: var(--ink);
}

.page_tabs a[aria-current="page"] {
  border-color: var(--ink);
  border-bottom-color: var(--panel);
  background: var(--panel);
  color: var(--ink);
  cursor: default;
}

.page_tabs a:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: -4px;
}

.intro {
  margin: 0 0 14px;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
}

legend {
  padding: 0 4px;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

fieldset.folded {
  padding-bottom: 0;
}

fieldset.folded > legend::before {
  transform: rotate(-90deg);
}

fieldset.folded > :not(legend) {
  display: none !important;
}

label {
  cursor: pointer;
}

/* ---- Rows: label | number | slider ---- */

table.controls {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;   /* same column widths in every box */
}

table.controls td:nth-child(2) {
  width: 72px;
}

table.controls col.col_label {
  width: 72px;
}

table.controls col.col_number {
  width: 72px;
}

table.controls th {
  width: 66px;
  padding: 2px 6px 2px 0;
  font-weight: normal;
  text-align: left;
  white-space: nowrap;
}

table.controls td {
  padding: 2px 0;
}

.number_slide {
  width: 62px;
  padding: 1px 3px;
  font: 13px var(--mono);
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 0;
}

.preset select {
  flex: 1;
  min-width: 0;
}

button:hover {
  background: var(--field);
}

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

/* ---- Save ---- */

.save_label {
  margin: 8px 0 2px;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
}

.save_label:first-of-type {
  margin-top: 2px;
}

.favourite_save {
  display: flex;
  margin: 4px 0 4px;
}

#zoom_level {
  display: inline-block;
  width: 84px;
  text-align: center;
  font: 13px var(--mono);
}

/* Buttons in the upper-right corner of the figure. */

.figure_tools {
  position: absolute;
  top: 37px;
  right: 37px;
  display: flex;
  gap: 6px;
}

/* On a desktop the Fit button is in the panel, next to the zoom buttons. */

#figureFit {
  display: none;
}

#undoButton, #redoButton {
  min-width: 30px;
  font-size: 15px;
  line-height: 1;
}

/* Hints for a mouse or for a touch screen: only the one that fits is shown. */

.for_touch {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .for_touch {
    display: inline;
  }
}

/* ---- Phones and narrow windows: the figure on top, the panel below ---- */

@media (max-width: 760px) {
  .figure_tools {
    top: 15px;
    right: 15px;
  }

  #figureFit {
    display: inline-block;
  }

  .number_slide {
    width: 66px;
  }

  table.controls td,
  table.controls th {
    padding-top: 3px;
    padding-bottom: 3px;
  }
}

/* ---- The line above the title: back to the hub, and light / dark
   (drawn by ../js/nav.js) ---- */

.hub_nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  margin: -8px 0 4px;
  font-size: 12.5px;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

.hub_logo {
  display: inline-block;
  padding: 3px 9px 4px;
  font: 13px/1 var(--serif);
  font-variant: small-caps;
  letter-spacing: 0.14em;
  color: var(--ink);
  text-decoration: none;
  border: 3px double var(--ink);
}

a.hub_logo:hover,
a.hub_logo:focus-visible {
  background: var(--field);
  outline: none;
}

.theme_switch {
  margin-left: auto;
  width: 26px;
  height: 22px;
  min-height: 0;
  padding: 0;
  font: 15px/1 var(--serif);
  color: var(--tab-ink);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.theme_switch:hover,
.theme_switch:focus-visible {
  color: var(--ink);
  background: var(--field);
  border-color: var(--rule);
}

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

/* ---- Scrollbars: thin, in the colours of the page; the panel's shows
   faintly and darkens while the pointer is over the panel ---- */

html {
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

#panel {
  scrollbar-width: thin;
  scrollbar-color: var(--rule-light) transparent;
  scrollbar-gutter: stable;   /* the panel does not shift when the bar appears */
}

#panel:hover,
#panel:focus-within {
  scrollbar-color: var(--rule) transparent;
}

/* (Browsers without scrollbar-color: the same look the older way.) */
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--rule-light); border: 2px solid transparent; border-radius: 4px; background-clip: padding-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--rule); }
}

/* ---- Going from page to page: no flash ----
   (same-site navigations, in browsers that support view transitions; others
   simply switch). The old page stays on screen until the new one is ready,
   then the new one replaces it at once: no white flash in between, and no
   cross-fade either, which let the old page (a figure's canvas, say) show
   through the new one for a moment. */

@view-transition {
  navigation: auto;
}

#panel {
  view-transition-name: panel;
}

::view-transition-group(*) {
  animation-duration: 0s;
}

::view-transition-old(*) {
  animation: none;
  opacity: 0;
}

::view-transition-new(*) {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}
