/* Colours sampled from the design drafts (pink ground, pink glass, red-pink title letters, white type),
   written by js/candy/theme.js into the --c-* variables. Noto Sans SC throughout: 900 for the title, 700 elsewhere. */
:root {
  color-scheme: only light;
  --c-bg: #cfa8aa;
  --c-outside: #8f6b6e;
  --c-card: #dcbfc1;
  --c-card-edge: #a8767c;
  --c-field: #f3e7e7;
  --c-field-edge: #e6d4d5;
  --c-tool: #ffffff;
  --c-tool-ink: #9a6f74;
  --c-ink: #ffffff;
  --c-ink-soft: #f0e4e4;
  --c-rope: #f6e9e9;
  --c-t0: #cc6b6b;
  --c-t1: #e4a9a9;
  --c-t2: #a94f4f;
  --c-t3: #d59696;
  --c-t4: #be3c3c;
  --c-t5: #a88a8c;
  --bg: #cfa8aa;
  --surface: #e7dcdc;
  --surface-2: #d9d0d0;
  --field: #e7dcdc;
  --ink: #7f6666;
  --ink-2: #8e4f55;
  --ink-3: #987575;
  --line: #7f6666;
  --bar: #7f6666;
  --on-dark: #f0e4e4;
  --accent: #cc6b6b;
  --radius: 3px;
  --radius-sm: 2px;
  --grain: none;
  --font-title: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font: var(--font-body);
  --font-weight: 700;
}

html,
body {
  background: var(--c-outside);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-weight: 700;
}

/* the page boils gently (js/candy/pageBoil.js); text-heavy panels use a gentler, slower boil;
   the export preview has no filter because the exported picture already carries the boil */
.page-boil {
  filter: url(#page-boil);
}

.page-boil-soft,
.modal-head,
.modal-text,
.modal-choices,
.modal-foot,
.modal .credit,
.popover {
  filter: url(#page-boil-soft);
}

#app {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
}

/* hidden until the first layout has given it its size, so it never shows as a small box in the corner */
.frame:not(.is-ready) {
  visibility: hidden;
}

.frame {
  position: absolute;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--c-bg);
  background-image: var(--grain);
  background-size: 160px 160px;
}

/* top bar, rope and hanging title */
.head {
  position: relative;
  flex: none;
  height: calc(60px + var(--u) * 15);
  min-height: 104px;
}

.rope {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  padding: 9px calc(var(--u) * 3 + 6px) 7px;
}

.quill-bar {
  display: flex;
  visibility: hidden;
}

.quill-bar .tool {
  margin-right: calc(var(--u) * 2);
}

.is-quill .quill-bar {
  visibility: visible;
}

.lang-seg {
  display: flex;
}

/* each option keeps a 44px touch area; the visible part is a small framed word */
.lang-opt {
  display: flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1;
}

.lang-opt:first-child {
  justify-content: flex-end;
}

.lang-face {
  display: block;
  padding: 5px 8px;
  border: 1.5px solid var(--c-ink);
}

.lang-opt:first-child .lang-face {
  border-right-width: 0;
  border-radius: 2px 0 0 2px;
}

.lang-opt:last-child .lang-face {
  border-radius: 0 2px 2px 0;
}

.lang-opt.is-on .lang-face {
  background: var(--c-ink);
  color: var(--c-tool-ink);
}

.title {
  position: absolute;
  left: 0;
  right: 0;
  top: 60px;
  bottom: 0;
  margin: 0;
  font-size: inherit;
}

.title-btn {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  height: 100%;
  min-height: 44px;
  color: inherit;
}

.title-btn[disabled] {
  cursor: default;
}

.title-chars {
  display: flex;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: calc(var(--u) * 8.4);
  line-height: 1.1;
  white-space: nowrap;
}

.title-piece {
  display: block;
  margin: 0 calc(var(--u) * 1.6);
}

.title-chars.is-words .title-piece {
  margin: 0 calc(var(--u) * 1.1);
}

