/* 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:
    radial-gradient(90% 70% at 50% 38%, rgba(255, 253, 249, .5) 0%, rgba(255, 253, 249, 0) 70%),
    var(--scrim);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity var(--dur-mid) ease;
}

.modal__panel {
  position: relative;
  width: min(100%, 31rem);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(110% 60% at 100% 0%, rgba(248, 215, 222, .4), rgba(248, 215, 222, 0) 62%),
    var(--kinari);
  box-shadow: 0 0 0 1px var(--hairline), 0 0 0 7px rgba(255, 253, 249, .4), 0 44px 90px -40px rgba(120, 78, 96, .7);
  color: var(--ink);
  opacity: 0;
  transform: translateY(14px) 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.46rem;
  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: 56px;
  height: 56px;
  margin-bottom: 16px;
  border-radius: 13px 10px 14px 11px / 11px 14px 10px 13px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .3), transparent 58%),
    var(--shu);
  color: #fff;
  font-family: var(--font-brush);
  font-size: 1.8rem;
  line-height: 1;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 2.5px var(--shu), inset 0 0 0 3.6px rgba(255, 253, 249, .7), 0 12px 18px -12px rgba(179, 77, 102, .9);
}

/* ---------- sign-in: a paper screen in a pale wooden frame ---------- */

.modal--shoji .modal__panel {
  width: min(100%, 27rem);
  border: 0;
  background: none;
  box-shadow: 0 0 0 7px rgba(255, 253, 249, .4), 0 44px 90px -40px rgba(120, 78, 96, .75);
}

.shoji {
  position: relative;
  padding: 14px;
  border-radius: var(--radius-lg);
  background:
    repeating-linear-gradient(92deg, rgba(165, 133, 79, 0) 0 9px, rgba(165, 133, 79, .1) 9px 10px, rgba(165, 133, 79, 0) 10px 23px),
    linear-gradient(180deg, #fffaf2, var(--wood-pale) 30%, var(--wood-mid) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), inset 0 0 0 2px rgba(207, 174, 120, .55);
}

/* paper behind a fine wooden lattice, lit from behind like morning */
.shoji__lattice {
  position: absolute;
  inset: 14px;
  border-radius: calc(var(--radius-lg) - 10px);
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 2px), rgba(205, 180, 151, .75) calc(25% - 2px) 25%),
    repeating-linear-gradient(180deg, transparent 0 74px, rgba(205, 180, 151, .75) 74px 76px),
    radial-gradient(90% 60% at 50% 30%, #fffdf9, rgba(255, 253, 249, 0) 80%),
    linear-gradient(180deg, var(--kasumi-top), var(--kasumi-mid) 60%, var(--kasumi-low));
  box-shadow: inset 0 0 0 1px rgba(205, 180, 151, .9), inset 0 0 36px rgba(255, 255, 255, .7);
}

.shoji__paper {
  position: relative;
  margin: 44px 28px;
  padding: 32px 26px 26px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius);
  background: var(--kinari);
  box-shadow: 0 0 0 1px var(--hairline-soft), 0 22px 40px -24px rgba(120, 78, 96, .6);
  text-align: left;
}

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

.shoji__paper .shoji__seal {
  position: absolute;
  top: -22px;
  right: 22px;
  width: 46px;
  height: 46px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  font-size: 1.45rem;
  transform: rotate(4deg);
  box-shadow: inset 0 0 0 2px var(--shu), inset 0 0 0 3.2px rgba(255, 253, 249, .8), 0 0 0 4px var(--kinari), 0 12px 18px -10px rgba(179, 77, 102, .8);
  -webkit-mask: none;
  mask: none;
}

.shoji__title {
  font-family: var(--font-heading);
  font-size: 1.46rem;
  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.06rem;
  color: var(--ink-soft);
}

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

  .shoji__lattice {
    inset: 10px;
  }

  .shoji__paper {
    margin: 34px 14px;
    padding: 30px 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(--rose-wash);
  border-color: var(--shu-bright);
  color: var(--beni);
}

.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(--sakura-deep);
  border-radius: 12px;
  background: #fff;
}

.editor__tip {
  margin-right: auto;
  font-family: var(--font-ui);
  font-size: .82rem;
  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: 196px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius);
  background: var(--kinari);
  box-shadow: 0 0 0 1px var(--hairline), 0 26px 50px -24px rgba(120, 78, 96, .7);
  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: 8px 13px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: .9rem;
  font-weight: 500;
  letter-spacing: .04em;
  text-align: left;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.menu__item:hover:not(:disabled),
.menu__item:focus-visible {
  outline: none;
  background: var(--rose-wash);
  color: var(--beni);
}

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

.menu__item--danger {
  position: relative;
  margin-top: 9px;
  color: var(--beni);
}

.menu__item--danger::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: -5px;
  height: 1px;
  background: var(--hairline-soft);
}

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

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

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

