/* "Park a worry" demo: a real Solyenne app screen in a phone, with the app's
 * own fold-and-pin animation. Mounted by /js/worry-park.js on any
 * .worry-park-demo.
 *
 * Inside the phone everything is laid out in the app's own points on a
 * 402 x 874 box (the iPhone screenshot size) that JS scales to the phone
 * width via --wp-s. The screen is a product screenshot of the Forest theme,
 * so its colours are fixed (like Okol); only the text around the phone uses
 * the site theme tokens.
 */

@font-face {
  font-family: Kalam;
  src: url("/site/fonts/kalam-latin.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: ComicNeue;
  src: url("/site/fonts/comicneue-latin.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

.worry-park-demo {
  /* App palette (Evergreen) used for everything drawn over the screenshot. */
  --wp-primary: #5f8e3e;
  --wp-ink: #111a1d;
  --wp-muted: #65747b;
  --wp-lavender: #eae7de;
  --wp-tile: #f2f4e9;
  --wp-paper: #f4e1dd; /* per-note colour, set by JS */
  --wp-paper-margin: rgba(160, 70, 60, 0.45);
  --wp-paper-line: rgba(82, 55, 47, 0.18);
  --wp-paper-hole: #fafaf4;
  --wp-paper-date: #65747b;
  --wp-paper-text: #2a3a4a;
  --wp-paper-accent: #5f8e3e;
  --wp-w: clamp(240px, 78vw, 300px); /* phone screen width */
  --wp-bezel: calc(var(--wp-w) * 0.04);
  --wp-s: 0.7463; /* screen width / 402, set by JS */
  display: block;
  /* Reserved so the lazily mounted phone never shifts the page. */
  min-height: calc(var(--wp-w) * 2.2541 + 168px);
  font-family: Manrope, system-ui, sans-serif;
  color: var(--ink);
}

.worry-park-demo *,
.worry-park-demo *::before,
.worry-park-demo *::after {
  box-sizing: border-box;
}

.wp-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* ---------- phone ---------- */

.wp-phone {
  position: relative;
  width: calc(var(--wp-w) + 2 * var(--wp-bezel));
  padding: var(--wp-bezel);
  border-radius: calc(var(--wp-w) * 0.14 + var(--wp-bezel));
  background: #1b1d1f;
  box-shadow: 0 0 0 1.5px #3a3d40 inset, 0 30px 60px rgba(25, 40, 29, 0.22);
}

.wp-phone::before,
.wp-phone::after { /* side buttons */
  content: "";
  position: absolute;
  right: -3px;
  width: 3px;
  border-radius: 2px;
  background: #2a2c2e;
}

.wp-phone::before { top: 22%; height: 9%; }
.wp-phone::after { top: 34%; height: 14%; }

.wp-screen {
  position: relative;
  width: var(--wp-w);
  aspect-ratio: 402 / 874;
  overflow: hidden;
  border-radius: calc(var(--wp-w) * 0.14);
  background: #fafaf6;
  isolation: isolate;
}

.wp-device {
  position: absolute;
  left: 0;
  top: 0;
  width: 402px;
  height: 874px;
  transform: scale(var(--wp-s));
  transform-origin: 0 0;
  font-family: ComicNeue, "Comic Sans MS", system-ui, sans-serif;
  font-weight: 400;
  color: var(--wp-ink);
}

.wp-device img {
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

.wp-layer {
  position: absolute;
  inset: 0;
}

.wp-home-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 402px;
  height: 874px;
}

/* The "Park a worry" button: a real button over the screenshot's button. */
.wp-fab {
  position: absolute;
  left: 235px;
  top: 715px;
  width: 151px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
}

.wp-fab::after { /* a gentle hint until the first tap */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  box-shadow: 0 0 0 0 rgba(95, 142, 62, 0.45);
  pointer-events: none;
}

.wp-fab[data-hint]::after {
  animation: wp-hint 2.4s ease-out infinite;
}

@keyframes wp-hint {
  0% { box-shadow: 0 0 0 0 rgba(95, 142, 62, 0.45); }
  70%, 100% { box-shadow: 0 0 0 12px rgba(95, 142, 62, 0); }
}

/* ---------- Home worries tile (drawn over the screenshot's tile) ---------- */

.wp-tile {
  position: absolute;
  left: 35px;
  top: 267.5px;
  width: 332px;
  height: 74px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 18px;
  background: var(--wp-tile);
  will-change: transform;
}

.wp-board {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 2.5px solid var(--wp-lavender);
  border-radius: 7px;
  background: linear-gradient(135deg, #fffcf7 0, #fffcf7 55%, #f8f5ee 100%);
  box-shadow: 0 1px 2px rgba(17, 26, 29, 0.06);
}

.wp-board::before { /* recessed top edge */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  border-radius: 4.5px 4.5px 0 0;
  background: linear-gradient(rgba(17, 26, 29, 0.06), rgba(17, 26, 29, 0));
}

.wp-board::after { /* faint marker stroke */
  content: "";
  position: absolute;
  left: 6px;
  right: 10px;
  bottom: 6px;
  height: 2px;
  border-radius: 1px;
  background: rgba(95, 142, 62, 0.12);
  transform: rotate(-4deg);
}

.wp-pinned {
  position: absolute;
  width: 13px;
  height: 15px;
  border-radius: 2px;
  background: var(--note);
  box-shadow: 0 1px 2px rgba(17, 26, 29, 0.16);
  transform: rotate(var(--rot, 0deg));
}

.wp-pinned::after { /* the pin */
  content: "";
  position: absolute;
  left: 4px;
  top: -2.5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--wp-primary);
  box-shadow: 0 1px 1px rgba(17, 26, 29, 0.3);
}

.wp-pinned[data-landing] {
  animation: wp-note-in 0.3s ease both;
}

@keyframes wp-note-in {
  from { opacity: 0; transform: translateY(4px) rotate(var(--rot, 0deg)); }
  to { opacity: 1; transform: translateY(0) rotate(var(--rot, 0deg)); }
}

.wp-tile-text {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.wp-tile-title {
  display: block;
  height: 18.2px;
  font-size: 14px;
  line-height: 18.2px;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-roll {
  position: relative;
  display: inline-block;
  height: 18.2px;
  overflow: hidden;
  vertical-align: top;
}

.wp-roll > span { display: block; }
.wp-roll .wp-roll-old { position: absolute; left: 0; top: 0; }

.wp-tile-sub {
  position: relative;
  display: block;
  margin-top: 1px;
  height: 16.74px;
  font-size: 13.5px;
  line-height: 16.74px;
  color: var(--wp-muted);
  white-space: nowrap;
}

.wp-tile-sub > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-sub-latest {
  position: absolute;
  inset: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--wp-primary);
  opacity: 0;
}

.wp-tile-view {
  flex: 0 0 auto;
  min-width: 44px;
  margin-left: -4px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 44px;
  text-align: center;
  color: var(--wp-primary);
}

/* ---------- Park it sheet ---------- */

.wp-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.54);
  opacity: 0;
  visibility: hidden;
}

.wp-sheet {
  position: absolute;
  left: 0;
  top: 475px;
  width: 402px;
  height: 399px;
  visibility: hidden;
  transform: translateY(100%);
}

.wp-sheet-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 402px;
  height: 399px;
}

.wp-text-input {
  position: absolute;
  left: 38px;
  top: 89px; /* sheet-relative: 475 + 89 = 564 */
  width: 296px;
  height: 120px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  resize: none;
  background: transparent;
  color: var(--wp-ink);
  font: 400 17px/22.1px ComicNeue, "Comic Sans MS", system-ui, sans-serif;
  letter-spacing: 0.1px;
  caret-color: var(--wp-primary);
}

.wp-text-input::placeholder {
  color: var(--wp-muted);
}

.wp-text-input:focus {
  outline: none;
}

.wp-text-input:focus-visible {
  outline: 2px solid rgba(95, 142, 62, 0.55);
  outline-offset: 6px;
}

.wp-park {
  position: absolute;
  left: 16.67px;
  top: 297.7px; /* 772.7 - 475 */
  width: 368.3px;
  height: 50.7px;
  padding: 0;
  border: 0;
  border-radius: 25px;
  background: transparent;
  cursor: pointer;
}

.wp-park img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.wp-park .wp-on { opacity: 0; }
.wp-park[data-ready] .wp-on { opacity: 1; }
.wp-park[data-ready] .wp-off { opacity: 0; }

.wp-park:focus-visible,
.wp-fab:focus-visible {
  outline: 3px solid rgba(95, 142, 62, 0.7);
  outline-offset: 3px;
}

.wp-error {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 262px;
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
  color: #8c3b2e;
  text-align: center;
}

/* ---------- animation layer (covers the phone screen only) ---------- */

.wp-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

.wp-stage[data-active] {
  visibility: visible;
  pointer-events: auto; /* swallows taps while the sequence runs */
}

.wp-dim {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(250, 250, 244, 0.85);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* The wrappers share one box: the left half of the sheet (the folded note),
 * so every transform pivots on the note's centre. */
.wp-fly {
  position: absolute;
  left: 81px; /* (402 - 390) / 2 + 75 */
  top: 277px; /* (874 - 780) / 2 + 230 */
  width: 120px;
  height: 150px;
  opacity: 0;
}

.wp-fly[data-on] { opacity: 1; }

.wp-in,
.wp-x,
.wp-y,
.wp-sr {
  position: absolute;
  inset: 0;
  will-change: transform, opacity;
}

.wp-sheet-scale {
  position: absolute;
  left: 0;
  top: 0;
  width: 240px;
  height: 300px;
}

/* ---------- notebook paper (ported from the app's NotebookPaper) ---------- */

.wp-half {
  position: absolute;
  overflow: hidden;
  border-radius: 3px;
  background: var(--wp-paper);
  box-shadow: 0 14px 34px rgba(17, 26, 29, 0.14);
}

.wp-paper {
  position: absolute;
  left: 0;
  top: 0;
  width: 240px;
  height: 300px;
  font-family: Kalam, "Comic Sans MS", cursive;
  font-weight: 400;
  background: var(--wp-paper);
}

.wp-paper::before { /* ruled lines every 26px, first at y = 39 */
  content: "";
  position: absolute;
  inset: 14px 0 0;
  background: repeating-linear-gradient(to bottom, transparent 0 25px, var(--wp-paper-line) 25px 26px);
}

.wp-paper::after { /* margin line */
  content: "";
  position: absolute;
  left: 34px;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--wp-paper-margin);
}

.wp-hole {
  position: absolute;
  left: 11px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(17, 26, 29, 0.22), rgba(17, 26, 29, 0) 55%), var(--wp-paper-hole);
}