.t0 { color: var(--c-t0); }
.t1 { color: var(--c-t1); }
.t2 { color: var(--c-t2); }
.t3 { color: var(--c-t3); }
.t4 { color: var(--c-t4); }
.t5 { color: var(--c-t5); }

/* round tool buttons (quill page top bar) */
.tool {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--c-tool);
  color: var(--c-tool-ink);
}

.tool .icon {
  display: block;
  width: 50%;
  height: 50%;
}

.tool .icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 4.2;
}

.tool[disabled] {
  opacity: 0.45;
  cursor: default;
}

/* subtitle row: empty on the home page, the subtitle on the result page */
.subrow {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--u) * 15);
}

.subtitle {
  margin: 0;
  padding: 0 calc(var(--u) * 6);
  color: var(--c-ink);
  font-size: calc(var(--u) * 6);
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-align: center;
  word-break: break-word;
  visibility: hidden;
}

.is-result .subtitle {
  visibility: visible;
}

/* jar stage */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.scene {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}

.scene:focus {
  outline: none;
}

.scene:focus-visible {
  box-shadow: inset 0 0 0 2px var(--c-ink);
}

/* written buttons with a white underline, as in the drafts */
.bottombar {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(var(--u) * 17);
  min-height: 70px;
  padding: 0 calc(var(--u) * 8) calc(var(--u) * 2);
  visibility: hidden;
}

.is-result .bottombar {
  visibility: visible;
}

/* the opening jar: one button, centred */
.is-opening .bottombar {
  justify-content: center;
}

.is-opening #btnExportHand {
  display: none;
}

.hand-btn {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0 calc(var(--u) * 1) calc(var(--u) * 1.4);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: calc(var(--u) * 5.6);
  line-height: 1.2;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.hand-btn::after {
  content: '';
  position: absolute;
  left: calc(var(--u) * 0.6);
  right: calc(var(--u) * 0.6);
  bottom: calc(var(--u) * 0.8);
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.hand-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

/* add card (draft 002) */
.bubble-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-float);
  visibility: hidden;
  pointer-events: none;
}

.bubble-layer.is-open {
  visibility: visible;
  pointer-events: auto;
}

.bubble {
  position: absolute;
  display: flex;
  flex-direction: column;
  padding: calc(var(--u) * 2.5) calc(var(--u) * 4.5) calc(var(--u) * 4);
  border: 3px solid var(--c-card-edge);
  border-radius: 4px;
  background-color: var(--c-card);
  background-image: var(--grain);
  background-size: 160px 160px;
}

.is-short .bubble {
  padding: calc(var(--u) * 1) calc(var(--u) * 3) calc(var(--u) * 2);
}

.is-short .seg,
.is-short .bubble-area {
  margin-top: calc(var(--u) * 1.5);
}

.bubble-thread {
  position: absolute;
  width: 3px;
  margin-left: -1.5px;
  background: var(--c-card-edge);
}

.thread-star {
  display: none;
}

.name-row {
  display: flex;
  align-items: center;
  flex: none;
}

.bubble-label {
  flex: none;
  margin-right: calc(var(--u) * 3);
  color: var(--c-ink);
  font-size: calc(var(--u) * 6.4);
  line-height: 1.4;
  letter-spacing: 0.06em;
}

.name-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 calc(var(--u) * 2);
  border: 2px solid var(--c-field-edge);
  border-radius: 3px;
  background: var(--c-field);
  color: var(--c-tool-ink);
  font-family: var(--font-body);
  font-size: 17px;
}

.name-input:focus {
  border-color: var(--c-ink);
}

.seg {
  display: flex;
  flex: none;
  margin-top: calc(var(--u) * 3);
  border: 2px solid var(--c-ink);
  border-radius: 999px;
}

.seg-btn {
  flex: 1 1 0;
  min-height: 44px;
  border-radius: 999px;
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: calc(var(--u) * 5);
  letter-spacing: 0.12em;
}

