/* ==========================================================================
   FoodBankSearch — Terms of Service Design Layer
   Scoped to body.terms-page. Inherits global tokens from style.css.
   Adheres to ui_ux_pro_max guidelines:
   - Modern typography (Plus Jakarta Sans + Inter)
   - Brand Green (#2E7D32) and Orange (#F57C00) palette
   - Layered cards with subtle elevations and smooth hover states
   - Accessible focus rings, 44px+ touch targets, and WCAG AA compliance
   - Responsive sticky table-of-contents sidebar with active state observer
   ========================================================================== */

.terms-page {
    --primary-color: #2E7D32;
    --primary-dark: #1B5E20;
    --primary-light: #4CAF50;
    --primary-soft: #e8f5e9;
    --secondary-color: #F57C00;
    --secondary-dark: #E65100;
    --secondary-soft: #fff3e0;
    --text-dark: #0f172a;
    --text-body: #334155;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --card-radius: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --shadow-card-hover: 0 16px 28px -6px rgba(15, 23, 42, 0.1), 0 4px 10px -2px rgba(46, 125, 50, 0.08);
    background-color: var(--bg-white);
    color: var(--text-dark);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.terms-page h1,
.terms-page h2,
.terms-page h3,
.terms-page h4,
.terms-page h5,
.terms-page .btn {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Accessibility Focus Rings */
.terms-page a:focus-visible,
.terms-page button:focus-visible,
.terms-page input:focus-visible,
.terms-page select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--primary-color) !important;
}

/* Skip Link */
.terms-page .skip-link {
    position: absolute;
    top: -60px;
    left: 1rem;
    background: var(--primary-color);
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    z-index: 9999;
    border-radius: 8px;
    transition: top 0.2s ease;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.terms-page .skip-link:focus {
    top: 1rem;
}

/* ---------- Hero Section ---------- */
.terms-page .terms-hero {
    position: relative;
    padding: clamp(3.5rem, 6vw, 5rem) 0 3.5rem;
    background: 
        radial-gradient(60% 60% at 15% 15%, rgba(46, 125, 50, 0.08) 0%, transparent 60%),
        radial-gradient(50% 50% at 85% 85%, rgba(245, 124, 0, 0.07) 0%, transparent 60%),
        linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}

.terms-page .hero-pattern {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(46, 125, 50, 0.09) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
    opacity: 0.6;
    pointer-events: none;
}

.terms-page .hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 1.15rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(46, 125, 50, 0.2);
    box-shadow: var(--shadow-sm);
    color: var(--primary-dark);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 1.25rem;
}

.terms-page .pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.7);
    animation: termsPulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes termsPulse {
    to {
        box-shadow: 0 0 0 10px rgba(46, 125, 50, 0);
    }
}

.terms-page .hero-title {
    font-size: clamp(2.2rem, 4.5vw, 3.4rem);
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.2;
    margin-bottom: 1.1rem;
    letter-spacing: -0.02em;
}

.terms-page .hero-highlight {
    color: var(--primary-color);
    position: relative;
    display: inline-block;
}

.terms-page .hero-subtitle {
    font-size: clamp(1.05rem, 1.5vw, 1.2rem);
    color: var(--text-body);
    line-height: 1.7;
    margin-bottom: 2rem;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

/* Hero Trust Badges */
.terms-page .hero-trust-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.85rem;
    margin-top: 1.5rem;
}

.terms-page .trust-badge-item {
    background: #ffffff;
    border: 1px solid #dcfce7;
    border-radius: 12px;
    padding: 0.6rem 1.15rem;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
}

.terms-page .trust-badge-item i {
    font-size: 1.05rem;
    color: var(--primary-color);
}

/* ---------- Main Content Layout ---------- */
.terms-page .terms-content-section {
    padding: 4rem 0 5rem;
    background-color: var(--bg-white);
}

/* Sticky Sidebar Table of Contents */
.terms-page .sidebar-toc-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.terms-page .sidebar-toc-card::-webkit-scrollbar {
    width: 5px;
}
.terms-page .sidebar-toc-card::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.terms-page .sidebar-toc-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terms-page .sidebar-toc-title i {
    color: var(--primary-color);
}

.terms-page .toc-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.terms-page .toc-nav-link {
    color: var(--text-body);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.terms-page .toc-nav-link:hover {
    background: var(--bg-light);
    color: var(--primary-dark);
    border-left-color: var(--primary-light);
}

.terms-page .toc-nav-link.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-left-color: var(--primary-color);
    font-weight: 700;
}

.terms-page .sidebar-contact-card {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 14px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.terms-page .sidebar-contact-card h4 {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.35rem;
}

.terms-page .sidebar-contact-card p {
    font-size: 0.82rem;
    color: #166534;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.terms-page .sidebar-contact-btn {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: underline;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Article Sections */
.terms-page .article-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: clamp(1.75rem, 3.5vw, 2.75rem);
    box-shadow: var(--shadow-card);
}

.terms-page .policy-section-block {
    margin-bottom: 3rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-light);
    scroll-margin-top: 110px;
}

.terms-page .policy-section-block:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.terms-page .policy-section-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.15rem;
}

.terms-page .policy-section-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.terms-page .policy-section-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
}

.terms-page .policy-text {
    font-size: 1rem;
    color: var(--text-body);
    line-height: 1.7;
    margin-bottom: 1.25rem;
}

/* Date Prepared & Scope Banner */
.terms-page .meta-status-banner {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2.25rem;
    font-size: 0.88rem;
    color: var(--text-body);
}

.terms-page .meta-status-banner .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.terms-page .meta-status-banner .meta-item i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* Quick Takeaway Cards Grid */
.terms-page .takeaways-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.terms-page .takeaway-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.terms-page .takeaway-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: #86efac;
}

