/**
  * Layers:
  *   base         : z-index 0 (background)
  *   participants : z-index 10 (participant children of participant-list)
  *   frame        : z-index 20 (header, navbar)
  *   overlay      : z-index 30 (modal dialogs)
  *   context      : z-index 40 (context menus)
 */

:root {
  --opacity-disabled: 0.4;
  --opacity-control-indicators: 0.25;
  --opacity-dragging: 1;

  --participant-default-border: 1px solid lightgrey;

  --framing-background-color: rgb(249,249,249);
}
* {
  font-family: sans-serif;
}
/**
 * 500px width looks good at 16px font-size
 * Max 32px at > 1024px
 * Trial & Error, 3.2vw seem to work well.
 */
html {
  font-size: clamp(16px, 3.2vw, 32px);
  line-height: 1.2;
}

.sr-only:not(:focus):not(:active) {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.flex-push-right {
  margin-left: auto;
}

/**
 * Match the small, medium, large, etc sizes here and in the file RoundTheTable.js
 */
body[data-font-size="small"] .content {
  font-size: 1.5rem;
}
body[data-font-size="large"] .content {
  font-size: 1.75rem;
}

body {
  position: absolute;
  padding: 0;
  margin: 0;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
}

/** Content container contains the level 1 header, the main content, and the nav controls. **/
.content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

div.main {
  flex: 1 0 auto;
  z-index: 0;
  display: flex;
  flex-direction: column;
}

nav.nav-controls {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-around;
  font-size: clamp(28px, 0.05vw, 56px);
  border-top: 1px solid lightgrey;
  padding: 0.5em;
  background-color: var(--framing-background-color);
  z-index: 20;
}

div.main h1 {
  flex: 0 0 auto;
  font-size: 0.5em;
  padding: 0.25em 1em;
  margin: 0;
  z-index: 20;
  text-align: center;
  background-color: white;
  border: none;
}
.nav-controls button {
  border: none;
  background-color: transparent;
  font-size: 1.25rem;
}
.nav-controls button[data-action="pause-meeting"] {
  display: none;
}
.nav-controls button[data-action="stop-meeting"] {
  opacity: var(--opacity-disabled);
}
body.meeting-running .nav-controls button[data-action="start-meeting"] {
  display: none;
}
body.meeting-running .nav-controls button[data-action="pause-meeting"] {
  display: block;
}
body.meeting-running .nav-controls button[data-action="stop-meeting"] {
  opacity: 1;
}
body.meeting-paused .nav-controls button[data-action="stop-meeting"] {
  opacity: 1;
}

/**
 * Participant list blocks.
 * Attending and absent group containers should have the same container padding, margins, etc.
 */
div.main .participant-group-container {
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border: none
}
div.main .participant-group-container h2 {
  font-size: 1rem;
  padding: 0.25rem 1rem;
  margin: 0;
  z-index: 20;
  text-align: center;
  background-color: white;
  border-bottom: var(--participant-default-border);
}

/** The attending list container "scrolls" up, but we don't want scroll bars, so we set
 *  overflow-y hidden and position relative and set the top of the list (or container?)
 *  to the negative top of the current participant's element; it should be hidden under
 *  the ancestor container elements due to the z-indexes that are set.
 */
div.main .participant-group-container .participant-list-container {
  overflow-y: hidden;
  position: relative;
  width: 100%;
}

/**
 * The participant list itself is an <OL> element with an <LI> element for each participant.
 */
div.main .participant-group-container .participant-list-container .participant-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 10;
  top: 0;
}

/**
 * The `animate` class causes the animation of the `top` property. The JS adds or removes
 * it from the attending list as needed.
 */
div.main .participant-group-container.attending .participant-list-container .participant-list.animate {
  transition: top 400ms ease-in;
}

/** The absent participant-list container styles. */
div.main .participant-group-container.absent {
  /** This pushes the absent list container to the bottom of the content area, sticking right above the nav controls. */
  margin: auto 0 0;
}

/**
 * The `drag-hover` class is added to the participant-list when the user is dragging a participant-item over it.
 */
div.main .participant-group-container .participant-list-container .participant-list.drag-hover {
  /** @TODO improve this design, it's just what I did to show the drag was happening. */
  opacity: var(--opacity-dragging);
  background-color: pink;
}

/** An individual participant's <LI> element, currently the same for both the attending and absent lists. **/
.participant-item {
  padding: 0.5em 1em;
  display: flex;
  min-height: 1.5em;
  align-content: center;
  border-left: var(--participant-default-border);
  border-right: var(--participant-default-border);
  border-bottom: var(--participant-default-border);
  border-top: none;
  z-index: 10;
}
.participant-item[data-is-last="true"] {
  border-bottom: 2px solid black;
}
.participant-item[data-is-clone] {
  opacity: var(--opacity-disabled);
}
.participant-item.no-participant-items {
  font-size: 1rem;
  text-align: center;
  font-style: italic;
}
.participant-item.dragging {
  /** @TODO improve this design, it's just what I did to show the drag was happening. */
  opacity: var(--opacity-dragging);
  background: lightgrey;
}

