/*
 * paywall.css — jpcite packet paywall (30% preview / 70% paid)
 *
 * Design SOT: site/_design/F2_paywall_ux_2026_05_18.md
 * Surface:    https://jpcite.com/packets/<id>/preview.html
 *
 * Constraints
 * -----------
 * - Pure CSS, no preprocessor.
 * - WCAG 2.1 AA color contrast (text #222 / bg #fff = 16.1:1).
 * - Mobile-first; single @media min-width 720px breakpoint only.
 * - Honors prefers-reduced-motion + prefers-color-scheme.
 * - File budget < 4 KB minified.
 */

/* ---------- 0. Visually-hidden helper for SR text ---------- */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- 1. Verified badge (Ed25519) ---------- */
.jpcite-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #2e7d32;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.jpcite-verified-badge::before {
  content: "\2713"; /* check mark */
  font-weight: 700;
}

/* ---------- 2. Sample cite block ---------- */
.jpcite-sample-cite {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  background: #f9fbff;
  border: 1px solid #c8d8f5;
  border-radius: 6px;
}
.jpcite-sample-cite__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.jpcite-sample-cite__url {
  color: #0050d0;
  word-break: break-all;
  font-size: 0.85rem;
}

/* ---------- 3. The 30% preview zone (always visible) ---------- */
[data-paywall-zone="preview"] {
  /* No special styling; the host packet styles cover layout */
  position: relative;
}

/* ---------- 4. The 70% paid zone — locked state ---------- */
[data-paywall-zone="full"] {
  position: relative;
  min-height: 240px;
}

main[data-paywall-state="locked"] [data-paywall-zone="full"] > .paywall-blur {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  transition: filter 240ms ease;
}

main[data-paywall-state="unlocked"] [data-paywall-zone="full"] > .paywall-blur {
  filter: none;
  pointer-events: auto;
  user-select: auto;
  -webkit-user-select: auto;
}

main[data-paywall-state="unlocked"] .paywall-overlay {
  display: none;
}

/* ---------- 5. Paywall overlay (CTA + trust) ---------- */
.paywall-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 1.5rem);
  max-width: 420px;
  padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  background: #ffffff;
  border: 1px solid #d0d7e2;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  text-align: center;
  z-index: 10;
}

