/* ============================================================
 * Motion: page transitions, stamp bounce, save animation, tour modal
 * All CSS-only (no JS animation libraries).
 * ============================================================ */

/* ---- page fade ------------------------------------------------ */
#app {
  transition: opacity 220ms var(--motion-ease-out);
}
#app.fading-out { opacity: 0; }

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen, .calendar-screen, .auth-wrap, .home-screen {
  animation: page-fade-in 260ms var(--motion-ease-out) both;
}

/* ---- stamp interactions ------------------------------------- */
@keyframes stamp-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}
.notebook .stamp-item.just-picked .stamp-img-wrap {
  animation: stamp-bounce 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- toast ---------------------------------------------------- */
@keyframes toast-pop {
  0%   { opacity: 0; transform: translate(-50%, -24px) scale(0.95); }
  15%  { opacity: 1; transform: translate(-50%, 0) scale(1.02); }
  30%  { transform: translate(-50%, 0) scale(1); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 1000;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toast-pop 2500ms forwards;
  white-space: nowrap;
}
.toast.success {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--ui-button-text, #fff);
}
.toast.error { background: #b84a4a; }

/* ---- save ripple on button ----------------------------------- */
@keyframes save-ripple {
  0%   { box-shadow: 0 0 0 0 var(--primary), 0 4px 12px rgba(0,0,0,0.1); }
  70%  { box-shadow: 0 0 0 20px rgba(248,200,212,0), 0 4px 12px rgba(0,0,0,0.1); }
  100% { box-shadow: 0 0 0 0 rgba(248,200,212,0), 0 4px 12px rgba(0,0,0,0.1); }
}
.notebook-save button.saved {
  animation: save-ripple 600ms ease-out;
}

/* ---- tour overlay -------------------------------------------- */
.tour-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  transition: opacity 260ms var(--motion-ease-out);
}
.tour-overlay-visible { opacity: 1; }
.tour-card {
  background: var(--ui-card-bg, #fff);
  border-radius: 24px;
  padding: 36px 28px 24px;
  max-width: 420px; width: 100%;
  max-height: calc(100vh - 48px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  text-align: center;
  position: relative;
  animation: tour-rise 320ms var(--motion-ease-out) both;
  display: flex; flex-direction: column;
  overflow: hidden;
}
/* Expanded slides (with full sample content) use an internal scroll region
   plus a sticky chrome footer (dots + buttons) always visible at the bottom. */
.tour-scroll-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 16px;
  margin-right: -4px;
  margin-left: -4px;
  padding-left: 4px;
}
.tour-sticky-chrome {
  flex: 0 0 auto;
  padding-top: 14px;
  border-top: 1px solid color-mix(in srgb, var(--text-muted) 15%, transparent);
  background: linear-gradient(transparent, var(--ui-card-bg, #fff) 20%);
  margin: 0 -4px;
  padding-left: 4px; padding-right: 4px;
}
.tour-sticky-chrome .tour-dots { margin-bottom: 14px; }
.tour-sticky-chrome .tour-actions { margin-bottom: 0; }
@keyframes tour-rise {
  from { transform: translateY(24px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.tour-skip {
  position: absolute; top: 16px; right: 16px;
  background: transparent; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}
.tour-skip:hover { background: var(--bg-soft); }
.tour-emoji {
  font-size: 56px;
  margin-bottom: 16px;
  animation: bob 2.4s ease-in-out infinite;
}
.tour-illust {
  margin: 0 auto 16px;
  max-width: 240px;
  animation: bob 3s ease-in-out infinite;
}
.tour-illust img {
  width: 100%; height: auto;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.10));
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.tour-title {
  margin: 0 0 12px;
  font-family: var(--typography-family-display, var(--typography-family-ja));
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.tour-body {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.8;
}
.tour-dots {
  display: flex; justify-content: center; gap: 8px;
  margin-bottom: 22px;
}
.tour-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ui-border, #ddd);
  transition: all 200ms;
}
.tour-dot.active {
  width: 24px;
  background: var(--primary);
  border-radius: 4px;
}
.tour-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.tour-prev {
  background: transparent; border: none;
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}
.tour-prev:hover { background: var(--bg-soft); color: var(--text); }
.tour-next {
  background: var(--primary);
  color: var(--ui-button-text, #fff);
  border: none;
  padding: 12px 32px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: transform 160ms;
}
.tour-next:hover { transform: translateY(-1px); }
.tour-next:active { transform: scale(0.97); }

/* ---- tour sample mockups -------------------------------------- */
.tour-sample {
  margin: 4px auto 20px;
  padding: 18px 18px 16px;
  background: color-mix(in srgb, var(--primary) 8%, var(--ui-card-bg, #fff));
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  max-width: 320px;
  text-align: center;
}
.tour-sample-eyebrow {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tour-sample-phrase {
  font-family: 'Klee One', cursive;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 14px;
}
.tour-sample-phrase-sm { font-size: 18px; margin-bottom: 8px; }
.tour-sample-strip {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 4px;
  margin-bottom: 14px;
}
.tour-sample-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.tour-sample-insight {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--ui-card-bg, #fff);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  text-align: left;
}
.tour-sample-bullet {
  color: var(--primary);
  flex: 0 0 auto;
  font-weight: 600;
}

/* naming sample */
.tour-sample-arrow {
  font-size: 20px;
  color: var(--primary);
  margin: 2px 0 6px;
  opacity: 0.7;
}
.tour-sample-name-card {
  background: var(--ui-card-bg, #fff);
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
.tour-sample-name-eyebrow {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.tour-sample-name {
  font-family: 'Klee One', cursive;
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.25;
}

/* ---- full analysis demo (tour slide 5) ------------------------ */
.tour-demo {
  text-align: left;
  margin-top: 8px;
}
.tour-demo-hero {
  padding: 18px 16px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 14%, var(--ui-card-bg, #fff)),
    color-mix(in srgb, var(--primary) 6%, var(--ui-card-bg, #fff)));
  border-radius: 16px;
  margin-bottom: 18px;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
.tour-demo-hero-eyebrow {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tour-demo-hero-name {
  font-family: 'Klee One', cursive;
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
  margin-bottom: 12px;
}
.tour-demo-hero-ainote {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--ui-card-bg, #fff);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  margin-bottom: 10px;
}
.tour-demo-hero-ainote-label { color: var(--text-muted); }
.tour-demo-hero-ainote-value { color: var(--text); font-weight: 600; }
.tour-demo-hero-intro {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.tour-demo-section-title {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 18px 0 10px;
  padding-left: 2px;
}

.tour-demo-insights { display: flex; flex-direction: column; gap: 10px; }
.tour-demo-insight-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--ui-card-bg, #fff);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--text-muted) 12%, transparent);
}
.tour-demo-insight-icon {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
}
.tour-demo-insight-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.tour-demo-insight-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.tour-demo-obs-card {
  padding: 12px 14px;
  background: color-mix(in srgb, var(--primary) 6%, var(--ui-card-bg, #fff));
  border-radius: 12px;
  border-left: 3px solid color-mix(in srgb, var(--primary) 40%, transparent);
  margin-bottom: 8px;
}
.tour-demo-obs-quote {
  font-size: 13px;
  color: var(--text);
  font-style: italic;
  margin-bottom: 4px;
}
.tour-demo-obs-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.tour-demo-strip {
  display: flex; flex-wrap: wrap; justify-content: flex-start;
  gap: 4px;
  padding: 10px 12px;
  background: var(--ui-card-bg, #fff);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--text-muted) 10%, transparent);
}
.tour-demo-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
}

.tour-demo-heart {
  padding: 12px 14px;
  background: var(--ui-card-bg, #fff);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--text-muted) 10%, transparent);
  display: flex; flex-direction: column; gap: 8px;
}
.tour-demo-heart-row {
  display: grid;
  grid-template-columns: 14px 70px 1fr 32px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.tour-demo-heart-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  justify-self: center;
}
.tour-demo-heart-label { color: var(--text); }
.tour-demo-heart-bar {
  display: block;
  height: 8px;
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  border-radius: 999px;
  overflow: hidden;
}
.tour-demo-heart-bar > span {
  display: block; height: 100%;
  border-radius: 999px;
}
.tour-demo-heart-pct {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.tour-demo-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}
.tour-demo-stats > div {
  padding: 10px 4px;
  background: var(--ui-card-bg, #fff);
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--text-muted) 10%, transparent);
  text-align: center;
}
.tour-demo-stat-num {
  font-family: 'Klee One', cursive;
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.1;
}
.tour-demo-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tour-demo-footer {
  margin-top: 20px;
  padding: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px dashed color-mix(in srgb, var(--text-muted) 20%, transparent);
}

/* ---- post-tour theme picker --------------------------------- */
/* Small phones don't have room for nested scroll inside a height-capped
   modal. We instead let the whole overlay scroll vertically, and keep the
   primary CTA as a sticky footer at the bottom of the card. */
.themepick-overlay {
  padding: 20px 16px;
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.themepick-card-wrap {
  background: var(--ui-card-bg, #fff);
  border-radius: 24px;
  padding: 28px 20px 0;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: tour-rise 320ms var(--motion-ease-out) both;
}
.themepick-title {
  margin: 0 0 6px;
  font-family: var(--typography-family-display, var(--typography-family-ja));
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.themepick-sub {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
}
.themepick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
  padding: 2px;
  /* No nested scroll, no flex:1 — grid lives inside a naturally-growing
     card which the outer overlay scrolls. This sidesteps the flex+aspect-
     ratio interaction bug that was squishing cards on small phones. */
}
.themepick-card {
  position: relative;
  width: 100%;
  /* Battle-tested aspect-ratio technique: zero height + padding-bottom
     expressed as a % of the width. 5/4 × 100% = 125%. This works in every
     browser including old WebKit where `aspect-ratio` on a grid item inside
     a scrollable flex column can render incorrectly. */
  height: 0;
  padding-bottom: 125%;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 160ms, border-color 160ms, box-shadow 160ms;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  box-sizing: border-box;
}
/* Gentle pulsing placeholder while the portrait image loads. The card's
   inline background color (theme palette) acts as the tint, so there's
   always something pleasant on screen before the image arrives. */
.themepick-card::before {
  content: "";
  position: absolute; inset: 0;
  background: inherit;
  animation: themepick-pulse 1.4s ease-in-out infinite;
  z-index: 0;
}
.themepick-card.img-loaded::before { display: none; }
@keyframes themepick-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1.0; }
}
.themepick-card > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0;
  transition: opacity 240ms ease-out;
  z-index: 1;
}
.themepick-card.img-loaded > img { opacity: 1; }
.themepick-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,0.12); }
.themepick-card.selected {
  border-color: var(--primary);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 35%, transparent);
}
.themepick-card.locked { opacity: 0.55; cursor: not-allowed; }
.themepick-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 10px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.02em;
  z-index: 2;
}
.themepick-lock {
  position: absolute; top: 8px; right: 8px;
  font-size: 14px;
}
.themepick-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  padding: 14px 0 20px;
  margin: 0 -20px 0;
  padding-left: 20px; padding-right: 20px;
  border-top: 1px solid color-mix(in srgb, var(--text-muted) 15%, transparent);
  position: sticky;
  bottom: 0;
  background: var(--ui-card-bg, #fff);
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  z-index: 5;
}
.themepick-skip {
  background: transparent; border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}
.themepick-skip:hover { background: var(--bg-soft); color: var(--text); }
.themepick-cta {
  background: var(--primary);
  color: var(--ui-button-text, #fff);
  border: none;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: transform 160ms;
}
.themepick-cta:hover:not(:disabled) { transform: translateY(-1px); }
.themepick-cta:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- tour pricing-info card (final slide) ---- */
.tour-pricing {
  margin: 4px auto 8px;
  max-width: 320px;
  text-align: center;
}
.tour-pricing-trial {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 18%, var(--ui-card-bg, #fff)),
    color-mix(in srgb, var(--primary) 8%, var(--ui-card-bg, #fff)));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.tour-pricing-trial-label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tour-pricing-trial-value {
  font-family: 'Klee One', cursive;
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 4px;
}
.tour-pricing-trial-note {
  font-size: 11px;
  color: var(--text-muted);
}

.tour-pricing-divider {
  position: relative;
  text-align: center;
  margin: 14px 0 12px;
}
.tour-pricing-divider::before {
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: color-mix(in srgb, var(--text-muted) 18%, transparent);
}
.tour-pricing-divider span {
  position: relative;
  display: inline-block;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--ui-card-bg, #fff);
  letter-spacing: 0.04em;
}

.tour-pricing-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.tour-pricing-plan {
  position: relative;
  padding: 14px 10px 12px;
  background: var(--ui-card-bg, #fff);
  border: 1px solid color-mix(in srgb, var(--text-muted) 14%, transparent);
  border-radius: 12px;
}
.tour-pricing-plan-featured {
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 20%, transparent);
}
.tour-pricing-plan-badge {
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: var(--ui-button-text, #fff);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tour-pricing-plan-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tour-pricing-plan-price {
  font-family: 'Klee One', cursive;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.tour-pricing-yen {
  font-size: 14px;
  margin-right: 1px;
}
.tour-pricing-per {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 2px;
  font-family: var(--typography-family-ja);
  font-weight: 400;
}
.tour-pricing-plan-monthly {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.tour-pricing-bullets {
  list-style: none;
  padding: 12px 14px;
  margin: 0;
  background: color-mix(in srgb, var(--text-muted) 5%, var(--ui-card-bg, #fff));
  border-radius: 10px;
  text-align: left;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
}
.tour-pricing-bullets li {
  position: relative;
  padding-left: 16px;
}
.tour-pricing-bullets li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 600;
}
