<?php
$pageTitle = "FAQ - Tom's Java Jive";
$metaDescription = "Frequently asked questions about Tom's Java Jive coffee, orders, shipping, and more.";
$breadcrumbs = [
    ['name' => 'Home', 'url' => 'https://tomsjavajive.com'],
    ['name' => 'FAQ', 'url' => 'https://tomsjavajive.com/faq.php']
];
require_once __DIR__ . '/includes/header.php';
?>

<section class="section" style="padding-top: 2rem; padding-bottom: 4rem;">
    <div class="container" style="max-width: 800px;">

        <div style="text-align: center; margin-bottom: 3rem;">
            <h1 style="font-size: 2.5rem; margin-bottom: 0.75rem;">Frequently Asked Questions</h1>
            <p style="color: var(--text-muted); font-size: 1.1rem;">Everything you need to know about Tom's Java Jive.</p>
        </div>

        <?php
        $faqs = [
            'Orders & Payment' => [
                ['q' => 'How do I place an order?', 'a' => 'Browse our <a href="/shop.php">shop</a>, add items to your cart, and proceed to checkout. We accept all major credit cards, debit cards, and PayPal.'],
                ['q' => 'Can I modify or cancel my order?', 'a' => 'Orders can be modified or cancelled within 1 hour of placement. After that, orders enter processing and cannot be changed. Contact us immediately at sales@tomsjavajive.com if you need to make a change.'],
                ['q' => 'Is my payment information secure?', 'a' => 'Yes. All payments are processed through Stripe, a PCI-DSS Level 1 certified payment processor. We never store your card details on our servers.'],
                ['q' => 'Do you offer gift cards?', 'a' => 'Yes! Digital gift cards are available in our shop and are delivered by email. They never expire.'],
            ],
            'Coffee & Products' => [
                ['q' => 'When is my coffee roasted?', 'a' => 'We roast to order — your beans are roasted within 24–48 hours of your order being placed, ensuring maximum freshness when they arrive.'],
                ['q' => 'What grind sizes do you offer?', 'a' => 'We offer whole bean, coarse (French press/cold brew), medium (drip/pour-over), and fine (espresso). Select your preferred grind at checkout.'],
                ['q' => 'How should I store my coffee?', 'a' => 'For maximum freshness, store your coffee in an airtight container in the freezer. Whole beans keep longer than ground coffee. If storing at room temperature, keep in a cool, dark place away from direct sunlight, heat, and moisture.'],
                ['q' => 'Are your coffees organic or fair trade?', 'a' => 'Many of our single origin coffees are sourced from farms with organic and fair trade practices. Each product listing includes sourcing details.'],
            ],
            'Coffee Freshness & Storage' => [
                ['q' => 'How long does coffee last?', 'a' => 'Properly stored coffee can last for months and even years, though flavor is best enjoyed within a few weeks of the roast date. Whole beans stay fresh longer than ground coffee because less surface area is exposed to air.'],
                ['q' => 'How can I tell if my coffee has gone bad?', 'a' => 'The best way to tell is by smell. If the pleasant aroma is gone, the coffee has likely gone stale. Stale coffee won\'t harm you, but it will have little flavor. It may also appear a lighter brown rather than its usual deep, dark color.'],
                ['q' => 'How should I store coffee beans to keep them fresh?', 'a' => 'Store beans in an airtight container in the freezer for maximum freshness. Whole beans keep longer than ground coffee because less surface area is exposed to air. Grind only the amount you plan to use each day to minimize unnecessary exposure.'],
                ['q' => 'How should I store ground coffee?', 'a' => 'Store ground coffee in an airtight container in your freezer immediately after opening. Freezer storage doesn\'t freeze it solid — it\'s always ready to use without defrosting. Just scoop and brew.'],
            ],
            'Account & Loyalty' => [
                ['q' => 'Do I need an account to order?', 'a' => 'No, you can check out as a guest. However, creating an account lets you track orders, earn loyalty points, save addresses, and view your order history.'],
                ['q' => 'How does the loyalty program work?', 'a' => 'You earn 1 point for every $1 spent. Points can be redeemed for discounts on future orders. Points are credited once your order is delivered.'],
                ['q' => 'How do I reset my password?', 'a' => 'Click "Forgot Password" on the <a href="/login.php">login page</a> and we\'ll email you a reset link.'],
            ],
        ];

        foreach ($faqs as $category => $items): ?>
        <div style="margin-bottom: 2.5rem;">
            <h2 style="font-size: 1.3rem; color: var(--primary); border-bottom: 2px solid var(--primary); padding-bottom: 0.5rem; margin-bottom: 1.25rem;"><?= $category ?></h2>
            <div style="display: flex; flex-direction: column; gap: 0.75rem;">
                <?php foreach ($items as $i => $faq): ?>
                <div style="border: 1px solid var(--border); border-radius: 8px; overflow: hidden;">
                    <button onclick="toggleFaq(this)"
                        style="width: 100%; text-align: left; padding: 1.1rem 1.25rem; background: none; border: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 1rem; font-weight: 600; color: var(--text);">
                        <?= htmlspecialchars($faq['q']) ?>
                        <span style="font-size: 1.4rem; line-height: 1; color: var(--primary); transition: transform 0.2s; flex-shrink: 0; margin-left: 1rem;">+</span>
                    </button>
                    <div style="display: none; padding: 0 1.25rem 1.1rem; color: var(--text-muted); line-height: 1.7;">
                        <?= $faq['a'] ?>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
        </div>
        <?php endforeach; ?>

        <div class="card" style="background: var(--primary); color: white; text-align: center; margin-top: 3rem;">
            <div class="card-body" style="padding: 2rem;">
                <h3 style="color: white; margin-bottom: 0.5rem;">Still have questions?</h3>
                <p style="opacity: 0.9; margin-bottom: 1.25rem;">We're happy to help. Reach out and we'll get back to you within one business day.</p>
                <a href="/contact.php" class="btn" style="background: white; color: var(--primary); font-weight: 600;">Contact Us</a>
            </div>
        </div>

    </div>
</section>

<script>
function toggleFaq(btn) {
    const answer = btn.nextElementSibling;
    const icon = btn.querySelector('span');
    const isOpen = answer.style.display === 'block';
    answer.style.display = isOpen ? 'none' : 'block';
    icon.textContent = isOpen ? '+' : '−';
    icon.style.transform = isOpen ? '' : 'rotate(0deg)';
}
</script>

<?php require_once __DIR__ . '/includes/footer.php'; ?>
