/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Color Palette */
  --color-dark: #1B1231;
  --color-paper: #DBD4ED;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #9977EE;
  
  /* Structural 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: 960px;
  
  /* Typography */
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --line-height-base: 1.55;
}

html {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: var(--line-height-base);
  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;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

ul, ol {
  list-style: none;
}

/* --- Layout Containers --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gap);
  padding-right: var(--gap);
}

.section-wrapper {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
  border-bottom: 1px solid rgba(25, 21, 35, 0.15);
}

.section-wrapper:last-of-type {
  border-bottom: none;
}

.dark-surface {
  background-color: var(--color-dark);
  color: var(--color-paper);
}

.dark-surface .container {
  color: var(--color-paper);
}

.dark-surface a:not(.btn) {
  color: var(--color-accent);
}

.dark-surface h1, .dark-surface h2, .dark-surface h3, .dark-surface p {
  color: var(--color-paper);
}

/* --- Typography --- */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-brand);
  margin-bottom: calc(var(--gap) / 2);
}

.dark-surface .section-label {
  color: var(--color-accent);
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  margin-bottom: var(--gap);
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  margin-bottom: var(--gap);
  text-wrap: balance;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: calc(var(--gap) / 1.5);
}

p {
  margin-bottom: var(--gap);
  max-width: 38em;
}

.highlight {
  color: var(--color-brand);
  font-weight: 700;
}

.dark-surface .highlight {
  color: var(--color-accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.5em;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-text);
}

.dark-surface .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.btn-secondary:hover {
  background-color: rgba(25, 21, 35, 0.05);
  transform: translateY(-2px);
}

.dark-surface .btn-secondary:hover {
  background-color: rgba(219, 212, 237, 0.1);
}

.btn-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* --- Cards & Panels --- */
.card {
  background-color: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
}

.dark-surface .card {
  background-color: var(--color-dark);
  border-color: var(--color-paper);
  box-shadow: 4px 4px 0 var(--color-paper);
}

.panel {
  background-color: var(--color-dark);
  border-radius: var(--radius-card);
  padding: calc(var(--gap) * 1.5);
  position: relative;
  overflow: hidden;
}

.dark-surface .panel {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Grid & Flex Utilities --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
}

.text-center {
  text-align: center;
}

/* --- Table --- */
.table-wrapper {
  overflow-x: auto;
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-paper);
}

.dark-surface table {
  background-color: var(--color-dark);
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}

.dark-surface th, .dark-surface td {
  border-bottom-color: rgba(219, 212, 237, 0.15);
}

th {
  font-weight: 700;
  background-color: rgba(25, 21, 35, 0.03);
}

.dark-surface th {
  background-color: rgba(219, 212, 237, 0.05);
}

tr:last-child td {
  border-bottom: none;
}

/* --- Tabs (Features) --- */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: var(--gap);
  flex-wrap: wrap;
}

.tab-btn {
  padding: 0.5em 1em;
  border: 2px solid var(--color-text);
  border-radius: var(--radius-btn);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  transition: all 0.2s ease;
}

.dark-surface .tab-btn {
  border-color: var(--color-paper);
  color: var(--color-paper);
}

.tab-btn[aria-selected="true"] {
  background-color: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}

.dark-surface .tab-btn[aria-selected="true"] {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border-color: var(--color-accent);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Accordion (FAQ) --- */
.faq-item {
  border: var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
  background-color: var(--color-paper);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.dark-surface .faq-item {
  background-color: var(--color-dark);
  border-color: var(--color-paper);
  box-shadow: 4px 4px 0 var(--color-paper);
}

summary {
  padding: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  transition: transform 0.2s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

details[open] summary {
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}

.dark-surface details[open] summary {
  border-bottom-color: rgba(219, 212, 237, 0.15);
}

.faq-content {
  padding: 1.25rem;
  color: var(--color-text);
}

.dark-surface .faq-content {
  color: var(--color-paper);
}

/* --- Header & Footer --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(219, 212, 237, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(25, 21, 35, 0.1);
}

.dark-surface .site-header {
  background-color: rgba(27, 18, 49, 0.9);
  border-bottom-color: rgba(219, 212, 237, 0.15);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.25rem;
}

.logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

nav ul {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

nav a {
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

nav a:hover, nav a[aria-current="page"] {
  opacity: 1;
  color: var(--color-brand);
}

.dark-surface nav a:hover, .dark-surface nav a[aria-current="page"] {
  color: var(--color-accent);
}

.site-footer {
  margin-top: auto;
  padding: var(--section-y) 0;
  border-top: 1px solid rgba(25, 21, 35, 0.1);
}

.dark-surface .site-footer {
  border-top-color: rgba(219, 212, 237, 0.15);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.footer-col ul li {
  margin-bottom: 0.5rem;
}

.footer-col a:hover {
  text-decoration: underline;
}

/* --- SVG Animations --- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes nodeGlow {
  0%, 100% { fill: rgba(153, 119, 238, 0.1); }
  50% { fill: var(--color-accent); }
}

@keyframes dashMove {
  to { stroke-dashoffset: 100; }
}

.hero-svg-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.hero-window {
  animation: float 6s ease-in-out infinite;
}

.hero-device-2 {
  animation: float 7s ease-in-out infinite 1s;
}

.grid-node {
  animation: nodeGlow 4s ease-in-out infinite;
}

.grid-node:nth-child(1) { animation-delay: 0s; }
.grid-node:nth-child(2) { animation-delay: 0.4s; }
.grid-node:nth-child(3) { animation-delay: 0.8s; }
.grid-node:nth-child(4) { animation-delay: 1.2s; }
.grid-node:nth-child(5) { animation-delay: 1.6s; }
.grid-node:nth-child(6) { animation-delay: 2.0s; }
.grid-node:nth-child(7) { animation-delay: 2.4s; }
.grid-node:nth-child(8) { animation-delay: 2.8s; }
.grid-node:nth-child(9) { animation-delay: 3.2s; }

.connection-line {
  stroke-dasharray: 10 5;
  animation: dashMove 2s linear infinite;
}

/* --- 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;
  }
}

/* --- Responsive Tweaks --- */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: row;
  }
  nav ul {
    gap: 1rem;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .hero-layout {
    flex-direction: column-reverse;
  }
}