.wp-text {
  position: absolute;
  left: 46px;
  margin: 0;
  line-height: 26px;
  white-space: nowrap;
}

.wp-date { top: 12px; font-size: 14px; color: var(--wp-paper-date); }
.wp-opens { top: 246px; font-size: 14px; color: var(--wp-paper-accent); }

.wp-worry {
  top: 64px;
  right: 16px;
  font-size: 21px;
  color: var(--wp-paper-text);
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 7;
  line-clamp: 7;
  overflow: hidden;
}

.wp-flap {
  position: absolute;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.wp-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3px;
  background: var(--wp-paper);
  box-shadow: 0 14px 34px rgba(17, 26, 29, 0.14);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.wp-flap-1 {
  left: 0;
  top: 150px;
  width: 240px;
  height: 150px;
  transform-origin: 50% 0;
}

.wp-flap-2 {
  left: 120px;
  top: 0;
  width: 120px;
  height: 150px;
  transform-origin: 0 50%;
}

.wp-flap-1 .wp-back { transform: rotateX(180deg); }
.wp-flap-2 .wp-back { transform: rotateY(180deg); }

.wp-crop,
.wp-flip-y,
.wp-flip-x {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.wp-flip-y { transform: scaleY(-1); }
.wp-flip-x { transform: scaleX(-1); }

.wp-piecebox {
  position: absolute;
  left: 0;
  top: 0;
  width: 240px;
  height: 150px;
  overflow: hidden;
}

.wp-at-bottom { top: -150px; }
.wp-piecebox.wp-at-right { left: -120px; }

.wp-piece-2 { position: absolute; left: 0; top: 0; width: 240px; height: 150px; display: none; }
.wp-piece-2[data-on] { display: block; }
.wp-first[data-off] { display: none; }

/* ---------- controls under the phone ---------- */

.wp-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 150px;
  max-width: 340px;
  text-align: center;
}

.wp-caption {
  margin: 0;
  min-height: 3em;
  font: 600 15px/1.5 Manrope, sans-serif;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.3s;
}

.wp-caption[data-show] { opacity: 1; }

.wp-sound {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: 600 14px Manrope, sans-serif;
  cursor: pointer;
}

.wp-sound svg { width: 20px; height: 20px; flex: 0 0 auto; }

.wp-sound[aria-pressed="true"] {
  background: var(--soft);
  color: var(--primary);
}

.wp-sound .wp-icon-on,
.wp-sound[aria-pressed="true"] .wp-icon-off { display: none; }
.wp-sound[aria-pressed="true"] .wp-icon-on { display: block; }

.wp-sound:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 3px;
}

.wp-note {
  margin: 0;
  font: 400 13px/1.5 Manrope, sans-serif;
  color: var(--muted);
}

.wp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- reduced motion: no slide, folds or flight ---------- */

@media (prefers-reduced-motion: reduce) {
  .wp-fab[data-hint]::after { animation: none; }
  .wp-caption { transition: none; }
  .wp-pinned[data-landing] { animation: wp-fade 0.3s ease both; }
}

@keyframes wp-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
