/* Container setup */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;

  /* Prevent "bouncing" on safari */
  position: fixed;
}
body {
  background-color: #ddd;
}

/* Layout styles */
.flexbox {
  display: flex;
}
.flexbox.column {
  flex-direction: column;
}
.flexbox.wrap {
  flex-wrap: wrap;
}
.flex {
  flex: 1;
}
.flex-grow {
  flex: 1 0;
}
.center {
  align-self: center;
  justify-content: center;
  align-items: center;
}
.stretch {
  align-self: center;
}
.block {
  margin: 8px;
}
td.block {
  padding: 8px;
}
.scroll {
  overflow-y: auto;
  box-shadow: inset 0 6px 4px -4px rgba(0, 0, 0, 0.1);
  position: relative;
}

/* Mask out the inset shadow when scrolled to the top. */
.scroll::before {
  content: "";
  position: absolute;
  top: 0;
  width: 100%;
  height: 6px;
  background: var(--bg-color);
}

.table {
  display: grid;
  flex: none;
  grid-template-columns: repeat(calc(var(--num-columns) - 1), auto) 1fr;
}
.table > .row {
  display: contents;
}
.table > .row:first-child > * {
  grid-row: 1;
}
.table > .row > :first-child {
  grid-column: 1;
}
.table > hr {
  grid-column-start: 1;
  grid-column-end: -1;
}

/* Collapsing margins */
.flexbox:not(.column):not(.wrap) > .block:not(.box) + .block:not(.box),
.table > .row > .block:not(.box) + .block:not(.box) {
  margin-left: 0;
}
.flexbox.column > .block:not(.box) + .block:not(.box) {
  margin-top: 0;
}
.flexbox.wrap.collapse {
  padding: 4px;
}
.flexbox.wrap.collapse > .block:not(.box) {
  margin: 4px;
}

