/* The editor's own look. The paper itself is styled by paper.css, copied from the theme. */

/* The same resets the theme applies, so the paper lays out the same way here */
*,
*::before,
*::after {
  box-sizing: border-box;
}

img {
  max-width: 100%;
}

:root {
  --ink: #24242a;
  --edge: #d9d9de;
  --accent: #3b5bdb;
  --color-background: #f3f3f5;

}

[hidden] {
  display: none !important;
}

/* Font size goes on body, not the root: the paper's line height is in rem and must match the site's */
body {
  color: var(--ink);
  font: 14px/1.4 system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  background: var(--color-background);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button,
.upload {
  padding: 6px 12px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button[aria-pressed='true'] {
  border-color: var(--accent);
  background: #edf1ff;
}

button.primary:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  color: #b42318;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--edge);
  background: #fff;
}

#status {
  flex: 1;
  text-align: end;
  color: #5c5c66;
}

#status.error {
  color: #b42318;
}

.demo {
  margin: 0;
  padding: 6px 16px;
  background: #fff4d6;
}

.segmented {
  display: flex;
}

.segmented button:first-child {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

.segmented button:last-child {
  margin-inline-start: -1px;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}

main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.stage {
  flex: 1;
  overflow: auto;
  padding: 24px 16px 120px;
}

/* A named container, so the theme's phone rules apply when the box (not the window) is narrow */
.view {
  container: paper-view / inline-size;
  width: 760px;
  margin-inline: auto;
  font-family: Fustat, sans-serif;
  user-select: none;
}

.view--phone {
  /* A 375px phone: 16px page margins, and stickers past the screen edge are cut off like on the site */
  width: 375px;
  padding-inline: 16px;
  overflow-x: clip;
}

/* Clicks go through the text to stickers behind it */
.view .journal-entry__text {
  pointer-events: none;
}

.view .journal-sticker[data-id] {
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.view .journal-sticker.is-locked {
  cursor: default;
}

.selection-layer {
  z-index: 3;
}

.selection {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

.handle {
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  pointer-events: auto;
  touch-action: none;
}

/* A bigger invisible target for fingers and the Pencil */
.handle::after {
  content: '';
  position: absolute;
  inset: -12px;
}

.handle--resize {
  inset-block-end: -14px;
  inset-inline-end: -14px;
  cursor: nwse-resize;
}

.handle--rotate {
  inset-block-start: -40px;
  inset-inline-start: calc(50% - 11px);
  cursor: grab;
}

.panel {
  width: 280px;
  overflow: auto;
  padding: 16px;
  border-inline-start: 1px solid var(--edge);
  background: #fff;
}

.panel section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-block-end: 24px;
}

.panel h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5c5c66;
}

.row {
  display: flex;
  gap: 8px;
}

.row button {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar .field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field input,
.field select {
  padding: 6px 8px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fff;
}

.field input:invalid {
  border-color: #b42318;
}

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

.upload {
  display: block;
}

.upload input {
  display: block;
  max-width: 100%;
  margin-block-start: 6px;
}

.library {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.library button {
  aspect-ratio: 1;
  padding: 6px;
}

.library img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.layers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.layers button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
}

.layers img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.layers .empty {
  color: #5c5c66;
}

/* Narrow screens (iPad upright): the panel moves under the page */
@media (max-width: 820px) {
  main {
    flex-direction: column;
  }

  .panel {
    width: auto;
    max-height: 40vh;
    border-inline-start: 0;
    border-block-start: 1px solid var(--edge);
  }
}
