/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

:root {
  /* --- Color Palette --- */
  --color-bg-dark: #141838;
  --color-bg-paper: #F7F5F3;
  --color-bg-paper-light: #EBE8E5;
  --color-text-body: #151723;
  --color-brand: #142CEB;
  --color-accent: #6EAFED;
  --color-white: #FFFFFF;
  --color-border: var(--color-text-body);

  /* --- Typography --- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* --- Spacing & Layout --- */
  --content-max: 1120px;
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --header-height: 64px;

  /* --- Radii & Shadows --- */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 2px solid var(--color-border);
  --card-shadow: 4px 4px 0 var(--color-border);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);

  /* --- Transitions --- */
  --transition-fast: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- Typography Scale --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--color-text-body);
}

.dark-mode h1, .dark-mode h2, .dark-mode h3, .dark-mode h4, .dark-mode h5, .dark-mode h6 {
  color: var(--color-white);
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: var(--gap);
  position: relative;
  padding-top: calc(var(--gap) / 2);
}

h2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 4px;
  background-color: var(--color-brand);
}

.dark-mode h2::before {
  background-color: var(--color-accent);
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  margin-bottom: calc(var(--gap) / 2);
  margin-top: var(--gap);
}

p {
  margin-bottom: 1em;
  max-width: 38em;
}

.hl {
  color: var(--color-brand);
  font-weight: 700;
}

.dark-mode .hl {
  color: var(--color-accent);
}

/* --- Layout Containers --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.section {
  padding-block: var(--section-y);
  position: relative;
}

.section--dark {
  background-color: var(--color-bg-dark);
  color: var(--color-white);
}

.section--paper {
  background-color: var(--color-bg-paper);
}

.section--paper-light {
  background-color: var(--color-bg-paper-light);
}

/* --- Header & Navigation --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg-paper);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.section--dark ~ .site-header,
.site-header.dark-header {
  background-color: var(--color-bg-dark);
  border-bottom-color: rgba(255,255,255,0.1);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
}

.nav-link:hover, .nav-link[aria-current="page"] {
  color: var(--color-brand);
}

.dark-mode .nav-link:hover,
.dark-mode .nav-link[aria-current="page"] {
  color: var(--color-accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.dark-mode .btn:focus-visible {
  outline-color: var(--color-accent);
}

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  border: none;
}

.btn--primary:hover {
  transform: translateY(-2px);
  filter: brightness(0.95);
}

.btn--secondary {
  background-color: transparent;
  border: 2px solid var(--color-text-body);
  color: var(--color-text-body);
}

.dark-mode .btn--secondary {
  border-color: var(--color-white);
  color: var(--color-white);
}

.btn--secondary:hover {
  background-color: rgba(0,0,0,0.05);
}

.dark-mode .btn--secondary:hover {
  background-color: rgba(255,255,255,0.1);
}

.btn svg {
  width: 20px;
  height: 20px;
}

/* --- Cards & Panels --- */
.card {
  background-color: var(--color-bg-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform var(--transition-fast);
}

.dark-mode .card {
  background-color: #1E234A; /* Slightly lighter than dark bg for contrast */
  border-color: var(--color-white);
  box-shadow: 4px 4px 0 rgba(255,255,255,0.1);
}

.card:hover {
  transform: translate(-2px, -2px);
}

.visual-panel {
  background-color: var(--color-bg-dark);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  position: relative;
  overflow: hidden;
}

.dark-mode .visual-panel {
  background-color: #0D1026;
}

/* --- Grid Systems --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: var(--gap);
  align-items: start;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--gap);
}

/* --- Feature Tabs --- */
.tabs-wrapper {
  margin-top: var(--gap);
}

.tabs-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 2px solid rgba(0,0,0,0.1);
  margin-bottom: 24px;
}

.dark-mode .tabs-nav {
  border-bottom-color: rgba(255,255,255,0.2);
}

.tab-radio {
  display: none;
}

.tab-label {
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-btn) var(--radius-btn) 0 0;
  transition: background-color var(--transition-fast);
  user-select: none;
}

.tab-label:hover {
  background-color: rgba(0,0,0,0.05);
}

.dark-mode .tab-label:hover {
  background-color: rgba(255,255,255,0.05);
}

.tab-radio:checked + .tab-label {
  background-color: var(--color-bg-paper);
  border: 2px solid var(--color-border);
  border-bottom-color: var(--color-bg-paper);
  margin-bottom: -2px;
  color: var(--color-brand);
}

.dark-mode .tab-radio:checked + .tab-label {
  background-color: #1E234A;
  border-color: var(--color-white);
  border-bottom-color: #1E234A;
  color: var(--color-accent);
}

.tab-content {
  display: none;
  background-color: var(--color-bg-paper);
  border: 2px solid var(--color-border);
  border-radius: 0 var(--radius-card) var(--radius-card) var(--radius-card);
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

.dark-mode .tab-content {
  background-color: #1E234A;
  border-color: var(--color-white);
}

.tab-radio:checked + .tab-label + .tab-content {
  display: block;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  margin-top: var(--gap);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-bg-paper);
}

.dark-mode table {
  background-color: #1E234A;
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.dark-mode th, .dark-mode td {
  border-bottom-color: rgba(255,255,255,0.1);
}

th {
  font-weight: 700;
  background-color: rgba(0,0,0,0.03);
}

.dark-mode th {
  background-color: rgba(255,255,255,0.05);
}

tr:last-child td {
  border-bottom: none;
}

/* --- FAQ (Details/Summary) --- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

details {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
  background-color: var(--color-bg-paper);
}

.dark-mode details {
  background-color: #1E234A;
  border-color: var(--color-white);
}

summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 400;
  transition: transform 0.2s;
}

details[open] summary::after {
  transform: rotate(45deg);
}

details p {
  margin-top: 16px;
  margin-bottom: 0;
  color: var(--color-text-body);
}

.dark-mode details p {
  color: var(--color-white);
}

/* --- Footer --- */
.site-footer {
  background-color: var(--color-bg-dark);
  color: var(--color-white);
  padding: 48px 0;
  margin-top: var(--section-y);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-link {
  opacity: 0.8;
  transition: opacity 0.2s;
}

.footer-link:hover {
  opacity: 1;
}

/* --- SVG Animations --- */
@keyframes drawPath {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes flowDot {
  0% { offset-distance: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(-10px); opacity: 1; }
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

.svg-flow-dot {
  fill: var(--color-accent);
  animation: flowDot 4s linear infinite;
  offset-path: path('M 100 200 Q 150 150 200 200 T 300 200'); /* Example path */
}

.svg-float {
  animation: floatBubble 6s ease-in-out infinite;
}

.svg-pulse {
  animation: pulseOpacity 3s ease-in-out infinite;
}

/* Path drawing utility */
.draw-path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawPath 2s ease forwards;
}

/* 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;
  }
  .svg-flow-dot, .svg-float, .svg-pulse {
    animation: none;
  }
}

/* Focus Visible */
*:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.dark-mode *:focus-visible {
  outline-color: var(--color-accent);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .nav-links {
    display: none; /* Simple mobile hide for now, could be burger menu */
  }
  
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  
  h1 {
    font-size: clamp(2rem, 8vw, 3rem);
  }
  
  .tabs-nav {
    flex-direction: column;
  }
  
  .tab-label {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-btn);
    margin-bottom: 8px;
  }
  
  .tab-radio:checked + .tab-label {
    border-radius: var(--radius-btn);
    margin-bottom: 8px;
  }
  
  .tab-content {
    border-radius: var(--radius-card);
    margin-top: -2px;
  }
}

