// ─── Legal pages (Privacy Policy + Terms) ───────────────────────────────────
// Rendered as a full-screen reading overlay, in the template's own type system
// (Instrument Serif headings + Inter body, warm-neutral palette).
//
// This is a TEMPLATE: the website owner who buys it swaps in their own details.
// Edit the three values below once and both pages update everywhere.
const LEGAL_BRAND        = 'Yoga with Tara';
const LEGAL_EMAIL        = 'hello@yogawithtara.com';
const LEGAL_UPDATED      = 'May 2026';
const LEGAL_JURISDICTION = '[Your Country / Province / State]';

// ── Content ──────────────────────────────────────────────────────────────────
// Plain prose, adapted for a creator selling digital products and collecting
// emails from their customers — same simple tone as a standard policy.
const PRIVACY_SECTIONS = [
  {
    h: 'Overview',
    p: [
      `It is ${LEGAL_BRAND}'s policy to respect your privacy regarding any information we may collect while you use this website. This Privacy Policy explains what information we collect, how we use it, how long we keep it, and the limited circumstances in which we may share it.`,
      `It applies only to information collected through this site and forms part of our Terms & Conditions.`,
    ],
  },
  {
    h: '1. Information We Collect',
    p: [
      `Like most websites, we collect non-personal information that your browser makes available automatically, such as browser type, device, referring page, and the date and time of your visit. We use this only to understand how visitors use the site, with the help of analytics tools such as [e.g. Google Analytics — name your analytics provider].`,
      `We collect personal information only when you choose to give it to us — for example, your email address when you subscribe, and the details needed to complete a purchase. We ask for the minimum necessary for each interaction.`,
    ],
  },
  {
    h: '2. Email & Subscriptions',
    p: [
      `When you submit your email address through one of our forms, we use it to send you the content, products, or updates you signed up for. We manage our email through [e.g. Mailchimp, ConvertKit — name your email provider]. You can unsubscribe at any time using the link in any email, and we will stop sending you messages.`,
      `We never sell your email address or share it with third parties for their own marketing.`,
    ],
  },
  {
    h: '3. Payments & E-commerce',
    p: [
      `When you buy a product, payment is processed by our secure third-party payment provider, [e.g. Stripe, PayPal — name your payment provider]. Your full card details are entered directly with that provider and are never stored on our servers — we only receive confirmation that a payment succeeded along with the information needed to deliver your purchase.`,
    ],
  },
  {
    h: '4. Cookies',
    p: [
      `We use cookies and similar technologies to remember your preferences and understand how the site is used. A cookie is a small piece of information stored by your browser.`,
      `Essential cookies are needed for the site to function. For non-essential cookies — such as analytics and marketing — we ask for your consent through a cookie banner when you first visit, and you can change or withdraw that consent at any time through [your cookie settings / banner link]. You can also set your browser to refuse cookies, though some features of the site may not work properly without them.`,
    ],
  },
  {
    h: '5. How We Share Information',
    p: [
      `We do not sell your personal information. We share it only with the service providers who help us run the site — such as our email, payment, and analytics providers — and only to the extent they need it to perform their service. We may also disclose information if required by law.`,
    ],
  },
  {
    h: '6. International Data Transfers',
    p: [
      `Some of our service providers may store or process data in countries outside your own. Where this happens, we take reasonable steps to ensure your information is handled in line with this policy and protected by appropriate safeguards.`,
    ],
  },
  {
    h: '7. Data Retention',
    p: [
      `We keep your personal information only as long as needed for the purposes described in this policy. For example, we retain your email address for as long as you remain subscribed, and purchase records for [e.g. as long as required for tax and accounting purposes]. When information is no longer needed, we delete it or anonymize it.`,
    ],
  },
  {
    h: '8. Security',
    p: [
      `The security of your personal information is important to us, but no method of transmission over the Internet or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your personal information, we cannot guarantee its absolute security.`,
    ],
  },
  {
    h: '9. Your Rights & Choices',
    p: [
      `You can unsubscribe from emails at any time, and you may contact us to ask what personal information we hold about you, or to request that we correct or delete it. You can always decline to provide information, though this may limit what you can do on the site.`,
      `Depending on where you live, you may have additional rights under laws such as the GDPR (EU/UK), the CCPA/CPRA (California), or PIPEDA (Canada) — including the right to access, correct, delete, or port your data, and to object to certain uses. To exercise any of these rights, contact us at ${LEGAL_EMAIL}.`,
    ],
  },
  {
    h: '10. Children\u2019s Privacy',
    p: [
      `This site is not directed at children, and we do not knowingly collect personal information from anyone under [13 / 16 — choose the age that applies in your region]. If you believe a child has provided us with personal information, please contact us and we will delete it.`,
    ],
  },
  {
    h: '11. Changes to This Policy',
    p: [
      `We may update this Privacy Policy from time to time. Any changes will be posted on this page with an updated "Last updated" date, and we encourage you to review it periodically.`,
    ],
  },
  {
    h: '12. Contact',
    p: [
      `If you have any questions about this Privacy Policy, please contact us at ${LEGAL_EMAIL}.`,
    ],
  },
];

