/* =========================================
   SafeW Global Styles
   Design System & Tokens
   ========================================= */

:root {
  /* Color Palette */
  --color-dark-bg: #140E25;
  --color-paper-bg: #F5F0E5;
  --color-text-main: #191523;
  --color-brand: #5214EB;
  --color-accent: #C8ED6E;

  /* Structural Tokens */
  --radius-card: 8px;
  --radius-btn: 6px;
  
  --card-border: 1px solid rgba(25, 21, 35, 0.16);
  --card-shadow: none;

  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;

  /* Typography Scale */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --h1-size: clamp(2rem, 4.6vw, 3.4rem);
  --h2-size: clamp(1.6rem, 3vw, 2.4rem);
  --body-size: 16px;
}

/* =========================================
   Base Reset & Typography
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--body-size);
  line-height: 1.75;
  color: var(--color-text-main);
  background-color: var(--color-paper-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  padding-left: 0;
  list-style: none;
}

/* =========================================
   Layout & Containers
   ========================================= */
.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);
}

/* Face Variants */
.face-dark {
  background-color: var(--color-dark-bg);
  color: var(--color-paper-bg);
}

.face-dark .hl {
  color: var(--color-accent);
}

.face-dark a:not(.btn) {
  color: var(--color-accent);
  text-decoration: underline;
}

.face-light {
  background-color: var(--color-paper-bg);
  color: var(--color-text-main);
}

.face-light .hl {
  color: var(--color-brand);
}

.face-light a:not(.btn) {
  color: var(--color-brand);
  text-decoration: underline;
}

/* Card Component */
.card {
  background: #fff; /* Paper cards inside dark faces use white/light bg */
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 24px;
  transition: transform 0.2s ease;
}

.face-dark .card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--color-paper-bg);
}

/* =========================================
   Typography Components
   ========================================= */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 16px;
  opacity: 0.8;
}

.face-light .section-label { color: var(--color-brand); }
.face-dark .section-label { color: var(--color-accent); }

h1 {
  font-size: var(--h1-size);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 24px 0;
}

h2 {
  font-size: var(--h2-size);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--gap) 0;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 16px 0;
}

p {
  margin: 0 0 16px 0;
  max-width: 38em;
}

.hl {
  font-weight: 700;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background-color: var(--color-brand);
  color: #fff;
}

.face-dark .btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark-bg);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-primary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-outline {
  background: transparent;
  border: 1px solid currentColor;
  color: currentColor;
}

.btn-outline:hover {
  background: rgba(0,0,0,0.05);
}

.face-dark .btn-outline {
  border-color: var(--color-paper-bg);
  color: var(--color-paper-bg);
}

.face-dark .btn-outline:hover {
  background: rgba(255,255,255,0.1);
}

/* =========================================
   Header & Footer
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 240, 229, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 16px 0;
}

.face-dark .site-header {
  background: rgba(20, 14, 37, 0.9);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.nav-link:hover { opacity: 1; }
.nav-link[aria-current="page"] { opacity: 1; font-weight: 700; color: var(--color-brand); }
.face-dark .nav-link[aria-current="page"] { color: var(--color-accent); }

.site-footer {
  padding: 64px 0;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-size: 0.9rem;
  opacity: 0.8;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 48px;
}

.footer-col h4 {
  font-weight: 700;
  margin-bottom: 16px;
}

.footer-col ul li { margin-bottom: 8px; }

/* =========================================
   Feature Tabs (Pure CSS)
   ========================================= */
.tabs-wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tab-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.tab-nav input[type="radio"] {
  display: none;
}

.tab-nav label {
  padding: 10px 20px;
  background: rgba(0,0,0,0.05);
  border-radius: var(--radius-btn);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
  transition: all 0.2s;
}

.face-dark .tab-nav label {
  background: rgba(255,255,255,0.05);
  color: var(--color-paper-bg);
}

.tab-nav input:checked + label {
  background: var(--color-brand);
  color: #fff;
}

.face-dark .tab-nav input:checked + label {
  background: var(--color-accent);
  color: var(--color-dark-bg);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-panel.active {
  display: block;
}

/* =========================================
   Process Flow (Horizontal)
   ========================================= */
.flow-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

.flow-step {
  flex: 1;
  min-width: 200px;
  text-align: center;
  padding: 24px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-card);
  position: relative;
}

.flow-arrow {
  font-size: 1.5rem;
  opacity: 0.5;
}

/* =========================================
   Timeline (Vertical Steps)
   ========================================= */
.timeline {
  position: relative;
  padding-left: 32px;
  border-left: 2px solid rgba(255,255,255,0.1);
}

.face-light .timeline {
  border-left-color: rgba(0,0,0,0.1);
}

.timeline-item {
  position: relative;
  margin-bottom: 48px;
}

.timeline-item:last-child { margin-bottom: 0; }

.timeline-marker {
  position: absolute;
  left: -41px;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--color-accent);
  color: var(--color-dark-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

/* =========================================
   News Grid
   ========================================= */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
}

.news-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.news-date {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-bottom: 8px;
  display: block;
}

/* =========================================
   Table
   ========================================= */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.face-dark th, .face-dark td {
  border-bottom-color: rgba(255,255,255,0.1);
}

th {
  font-weight: 700;
  background: rgba(0,0,0,0.02);
}

/* =========================================
   FAQ Details
   ========================================= */
details {
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding: 16px 0;
}

.face-dark details {
  border-bottom-color: rgba(255,255,255,0.1);
}

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.2rem;
  font-weight: 300;
}

details[open] summary::after { content: "-"; }

details p {
  margin-top: 16px;
  opacity: 0.9;
}

/* =========================================
   SVG Animations
   ========================================= */
@keyframes orbitRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.svg-orbit {
  transform-origin: center;
  animation: orbitRotate linear infinite;
}

.svg-pulse {
  animation: pulseOpacity ease-in-out infinite;
}

.svg-float {
  animation: floatY ease-in-out infinite;
}

/* Animation Durations */
.d-slow { animation-duration: 20s; }
.d-med { animation-duration: 12s; }
.d-fast { animation-duration: 6s; }

/* 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 Utilities */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; gap: 16px; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .flow-container { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); margin: 16px 0; }
}
