/* 
 * SafeW Global Styles & Design System
 * Theme: Blue-Purple Deep Base + Brand Accent · Deep Beige Paper
 */

:root {
    /* Color Palette */
    --color-deep: #1B1231;      /* Dark Surface */
    --color-paper: #DBD4ED;     /* Light Paper */
    --color-text: #191523;      /* Text on Paper */
    --color-brand: #5214EB;     /* Brand Color (Paper context) */
    --color-accent: #9977EE;    /* Accent Color (Button, Highlight on Deep) */
    
    /* UI Tokens */
    --radius-card: 24px;
    --radius-btn: 999px;
    --card-border: 2px solid var(--color-text);
    --card-shadow: 4px 4px 0 var(--color-text);
    --section-y: clamp(2.5rem, 5vw, 4rem);
    --gap: clamp(0.75rem, 1.5vw, 1.25rem);
    --content-max: 1120px;
    
    /* Typography */
    --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    --lh-body: 1.55;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-family: var(--font-main);
    background-color: var(--color-paper);
    color: var(--color-text);
    line-height: var(--lh-body);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

img, svg {
    display: block;
    max-width: 100%;
}

/* Layout Utilities */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

.section {
    padding-top: var(--section-y);
    padding-bottom: var(--section-y);
}

.bg-deep {
    background-color: var(--color-deep);
    color: var(--color-paper);
}

.bg-paper {
    background-color: var(--color-paper);
    color: var(--color-text);
}

/* Typography Components */
.section-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.5em;
    text-transform: uppercase;
}

.paper-surface .section-label {
    color: var(--color-brand);
}

.deep-surface .section-label {
    color: var(--color-accent);
}

h1, h2, h3, h4 {
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h1 {
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    margin-bottom: 0.5em;
}

h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    margin-bottom: 0.8em;
}

h3 {
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    margin-bottom: 0.6em;
}

p {
    margin-bottom: 1em;
    max-width: 38em;
}

.hl {
    /* Highlight keyword logic handled in HTML classes or specific colors */
}

.paper-surface .hl {
    color: var(--color-brand);
}

.deep-surface .hl {
    color: var(--color-accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 24px;
    border-radius: var(--radius-btn);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    gap: 8px;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-deep);
    border: none;
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--color-text);
    color: var(--color-text);
}

.deep-surface .btn-secondary {
    border-color: var(--color-paper);
    color: var(--color-paper);
}

/* Cards & Panels */
.card {
    background-color: var(--color-paper);
    border: var(--card-border);
    border-radius: var(--radius-card);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    position: relative;
}

.deep-surface .card {
    background-color: var(--color-deep);
    border-color: var(--color-paper);
    box-shadow: 4px 4px 0 var(--color-paper);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    margin-bottom: 1.5rem;
    border: var(--card-border);
    border-radius: var(--radius-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Ensure table doesn't squish too much */
}

th, td {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.deep-surface th, .deep-surface td {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

th {
    font-weight: 700;
    background-color: rgba(0,0,0,0.03);
}

.deep-surface th {
    background-color: rgba(255,255,255,0.05);
}

tr:last-child th, tr:last-child td {
    border-bottom: none;
}

/* FAQ Details */
details {
    border: var(--card-border);
    border-radius: var(--radius-card);
    margin-bottom: 1rem;
    background-color: var(--color-paper);
    transition: all 0.3s ease;
}

.deep-surface details {
    background-color: var(--color-deep);
    border-color: var(--color-paper);
}

summary {
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-left: 2.5rem;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: '';
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
    opacity: 0.5;
}

details[open] summary::before {
    opacity: 1;
    background-color: currentColor;
}

details > div {
    padding: 0 1.5rem 1.5rem 1.5rem;
    line-height: 1.6;
}

/* Header & Footer */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--color-paper);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 1rem 0;
}

.deep-surface .site-header {
    background-color: var(--color-deep);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand img {
    height: 32px;
    width: auto;
}

nav ul {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

nav a:hover, nav a[aria-current="page"] {
    color: var(--color-brand);
}

.deep-surface nav a:hover, .deep-surface nav a[aria-current="page"] {
    color: var(--color-accent);
}

.site-footer {
    background-color: var(--color-deep);
    color: var(--color-paper);
    padding: 3rem 0;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.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 ul li {
    margin-bottom: 0.5rem;
}

.footer-col a:hover {
    text-decoration: underline;
}

.copyright {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* SVG Animation Classes */
.anim-float {
    animation: float 6s ease-in-out infinite;
}

.anim-draw {
    pathLength: 1;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    animation: drawLine 4s ease-in-out infinite alternate;
}

.anim-breathe {
    animation: breathe 4s ease-in-out infinite;
}

.anim-slide-in {
    animation: slideIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes drawLine {
    0% { stroke-dashoffset: 1; }
    50%, 80% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 1; }
}

@keyframes breathe {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

@keyframes slideIn {
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 1rem;
    }
    
    nav ul {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    h1 {
        font-size: 2.5rem;
    }
}

@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;
    }
}