.paywall-overlay__lock {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.paywall-overlay__heading {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a1a1a;
}

.paywall-overlay__price {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #444;
}
.paywall-overlay__price strong {
  color: #1a1a1a;
  font-size: 1.05rem;
}

/* ---------- 6. Pay button (CTA) ---------- */
.paywall-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 56px;
  width: 100%;
  padding: 0 1.2rem;
  background: #000000;
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background 120ms ease;
}
.paywall-cta:hover { background: #1a1a1a; }
.paywall-cta:focus-visible {
  outline: 3px solid #0050d0;
  outline-offset: 2px;
}
.paywall-cta[disabled] {
  background: #888;
  cursor: not-allowed;
}

/* Stripe mounts the Apple Pay native button inside #paywall-pay-mount; */
/* keep the parent button visible only while Stripe.js hasn't mounted. */
.paywall-cta[data-stripe-mounted="true"] > .paywall-cta__label { display: none; }
#paywall-pay-mount { width: 100%; min-height: 56px; }

/* ---------- 7. Trust signals ---------- */
.paywall-trust {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: #555;
  line-height: 1.5;
}
.paywall-trust a {
  color: #0050d0;
  text-decoration: underline;
}
.paywall-trust a:focus-visible {
  outline: 2px solid #0050d0;
  outline-offset: 2px;
}
.paywall-trust__sep {
  margin: 0 0.3rem;
  color: #aaa;
}

/* ---------- 8. Close (x) button ---------- */
.paywall-close {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 1.2rem;
  color: #555;
  cursor: pointer;
  border-radius: 50%;
}
.paywall-close:hover { background: #f0f0f0; }
.paywall-close:focus-visible {
  outline: 2px solid #0050d0;
  outline-offset: 2px;
}

/* ---------- 9. Inline error ---------- */
.paywall-error {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  background: #fde8e8;
  color: #8a1a1a;
  border: 1px solid #f5b5b5;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: left;
}
.paywall-error[hidden] { display: none; }

/* ---------- 10. Live region (SR-only status) ---------- */
.paywall-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- 11. Mobile-first responsive ---------- */
@media (min-width: 720px) {
  .paywall-overlay {
    max-width: 460px;
    padding: 1.75rem 1.5rem;
  }
  .paywall-overlay__heading { font-size: 1.25rem; }
}

/* ---------- 12. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  main[data-paywall-state="locked"] [data-paywall-zone="full"] > .paywall-blur,
  main[data-paywall-state="unlocked"] [data-paywall-zone="full"] > .paywall-blur,
  .paywall-cta {
    transition: none !important;
  }
}

/* ---------- 13. Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  .paywall-overlay {
    background: #1a1a1a;
    border-color: #333;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  }
  .paywall-overlay__heading { color: #f1f1f1; }
  .paywall-overlay__price { color: #d0d0d0; }
  .paywall-overlay__price strong { color: #fff; }
  .paywall-trust { color: #aaa; }
  .paywall-trust a { color: #7ab2ff; }
  .paywall-close { color: #aaa; }
  .paywall-close:hover { background: #2a2a2a; }
  .paywall-cta { background: #ffffff; color: #000000; }
  .paywall-cta:hover { background: #e8e8e8; }
  .jpcite-sample-cite { background: #15202b; border-color: #2a3947; }
  .jpcite-verified-badge { background: #143a18; color: #8fdc92; border-color: #2e7d32; }
}

/* ---------- 14. Print: always unlocked, no overlay ---------- */
@media print {
  main[data-paywall-state] [data-paywall-zone="full"] > .paywall-blur {
    filter: none !important;
  }
  .paywall-overlay { display: none !important; }
}

/* ---------- 15. Ingredient (素材) notice ----------
 * Disclaimer: this packet is an "ingredient" — an AI agent is expected
 * to read it and apply a short finishing step (~500 token, ~¥10) before
 * returning a user-facing answer. The notice is rendered at the top of
 * every preview page (j2 template + generated samples).
 *
 * Marker class .packet-ingredient-notice doubles as an idempotency
 * marker — re-injection scripts MUST skip files that already contain it.
 */
.packet-ingredient-notice {
  margin: 1.5rem 0;
  padding: 0.9rem 1.05rem;
  background: #fff8e1;            /* amber 50 */
  border: 1px solid #f6c343;      /* amber 400 */
  border-left: 4px solid #d18f00; /* amber 700 */
  border-radius: 6px;
  color: #5a4300;
  font-size: 0.93rem;
  line-height: 1.55;
}
.packet-ingredient-notice strong {
  color: #3a2c00;
  font-weight: 700;
}
.packet-ingredient-notice::before {
  content: "\1f9ea";  /* test-tube emoji as "ingredient" icon */
  margin-right: 0.35rem;
  font-size: 1.05rem;
}
.packet-ingredient-notice a {
  color: #0050d0;
  text-decoration: underline;
}
.packet-ingredient-notice a:hover {
  text-decoration: none;
}
@media (max-width: 480px) {
  .packet-ingredient-notice {
    margin: 1rem 0;
    padding: 0.75rem 0.85rem;
    font-size: 0.88rem;
  }
}
@media (prefers-color-scheme: dark) {
  .packet-ingredient-notice {
    background: #2a2410;
    border-color: #8a6a00;
    border-left-color: #ffb74d;
    color: #ffe0a3;
  }
  .packet-ingredient-notice strong { color: #ffeec2; }
  .packet-ingredient-notice a { color: #7ab2ff; }
}
