/* zen — the chrome is the house style, kept deliberately quiet; the canvas is the
   exception the page exists for.

   Quiet means: no black bars, borders at --line rather than --ink, a translucent panel
   that takes the colour of whatever is behind it, small type, and an active row marked by
   a filled square and a faint wash instead of a slab of black. Hover still inverts,
   because that is the one place the house style wants to be loud.

   Tokens are repeated rather than imported: samuelagain.css is the landing page's
   stylesheet and this page is a separate document with no shared layer between them. */

:root {
  --ink: #050505;
  --paper: #ffffff;
  --grey: #777777;
  --line: #d8d8d8;
  --hair: #ececec;
  --utility: "DejaVu Sans Mono", "Liberation Mono", monospace;
  --panel: 282px;
  --inset: 20px;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--utility);
  font-size: 14px;
  text-rendering: geometricPrecision;
}

/* The stage is the whole viewport. The chrome floats over it rather than taking layout
   space, so no graphic is ever drawn into a box narrower than the screen. */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#plate {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- chrome ---------------------------------------------------------------------- */

.chrome {
  position: fixed;
  top: var(--inset);
  left: var(--inset);
}

/* Idle in full screen collapses to the chip and stops there — it never hides the chip
   itself. The chip is the only way back, and an Ivy run (016416) tucked the panel in full
   screen, waited, and found nothing on screen to click. A pointer brings the panel back,
   but a finger has nothing to aim at, and the chip is already as quiet as a control gets. */

.panel {
  width: var(--panel);
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  transition: opacity .25s linear, transform .25s linear, visibility 0s linear;
}

/* The blur is what lets the panel sit at 82% over a dark graphic and still read as one
   surface. Where it is unsupported the panel just gets more opaque. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .panel {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel { background: rgba(255, 255, 255, .94); }
}

/* visibility, not just opacity: an opacity-0 panel is still a focusable, clickable,
   screen-reader-visible panel, and "tucked away" has to mean actually away. The delay on
   that one property lets the fade finish before it is taken out. */
body[data-chrome="tucked"] .panel,
body[data-chrome="idle"] .panel {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);
  pointer-events: none;
  transition-delay: 0s, 0s, .25s;
}

/* Tucked, the panel is gone and this is all that is left: a chip the size of a label. */
.handle {
  display: none;
  align-items: center;
  gap: 5px;
  margin: 0;
  min-height: 26px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, .82);
  color: var(--grey);
  border: 1px solid var(--line);
  border-radius: 0;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  appearance: none;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .handle {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

body[data-chrome="tucked"] .handle,
body[data-chrome="idle"] .handle { display: inline-flex; }

.handle:hover,
.handle:focus-visible {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  outline: 0;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 6px 9px;
}

.meta { border-bottom: 1px solid var(--hair); }
.acts { border-bottom: 1px solid var(--hair); }
.keys { border-top: 1px solid var(--hair); }

/* The two actions are the only things on this panel that are not a choice of graphic, so
   they get more than the bare minimum height — and the extra margin means a click aimed
   at the label lands on the button. */
.acts {
  padding: 8px 9px;
}

.acts .button { min-height: 40px; }

.keys {
  display: block;
  padding: 7px 9px;
  color: var(--grey);
  font-size: 9px;
  line-height: 1.6;
  letter-spacing: .1em;
  text-align: center;
}

.label {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--grey);
}

.label.strong { color: var(--ink); }

a.link {
  color: var(--grey);
  text-decoration: none;
}

a.link:hover,
a.link:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: 0;
}

/* --- the picker ------------------------------------------------------------------ */

/* Two columns at every width. Thirteen rows in one column made the panel about 570px
   tall on an 800px screen, which is not a subtle thing to park over a graphic and pushed
   the buttons down to the bottom edge. Seven rows of two is half the height and the same
   list, and it is the layout the phone already used. */
.picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* The list is allowed to grow; the panel is not. Past this it scrolls inside itself,
     the same way the landing page's index does, so adding graphics can never push the
     buttons off the screen or bury the graphic behind its own controls. */
  max-height: min(52dvh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.row:nth-child(2n) { border-right: 0; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  /* 34px, the same floor the eight-row version had. Thirteen one-word labels packed
     tighter than this are easy to mis-aim at — an Ivy run meant AURORA and hit PLUMB at
     32px — and this list is the page's whole interface. Quieter is a matter of colour
     and weight; it is never a reason to make a target smaller. */
  min-height: 34px;
  margin: 0;
  padding: 7px 9px 7px 7px;
  background: transparent;
  color: var(--ink);
  border: 0;
  /* Reserved on every row, inked only on the active one, so marking a row moves nothing.
     A border and not a box-shadow: this style has no shadows of any kind. */
  border-left: 2px solid transparent;
  border-right: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  border-radius: 0;
  font-family: inherit;
  font-size: .78rem;
  letter-spacing: .06em;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
}

.row:last-child { border-bottom: 0; }

.row .num {
  width: 1.4em;
  color: var(--grey);
  font-size: 9px;
}

.row .name { flex: 1; }

/* A filled square for colour, a hollow one for monochrome. Squares, because nothing in
   this style is round and a legend swatch is never a circle. */
.row .mark {
  width: 6px;
  height: 6px;
  border: 1px solid currentColor;
  background: transparent;
}

.row[data-palette="colour"] .mark { background: currentColor; }

/* A ring around the swatch marks a graphic that answers the pointer. An outline and not
   a box-shadow, because this style has no shadows; the row also carries the fact in
   words for a screen reader. */
.row[data-reactive="true"] .mark {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

/* The active row: a faint wash and a solid left edge, not a slab of black. */
.row[aria-current="true"] {
  background: rgba(5, 5, 5, .06);
  border-left-color: var(--ink);
}

.row[aria-current="true"] .num { color: var(--ink); }

/* Hover is the one loud thing left, because it is feedback and has to be unmistakable. */
.row:hover,
.row:focus-visible {
  background: var(--ink);
  color: var(--paper);
  border-left-color: var(--ink);
  outline: 0;
}

.row:hover .num,
.row:focus-visible .num { color: var(--paper); }

/* --- buttons --------------------------------------------------------------------- */

.button {
  margin: 0;
  /* 32px, unchanged when the panel got quieter: subtlety is a matter of colour and
     weight, and is never a reason to shrink something you have to hit. */
  min-height: 32px;
  padding: 7px 9px;
  background: transparent;
  color: var(--grey);
  border: 1px solid var(--line);
  border-radius: 0;
  font-family: inherit;
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  appearance: none;
}

.button:hover,
.button:focus-visible {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  outline: 0;
}

.noscript {
  position: fixed;
  inset: auto var(--inset) var(--inset) var(--inset);
  margin: 0;
  padding: 9px;
  background: var(--paper);
  border: 1px solid var(--ink);
  font-size: 11px;
}

/* Screen-reader-only: the colour/monochrome mark is a square to look at, and this is the
   same fact in words. */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- narrow screens -------------------------------------------------------------- */

@media (max-width: 640px) {
  .chrome {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .panel { width: auto; }

  /* 44px, the finger floor: these are the only controls on the page and they are being
     tapped one-handed. Eighteen of them at that height is more screen than a phone can
     spare, so the list scrolls sooner here and the graphic keeps most of the window. */
  .row { min-height: 44px; }

  .picker { max-height: 34dvh; }

  /* `.acts .button` is more specific than `.button`, so the action buttons have to be
     named here too or they keep their 40px desktop height and miss the finger floor. */
  .button,
  .acts .button,
  .handle { min-height: 44px; }
}

/* The page is a page of motion, so reduced motion cannot mean "the same thing, slower".
   zen.js draws exactly one frame per graphic and never starts the loop; this takes the
   transitions off the chrome to match. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
