/* Quest Book and Settings. Book classes use bk-, settings classes use st-. Tokens only. */

/* ---------- Quest Book: a battered field journal ---------- */

.bk-book {
  padding: 20px 14px 40px;
}

.bk-heading,
.st-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--tomato);
}

.bk-sample-note {
  margin-top: 14px;
  padding: 10px 12px;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--radius-card);
  font-family: var(--font-card);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--ink);
}

.bk-page {
  position: relative;
  margin-top: 30px;
  padding: 26px 16px 34px;
  background-color: var(--card-paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
  color: var(--card-ink);
  /* Dog-eared, knocked-about page edge */
  clip-path: polygon(0 4px, 3% 0, 41% 3px, 72% 0, 100% 5px, 99.4% 38%, 100% 71%, 99% 100%, 64% calc(100% - 4px), 37% 100%, 8% calc(100% - 3px), 0 calc(100% - 9px), 0.7% 52%);
}

.bk-page:nth-of-type(even) {
  transform: rotate(0.5deg);
}

.bk-page:nth-of-type(odd) {
  transform: rotate(-0.4deg);
}

.bk-month {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.25rem;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--card-ink);
  text-shadow: 2px 2px 0 var(--marigold);
}

.bk-page-sample .bk-month {
  border-bottom-style: dashed;
}

.bk-stamp {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  grid-template-areas: "ink words";
  gap: 14px;
  align-items: center;
  margin-top: 20px;
}

.bk-stamp:nth-child(even) {
  grid-template-columns: minmax(0, 1fr) 96px;
  grid-template-areas: "words ink";
}

.bk-ink {
  grid-area: ink;
  width: 96px;
  height: 96px;
  color: var(--tomato);
  opacity: 0.86;
  mix-blend-mode: multiply;
  transform: translateX(var(--bk-nudge, 0)) rotate(var(--bk-tilt, 0deg));
}

.bk-ink svg {
  width: 100%;
  height: 100%;
}

.bk-words {
  grid-area: words;
  min-width: 0;
}

.bk-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bk-text {
  margin-top: 4px;
  font-family: var(--font-card);
  font-size: 0.98rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.bk-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-family: var(--font-card);
  font-size: 0.85rem;
}

.bk-remove {
  margin-left: auto;
  padding: 0 4px;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bk-sample-tag {
  padding: 1px 6px;
  border: 1.5px solid var(--card-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-3deg);
}

/* ---------- Settings: one calm scrolling page ---------- */

.st-page {
  padding: 20px 16px 40px;
}

.st-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 2px solid var(--surface);
}

.st-heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
}

.st-label {
  display: block;
  font-size: 1rem;
  color: var(--ink-soft);
}

/* 16px or larger stops iOS zooming the page when a field takes focus. */
.st-input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid var(--ink-soft);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-card);
  font-size: 1.05rem;
}

.st-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.st-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.st-chip {
  flex: 1 1 auto;
  min-height: 52px;
  padding: 8px 14px;
  border: 2px solid var(--ink-soft);
  border-radius: var(--radius-card);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
}

.st-chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  box-shadow: 2px 2px 0 var(--tomato);
}

.st-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 60px;
  padding: 8px 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.02rem;
  text-align: left;
}

.st-toggle-state {
  min-width: 56px;
  padding: 6px 10px;
  border: 2px solid var(--ink-soft);
  border-radius: var(--radius-card);
  text-align: center;
  color: var(--ink-soft);
}

.st-toggle[aria-checked="true"] .st-toggle-state {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.st-action {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: var(--tap-big);
  padding: 10px 16px;
  border-radius: var(--radius-card);
  background: var(--card-paper);
  color: var(--card-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 3px 3px 0 var(--tomato);
  cursor: pointer;
}

.st-action:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--tomato);
}

.st-file-label {
  position: relative;
}

/* Kept focusable rather than display:none so the picker still works from a keyboard. */
.st-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.st-file-label:focus-within,
.st-chip:focus-visible,
.st-toggle:focus-visible,
.st-action:focus-visible,
.st-delete:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 2px;
}

.st-note,
.st-result {
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.st-result {
  color: var(--ink);
}

.st-result:empty,
.st-error:empty {
  display: none;
}

.st-error {
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--ink);
  border-left: 4px solid var(--tomato);
  padding-left: 10px;
}

.st-quests {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.st-quests:empty {
  display: none;
}

.st-quest {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-card);
  background: var(--surface);
}

.st-quest-words {
  flex: 1 1 auto;
  min-width: 0;
}

.st-quest-text {
  font-family: var(--font-card);
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.st-delete {
  flex: 0 0 auto;
  min-height: var(--tap-min);
  padding: 6px 12px;
  border: 2px solid var(--ink-soft);
  border-radius: var(--radius-card);
  font-weight: 700;
  color: var(--ink);
}

.st-copy {
  display: block;
  width: 100%;
  padding: 10px;
  border: 2px solid var(--ink-soft);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-card);
  font-size: 1rem;
  resize: vertical;
}