/**
 * The Participant's displayed name, e.g. not currently being edited.
 *
 * Displayed by default.
 */
.participant-item .name-display {
  flex: 1 1 auto;
  text-align: center;
  background-color: transparent;
  margin: 0 1em;
  border: none;
  font-size: 1em;
  font-weight: normal;
}
/**
 * The Participant's name being edited
 *
 * Hidden by default.
 */
.participant-item .name-edit {
  display: none;
  font-size: 1em;
  margin: 0 1em;
  width: calc(100% - (2 * 1em));
  text-align: center;
}

/**
 * Participants in the absent list.
 */
div.main .participant-group-container.absent .participant-item .name-display,
div.main .participant-group-container.absent .participant-item .name-edit {
  font-size: 0.75em;
  text-align: left;
}

/** The display and edit version of the name should be swapped, visually, when being edited. */
.participant-item.editing .name-edit {
  display: inline;
}
.participant-item.editing .name-display {
  display: none;
}

/**
 * Container for indicators of various sorts on the left and the right of the name,
 * depending on situation.
 */
.participant-item .indicators {
  flex: 0 1 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  font-size: 1rem;
  width: 1rem;
}
/** The indicator elements themselves. Hidden by default, but evenly distributed within the row. */
.participant-item .indicators * {
  display: none;
  flex: 1 1 auto;
}
/** If the Participant is currently speaking, the "is-speaking" indicator should be shown. */
.participant-item[data-is-speaking="true"] .indicators .is-speaking {
  display: inline;
}
/** Turn off the "is-speaking" indicator if the list is being animated, it looks funny. */
.participant-list.animating .participant-item[data-is-speaking="true"] .indicators .is-speaking {
  display: none;
}
/** If the Participant is speaking next, the "next-up" indicator should be shown. */
.participant-item[data-is-next-up="true"] .indicators .next-up {
  display: inline;
}
/** Turn off the "next-up" indicator if the list is being animated, it looks funny. */
.participant-list.animating .participant-item[data-is-next-up="true"] .indicators .next-up {
  display: none;
}

/**
 * "Controls" are indicators that the user can use to manipulate the participant data.
 *
 * They are only shown in the modes where it makes sense to show them, detailed below.
 */
.participant-item .indicators .control {
  display: none;
}

/**
 * Meeting status block
 *
 * When visible, shown at the bottom of the main container, stuck right above the nav controls.
 * The absent participant list is immediately above the meeting status block.
 */
.meeting-status {
  flex: 0 1 auto;
  border: var(--participant-default-border);
  padding: 0.5rem 1rem;
  font-size: 1rem;
  display: flex;
  justify-content: flex-start;
  background-color: var(--framing-background-color);
}
/** If the app doesn't have the `meeting-status-shown` class, the block is not displayed. */
body:not(.meeting-status-shown) .meeting-status {
  display: none;
}

.meeting-status .state {
  margin-right: 1rem;
}

/** Popup or context menu. */
.menu {
  padding: 0;
  list-style: none;
  border-top: 1px solid lightgrey;
  margin: 0;
  z-index: 40;
  position: absolute;
  top: 1em;
  left: 1em;
  background-color: white;
}

/** Menu item button. */
.menu li button {
  width: 100%;
  padding: 0.5rem .5rem;
  display: flex;
  text-align: left;
  border-left: 1px solid lightgrey;
  border-right: 1px solid lightgrey;
  border-bottom: 1px solid lightgrey;
  border-top: none;
  z-index: 40;
  background-color: transparent;
  font-size: 1rem;
}
.menu li button:hover {
  background-color: #1f1f1f;
  color: white;
}
.menu li button span.hotkey {
  flex: 0 1 auto;
}
.menu li .icon {
  flex: 0 1 auto;
  padding-right: .5rem;
}
.menu li .menu-label {
  flex: 1 1 auto;
}
/**
 * Change the meeting status show/hide menu labels' visibility as appropriate.
 */
body.meeting-status-shown .menu li[data-action="toggle-meeting-status"] .menu-label.meeting-status-shown {
  display: inline;
}
body.meeting-status-shown .menu li[data-action="toggle-meeting-status"] .menu-label:not(.meeting-status-shown) {
  display: none;
}
body:not(.meeting-status-shown) .menu li[data-action="toggle-meeting-status"] .menu-label.meeting-status-shown {
  display: none;
}
body:not(.meeting-status-shown) .menu li[data-action="toggle-meeting-status"] .menu-label:not(.meeting-status-shown) {
  display: inline;
}


/** General dialog styles */

dialog {
  border: 1.5px solid black;
}

dialog > form {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  position: relative;
  z-index: 30;
}

dialog h1 {
  margin: 0 0 1em;
  text-align: center;
}

/** Dialog specific styles */
dialog > form > ul.actions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: space-around;
  padding-top: 0.5em;
}

dialog textarea {
  resize: none;
  width: 100%;
}

dialog .note {
  font-style: italic;
}
