/* =========================================
   SafeW Global Styles & Design System
   Theme: Blue-Purple Dark + Beige Paper
   ========================================= */

/* --- 1. Design Tokens & Variables --- */
:root {
    /* Colors */
    --color-bg-dark: #1B1231;
    --color-paper: #DBD4ED;
    --color-text: #191523;
    --color-brand: #5214EB;
    --color-accent: #9977EE;
    
    /* Spacing & Rhythm */
    --section-y: clamp(2.5rem, 5vw, 4rem);
    --gap: clamp(0.75rem, 1.5vw, 1.25rem);
    
    /* Typography Scale */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --h1-size: clamp(2.6rem, 6.4vw, 5rem);
    --h2-size: clamp(1.8rem, 3.5vw, 2.8rem);
    --h3-size: clamp(1.3rem, 2vw, 1.6rem);
    --body-size: clamp(1rem, 1.1vw, 1.125rem);
    
    /* Components */
    --radius-card: 24px;
    --radius-btn: 999px;
    --card-border: 2px solid var(--color-text);
    --card-shadow: 4px 4px 0 var(--color-text);
    --content-max: 1120px;
}

/* --- 2. Base Reset & Typography --- */
*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    font-family: var(--font-sans);
    background-color: var(--color-paper);
    color: var(--color-text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

img, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

h1, h2, h3, h4 {
    line-height: 1.15;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-top: 0;
    margin-bottom: var(--gap);
}

h1 { font-size: var(--h1-size); }
h2 { font-size: var(--h2-size); }
h3 { font-size: var(--h3-size); }

p {
    margin-bottom: var(--gap);
    font-size: var(--body-size);
    max-width: 65ch;
}

a {
    color: var(--color-brand);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s ease;
}

.dark-section a { color: var(--color-accent); }

ul, ol {
    padding-left: 1.5em;
    margin-bottom: var(--gap);
}

li { margin-bottom: 0.5em; }

/* --- 3. Layout Utilities --- */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

.section {
    padding-block: var(--section-y);
    position: relative;
}

.dark-section {
    background-color: var(--color-bg-dark);
    color: var(--color-paper);
}

/* Dark section overrides for text colors */
.dark-section h1, .dark-section h2, .dark-section h3, .dark-section p, .dark-section li {
    color: var(--color-paper);
}
.dark-section strong { color: var(--color-paper); }

/* Highlight spans */
.hl { color: var(--color-brand); }
.dark-section .hl { color: var(--color-accent); }

/* Eyebrow / Label */
.section-label {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.5em;
    color: var(--color-brand);
    display: flex;
    align-items: center;
    gap: 0.5em;
}
.dark-section .section-label { color: var(--color-accent); }

/* Section Number Decorator */
.section-number {
    font-size: 0.8rem;
    font-weight: 800;
    opacity: 0.6;
    margin-right: 0.5em;
    font-variant-numeric: tabular-nums;
}

/* Contrast Fixes for Section Numbers */
.dark-section .section-label span.section-number {
    color: var(--color-paper);
}
.section:not(.dark-section) .section-label span.section-number {
    color: var(--color-brand);
}

/* --- 4. Components --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    padding: 0.8em 1.8em;
    border-radius: var(--radius-btn);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0.2, 1), box-shadow 0.2s ease;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--color-accent);
    color: #ffffff;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153, 119, 238, 0.4);
}

/* Contrast fixes for buttons on specific backgrounds */
.site-header .container.header-inner a.btn.btn-primary {
    color: #1B1231 !important;
}
.section.dark-section .container.hero-layout .hero-text a.btn.btn-primary {
    color: #1B1231 !important;
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--color-text);
    color: var(--color-text);
}
.dark-section .btn-secondary {
    border-color: var(--color-paper);
    color: var(--color-paper);
}
.btn-secondary:hover {
    background-color: rgba(0,0,0,0.05);
    transform: translateY(-2px);
}
.dark-section .btn-secondary:hover {
    background-color: rgba(255,255,255,0.1);
}