const TERMS_SECTIONS = [
  {
    h: 'Overview',
    p: [
      `These Terms and Conditions govern your use of this website and any products or content offered through it (the "Service"), operated by ${LEGAL_BRAND} ("we," "us," or "our"). By accessing or using the Service, you agree to be bound by these Terms. If you do not agree, please do not use the Service.`,
      `Please also review our Privacy Policy, which explains how we collect and use your information and forms part of these Terms.`,
    ],
  },
  {
    h: '1. Use of the Service',
    p: [
      `You may use the Service for lawful purposes only. You agree not to misuse the site, attempt to disrupt it, or access it in any way that could damage or impair it. You represent that you are at least 18 years old, or that you are using the Service with the consent and supervision of a parent or guardian.`,
    ],
  },
  {
    h: '2. Email Updates',
    p: [
      `When you subscribe with your email, you consent to receive the content and updates you signed up for. You can unsubscribe at any time using the link included in every email. We will only use your email address as described in our Privacy Policy.`,
    ],
  },
  {
    h: '3. Purchases & Payment',
    p: [
      `Prices for products are shown at checkout in the stated currency. Payment is handled by our secure third-party payment provider, and your purchase is confirmed once payment is successfully processed. You agree to provide accurate and complete payment information.`,
    ],
  },
  {
    h: '4. Digital Products & License',
    p: [
      `Products sold through this site are digital and are provided for your personal, non-commercial use. You may not resell, redistribute, share, or republish them without our written permission. We retain all ownership of the products and their contents.`,
    ],
  },
  {
    h: '5. Refunds & Cancellation',
    p: [
      `Because our products are digital and delivered immediately, all sales are generally final once a product has been accessed or downloaded.`,
      `By completing your purchase, you request immediate access to your digital product and acknowledge that, where a statutory cancellation or "cooling-off" period would otherwise apply, you lose that right once delivery begins.`,
      `If you experience a problem with your purchase, contact us at ${LEGAL_EMAIL} and we will do our best to make it right. Nothing in this section affects any rights you have under applicable consumer protection law that cannot be waived.`,
    ],
  },
  {
    h: '6. Health & Wellness Disclaimer',
    p: [
      `Our content may include physical exercises, movement practices, or wellness guidance. This content is provided for general informational and educational purposes only and is not medical advice. It is not a substitute for advice from a qualified physician or healthcare professional.`,
      `You should consult a doctor before beginning any new exercise program, especially if you are pregnant, recovering from injury, or have any medical condition. By using our content, you acknowledge that physical activity carries inherent risks, and you participate voluntarily and at your own risk. You are responsible for exercising within your own limits and stopping if you feel pain or discomfort.`,
    ],
  },
  {
    h: '7. Intellectual Property',
    p: [
      `All content on this site — including text, images, designs, and products — is owned by or licensed to ${LEGAL_BRAND} and is protected by applicable intellectual property laws. You may not copy, reproduce, or use it except as expressly permitted.`,
    ],
  },
  {
    h: '8. Links to Other Websites',
    p: [
      `Our Service may contain links to third-party websites that we do not own or control. We are not responsible for the content, privacy policies, or practices of any third-party sites, and we encourage you to review their terms before using them.`,
    ],
  },
  {
    h: '9. "As Is" Disclaimer',
    p: [
      `The Service is provided "as is" and "as available" without warranties of any kind, whether express or implied. To the fullest extent permitted by law, we disclaim all warranties, including those of merchantability, fitness for a particular purpose, and non-infringement.`,
    ],
  },
  {
    h: '10. Limitation of Liability',
    p: [
      `To the maximum extent permitted by law, ${LEGAL_BRAND} will not be liable for any indirect, incidental, or consequential damages arising from your use of, or inability to use, the Service. Our total liability is limited to the amount you paid us, if any, for the product in question.`,
      `Nothing in these Terms excludes or limits our liability for anything that cannot be excluded or limited under applicable law — including liability for death or personal injury caused by negligence, or for fraud.`,
    ],
  },
  {
    h: '11. Governing Law',
    p: [
      `These Terms are governed by the laws of ${LEGAL_JURISDICTION}, without regard to its conflict-of-law rules. Any disputes arising from these Terms or your use of the Service will be subject to the exclusive jurisdiction of the courts located in ${LEGAL_JURISDICTION}.`,
    ],
  },
  {
    h: '12. Changes to These Terms',
    p: [
      `We may modify these Terms at any time at our sole discretion. When we make material changes, we will make reasonable efforts to provide notice. By continuing to use the Service after changes take effect, you agree to the revised Terms.`,
    ],
  },
  {
    h: '13. Severability & Entire Agreement',
    p: [
      `If any provision of these Terms is found to be unenforceable or invalid, that provision will be limited or removed to the minimum extent necessary, and the remaining provisions will remain in full force and effect.`,
      `These Terms, together with our Privacy Policy, make up the entire agreement between you and us regarding the Service and replace any prior agreements on the subject.`,
    ],
  },
  {
    h: '14. Contact',
    p: [
      `If you have any questions about these Terms and Conditions, you can contact us at ${LEGAL_EMAIL}.`,
    ],
  },
];

