/*
 * notion-enhancer
 * (c) 2020 dragonwocky <thedragonring.bod@gmail.com>
 * (https://dragonwocky.me/) under the MIT license
 */

@import './buttons.css';
@import './scrollbars.css';
@import './localised.css';

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

* {
  box-sizing: border-box;
  word-break: break-word;
  text-decoration: none;
  text-size-adjust: 100%;
  outline-color: var(--theme_local--card-border);
}
*:active {
  outline: none;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--theme_local--main);
}

body:not([style]) > * {
  display: none !important;
}
body:not([style])::after {
  content: '';
  position: absolute;
  left: 44vw;
  top: calc(50% - 7.5vw);
  width: 10vw;
  height: 10vw;
  border: 4px solid rgb(34, 34, 34);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

main {
  padding: 1em 1em 2.9em 1em;
  height: 100%;
  overflow: auto;
}
main section {
  border-radius: 2px;
  margin-bottom: 0.75em;
}

/* inline formatting */

body,
button {
  color: var(--theme_local--text);
  font-family: var(--theme_local--font_sans);
}

code {
  border-radius: 0.1em;
  padding: 0.2em 0.4em;
  font: 0.85em var(--theme_local--font_code);
  /* color: var(--theme_local--code_inline-text); */
  background: var(--theme_local--code_inline-background);
}

u {
  text-decoration: underline;
}
s {
  text-decoration: line-through;
}

/* titlebar */

#menu-titlebar::before {
  content: '';
  position: absolute;
  width: 100%;
  -webkit-app-region: no-drag;
  top: 0;
  left: 0;
  height: 2px;
}

#menu-titlebar {
  display: flex;
  padding: 0.4em;
  -webkit-app-region: drag;
}
#menu-titlebar button {
  -webkit-app-region: no-drag;
}
#menu-titlebar :first-child {
  margin-left: auto;
}
#menu-titlebar {
  background: var(--theme_local--dragarea);
}

/* alerts */

#alerts [role='alert'] {
  display: flex;
  padding: 0.75em;
}
#alerts [role='alert']::before {
  content: '!';
  display: block;
  /* margin: auto 0; */
  font-weight: bold;
  font-size: 1.2em;
  padding-right: 0.5rem;
}
#alerts [role='alert'] p {
  font-size: 1rem;
  margin: auto 0;
  padding-left: 0.5em;
  color: var(--theme_local--text_ui);
}

#alerts .error::before {
  color: var(--theme_local--bg_red);
}
#alerts .error {
  border: 1px solid var(--theme_local--bg_red);
  background: var(--theme_local--line_red);
}

#alerts .warning::before {
  color: var(--theme_local--bg_yellow);
}
#alerts .warning {
  border: 1px solid var(--theme_local--bg_yellow);
  background: var(--theme_local--line_yellow);
}

#alerts .info::before {
  color: var(--theme_local--bg_blue);
}
#alerts .info {
  border: 1px solid var(--theme_local--bg_blue);
  background: var(--theme_local--line_blue);
}

#alerts .success::before {
  content: '✓';
  color: var(--theme_local--bg_green);
}
#alerts .success {
  border: 1px solid var(--theme_local--bg_green);
  background: var(--theme_local--line_green);
}

.notion-light-theme #alerts [role='alert']::before {
  color: rgba(0, 0, 0, 0.2);
}
.notion-light-theme #alerts [role='alert'] {
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* module meta */

#modules section {
  background: var(--theme_local--sidebar);
  border: 1px solid var(--theme_local--table-border);
}
#modules section > div {
  padding: 0.75em;
}
.notion-light-theme #modules section {
  background: var(--theme_local--main);
}

#modules section h3,
#modules section p {
  margin: 0;
  font-size: 1rem;
}

/* #modules section .meta .toggle input + label .switch:before {
  background: linear-gradient(
    90deg,
    var(--theme_local--text_green),
    var(--theme_local--bg_green)
  );
} */
#modules section .desc {
  margin: 0.3em 0 0.4em 0;
  font-size: 0.9em;
}
#modules section .desc p {
  font-size: inherit;
  margin: 0;
}
#modules section .desc blockquote {
  margin: 0.3em 0;
  border-left: 0.3em solid var(--theme_local--table-border);
  padding-left: 0.7em;
}

