/* Modals, sign-in, editor, menus, lightbox, toasts, uploads, drop overlay. */

/* ---------- modal shell ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 18, 32, .74);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--dur-mid) ease;
}

.modal__panel {
  position: relative;
  width: min(100%, 31rem);
  border: 1px solid var(--kin-deep);
  border-radius: var(--radius);
  background: var(--kinari);
  box-shadow: 0 0 0 5px rgba(251, 246, 234, .08), 0 40px 80px -30px rgba(0, 0, 0, .85);
  color: var(--ink);
  opacity: 0;
  transform: translateY(16px) scale(.985);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) var(--ease-brush);
}

.modal.is-open .modal__backdrop {
  opacity: 1;
}

.modal.is-open .modal__panel {
  opacity: 1;
  transform: none;
}

.modal.is-closing {
  pointer-events: none;
}

.modal--narrow .modal__panel {
  width: min(100%, 26rem);
}

.modal--wide .modal__panel {
  width: min(100%, 40rem);
}

.modal--editor .modal__panel {
  width: min(100%, 52rem);
}

.modal__panel:focus,
.modal__panel:focus-visible {
  outline: none;
}

.dialog {
  padding: clamp(24px, 4vw, 38px);
}

.dialog.is-busy {
  cursor: progress;
}

.dialog__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .05em;
  color: var(--sumi);
  overflow-wrap: anywhere;
}

.dialog__lead {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 26px;
}

.dialog--confirm {
  text-align: center;
}

.dialog--confirm .dialog__actions {
  justify-content: center;
}

.dialog__glyph {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  border-radius: 5px;
  background: var(--shu);
  color: var(--kinari);
  font-family: var(--font-brush);
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(251, 246, 234, .2);
}

/* ---------- sign-in: a shoji panel ---------- */

.modal--shoji .modal__panel {
  width: min(100%, 27rem);
  border: 0;
  background: none;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .9);
}

.shoji {
  position: relative;
  padding: 16px;
  border-radius: 3px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .22), rgba(0, 0, 0, 0) 12%, rgba(0, 0, 0, 0) 88%, rgba(0, 0, 0, .22)),
    repeating-linear-gradient(92deg, var(--wood) 0 7px, var(--wood-light) 7px 9px, var(--wood) 9px 17px),
    var(--wood);
  box-shadow: inset 0 0 0 1px rgba(233, 213, 163, .25), inset 0 0 0 2px rgba(0, 0, 0, .35);
}

/* paper behind a wooden lattice */
.shoji__lattice {
  position: absolute;
  inset: 16px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 3px), var(--wood) calc(25% - 3px) 25%),
    repeating-linear-gradient(180deg, transparent 0 74px, var(--wood) 74px 77px),
    linear-gradient(180deg, #fdf9ee, var(--washi));
  box-shadow: inset 0 0 40px rgba(150, 118, 58, .18);
}

.shoji__paper {
  position: relative;
  margin: 46px 30px;
  padding: 30px 26px 26px;
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  background: var(--kinari);
  box-shadow: 0 14px 30px -18px rgba(42, 30, 16, .7);
  text-align: left;
}

.shoji__paper.is-busy {
  cursor: progress;
}

.shoji__paper .shoji__seal {
  position: absolute;
  top: -22px;
  right: 22px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background: var(--shu);
  color: var(--kinari);
  font-family: var(--font-brush);
  font-size: 1.45rem;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(251, 246, 234, .22), 0 8px 16px -8px rgba(143, 36, 36, .9);
}

.shoji__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--sumi);
}

.shoji__lead {
  margin-top: 4px;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--ink-soft);
}

@media (max-width: 460px) {
  .shoji {
    padding: 11px;
  }

  .shoji__lattice {
    inset: 11px;
  }

  .shoji__paper {
    margin: 34px 14px;
    padding: 28px 18px 20px;
  }
}

/* ---------- note editor ---------- */

.editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.editor__head .btn[aria-pressed="true"] {
  background: var(--kon);
  border-color: var(--kin-deep);
  color: var(--kin-light);
}

.editor__body {
  min-height: 40vh;
  font-size: 1.02rem;
  line-height: 1.8;
}

.editor__preview {
  min-height: 40vh;
  max-width: none;
  padding: 18px 20px;
  border: 1px dashed var(--paper-edge);
  border-radius: var(--radius);
  background: #fffdf6;
}

.editor__tip {
  margin-right: auto;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: .95rem;
  color: var(--ink-faint);
}

@media (max-width: 560px) {
  .editor__tip {
    display: none;
  }
}

/* ---------- popover menu ---------- */

.menu {
  position: fixed;
  z-index: calc(var(--z-overlay) + 5);
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--kin-deep);
  border-radius: 4px;
  background: var(--kinari);
  box-shadow: 0 24px 44px -20px rgba(0, 0, 0, .75);
  animation: menu-in var(--dur-fast) var(--ease-brush);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.menu__item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-align: left;
}