.btn:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* Cards */
.card {
    background: var(--color-paper);
    border: var(--card-border);
    border-radius: var(--radius-card);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: transform 0.2s ease;
}
.dark-section .card {
    background: var(--color-bg-dark);
    border-color: var(--color-paper);
    box-shadow: 4px 4px 0 var(--color-paper);
}
.card:hover {
    transform: translateY(-4px);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--gap);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 600px; /* Forces scroll on small phones */
}
th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
.dark-section th, .dark-section td {
    border-bottom-color: rgba(255,255,255,0.1);
}
th {
    font-weight: 700;
    background: rgba(0,0,0,0.03);
}
.dark-section th { background: rgba(255,255,255,0.05); }

/* FAQ / Details */
details {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    padding: 1rem;
    background: rgba(255,255,255,0.5);
}
.dark-section details {
    border-color: rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
}
summary {
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
summary::-webkit-details-marker { display: none; }
summary::after {
    content: "+";
    font-size: 1.2em;
    font-weight: 400;
    transition: transform 0.2s;
}
details[open] summary::after { transform: rotate(45deg); }
details p {
    margin-top: 1rem;
    margin-bottom: 0;
    padding-top: 1rem;
    border-top: 1px dashed rgba(0,0,0,0.1);
}
.dark-section details p { border-top-color: rgba(255,255,255,0.1); }

/* --- 5. Header & Footer --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(219, 212, 237, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 0.75rem 0;
}
.dark-section.site-header { background: rgba(27, 18, 49, 0.9); border-bottom-color: rgba(255,255,255,0.1); }

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo img {
    height: 32px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.nav-links a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}
.dark-section .nav-links a { color: var(--color-paper); }
.nav-links a:hover { color: var(--color-brand); }
.dark-section .nav-links a:hover { color: var(--color-accent); }
.nav-links a[aria-current="page"] {
    color: var(--color-brand);
    border-bottom: 2px solid var(--color-brand);
}
.dark-section .nav-links a[aria-current="page"] { color: var(--color-accent); border-bottom-color: var(--color-accent); }

.mobile-menu-btn { display: none; background: none; border: none; color: inherit; cursor: pointer; }

.site-footer {
    background: var(--color-bg-dark);
    color: var(--color-paper);
    padding: 3rem 0;
    margin-top: auto;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}
.footer-col h4 { color: var(--color-accent); margin-bottom: 1rem; font-size: 1rem; }
.footer-col a { color: rgba(219, 212, 237, 0.7); text-decoration: none; display: block; margin-bottom: 0.5rem; }
.footer-col a:hover { color: var(--color-paper); }
.copyright { text-align: center; margin-top: 3rem; font-size: 0.85rem; opacity: 0.6; }

/* --- 6. SVG Animation Keyframes --- */
@keyframes draw-line {
    0% { stroke-dashoffset: 1; }
    100% { stroke-dashoffset: 0; }
}
@keyframes float-up {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes pulse-opacity {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes slide-in-right {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Animation Classes */
.anim-draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    animation: draw-line 2s ease forwards;
}
.anim-float {
    animation: float-up 4s ease-in-out infinite;
}
.anim-pulse {
    animation: pulse-opacity 3s ease-in-out infinite;
}
.anim-spin {
    animation: spin-slow 20s linear infinite;
    transform-box: fill-box;
    transform-origin: center;
}
.anim-slide {
    animation: slide-in-right 0.8s ease-out forwards;
}

/* Staggered delays for children */
.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- 7. Responsive Adjustments --- */
@media (max-width: 768px) {
    .nav-links { display: none; } /* Simplified for this task, ideally JS toggle */
    .mobile-menu-btn { display: block; }
    
    .zigzag-row {
        flex-direction: column-reverse;
    }
    
    .hero-layout {
        flex-direction: column-reverse;
        text-align: center;
    }
    
    .persona-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .zigzag-row {
        display: flex;
        align-items: center;
        gap: 3rem;
    }
    .zigzag-row.reverse { flex-direction: row-reverse; }
    .zigzag-text { flex: 1; }
    .zigzag-visual { flex: 1; }
    
    .persona-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--gap);
    }
}