.modal--lightbox .modal__backdrop {
  background:
    radial-gradient(80% 70% at 50% 38%, rgba(221, 213, 239, .34) 0%, rgba(221, 213, 239, 0) 70%),
    linear-gradient(180deg, rgba(86, 70, 92, .93), rgba(66, 54, 68, .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, #fffaf2, var(--wood-mid) 55%, var(--wood-deep));
  box-shadow: 0 4px 10px rgba(40, 28, 40, .4), inset 0 1px 0 rgba(255, 255, 255, .8);
}

.kakejiku__rod--foot {
  width: calc(100% + 44px);
  height: 14px;
  border-radius: 7px;
  background:
    linear-gradient(90deg, var(--kin) 0 12px, transparent 12px calc(100% - 12px), var(--kin) calc(100% - 12px)),
    linear-gradient(180deg, #fffaf2, var(--wood-mid) 55%, var(--wood-deep));
}

.kakejiku__mount {
  padding: clamp(14px, 3vh, 30px) clamp(10px, 1.6vw, 20px);
  background:
    linear-gradient(180deg, rgba(207, 174, 120, .7) 0 3px, transparent 3px calc(100% - 3px), rgba(207, 174, 120, .7) calc(100% - 3px)),
    linear-gradient(180deg, var(--kasumi-mid) 0%, var(--fuji-light) 100%);
  box-shadow: 0 34px 70px -28px rgba(30, 20, 32, .8);
}

.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.06rem;
  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 rgba(255, 253, 249, .5);
  border-radius: 50%;
  background: rgba(255, 253, 249, .16);
  color: var(--on-dark);
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.lightbox__btn:hover {
  background: var(--kinari);
  border-color: var(--kinari);
  color: var(--beni);
}

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

.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-ui);
  font-size: .82rem;
  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 {
  --tone: var(--ai);
  --tone-wash: #eef0f9;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px 12px 13px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--tone-wash), var(--kinari) 46%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tone) 34%, transparent), 0 22px 44px -22px rgba(120, 78, 96, .65);
  color: var(--ink);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) var(--ease-brush);
}

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

.toast--error {
  --tone: var(--shu);
  --tone-wash: #fdeef0;
}

.toast--ok {
  --tone: var(--matsu);
  --tone-wash: #eef4ec;
}

.toast__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px 6px 9px 7px / 7px 9px 6px 8px;
  background: var(--tone);
  color: #fff;
  font-family: var(--font-brush);
  font-size: .95rem;
  line-height: 1;
  transform: rotate(-3deg);
}

.toast__text {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 1px;
  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);
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

.toast__close:hover {
  color: var(--ink);
  background: rgba(230, 217, 198, .55);
}

.toasts :focus-visible {
  border-radius: 50%;
}

/* ---------- 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 rgba(255, 255, 255, .9);
  border-radius: var(--radius-lg);
  background: var(--kinari);
  box-shadow: 0 0 0 1px var(--hairline), 0 30px 60px -28px rgba(120, 78, 96, .7);
  color: var(--ink);
  overflow: hidden;
  transition: left var(--dur-mid) var(--ease-fold);
}

.uploads__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  background: linear-gradient(180deg, var(--kasumi-top), var(--kasumi-mid));
  color: var(--ink);
  box-shadow: inset 0 -1px 0 var(--hairline);
}

.uploads__seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px 6px 9px 7px / 7px 9px 6px 8px;
  background: var(--shu);
  color: #fff;
  font-family: var(--font-brush);
  font-size: .98rem;
  line-height: 1;
  transform: rotate(-3deg);
}

.uploads__title {
  flex: 1 1 auto;
  font-family: var(--font-ui);
  font-size: .9rem;
  font-weight: 500;
  letter-spacing: .06em;
}

.uploads__clear {
  padding: 3px 12px;
  border: 1px solid rgba(201, 120, 143, .5);
  border-radius: 999px;
  background: rgba(255, 253, 249, .7);
  color: var(--beni);
  font-family: var(--font-ui);
  font-size: .78rem;
  letter-spacing: .06em;
  transition: background-color var(--dur-fast) ease;
}

.uploads__clear:hover {
  background: #fff;
}

.uploads__list {
  max-height: min(46vh, 340px);
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 120, 143, .4) transparent;
}

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

.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-ui);
  font-size: .82rem;
  font-weight: 500;
  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);
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

.upload__btn:hover {
  color: var(--beni);
  background: var(--rose-wash);
}

.uploads .upload__btn:focus-visible {
  outline-offset: 1px;
  border-radius: 50%;
}

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

.upload__ink {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--fuji) 0%, var(--sakura-deep) 60%, var(--shu-bright) 100%);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 240ms linear;
}

.upload__status {
  margin-top: 5px;
  font-family: var(--font-ui);
  font-size: .78rem;
  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);
  font-size: .96rem;
}

.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:
    radial-gradient(70% 60% at 50% 45%, rgba(255, 253, 249, .7), rgba(255, 253, 249, 0) 75%),
    rgba(244, 222, 234, .78);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  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(--shu-bright);
  border-radius: 28px;
  background: rgba(255, 253, 249, .92);
  box-shadow: 0 0 0 8px rgba(255, 253, 249, .45), 0 40px 80px -40px rgba(120, 78, 96, .7);
  color: var(--ink);
  text-align: center;
}

.dropzone__glyph {
  display: inline-grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 18px 14px 20px 15px / 15px 20px 14px 18px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .3), transparent 58%),
    var(--shu);
  color: #fff;
  font-family: var(--font-brush);
  font-size: 2.6rem;
  line-height: 1;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 3px var(--shu), inset 0 0 0 4.2px rgba(255, 253, 249, .7), 0 16px 26px -16px rgba(179, 77, 102, .9);
}

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

.dropzone__sub {
  margin-top: 6px;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-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;
  }
}