.seg-btn.is-on {
  background: var(--c-ink);
  color: var(--c-tool-ink);
}

.bubble-area {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: calc(var(--u) * 3);
}

.pane {
  position: relative;
  grid-area: 1 / 1;
  min-height: 0;
}

.pane.is-hidden {
  visibility: hidden;
}

.img-drop {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: 2px solid var(--c-ink);
  border-radius: 3px;
}

.img-preview {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.img-tools {
  position: absolute;
  left: calc(var(--u) * 2.5);
  right: calc(var(--u) * 2.5);
  bottom: calc(var(--u) * 2.5);
  display: flex;
  justify-content: center;
}

.pick-btn {
  flex: 1 1 0;
  min-height: 44px;
  margin: 0 calc(var(--u) * 1.2);
  border-radius: 3px;
  background: var(--c-tool);
  color: var(--c-tool-ink);
  font-family: var(--font-body);
  font-size: calc(var(--u) * 4.8);
  letter-spacing: 0.12em;
}

.round-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: calc(var(--u) * 12);
  height: calc(var(--u) * 12);
  min-width: 44px;
  min-height: 44px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--c-tool);
  color: var(--c-tool-ink);
}

.round-btn.is-on {
  border-color: var(--c-tool-ink);
}

.text-input,
.text-mirror {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: calc(var(--u) * 3);
  border: 2px solid var(--c-ink);
  border-radius: 3px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}

/* the typed text is drawn by the mirror underneath, one colour per character */
.text-input {
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--c-ink);
  resize: none;
  overflow-y: auto;
  scrollbar-width: none;
}

.text-input::-webkit-scrollbar {
  display: none;
}

.text-mirror {
  border-color: transparent;
  color: var(--c-ink);
  overflow: hidden;
  pointer-events: none;
}

.confirm-btn {
  position: absolute;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
}

/* quill page */
.quill-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-popover);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--c-bg);
  background-image: var(--grain);
  background-size: 160px 160px;
  visibility: hidden;
  pointer-events: none;
}

.quill-layer.is-open {
  visibility: visible;
  pointer-events: auto;
}

.paper-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: none;
  cursor: crosshair;
}

.paper-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.pen-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: calc(var(--z-popover) + 1);
  pointer-events: none;
  visibility: hidden;
}

.is-quill .pen-overlay {
  visibility: visible;
}

.quill-bottom {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--u) * 16);
  min-height: 66px;
  padding: 0 calc(var(--u) * 5);
}

.quill-tools {
  display: flex;
}

.quill-tools .round-btn {
  margin: 0 calc(var(--u) * 1.2);
}

.size-dot {
  display: block;
  border-radius: 50%;
  background: var(--c-tool-ink);
}

.drawn-icon {
  display: block;
}

/* shared dialogs */
.modal {
  border: 2px solid var(--c-card-edge);
  background-image: var(--grain);
  background-size: 160px 160px;
  font-family: var(--font-body);
}

.modal-text:empty,
.crop-note:empty {
  display: none;
}

/* short landscape screens shrink the page unit; dialogs keep a readable size from the screen height instead */
@media (orientation: landscape) and (max-height: 520px) {
  .modal-overlay {
    --u: calc(100vh / 100);
    --radius: calc(var(--u) * 2.6);
    --radius-sm: calc(var(--u) * 1.6);
    --border-w: calc(var(--u) * 0.5);
    --text: calc(var(--u) * 4);
    --text-small: calc(var(--u) * 3.4);
    --gap-1: calc(var(--u) * 1);
    --gap-2: calc(var(--u) * 2);
    --gap-3: calc(var(--u) * 3);
  }

  .modal-preview {
    max-height: 45vh;
  }
}

/* dialog cross: drawn in the card edge colour */
.modal-head {
  border-bottom: 0;
}

.modal-close {
  color: var(--c-card-edge);
  background: transparent;
}

.modal-close:active {
  background: var(--c-field-edge);
}

.btn {
  font-family: var(--font-body);
  letter-spacing: 0.08em;
}