/* Overrides, tweaks */
a {
  color: inherit;
}
a.button {
  text-decoration: none;
}
hr {
  border-style: none;
  margin: 0;
  height: 1px;
  background: var(--divider-color);
  width: 100%;
  flex-shrink: 0;
}
textarea {
  resize: none;
}
i.material-icons {
  user-select: none;
}
.title-case {
  text-transform: capitalize;
}
select,
input,
.big {
  font-size: 1.2rem;
  min-width: 0;
}
input[type=checkbox] {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

input:invalid {
  color: var(--fg3-color);
  background: #faa;
}

/* App Theme */
:root {
  font-family: "Source Sans Pro";
  font-size: 18px;
  /*   font-size: max(18px, 100vw * 18 / 768); */

  --fg-color: #111;
  --bg-color: #f8fafc;
  --fg2-color: #fff;
  --bg2-color: #059;
  --fg3-color: #b00;
  --divider-color: #ccc;
  --backdrop-color: rgba(0, 0, 0, 0.2);
  --highlight-color: #fc0;

  /* Minimum dimension for tap-able (finger-sized) things. */
  --tile-size: 56px;
}
h1 {
  font-size: 64px;
  line-height: 100%;
  letter-spacing: -0.07em;
}
h2 {
  font-size: 32px;
  line-height: 100%;
  letter-spacing: -0.05em;
}
h3 {
  font-size: 24px;
  line-height: 100%;
}
.placeholder {
  opacity: 50%;
}
.disabled {
  opacity: 25%;
}

emoji-picker {
  width: calc(100% + 2px);
  margin: -1px;
  --background: var(--bg-color);
  --border-color: var(--divider-color);
  --indicator-color: var(--fg-color);
  --emoji-size: 24px;
}

/* App Components */

.app {
  height: 100%;
  overflow: hidden;
  position: relative;

  /* Enforce a max width on wide screens */
  max-width: 768px;
  margin: 0 auto;
  box-shadow: 0 0 4px 1px rgba(0, 0, 0, 0.2);

  color: var(--fg-color);
  background: var(--bg-color);

  /* (Attempt to) disable touble-tap zoom */
  touch-action: manipulation;
}
.app--dark-theme {
  --fg-color: #eee;
  --bg-color: #002;
  --fg2-color: #fff;
  --bg2-color: #06b;
  --fg3-color: #e22;
  --divider-color: #444;
  --backdrop-color: rgba(255, 255, 255, 0.2);
  --highlight-color: #860;
}
.app__view {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
}
.app__bar {
  height: var(--tile-size);
}
.app_page {
  background: var(--bg-color);
}

.dialog__box {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  overflow: hidden;
  /*   width: fit-content; */
  height: fit-content;
  max-width: min(90vw, 690px);
  max-height: 90vh;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}
.dialog__box .app__bar h2 {
  font-size: 26px;
}
.dialog__backdrop {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: var(--backdrop-color);
}

.scale-input__button,
.icon-button {
  height: var(--tile-size);
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  user-select: none;
}
.icon-button {
  flex: none;
  min-width: var(--tile-size);
}
.icon-button--labeled {
  padding-right: 20px;
}
.icon-button--labeled > .material-icons {
  margin: 0 8px 0 16px;
}
.icon-button--fill:not(.disabled) {
  color: var(--fg2-color);
  background: var(--bg2-color);
}
.icon-button--raised:not(.disabled) {
  border-radius: 6px;
  color: var(--fg2-color);
  background: var(--bg2-color);
}

.factor-suggestions {
  justify-content: center;
}
.factor-button {
  height: 40px;
  min-width: var(--tile-size);
  padding: 0 8px;
  border: 1px solid var(--divider-color);
  border-radius: 8px;
  user-select: none;
}
.factor-button__emoji {
  margin-right: 4px;
}
.factor-button--selected {
  color: var(--fg2-color);
  background: var(--bg2-color);
  border-color: var(--bg2-color);
}

.menu {
  grid-template-columns: var(--tile-size) 1fr;
  grid-auto-rows: var(--tile-size);
}

.menu-item__label {
  user-select: none;
  margin-right: 8px;
}

.date-bar__nav {
  display: flex;
  flex: 1;
}
.date-bar__date {
  font-weight: bold;
  font-size: 1.1rem;
  flex: 2;
}
.date-bar__date--today {
  color: var(--fg3-color);
}

@media (pointer: coarse) {
  .days-list__scroll-container::-webkit-scrollbar {
    display: none;
  }
}
.days-list__item {
  box-sizing: border-box;
  border-bottom: 1px solid var(--divider-color);
  overflow: hidden;
  position: relative;
  max-height: 88px;
}
.days-list:not(.days-list--search) .days-list__item--weekend {
  background: rgba(0, 0, 0, 0.03);
}

.days-list:not(.days-list--search) .days-list__item--monthend {
  border-bottom: 1px solid var(--fg-color);
}
.days-list__item--today {
  background: rgba(187, 0, 0, 0.03);
}
.days-list__item--today .days-list__item-caption {
  font-weight: bold;
  color: var(--fg3-color);
}
.days-list__item-caption {
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  margin: 0 4px;
}
.days-list__item-records {
  margin: 0 3px;
}
.days-list__diff {
  min-height: 4px;
  background-color: var(--divider-color);
  text-align: center;
  font-size: 14px;
  border-bottom: 1px solid var(--divider-color);
}
.days-list--search__message {
  margin: 24px 16px 0;
  text-align: center;
}
.days-list--search__message .material-icons {
  vertical-align: -.25em;
}

.record-tile {
  padding: 1px 4px 1px 0;
  margin: 1px 2px;
  font-size: 16px;
  white-space: nowrap;
}
.record-tile--bordered {
  border: 1px solid var(--divider-color);
  background-color: var(--bg-color);
  border-radius: 8px;
}
.record-tile--dim {
  filter: saturate(0);
  opacity: 25%;
}
.record-tile__value:not(:empty) {
  font-weight: bold;
  margin-left: 4px;
}
.record-tile__note {
  font-style: italic;
  margin-left: 4px;
}

.note__highlight {
  background-color: var(--highlight-color);
}

.log-day {
  touch-action: pan-y;
}
.log-day__table-wrapper {
  min-height: 96px;
  flex: none;
}
.log-day__table > hr:last-child {
  position: sticky;
  bottom: var(--tile-size);
  bottom: calc(var(--tile-size) + env(safe-area-inset-bottom));
}
.log-day__add-button {
  background: var(--bg-color);
  position: sticky;
  height: calc(var(--tile-size) + env(safe-area-inset-bottom));
  bottom: 0;
}

.log-record>* {
  min-height: 24px;
}
.log-record__emoji,
.factor-type-row__emoji {
  font-size: 120%;
  margin-left: 8px;
  text-align: center;
}
.log-record__value {
  font-weight: bold;
}
.log-record__note {
  overflow: hidden;
  max-height: calc(var(--tile-size) - 16px);
  white-space: pre-line;

  /* Special webkit (chrome) sauce to add an ellipsis.*/
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.log-record__note.placeholder {
  font-style: italic;
}

.edit-record-form label:not(.edit-record-form__value-label--scale10) {
  text-align: right;
}
.edit-record-form__buttons {
  grid-column: 1 / 3;
}
.edit-record-form__value-label--scale5 {
  align-self: center;
}
.edit-record-form__value--scale10,
.edit-record-form__value-label--scale10 {
  grid-column: 1 / span 2;
}

.form-buttons {
  justify-content: flex-end;
}

.scale-input__button--selected {
  color: var(--fg2-color);
  background-color: var(--bg2-color);
  border-radius: 6px;
}

.factor-types-table {
  border-spacing: 0;
}

.factor-type-row.sortable-chosen {
  background-color: var(--divider-color);
}
.factor-type-row:not(:last-child) td {
  border-bottom: 1px solid var(--divider-color);
}
.factor-type-row__emoji {
  width: 0;
}
.factor-type-row__drag {
  color: var(--divider-color);
  width: 0;
  cursor:grab;
}

.factor-type-form__emoji-button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--divider-color);
  border-radius: 6px;
  height: var(--tile-size);
  width: var(--tile-size);
  font-size: 150%;
}
.factor-type-form__emoji-button-placeholder {
  font-size: 50%;
}

/* Not proud of this */
.factor-type-form__footer--emoji-picker,
.factor-type-form__footer--emoji-picker + .form-buttons {
  display: none;
}

.factor-trends-view__edge {
  width: 1px;
  background-color: var(--divider-color);
  flex: 0.5;
}

.welcome-view {
  justify-content: center;
}
.welcome-view__banner {
  font-size: 17vmin;
  margin: 24px;
}
.welcome-view__block {
  margin: 8px 32px;
}
.welcome-view__block--button {
  margin: 24px 32px 8px;
  align-self: center;
  justify-content: center;
  align-items: center;
}

.factor-type-color {
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--divider-color);
}