.menu__item:hover:not(:disabled),
.menu__item:focus-visible {
  outline: none;
  background: rgba(200, 163, 90, .24);
}

.menu__item:disabled {
  color: var(--ink-faint);
  opacity: .6;
}

.menu__item--danger {
  margin-top: 4px;
  border-top: 1px solid var(--hairline-soft);
  border-radius: 0 0 3px 3px;
  color: var(--beni);
}

.menu__item--danger:hover:not(:disabled),
.menu__item--danger:focus-visible {
  background: var(--shu);
  color: var(--kinari);
}

/* ---------- lightbox: a hanging scroll ---------- */

.modal--lightbox {
  padding: 0;
  overflow: hidden;
}

.modal--lightbox .modal__backdrop {
  background:
    radial-gradient(80% 70% at 50% 40%, rgba(35, 50, 83, .55) 0%, rgba(13, 18, 32, 0) 70%),
    rgba(10, 13, 23, .95);
}

.modal--lightbox .modal__panel {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  transform: none;
}

.lightbox {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  color: var(--on-dark);
}

.lightbox__stage {
  grid-column: 2;
  display: grid;
  place-items: center;
  height: 100%;
  min-width: 0;
  padding: 56px 0 44px;
  touch-action: pan-y;
}

.kakejiku {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  transition: opacity var(--dur-fast) ease;
}

.kakejiku.is-loading .kakejiku__img {
  opacity: .25;
}

.kakejiku__rod {
  position: relative;
  z-index: 1;
  width: calc(100% + 28px);
  height: 9px;
  border-radius: 5px;
  background: linear-gradient(180deg, #7a583a, #3b2616);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(233, 213, 163, .35);
}

.kakejiku__rod--foot {
  width: calc(100% + 44px);
  height: 15px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--kin-deep) 0 12px, transparent 12px calc(100% - 12px), var(--kin-deep) calc(100% - 12px)),
    linear-gradient(180deg, #7a583a, #33200f);
}

.kakejiku__mount {
  padding: clamp(14px, 3vh, 30px) clamp(10px, 1.6vw, 20px);
  background:
    linear-gradient(180deg, rgba(200, 163, 90, .35) 0 4px, transparent 4px calc(100% - 4px), rgba(200, 163, 90, .35) calc(100% - 4px)),
    linear-gradient(180deg, var(--ai) 0%, var(--kon) 100%);
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .9);
}

.kakejiku__paper {
  padding: clamp(6px, 1vw, 12px);
  background: var(--kinari);
  box-shadow: inset 0 0 0 1px var(--paper-edge);
}

.kakejiku__img {
  width: auto;
  height: auto;
  max-width: calc(100vw - 190px);
  max-height: calc(100vh - 250px);
  object-fit: contain;
  transition: opacity var(--dur-fast) ease;
  user-select: none;
  -webkit-user-select: none;
}

.kakejiku__caption {
  /* take the scroll's width without widening it */
  width: 0;
  min-width: 100%;
  padding: 10px 16px 12px;
  background: var(--kinari);
  border-top: 1px solid var(--paper-edge);
  color: var(--ink-soft);
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 1.04rem;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
  max-height: 5.4em;
  overflow-y: auto;
}

.lightbox__btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: rgba(20, 27, 46, .7);
  color: var(--kin-light);
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.lightbox__btn:hover {
  background: var(--ai);
  border-color: var(--kin);
}

.modal .lightbox__btn:focus-visible {
  outline-color: var(--kin-light);
}

.lightbox__prev {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
}

.lightbox__stage {
  grid-row: 1;
}

.lightbox__next {
  grid-column: 3;
  grid-row: 1;
  justify-self: center;
}

.lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.lightbox__count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  font-family: var(--font-latin);
  font-size: 1rem;
  letter-spacing: .3em;
  text-align: center;
  color: var(--on-dark-soft);
  pointer-events: none;
}

@media (max-width: 640px) {
  .lightbox {
    grid-template-columns: 8px minmax(0, 1fr) 8px;
  }

  .lightbox__prev,
  .lightbox__next {
    position: absolute;
    bottom: 10px;
    z-index: 2;
  }

  .lightbox__prev {
    left: 14px;
  }

  .lightbox__next {
    right: 14px;
  }

  .lightbox__stage {
    padding: 66px 0 70px;
  }

  .kakejiku__img {
    max-width: calc(100vw - 64px);
    max-height: calc(100vh - 290px);
  }

  .kakejiku__rod {
    width: calc(100% + 14px);
  }

  .kakejiku__rod--foot {
    width: calc(100% + 22px);
  }
}

