/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

:root {
    /* Color Palette - Strictly defined */
    --color-dark-bg: #2D1438;
    --color-paper: #F6F3F7;
    --color-text-body: #1F1523;
    --color-brand: #9E13DD;
    --color-accent: #6EEDA8;

    /* Derived Text Colors */
    --text-on-dark: #F6F3F7;
    --text-on-paper: #1F1523;

    /* Layout & Spacing */
    --content-max: 960px;
    --radius-card: 20px;
    --radius-btn: 12px;
    --card-shadow: 0 10px 28px -14px rgba(31, 21, 35, 0.3);
    
    /* Rhythm */
    --section-y: clamp(2.5rem, 5vw, 4rem);
    --gap: clamp(0.75rem, 1.5vw, 1.25rem);
    
    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text-on-paper);
    background-color: var(--color-paper);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Typography Utilities */
h1, h2, h3, h4 {
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    margin-bottom: var(--gap);
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    margin-bottom: var(--gap);
}

h3 {
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    margin-bottom: var(--gap);
}

p {
    margin-bottom: var(--gap);
    max-width: 38em;
}

a {
    color: var(--color-brand);
    text-decoration: none;
    transition: color 0.2s ease;
}

.dark-theme a {
    color: var(--color-accent);
}

a:hover {
    text-decoration: underline;
}

/* Layout Containers */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

section {
    padding: var(--section-y) 0;
    position: relative;
}

/* Theme Classes */
.light-theme {
    background-color: var(--color-paper);
    color: var(--text-on-paper);
}

.dark-theme {
    background-color: var(--color-dark-bg);
    color: var(--text-on-dark);
}

/* Highlight Keyword */
.hl {
    color: var(--color-brand);
    font-weight: 700;
}

.dark-theme .hl {
    color: var(--color-accent);
}

/* Badge / Eyebrow */
.badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.5em;
    text-transform: uppercase;
}

.light-theme .badge {
    color: var(--color-brand);
}

.dark-theme .badge {
    color: var(--color-accent);
}

/* Buttons */
.btn-group {
    display: flex;
    gap: var(--gap);
    flex-wrap: wrap;
    margin-top: var(--gap);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 24px;
    border-radius: var(--radius-btn);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none !important;
}

.btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-dark-bg);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

.dark-theme .btn-primary {
    background-color: var(--color-accent);
    color: var(--color-dark-bg);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--color-text-body);
    color: var(--color-text-body);
}

.dark-theme .btn-secondary {
    border-color: var(--text-on-dark);
    color: var(--text-on-dark);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* Cards */
.card {
    background: var(--color-paper);
    border-radius: var(--radius-card);
    padding: var(--gap);
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dark-theme .card {
    background: rgba(246, 243, 247, 0.05); /* Slight tint of paper */
    border: 1px solid rgba(246, 243, 247, 0.1);
    box-shadow: none;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 32px -10px rgba(31, 21, 35, 0.4);
}

.dark-theme .card:hover {
    background: rgba(246, 243, 247, 0.08);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--gap);
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-card);
    background: var(--color-paper);
    padding: var(--gap);
    box-shadow: var(--card-shadow);
}

.dark-theme .table-wrapper {
    background: rgba(246, 243, 247, 0.05);
    border: 1px solid rgba(246, 243, 247, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(31, 21, 35, 0.1);
}

.dark-theme th, .dark-theme td {
    border-bottom: 1px solid rgba(246, 243, 247, 0.1);
}

th {
    font-weight: 700;
    color: var(--color-brand);
}

.dark-theme th {
    color: var(--color-accent);
}

tr:last-child th, tr:last-child td {
    border-bottom: none;
}

/* FAQ Details */
.faq-item {
    margin-bottom: var(--gap);
    border-bottom: 1px solid rgba(31, 21, 35, 0.1);
    padding-bottom: var(--gap);
}

.dark-theme .faq-item {
    border-bottom: 1px solid rgba(246, 243, 247, 0.1);
}

summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: '+';
    font-size: 1.2em;
    font-weight: 300;
}

details[open] summary::after {
    content: '-';
}

details p {
    margin-top: 12px;
    margin-bottom: 0;
    opacity: 0.9;
}

/* Timeline Component */
.timeline {
    position: relative;
    padding-left: 24px;
    border-left: 2px solid var(--color-brand);
}

.dark-theme .timeline {
    border-left-color: var(--color-accent);
}

.timeline-item {
    position: relative;
    margin-bottom: var(--gap);
    padding-bottom: var(--gap);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 6px;
    width: 10px;
    height: 10px;
    background: var(--color-brand);
    border-radius: 50%;
    border: 2px solid var(--color-paper);
}

.dark-theme .timeline-item::before {
    background: var(--color-accent);
    border-color: var(--color-dark-bg);
}

/* Header & Footer */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: rgba(246, 243, 247, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(31, 21, 35, 0.05);
    padding: 16px 0;
}

.dark-theme .site-header {
    background-color: rgba(45, 20, 56, 0.9);
    border-bottom: 1px solid rgba(246, 243, 247, 0.05);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-text-body);
    text-decoration: none;
}

.dark-theme .brand {
    color: var(--text-on-dark);
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-link {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-body);
    text-decoration: none;
}

.dark-theme .nav-link {
    color: var(--text-on-dark);
}

.nav-link:hover {
    color: var(--color-brand);
}

.dark-theme .nav-link:hover {
    color: var(--color-accent);
}

.nav-link.active {
    color: var(--color-brand);
    font-weight: 700;
}

.dark-theme .nav-link.active {
    color: var(--color-accent);
}

.site-footer {
    padding: 48px 0;
    border-top: 1px solid rgba(31, 21, 35, 0.1);
    margin-top: var(--section-y);
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

.dark-theme .site-footer {
    border-top-color: rgba(246, 243, 247, 0.1);
}

/* SVG Animations */
.svg-icon {
    width: 100%;
    height: auto;
    display: block;
}

/* Keyframes */
@keyframes draw-line {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes breathe {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Animation Classes */
.anim-draw {
    path {
        pathLength: 1;
        stroke-dasharray: 1;
        animation: draw-line 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }
}

.anim-float {
    animation: float 4s ease-in-out infinite;
}

.anim-breathe {
    animation: breathe 3s ease-in-out infinite;
}

.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .nav-links {
        display: none; /* Simplified for this static generation, usually would be a hamburger */
    }
    
    .header-inner {
        justify-content: center;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* 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;
    }
    
    .anim-draw path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }
}
