/* ============================================================
   The Personal Challenge — scrapbook / journal-page aesthetic
   Same navy + pastel world as AI Human Bingo and 3 Commitments: a
   dark backdrop holds a tilted, taped-down paper card. Two text
   contexts to keep straight throughout this file:
     - directly on the navy page (body, header, footer, toast) → light
       text: --paper or --muted
     - on the light paper card (the form itself) → dark text: --ink,
       --accent-ink or --muted-2, and rule lines use --paper-line
   Palette (identical tokens/values to the root stylesheet)
     --ink #3d4a63 (navy, doubles as dark text-on-paper)
     --paper #faf5ea (card stock)      --muted-2 #6b6459 (text-on-paper, secondary)
     --accent #9dbb8a (sage)  --coral #d99aa6 (dusty pink)  --sky #a9c6de (powder)
     --cream #e6d98f  --accent-ink #232c3e (dark text-on-pastel-fill)
   Type: Permanent Marker (handwriting) / Work Sans (body) / IBM Plex Mono (meta)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&family=Work+Sans:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #3d4a63;
  --ink-soft: #4a5872;
  --paper: #faf5ea;
  --paper-dim: #efe7d8;
  --accent: #9dbb8a;
  --accent-deep: #466b3d;
  --accent-ink: #232c3e;
  --coral: #d99aa6;
  --coral-deep: #b06e7a;
  --sky: #a9c6de;
  --cream: #e6d98f;
  --muted: #98a2b8;
  --muted-2: #6b6459;
  --line: rgba(250, 245, 234, 0.14);
  --paper-line: rgba(61, 74, 99, 0.16);
  --shadow: 0 14px 30px -14px rgba(15, 19, 28, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  padding-inline: 16px;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 800px 460px at 12% -8%, rgba(217, 154, 166, 0.12), transparent 60%),
    radial-gradient(ellipse 700px 460px at 100% 4%, rgba(169, 198, 222, 0.12), transparent 55%);
  color: var(--paper);
  font-family: "Work Sans", -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding-bottom: 128px;
}

/* ---------- header ---------- */

.page-header {
  padding-block: 22px 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.back-link {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--sky);
  text-decoration: none;
  margin-bottom: 6px;
}

.back-link:hover { text-decoration: underline; }

.kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--coral);
}

.page-header h1 {
  font-family: "Permanent Marker", cursive;
  font-weight: 400;
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1.1;
  margin: 4px 0 0;
  color: var(--paper);
}

.subline {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 46ch;
}

/* ---------- framing note ---------- */

.framing-note {
  margin: 18px 0 22px;
  background: var(--paper);
  border-radius: 4px 14px 4px 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  transform: rotate(-0.6deg);
}

.framing-note svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--coral-deep);
}

.framing-note p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}

/* ---------- pledge card ---------- */

.pledge-card-wrap {
  position: relative;
  margin-top: 10px;
}

.tape {
  position: absolute;
  width: 84px;
  height: 30px;
  opacity: 0.9;
  box-shadow: 0 2px 5px rgba(15, 19, 28, 0.3);
  z-index: 2;
}

.tape-a {
  top: -14px;
  left: 24px;
  transform: rotate(-7deg);
  background: repeating-linear-gradient(45deg, var(--coral) 0 8px, #e8bbc7 8px 16px);
}

.tape-b {
  top: -12px;
  right: 20px;
  transform: rotate(6deg);
  background: repeating-linear-gradient(45deg, var(--sky) 0 8px, #c3d9ec 8px 16px);
}

.pledge-card {
  position: relative;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 30px 26px 26px;
  transform: rotate(0.4deg);
}

.pledge-card::before,
.pledge-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper-dim);
  border-radius: 6px;
  z-index: -1;
}

.pledge-card::before { transform: rotate(-1.4deg) translateY(3px); }
.pledge-card::after { transform: rotate(1deg) translateY(5px); opacity: 0.8; }

.field-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.field {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.field input {
  font-family: "Permanent Marker", cursive;
  font-size: 19px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px dashed var(--paper-line);
  padding: 4px 2px 6px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}

.field input:focus { border-bottom-color: var(--coral-deep); }
.field input::placeholder { color: var(--muted-2); opacity: 0.6; font-family: "Work Sans", sans-serif; font-size: 15px; }

.doodle-divider {
  color: var(--muted-2);
  opacity: 0.4;
  height: 14px;
  margin: 4px 0 20px;
}

.doodle-divider svg { width: 100%; height: 100%; display: block; }

.prompt-block {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-tag {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tag-color, var(--accent));
  color: var(--accent-ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.prompt-question {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.prompt-question .hint {
  font-weight: 500;
  color: var(--muted-2);
  font-size: 13px;
}

.examples {
  margin: 0;
  font-style: italic;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted-2);
}

.prompt-block textarea {
  font-family: "Work Sans", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: repeating-linear-gradient(var(--paper) 0px, var(--paper) 26px, var(--paper-line) 27px);
  line-height: 27px;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  padding: 2px 10px;
  resize: vertical;
  min-height: 84px;
  outline: none;
  transition: border-color 0.15s ease;
}

.prompt-block textarea:focus { border-color: var(--coral-deep); }
.prompt-block textarea::placeholder { color: var(--muted-2); opacity: 0.7; }

.char-count {
  align-self: flex-end;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  color: var(--muted-2);
}

.revisit-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  margin-top: 4px;
}

.revisit-row input { width: 16px; height: 16px; accent-color: var(--accent-deep); }
.revisit-date { color: var(--muted-2); margin-left: 4px; }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.disclaimer {
  margin: 0;
  max-width: 52ch;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.disclaimer strong { color: var(--paper); font-weight: 700; }

.share-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.share-row { display: flex; align-items: center; gap: 10px; }

.share-label {
  font-family: "Work Sans", sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--paper);
}

.share-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.share-btn svg { width: 17px; height: 17px; }
.share-btn:hover { border-color: var(--coral-deep); color: var(--coral-deep); }
.share-btn:active { transform: scale(0.94); }
.share-btn:disabled { opacity: 0.5; cursor: progress; }

.module-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.module-links-sep { color: var(--muted); }

.module-link {
  font-family: "Work Sans", sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sky);
  text-decoration: none;
}

.module-link:hover { color: var(--paper); text-decoration: underline; }

.credit {
  margin: 0;
  font-family: "Permanent Marker", cursive;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- action bar ---------- */

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, var(--ink) 60%, rgba(61,74,99,0));
}

.action-bar-inner {
  width: 100%;
  max-width: 620px;
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.btn {
  font-family: "Work Sans", sans-serif;
  font-weight: 700;
  font-size: 14px;
  border-radius: 12px;
  border: none;
  padding: 13px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-save {
  flex: 1;
  background: var(--coral);
  color: var(--accent-ink);
  box-shadow: 0 10px 26px -10px rgba(217, 154, 166, 0.55);
}

.btn-save:hover { filter: brightness(1.06); }
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-reset {
  background: var(--paper);
  color: var(--muted-2);
  border: 1px solid var(--paper-line);
  width: 48px;
  flex-shrink: 0;
}

.btn-reset:hover { color: var(--coral-deep); border-color: var(--coral); }

#exportCanvas { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