/* ---------- toasts: small paper slips ---------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: calc(var(--z-overlay) + 10);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(24rem, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--paper-edge);
  border-left: 3px solid var(--kin-deep);
  border-radius: 2px;
  background: var(--kinari);
  box-shadow: 0 18px 36px -18px rgba(0, 0, 0, .7);
  color: var(--ink);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-fast) ease, transform var(--dur-mid) var(--ease-brush);
}

.toast.is-in {
  opacity: 1;
  transform: none;
}

.toast--error {
  border-left-color: var(--shu);
}

.toast--ok {
  border-left-color: var(--matsu);
}

.toast__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 3px;
  background: var(--kin-deep);
  color: var(--kinari);
  font-family: var(--font-brush);
  font-size: .92rem;
  line-height: 1;
}

.toast--error .toast__mark {
  background: var(--shu);
}

.toast--ok .toast__mark {
  background: var(--matsu);
}

.toast__text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .98rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.toast__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--ink-faint);
}

.toast__close:hover {
  color: var(--ink);
  background: rgba(212, 196, 160, .5);
}

.toasts :focus-visible {
  outline-color: var(--kin-deep);
}

/* ---------- upload tray ---------- */

.uploads {
  position: fixed;
  left: calc(var(--sb-w) + 18px);
  bottom: 18px;
  z-index: calc(var(--z-sidebar) + 10);
  width: min(22rem, calc(100vw - 36px));
  border: 1px solid var(--kin-deep);
  border-radius: var(--radius);
  background: var(--kinari);
  box-shadow: 0 26px 50px -22px rgba(0, 0, 0, .75);
  color: var(--ink);
  transition: left var(--dur-mid) var(--ease-fold);
}

.uploads__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: linear-gradient(180deg, var(--kon), var(--kon-deep));
  color: var(--on-dark);
  border-radius: 2px 2px 0 0;
  box-shadow: inset 0 -1px 0 var(--kin-deep);
}

.uploads__seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 3px;
  background: var(--shu);
  color: var(--kinari);
  font-family: var(--font-brush);
  font-size: .95rem;
  line-height: 1;
}

.uploads__title {
  flex: 1 1 auto;
  font-family: var(--font-latin);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .1em;
}

.uploads__clear {
  padding: 2px 8px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  color: var(--kin-light);
  font-family: var(--font-latin);
  font-size: .9rem;
  letter-spacing: .08em;
}

.uploads__clear:hover {
  background: rgba(200, 163, 90, .16);
}

.uploads__clear:focus-visible {
  outline-color: var(--kin-light);
}

.uploads__list {
  max-height: min(46vh, 340px);
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
}

.upload {
  padding: 10px 12px 11px;
}

.upload + .upload {
  border-top: 1px solid var(--hairline-soft);
}

.upload__top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .96rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload__pct {
  flex: none;
  font-family: var(--font-latin);
  font-size: .96rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.upload__btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--ink-faint);
}

.upload__btn:hover {
  color: var(--ink);
  background: rgba(212, 196, 160, .55);
}

.uploads .upload__btn:focus-visible {
  outline-color: var(--kin-deep);
  outline-offset: 1px;
}

/* ink soaking along a strip of paper */
.upload__bar {
  height: 5px;
  margin-top: 6px;
  border-radius: 3px;
  background: var(--washi-deep);
  overflow: hidden;
}

.upload__ink {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sumi) 0%, var(--ai) 70%, var(--ai-light) 100%);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 240ms linear;
}

.upload__status {
  margin-top: 4px;
  font-family: var(--font-latin);
  font-size: .9rem;
  line-height: 1.4;
  color: var(--ink-faint);
  overflow-wrap: anywhere;
}

.upload.is-queued .upload__bar {
  opacity: .5;
}

.upload.is-done .upload__ink {
  background: var(--matsu);
}

.upload.is-done .upload__pct {
  color: var(--matsu);
  font-family: var(--font-brush);
}

.upload.is-error .upload__ink {
  background: var(--shu);
  transform: scaleX(1) !important;
  opacity: .35;
}

.upload.is-error .upload__status {
  color: var(--beni);
}

/* ---------- full-area drop overlay ---------- */

.dropzone {
  position: fixed;
  inset: 0 0 0 var(--sb-w);
  z-index: calc(var(--z-sidebar) + 20);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 18, 32, .8);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) ease, visibility 0s linear var(--dur-fast);
}

.dropzone.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--dur-fast) ease, visibility 0s;
}

.dropzone__card {
  width: min(100%, 34rem);
  padding: clamp(30px, 6vw, 56px) 28px;
  border: 2px dashed var(--kin);
  border-radius: 6px;
  background: rgba(20, 27, 46, .72);
  color: var(--on-dark);
  text-align: center;
}

.dropzone__glyph {
  display: inline-grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 6px;
  background: var(--shu);
  color: var(--kinari);
  font-family: var(--font-brush);
  font-size: 2.6rem;
  line-height: 1;
}

.dropzone__title {
  margin-top: 20px;
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--kin-light);
}

.dropzone__sub {
  margin-top: 6px;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--on-dark-soft);
}

@media (max-width: 860px) {
  .uploads {
    left: 18px;
    bottom: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal__backdrop,
  .modal__panel,
  .toast,
  .upload__ink,
  .dropzone,
  .uploads,
  .kakejiku,
  .kakejiku__img {
    transition: none !important;
  }

  .menu {
    animation: none;
  }
}