const LEGAL_PAGES = {
  privacy: { title: 'Privacy Policy',        sections: PRIVACY_SECTIONS },
  terms:   { title: 'Terms and Conditions',  sections: TERMS_SECTIONS  },
};

// ── Page ─────────────────────────────────────────────────────────────────
// Rendered as a full in-tree view (inside the scaled canvas), so it reuses the
// template's own NavBar + warm HeroBackdrop + Footer and scales identically to
// every other page. No sticky bar, no close button — Escape returns to the
// previous view, and the footer / Tweaks panel switch between the two pages.
const LegalPage = ({ page, onClose }) => {
  const bp = useBreakpoint();

  React.useEffect(() => {
    const onKey = e => { if (e.key === 'Escape') onClose(); };
    window.addEventListener('keydown', onKey);
    return () => window.removeEventListener('keydown', onKey);
  }, [onClose]);

  // Land at the top of the page whenever you open or switch a legal page.
  React.useEffect(() => { window.scrollTo({ top: 0, behavior: 'instant' }); }, [page]);

  const data = LEGAL_PAGES[page];
  if (!data) return null;

  const isDesk   = bp === 'desktop' || bp === 'largeDesktop';
  const isTablet = bp === 'tablet';

  // Desktop sizes live in the 1920-px design canvas (scaled down by the host);
  // tablet/mobile are real pixels.
  const sectionPad = isDesk ? '320px 128px 160px'
                   : isTablet ? '200px 64px 96px'
                   : '136px 24px 72px';
  const maxW       = isDesk ? 1040 : isTablet ? 720 : 560;
  const titleSize  = isDesk ? 104 : isTablet ? 60 : 42;
  const headSize   = isDesk ? 32  : isTablet ? 22 : 19;
  const bodySize   = isDesk ? 24  : isTablet ? 17 : 16;
  const metaSize   = isDesk ? 19  : 14;
  const secGap     = isDesk ? 64  : isTablet ? 44 : 34;

  return (
    <main style={{ position: 'relative', background: '#fff', minHeight: '100vh' }}>
      <HeroBackdrop />
      <NavBar brand={LEGAL_BRAND} />

      <section style={{ position: 'relative', padding: sectionPad }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          <h1 className="serif" style={{
            fontFamily: 'Instrument Serif', fontWeight: 400,
            fontSize: titleSize, lineHeight: 1.02, letterSpacing: '-0.02em',
            color: '#101010', margin: '0 0 16px',
          }}>{data.title}</h1>
          <div style={{
            fontFamily: 'Inter', fontSize: metaSize, color: '#9a8f84',
            marginBottom: isDesk ? 80 : 48,
          }}>Last updated: {LEGAL_UPDATED}</div>
          {/* Anchors the warm HeroBackdrop fade on tablet/mobile to the title zone.
              Must stay in normal flow (NOT position:absolute) so HeroBackdrop
              measures its real position just below the title — an absolute
              top:0 anchor collapses the warm zone to ~1px and the animation
              disappears on mobile/tablet. */}
          <div data-hero-anchor style={{ height: 1, width: 1 }} />

          {data.sections.map((sec, i) => (
            <div key={i} style={{ marginBottom: secGap }}>
              <h2 style={{
                fontFamily: 'Inter', fontWeight: 600,
                fontSize: headSize, letterSpacing: '-0.01em',
                color: '#101010', margin: `0 0 ${isDesk ? 22 : 16}px`,
              }}>{sec.h}</h2>
              {sec.p.map((para, j) => (
                <p key={j} style={{
                  fontFamily: 'Inter', fontWeight: 400,
                  fontSize: bodySize, lineHeight: 1.72,
                  color: '#4a443e', margin: `0 0 ${isDesk ? 22 : 16}px`, textWrap: 'pretty',
                }}>{para}</p>
              ))}
            </div>
          ))}
        </div>
      </section>

      <Footer tagline="A space where you can be fully you" sub="Check my channel Yoga with Tara" />
    </main>
  );
};
