/* Shared page layout for pages that are mostly text, tables and forms (the
   hub, Bazi): the side panel fixed on the left, the page's content beside it;
   on a phone, the panel first and the content under it. The figure apps
   (Mandelbrot, Similar, Triangles) have their own layout around the figure,
   with the same panel.

     <div id="panel"> ... </div>
     <main id="page_main"> ... </main>

   Load after tokens.css and base.css. */

html, body {
  margin: 0;
  min-height: 100%;
}

#panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--panel-width);
  box-sizing: border-box;
  padding: 18px 18px 24px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--rule);
}

#page_main {
  margin-left: var(--panel-width);
  box-sizing: border-box;
  padding: 24px 32px 48px;
}

fieldset {
  margin: 0 0 14px;
  padding: 6px 10px 8px;
  border: 1px solid var(--rule);
}

#panel legend[role="button"] {
  cursor: pointer;
  user-select: none;
}

#panel legend[role="button"]::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin: 0 6px 1px 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--muted);
  vertical-align: middle;
  transition: transform 0.12s;
}

#panel legend[role="button"]:hover::before {
  border-top-color: var(--ink);
}

#panel legend[role="button"]:focus-visible {
  outline: 1px dotted var(--ink);
}

button {
  padding: 2px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-dark);
  border-radius: 0;
  cursor: pointer;
}

button:disabled {
  color: var(--muted);
  cursor: default;
}

select,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"] {
  box-sizing: border-box;
  padding: 1px 4px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule-dark);
  border-radius: 0;
}

.hint {
  margin: 4px 0 0;
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
}

/* Headings of the content, as in a printed book (:where keeps them easy to
   override: an app's own h2 rules win). */
:where(#page_main) h2 {
  margin: 28px 0 10px;
  font-size: 19px;
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--rule);
}

:where(#page_main) h2:first-child {
  margin-top: 0;
}

/* A box of the content: the same frame as the panel's sections. */
.plate {
  margin: 0 0 18px;
  padding: 12px 16px;
  background: var(--field);
  border: 1px solid var(--rule);
}

/* ---- Phones and narrow windows: the panel first, the content under it ---- */

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }

  #panel {
    position: static;
    width: auto;
    padding: 14px 14px 20px;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  #page_main {
    margin-left: 0;
    padding: 16px 14px 40px;
  }

  /* Larger targets for fingers; 16px text stops phones zooming into a field. */
  button {
    min-height: 34px;
    padding: 4px 12px;
    font-size: 16px;
  }

  select,
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  input[type="time"] {
    min-height: 34px;
    font-size: 16px;
  }
}

@media print {
  #panel { display: none; }
  #page_main { margin-left: 0; max-width: none; padding: 0; }
  body { background: none; }
}
