/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

/* --- Variables --- */
:root {
  /* Colors */
  --color-dark-bg: #271334;
  --color-paper: #E9E8EA;
  --color-text-body: #1D1523;
  --color-brand: #8A13DD;
  --color-accent: #9EED6E;
  
  /* Derived for specific contexts */
  --color-text-on-dark: var(--color-paper);
  --color-accent-on-dark: var(--color-accent);
  
  /* Spacing & Layout */
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1280px;
  
  /* Radius */
  --radius-card: 20px;
  --radius-btn: 12px;
  
  /* Typography */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "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-family);
  background-color: var(--color-paper);
  color: var(--color-text-body);
  line-height: 1.55;
  font-size: 16px;
  -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 --- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  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);
  position: relative;
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  margin-bottom: calc(var(--gap) * 0.5);
}

p {
  margin-bottom: var(--gap);
  max-width: 38em;
}

/* Highlighted text */
.hl {
  color: var(--color-brand);
}

.dark-mode .hl {
  color: var(--color-accent);
}

/* Eyebrow / Label */
.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.5em;
  color: var(--color-brand);
}

.dark-mode .eyebrow {
  color: var(--color-accent);
}

/* --- Layout Container --- */
.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);
  position: relative;
}

/* Alternating Backgrounds */
.section-dark {
  background-color: var(--color-dark-bg);
  color: var(--color-text-on-dark);
}

.section-paper {
  background-color: var(--color-paper);
  color: var(--color-text-body);
}

/* Dividers */
.divider {
  height: 1px;
  background-color: rgba(0,0,0,0.1);
  margin: 0;
  border: none;
}

.section-dark .divider {
  background-color: rgba(255,255,255,0.1);
}

/* --- Components: Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
  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-bg);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--color-text-body);
  color: var(--color-text-body);
}

.dark-mode .btn-secondary {
  border-color: var(--color-text-on-dark);
  color: var(--color-text-on-dark);
}

.btn-secondary:hover {
  background-color: rgba(0,0,0,0.05);
}

.dark-mode .btn-secondary:hover {
  background-color: rgba(255,255,255,0.1);
}

/* --- Components: Cards --- */
.card {
  background-color: rgba(0,0,0,0.02); /* Slightly darker than paper */
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform 0.2s ease;
}

.section-dark .card {
  background-color: rgba(255,255,255,0.05); /* Slightly lighter than dark bg */
}

.card:hover {
  transform: translateY(-4px);
}

/* --- Components: Tables --- */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
  border-radius: var(--radius-card);
  background: rgba(0,0,0,0.02);
  padding: 1px; /* For border effect if needed, or just spacing */
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

.table-wrapper th, .table-wrapper td {
  text-align: left;
  padding: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.table-wrapper th {
  font-weight: 700;
  color: var(--color-brand);
}

.section-dark .table-wrapper th {
  color: var(--color-accent);
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

/* --- Components: FAQ (Details/Summary) --- */
details {
  margin-bottom: var(--gap);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: var(--gap);
}

summary {
  font-weight: 600;
  font-size: 1.1rem;
  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.5rem;
  font-weight: 400;
  transition: transform 0.2s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

details p {
  margin-top: var(--gap);
  color: inherit;
  opacity: 0.9;
}

/* --- Header & Nav --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(233, 232, 234, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.section-dark ~ .header {
  background-color: rgba(39, 19, 52, 0.9);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
}

.logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.nav-links a:hover, .nav-links a[aria-current="page"] {
  opacity: 1;
  color: var(--color-brand);
}

.section-dark .nav-links a {
  color: var(--color-text-on-dark);
}

.section-dark .nav-links a:hover, 
.section-dark .nav-links a[aria-current="page"] {
  color: var(--color-accent);
}

/* --- Footer --- */
.footer {
  background-color: var(--color-dark-bg);
  color: var(--color-paper);
  padding: 48px 0;
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
}

.footer-col h4 {
  margin-bottom: 16px;
  color: var(--color-accent);
}

.footer-col ul li {
  margin-bottom: 8px;
}

.footer-col a:hover {
  text-decoration: underline;
}

.footer-bottom {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  opacity: 0.6;
}

/* --- SVG Animation Classes --- */
/* Star flicker */
@keyframes star-flicker {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.star {
  animation: star-flicker 3s infinite ease-in-out;
}

.star:nth-child(odd) {
  animation-delay: 1s;
  animation-duration: 4s;
}

/* Line draw */
@keyframes line-flow {
  to { stroke-dashoffset: -100; }
}

.flow-line {
  stroke-dasharray: 10 10;
  animation: line-flow 1s linear infinite;
}

/* Float */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.float-anim {
  animation: float 6s ease-in-out infinite;
}

/* Bubble pop */
@keyframes bubble-pop {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

.bubble-pop {
  animation: bubble-pop 4s ease-in-out 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) {
  .nav-links {
    display: none; /* Simplified for mobile, usually needs a hamburger, keeping simple here */
  }
  
  .grid-2-col {
    grid-template-columns: 1fr;
  }
  
  .alt-row {
    flex-direction: column-reverse;
  }
}

.grid-2-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.alt-row {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.text-right-mobile {
  text-align: right;
}

@media (max-width: 768px) {
  .text-right-mobile {
    text-align: left;
  }
}
