/* ------------------------------------------------------------
   Tokens
   paper / ink / stout / stone are the grounds:
   cream, ginger cat, cocoa, butter.
   Pink is the single accent: yes, send, selected.
------------------------------------------------------------ */
:root {
  --cream: #fff3e2;
  --ginger: #ff7a45;
  --cocoa: #2b1d14;
  --butter: #ffd166;
  --accent: #e0457b;

  --display: "Fredoka", "Arial Rounded MT Bold", system-ui, sans-serif;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --pad-x: 24px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

[data-theme="paper"] {
  --bg: var(--cream);
  --fg: var(--cocoa);
  --muted: #8a6f5c;
}
[data-theme="ink"] {
  --bg: var(--ginger);
  --fg: var(--cocoa);
  --muted: #6b3418;
}
[data-theme="stout"] {
  --bg: var(--cocoa);
  --fg: var(--cream);
  --muted: #c9a98f;
}
[data-theme="stone"] {
  --bg: var(--butter);
  --fg: var(--cocoa);
  --muted: #7a5a1e;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--cocoa);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

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

/* ------------------------------------------------------------
   Story shell
------------------------------------------------------------ */
.story {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  transition:
    background-color 0.6s ease,
    color 0.6s ease;
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(var(--safe-t) + 14px) 16px 14px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--bg) 70%,
    color-mix(in srgb, var(--bg) 0%, transparent)
  );
}

.bars {
  display: flex;
  gap: 6px;
}

.bar {
  flex: 1;
  height: 6px;
  border-radius: 6px;
  overflow: hidden;
  background: color-mix(in srgb, var(--fg) 16%, transparent);
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s var(--ease);
}

.meta {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 calc(var(--pad-x) - 16px);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.story.is-locked .bars,
.story.is-locked #counter {
  visibility: hidden;
}

/* ------------------------------------------------------------
   Slides
------------------------------------------------------------ */
.slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: calc(var(--safe-t) + 84px) var(--pad-x) calc(var(--safe-b) + 40px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.35s ease,
    visibility 0s linear 0.35s;
}

.slide.is-active {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.45s ease 0.1s,
    visibility 0s;
}

.slide--bottom {
  justify-content: flex-end;
}

.slide--scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 0;
  -webkit-user-select: text;
  user-select: text;
}

/* Staggered reveal with a little bounce */
.r {
  opacity: 0;

  transform: translateY(20px) scale(0.96);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.slide.is-active .r {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.6s ease,
    transform 0.8s var(--pop);
  transition-delay: calc(var(--d, 0) * 120ms + 150ms);
}

/* ------------------------------------------------------------
   Cat photos: tilted stickers with a white border
------------------------------------------------------------ */
.pic {
  display: flex;
  flex: 0 1 auto;
  min-height: 0;
  margin: 0 0 28px;
}

.pic img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 340px);
  max-height: var(--h, 34svh);
  object-fit: cover;
  border: 6px solid #fff;
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--cocoa);
  transform: rotate(var(--rot, 0deg));
  animation: bob 4s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: rotate(var(--rot, 0deg)) translateY(0);
  }
  50% {
    transform: rotate(calc(var(--rot, 0deg) * 0.9)) translateY(-6px);
  }
}

.pic-pair {
  display: flex;
  align-items: flex-end;
  min-height: 0;
  margin-bottom: 28px;
}

.pic-pair .pic {
  --h: 30svh;
  margin: 0;
}
.pic-pair .pic img {
  max-width: 100%;
}
.pic-pair .pic:first-child {
  width: 55%;
}
.pic-pair .pic:last-child {
  width: 48%;
  margin: 0 0 18px -6%;
}
.pic-pair .pic:last-child img {
  animation-delay: -2s;
}

.pic--small {
  flex-shrink: 0;
  margin-bottom: 18px;
}
.pic--small img {
  --h: 120px;
  max-width: 180px;
}

/* ------------------------------------------------------------
   Type
------------------------------------------------------------ */
.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(3.2rem, 16cqi, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  max-width: 11ch;
  text-wrap: balance;
}

.display--m {
  font-size: clamp(2.3rem, 10.5cqi, 3.6rem);
  line-height: 1;
  max-width: 13ch;
}
.display--s {
  font-size: clamp(2.1rem, 9.5cqi, 3rem);
  line-height: 1.02;
  max-width: 12ch;
}

.lede {
  margin: 20px 0 0;
  max-width: 30ch;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.5;
  color: color-mix(in srgb, var(--fg) 80%, transparent);
  text-wrap: pretty;
}

.lede--tight {
  margin-top: 12px;
}

.hint {
  align-self: flex-end;
  margin: 44px 0 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* .slide.is-active .hint {
  animation: nudge 1.6s ease-in-out 1.4s infinite;
} */

@keyframes nudge {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 6px 0;
  }
}

.sign {
  margin: 40px 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.2;
}

