/* =========================================
   SafeW Global Styles & Design System
   ========================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colors */
  --color-dark: #251943;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #ED6E89;

  /* Layout & Spacing */
  --content-max: 1120px;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  
  /* Components */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(25, 21, 35, 0.3);
  
  /* Typography */
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --lh-tight: 1.15;
  --lh-body: 1.55;
}

html {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--color-text);
  background-color: var(--color-paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Layout Containers --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-block: var(--section-y);
  position: relative;
}

.section-dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}

.section-paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}

/* Alternating section dividers */
.section:not(:last-child)::after {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  background-color: currentColor;
  opacity: 0.15;
  margin-top: var(--section-y);
}

.section-dark::after {
  background-color: var(--color-paper);
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  margin-bottom: calc(var(--gap) * 1.5);
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  margin-bottom: var(--gap);
}

p {
  margin-bottom: var(--gap);
  max-width: 38em;
}

.subtitle {
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  opacity: 0.9;
  margin-bottom: calc(var(--gap) * 1.5);
  line-height: 1.4;
}

/* Highlighted keywords */
.hl {
  color: var(--color-brand);
}
.section-dark .hl {
  color: var(--color-accent);
}

/* --- Header & Nav --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(219, 212, 237, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
  padding-block: 16px;
}

.section-dark ~ .header,
.header.header-dark {
  background-color: rgba(37, 25, 67, 0.95);
  border-bottom: 1px solid rgba(219, 212, 237, 0.1);
  color: var(--color-paper);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo img {
  height: 32px;
  width: auto;
}

.nav-list {
  display: flex;
  gap: var(--gap);
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 12px;
  transition: opacity 0.2s;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  opacity: 0.7;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s;
  border: none;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(237, 110, 137, 0.4);
}

.btn-secondary {
  background-color: transparent;
  border: 2px solid currentColor;
  color: inherit;
}

.btn-secondary:hover {
  background-color: rgba(128, 128, 128, 0.1);
  transform: translateY(-2px);
}

/* --- Cards & Panels --- */
.card {
  background-color: #fff;
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--gap);
  border-radius: var(--radius-card);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 14px 32px -12px rgba(25, 21, 35, 0.35);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid currentColor;
  border-radius: var(--radius-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 16px;
  border-bottom: 1px solid currentColor;
}

th {
  font-weight: 700;
  background-color: rgba(128, 128, 128, 0.1);
}

tr:last-child td {
  border-bottom: none;
}

/* --- FAQ --- */
.faq-item {
  border-bottom: 1px solid currentColor;
}

.faq-item summary {
  padding: 16px 0;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: 300;
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  margin-top: var(--gap);
  opacity: 0.9;
}

/* --- Feature Tabs (No JS fallback handled by HTML structure) --- */
.tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin-bottom: var(--gap);
  border-bottom: 1px solid currentColor;
}

.tab-trigger {
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 1rem;
  font-weight: 700;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  position: relative;
}

.tab-trigger[aria-selected="true"] {
  opacity: 1;
}

.tab-trigger[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: currentColor;
}

.tab-panel {
  display: none;
}

.tab-panel[aria-hidden="false"] {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Timeline --- */
.timeline {
  border-left: 2px solid currentColor;
  padding-left: var(--gap);
  margin-left: var(--gap);
}

.timeline-step {
  position: relative;
  margin-bottom: var(--gap);
  padding-bottom: var(--gap);
  border-bottom: 1px dashed currentColor;
}

.timeline-step:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.timeline-step::before {
  content: attr(data-step);
  position: absolute;
  left: calc(var(--gap) * -1 - 20px);
  top: 0;
  width: 32px;
  height: 32px;
  background-color: var(--color-accent);
  color: var(--color-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn);
}

/* --- SVG Animations --- */
.svg-flow {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: flowDash 3s linear infinite;
}

@keyframes flowDash {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.svg-dot-move {
  animation: dotMove 4s ease-in-out infinite alternate;
}

@keyframes dotMove {
  0% { transform: translateX(-5px); }
  100% { transform: translateX(5px); }
}

/* Accessibility: 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;
  }
  
  .tab-panel {
    display: block;
  }
}

/* Responsive Utilities */
@media (max-width: 768px) {
  .nav-list {
    display: none; /* Simplify header for mobile, or use hamburger if JS allowed. Keeping simple here. */
  }
  
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}

.grid-2-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

@media (max-width: 900px) {
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}