.terms-page .takeaway-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #dcfce7;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.terms-page .takeaway-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
}

.terms-page .takeaway-desc {
    font-size: 0.84rem;
    color: var(--text-light);
    line-height: 1.5;
    margin: 0;
}

/* Highlight / Alert Boxes */
.terms-page .highlight-box {
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.05) 0%, rgba(46, 125, 50, 0.1) 100%);
    border: 1px solid rgba(46, 125, 50, 0.2);
    border-left: 4px solid var(--primary-color);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 14px 14px 0;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.terms-page .highlight-box.warning {
    background: linear-gradient(135deg, rgba(245, 124, 0, 0.05) 0%, rgba(245, 124, 0, 0.1) 100%);
    border-color: rgba(245, 124, 0, 0.2);
    border-left-color: var(--secondary-color);
}

.terms-page .highlight-box.danger {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.05) 0%, rgba(220, 38, 38, 0.1) 100%);
    border-color: rgba(220, 38, 38, 0.2);
    border-left-color: #dc2626;
}

.terms-page .highlight-box i {
    color: var(--primary-color);
    font-size: 1.35rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.terms-page .highlight-box.warning i {
    color: var(--secondary-color);
}

.terms-page .highlight-box.danger i {
    color: #dc2626;
}

.terms-page .highlight-box p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-body);
    line-height: 1.6;
}

/* Comparative Grid: Permitted vs Prohibited */
.terms-page .comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.terms-page .comparison-box {
    border-radius: 14px;
    padding: 1.5rem;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
}

.terms-page .comparison-box.allowed {
    border-top: 4px solid var(--primary-color);
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 25%);
}

.terms-page .comparison-box.prohibited {
    border-top: 4px solid #dc2626;
    background: linear-gradient(180deg, #fef2f2 0%, #ffffff 25%);
}

.terms-page .comparison-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terms-page .comparison-box.allowed .comparison-title {
    color: var(--primary-dark);
}

.terms-page .comparison-box.prohibited .comparison-title {
    color: #991b1b;
}

.terms-page .comparison-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.terms-page .comparison-list li {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-body);
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
}

.terms-page .comparison-box.allowed .comparison-list li i {
    color: var(--primary-color);
    font-size: 1rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.terms-page .comparison-box.prohibited .comparison-list li i {
    color: #dc2626;
    font-size: 1rem;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Subcard Grid */
.terms-page .subcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.terms-page .subcard {
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.terms-page .subcard:hover {
    transform: translateY(-2px);
    border-color: #86efac;
    box-shadow: var(--shadow-sm);
}

.terms-page .subcard-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.terms-page .subcard-header i {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.terms-page .subcard-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
}

.terms-page .subcard-text {
    font-size: 0.9rem;
    color: var(--text-body);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.terms-page .subcard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.terms-page .subcard-list li {
    font-size: 0.86rem;
    color: var(--text-light);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.terms-page .subcard-list li i {
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-top: 3px;
    flex-shrink: 0;
}

/* Direct Legal Contact Card */
.terms-page .legal-contact-card {
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%);
    color: #ffffff;
    border-radius: var(--card-radius);
    padding: clamp(2rem, 4vw, 3rem);
    margin-top: 2.5rem;
    box-shadow: 0 12px 28px -4px rgba(46, 125, 50, 0.25);
    position: relative;
    overflow: hidden;
}

.terms-page .legal-contact-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.terms-page .legal-contact-card h3 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 0.75rem;
}

.terms-page .legal-contact-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 650px;
    margin-bottom: 1.75rem;
}

.terms-page .contact-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.terms-page .contact-detail-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.terms-page .contact-detail-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 0.25rem;
}

.terms-page .contact-detail-value {
    font-size: 0.98rem;
    font-weight: 700;
    color: #ffffff;
    word-break: break-all;
}

.terms-page .contact-detail-value a {
    color: #ffffff;
    text-decoration: underline;
}

.terms-page .contact-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.terms-page .btn-legal-contact {
    background: #ffffff;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.75rem 1.75rem;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.terms-page .btn-legal-contact:hover {
    background: #f8fafc;
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.terms-page .btn-legal-outline {
    background: transparent;
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.terms-page .btn-legal-outline:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #ffffff;
    color: #ffffff;
}

/* Bottom Conversion Banner */
.terms-page .bottom-cta-banner {
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 2.25rem 2.5rem;
    margin-top: 3rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.terms-page .cta-text-content h4 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
}

.terms-page .cta-text-content p {
    font-size: 0.92rem;
    color: var(--text-light);
    margin: 0;
    max-width: 550px;
}

.terms-page .cta-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.terms-page .btn-find-food {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.7rem 1.4rem;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.terms-page .btn-find-food:hover {
    background: var(--primary-dark);
    color: #ffffff;
    transform: translateY(-2px);
}

.terms-page .btn-snap-help {
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1.5px solid var(--border-color);
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.7rem 1.4rem;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.terms-page .btn-snap-help:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #ffffff;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .terms-page .sidebar-toc-card {
        position: static;
        margin-bottom: 2rem;
        max-height: none;
    }

    .terms-page .bottom-cta-banner {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.75rem;
    }
}

@media (max-width: 575.98px) {
    .terms-page .hero-trust-badges {
        flex-direction: column;
    }

    .terms-page .meta-status-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .terms-page .article-card {
        padding: 1.25rem;
    }

    .terms-page .highlight-box {
        flex-direction: column;
        gap: 0.5rem;
    }

    .terms-page .contact-action-row {
        flex-direction: column;
        width: 100%;
    }

    .terms-page .btn-legal-contact,
    .terms-page .btn-legal-outline {
        width: 100%;
        justify-content: center;
    }
}