#modules section .desc a {
  color: currentColor;
  text-decoration: underline dotted;
}

#modules section .desc img {
  width: 100%;
  max-width: 20em;
  margin: 0.5em 0;
}
#modules section .desc :first-child img:first-child {
  margin-top: 0;
}
#modules section .desc :last-child img:last-child {
  margin-bottom: 0;
}

#modules section .author {
  color: currentColor;
}
#modules section .author img {
  max-height: 1em;
  max-width: 1em;
  margin-bottom: 0.15625em;
  display: inline-block;
  vertical-align: middle;
  border-radius: 50%;
}
#modules section .tags,
#modules section .version {
  font-size: 0.85em;
  color: var(--theme_local--text_ui);
}

/* module options */

#modules .disabled .options {
  display: none;
}
#modules section .options {
  border-top: 1px solid var(--theme_local--table-border);
  background: var(--theme_local--card);
}
#modules section .options p {
  font-size: 0.9em;
}
#modules section .options p:not(:last-child) {
  padding-bottom: 0.5em;
  border-bottom: 0.5px solid var(--theme_local--table-border);
  margin-bottom: 0.5em;
}

.toggle *,
.input *,
.select *,
.file * {
  cursor: pointer;
}
.select select,
.input input[type='text'],
.input input[type='number'],
.file input[type='file'] + label .choose {
  width: 100%;
  margin: 0.25em 0;
  font-size: 0.9rem;
  padding: 0.4rem 0.2rem;
  border: none;
  color: var(--theme_local--text);
  background: var(--theme_local--main);
}
.select select:focus,
.input input[type='text']:focus,
.input input[type='number']:focus,
.file input[type='file']:focus + label .choose,
.file input[type='file'] + label .choose:hover {
  outline: var(--theme_local--table-border) solid 2px;
}
.file input[type='file'],
.toggle input[type='checkbox'] {
  display: none;
}

.input input[type='text'],
.input input[type='number'] {
  padding: 0.4rem;
  cursor: text;
}

.file input[type='file'] + label .label {
  position: relative;
  display: flex;
}
.file input[type='file'] + label .label .name {
  flex-basis: calc(100% - 1.5rem);
}
.file input[type='file'] + label .label .clear {
  font-size: 1rem;
  position: absolute;
  top: 0.4em;
  right: 0;
  width: 1em;
  height: 0.1em;
  border: 0.35em solid var(--theme_local--card);
  background: currentColor;
}
.file input[type='file'] + label .choose {
  display: block;
  white-space: nowrap;
  overflow: hidden;
}
.file input[type='file'] + label .choose svg {
  padding-top: 0.5em;
  height: 1.25em;
  width: 1.25em;
}

.toggle input[type='checkbox'] + label {
  display: flex;
}
.toggle input[type='checkbox'] + label .name {
  flex-basis: calc(100% - 2.25em);
}
.toggle input[type='checkbox'] + label .switch {
  position: relative;
  margin-top: 0.5em;
  float: right;
  height: 0.65em;
  width: 2em;
  background: var(--theme_local--main);
  border-radius: 5px;
}
.toggle input[type='checkbox'] + label .switch::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--theme_local--primary),
    var(--theme_local--primary_click)
  );
  opacity: var(--menu--toggle_opacity, 0);
  transition: opacity 300ms;
}
.toggle input[type='checkbox'] + label .switch .dot {
  position: absolute;
  width: 1em;
  height: 1em;
  top: -0.15em;
  border-radius: 50%;
  transform: translateX(var(--menu--toggle_offset, 0));
  transition: transform 350ms, box-shadow 350ms;
  background: var(--theme_local--todo_ticked-fill);
  box-shadow: 2px 1px 4px var(--theme_local--table-border);
}
.toggle input[type='checkbox']:checked + label {
  --menu--toggle_offset: 1em;
  --menu--toggle_opacity: 1;
}