/* 
 * SafeW Global Styles
 * Design Token & Base System
 */

:root {
  /* Colors - Palette */
  --color-bg-dark: #140E25;
  --color-bg-paper: #F5F0E5;
  --color-text-main: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;
  
  /* Derived UI Colors */
  --color-border-light: rgba(25, 21, 35, 0.1);
  --color-overlay: rgba(20, 14, 37, 0.85);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --text-base: 1rem;
  --text-sm: 0.875rem;
  --text-lg: 1.125rem;
  --h1-size: clamp(2rem, 4.6vw, 3.4rem);
  --h2-size: clamp(1.6rem, 3vw, 2.4rem);
  --h3-size: 1.25rem;

  /* Spacing & Layout */
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;
  --radius-card: 8px;
  --radius-btn: 6px;
  --header-height: 64px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text-main);
  background-color: var(--color-bg-paper);
  -webkit-font-smoothing: antialiased;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding: var(--section-y) 0;
}

.bg-dark {
  background-color: var(--color-bg-dark);
  color: var(--color-bg-paper);
}

.bg-paper {
  background-color: var(--color-bg-paper);
  color: var(--color-text-main);
}

.text-accent {
  color: var(--color-accent);
}

.text-brand {
  color: var(--color-brand);
}

/* Typography Components */
.label-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--gap);
  padding: 4px 8px;
  border-radius: 4px;
}

.bg-paper .label-tag {
  color: var(--color-brand);
  background: rgba(82, 20, 235, 0.1);
}

.bg-dark .label-tag {
  color: var(--color-accent);
  background: rgba(200, 237, 110, 0.15);
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}

h1 {
  font-size: var(--h1-size);
  margin-bottom: var(--gap);
}

h2 {
  font-size: var(--h2-size);
  margin-bottom: calc(var(--gap) * 1.5);
}

h3 {
  font-size: var(--h3-size);
  margin-bottom: var(--gap);
}

p {
  margin-bottom: var(--gap);
  max-width: 38em;
}

/* 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: var(--text-base);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  border: none;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(200, 237, 110, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text-main);
  border: 1px solid var(--color-text-main);
}

.bg-dark .btn-secondary {
  color: var(--color-bg-paper);
  border-color: var(--color-bg-paper);
}

.btn-secondary:hover {
  background-color: rgba(25, 21, 35, 0.05);
}

.bg-dark .btn-secondary:hover {
  background-color: rgba(245, 240, 229, 0.1);
}

.btn-icon {
  margin-right: 8px;
  width: 20px;
  height: 20px;
}

/* Header & Nav */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg-paper);
  border-bottom: 1px solid var(--color-border-light);
  height: var(--header-height);
}

.bg-dark .header {
  background-color: var(--color-bg-dark);
  border-bottom-color: rgba(245, 240, 229, 0.1);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
}

.logo img {
  height: 32px;
  width: auto;
}

.nav-list {
  display: flex;
  gap: var(--gap);
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.nav-link:hover, .nav-link[aria-current="page"] {
  opacity: 1;
  color: var(--color-brand);
}

.bg-dark .nav-link:hover, .bg-dark .nav-link[aria-current="page"] {
  color: var(--color-accent);
}

@media (max-width: 768px) {
  .nav-list {
    display: none; /* Simplified for mobile view in this task */
  }
}

/* Footer */
.footer {
  background-color: var(--color-bg-dark);
  color: var(--color-bg-paper);
  padding: var(--section-y) 0;
  border-top: 1px solid rgba(245, 240, 229, 0.1);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--section-y);
}

.footer-col h4 {
  color: var(--color-accent);
  margin-bottom: var(--gap);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-col ul li {
  margin-bottom: 8px;
}

.footer-col a {
  opacity: 0.7;
  font-size: var(--text-sm);
}

.footer-col a:hover {
  opacity: 1;
  text-decoration: underline;
}

.copyright {
  margin-top: var(--section-y);
  text-align: center;
  font-size: var(--text-sm);
  opacity: 0.5;
  border-top: 1px solid rgba(245, 240, 229, 0.1);
  padding-top: var(--gap);
}

/* Cards */
.card {
  background-color: var(--color-bg-paper);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow, 0 10px 28px -14px rgba(25, 21, 35, 0.3));
  padding: var(--gap);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
}

th {
  background-color: rgba(25, 21, 35, 0.05);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

/* FAQ Details */
details {
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-card);
  margin-bottom: var(--gap);
  padding: var(--gap);
  transition: background-color 0.2s;
}

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.25rem;
  font-weight: 300;
}

details[open] summary::after {
  content: "-";
}

details p {
  margin-top: var(--gap);
  font-size: var(--text-sm);
  opacity: 0.9;
}

/* Tabs (CSS Only) */
.tab-radio {
  display: none;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--gap);
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--gap);
}

.tab-label {
  padding: 8px 16px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-weight: 500;
  font-size: var(--text-sm);
  transition: all 0.2s;
  border: 1px solid transparent;
}

.tab-label:hover {
  background-color: rgba(25, 21, 35, 0.05);
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

/* Tab Logic */
#tab-1:checked ~ .tab-nav label[for="tab-1"],
#tab-2:checked ~ .tab-nav label[for="tab-2"],
#tab-3:checked ~ .tab-nav label[for="tab-3"],
#tab-4:checked ~ .tab-nav label[for="tab-4"] {
  background-color: var(--color-brand);
  color: white;
}

#tab-1:checked ~ .tab-panel .panel-1,
#tab-2:checked ~ .tab-panel .panel-2,
#tab-3:checked ~ .tab-panel .panel-3,
#tab-4:checked ~ .tab-panel .panel-4 {
  display: block;
}

/* Steps */
.step-row {
  display: flex;
  gap: var(--gap);
  counter-reset: step-counter;
}

.step-item {
  flex: 1;
  position: relative;
  padding-top: 40px;
}

.step-item::before {
  counter-increment: step-counter;
  content: "0" counter(step-counter);
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  font-weight: 700;
  font-size: var(--text-sm);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* News Grid */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
}

.news-card {
  background-color: rgba(245, 240, 229, 0.05);
  border: 1px solid rgba(245, 240, 229, 0.1);
  padding: var(--gap);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.news-date {
  font-size: var(--text-sm);
  opacity: 0.6;
  margin-bottom: 8px;
}

.news-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-accent);
}

.news-excerpt {
  font-size: var(--text-sm);
  opacity: 0.8;
  flex-grow: 1;
}

/* Workflow Flow */
.flow-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  overflow-x: auto;
  padding-bottom: 8px;
}

.flow-node {
  flex: 1;
  min-width: 200px;
  background-color: rgba(25, 21, 35, 0.05);
  padding: var(--gap);
  border-radius: var(--radius-card);
  text-align: center;
  position: relative;
}

.flow-arrow {
  flex-shrink: 0;
  opacity: 0.3;
}

/* SVG Animation Classes */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

@keyframes dash {
  to { stroke-dashoffset: 0; }
}

.animate-float-1 { animation: float 6s ease-in-out infinite; }
.animate-float-2 { animation: float 7s ease-in-out infinite 1s; }
.animate-breathe { animation: breathe 3s ease-in-out infinite; }
.animate-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: dash 2s ease forwards; }

svg path.animate-draw {
  pathLength: 1;
}

@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;
  }
  .animate-float-1, .animate-float-2, .animate-breathe {
    animation: none;
    transform: none;
  }
}

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.bg-dark :focus-visible {
  outline-color: var(--color-accent);
}