.fine {
  margin: 24px 0 0;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-weight: 600;
}

/* ------------------------------------------------------------
   Buttons: chunky, with a solid drop shadow
------------------------------------------------------------ */
.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 36px;
}

.btn {
  height: 58px;
  padding: 0 34px;
  border: 2.5px solid var(--cocoa);
  border-radius: 999px;
  font: 700 1.125rem/1 var(--display);
  letter-spacing: 0.01em;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 5px 0 var(--cocoa);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    opacity 0.2s ease,
    background-color 0.2s ease;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--cocoa);
}

.btn:focus-visible,
.link-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--ghost {
  background: var(--cream);
  color: var(--cocoa);
}

.btn--wide {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* The runaway No button, once it leaves the layout */
.btn.is-loose {
  position: fixed;
  z-index: 40;
  margin: 0;
  background: var(--cream);
  color: var(--cocoa);
  transition:
    left 0.42s var(--pop),
    top 0.42s var(--pop),
    transform 0.15s ease;
}

.no-placeholder {
  display: inline-block;
}

/* ------------------------------------------------------------
   Choices and date
------------------------------------------------------------ */
#choicesForm,
#whenForm {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

.options {
  margin: 28px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

#optionList {
  display: grid;
  gap: 10px;
}

.opt {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px 14px 20px;
  border: 2.5px solid var(--cocoa);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 var(--cocoa);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.2s var(--pop),
    background-color 0.2s ease,
    box-shadow 0.15s ease;
}

.opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.opt-label {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.1;
  color: var(--cocoa);
}

.opt-note {
  display: block;
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.opt-mark {
  position: relative;
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--cocoa);
  border-radius: 50%;
  background: var(--cream);
  transition: background-color 0.2s ease;
}

.opt-mark::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg) scale(0.4);
  opacity: 0;
  transition:
    transform 0.25s var(--pop),
    opacity 0.15s ease;
}

.opt.is-checked {
  background: var(--butter);
  transform: rotate(-1deg);
}
.opt.is-checked .opt-mark {
  background: var(--accent);
}
.opt.is-checked .opt-mark::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.opt:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.field {
  margin-top: 28px;
}
.field--first {
  margin-top: 32px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
}

.field input,
.field textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2.5px solid var(--cocoa);
  border-radius: 16px;
  background: #fff;
  color: var(--cocoa);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field input {
  font: 600 1.25rem/1.2 var(--display);
}
.field textarea {
  font: 600 1rem/1.5 var(--sans);
  resize: none;
}

.field input::placeholder,
.field textarea::placeholder {
  color: color-mix(in srgb, var(--cocoa) 40%, transparent);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Native date and time pickers: keep the box look on iOS too */
.field input[type="date"],
.field input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 3.4rem;
  text-align: left;
}

.field input::-webkit-date-and-time-value {
  text-align: left;
}

.submit-bar {
  position: sticky;
  bottom: 0;
  margin: auto calc(var(--pad-x) * -1) 0;
  padding: 36px var(--pad-x) calc(var(--safe-b) + 24px);
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg) 0%, transparent),
    var(--bg) 38%
  );
}

.error {
  margin: 0 0 14px;
  font-weight: 700;
  font-size: 0.9375rem;
  line-height: 1.45;
}

/* ------------------------------------------------------------
   Modal: full screen sad kitten
------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  background: var(--butter);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal[hidden] {
  display: none;
}
.modal.is-open {
  opacity: 1;
}

.modal-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 40px) var(--pad-x) calc(var(--safe-b) + 40px);
  color: var(--cocoa);
  transform: translateY(28px) scale(0.97);
  transition: transform 0.5s var(--pop);
}

.modal.is-open .modal-panel {
  transform: none;
}

.modal-panel .pic {
  --h: 44svh;
}

.sad-face {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 3.5rem;
  line-height: 1;
}

.modal-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.75rem;
  line-height: 1;
}

.modal-body {
  margin: 12px 0 0;
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: #7a5a1e;
}

.link-btn {
  margin-top: 28px;
  padding: 0;
  border: 0;
  background: none;
  font: 700 1.0625rem var(--display);
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2.5px;
  text-underline-offset: 5px;
  cursor: pointer;
}

/* ------------------------------------------------------------
   Desktop: full screen, content in a centred column
------------------------------------------------------------ */
@media (min-width: 900px) {
  .chrome,
  .slide {
    padding-left: max(var(--pad-x), calc((100% - 560px) / 2));
    padding-right: max(var(--pad-x), calc((100% - 560px) / 2));
  }

  .slide--bottom {
    justify-content: center;
  }

  .meta {
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    animation: none !important;
  }
}

/* ------------------------------------------------------------
   Final message: big happy cat, everything centred
------------------------------------------------------------ */
.slide--end {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.slide--end .lede,
.slide--end .display { margin-left: auto; margin-right: auto; }

.pic--end { justify-content: center; }
.pic--end img { --h: 46svh; }
