/* =========================================
   SafeW Global Styles (style.css)
   ========================================= */

/* --- Design Tokens & Variables --- */
:root {
  /* Colors */
  --color-dark-bg: #19102D;
  --color-paper: #F4F3F7;
  --color-text-body: #191523;
  --color-brand: #5214EB;
  --color-accent: #D66EED;
  
  /* Derived for specific contexts to ensure contrast without creating new gray tones */
  --color-text-on-dark: #F4F3F7;
  --color-link-light: #5214EB;
  --color-link-dark: #D66EED;
  --color-border-subtle: rgba(25, 21, 35, 0.1);
  --color-border-dark-subtle: rgba(244, 243, 247, 0.1);

  /* Spacing & Layout */
  --content-max: 1280px;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --header-height: 72px;

  /* Radius & Borders */
  --radius-card: 0;
  --radius-btn: 0;
  --card-border: 0;
  --card-shadow: none;
  
  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --h1-size: clamp(2rem, 4.6vw, 3.4rem);
  --h2-size: clamp(1.6rem, 3vw, 2.4rem);
  --body-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  background-color: var(--color-paper);
  color: var(--color-text-body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-link-light);
  text-decoration: none;
  transition: opacity 0.2s ease;
}
a:hover {
  opacity: 0.8;
}

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Layout Utilities --- */
.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;
}

.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);
}

/* Divider between sections */
.divider {
  width: 100%;
  height: 1px;
  background-color: var(--color-border-subtle);
}
.section--dark + .section--paper .divider,
.section--paper + .section--dark .divider {
  background-color: var(--color-border-dark-subtle);
}

/* --- Typography Components --- */
.breadcrumb {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  color: var(--color-brand);
}
.section--dark .breadcrumb {
  color: var(--color-accent);
}

h1 {
  font-size: var(--h1-size);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  margin-bottom: 1.5rem;
  color: inherit;
}

h2 {
  font-size: var(--h2-size);
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 1.5rem;
  color: inherit;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: inherit;
}

p {
  font-size: var(--body-size);
  margin-bottom: 1rem;
  max-width: 38em;
}

.highlight {
  color: var(--color-brand);
}
.section--dark .highlight {
  color: var(--color-accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-dark-bg);
  border: none;
}
.btn--primary:hover {
  background-color: #c45de0;
  transform: translateY(-2px);
}

.btn--secondary {
  background-color: transparent;
  color: var(--color-text-body);
  border: 1px solid var(--color-text-body);
}
.section--dark .btn--secondary {
  color: #ffffff;
  border-color: #ffffff;
}
.btn--secondary:hover {
  background-color: rgba(25, 21, 35, 0.05);
  transform: translateY(-2px);
}
.section--dark .btn--secondary:hover {
  background-color: rgba(244, 243, 247, 0.1);
}

/* --- Header & Navigation --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background-color: rgba(244, 243, 247, 0.95);
  backdrop-filter: blur(8px);
  z-index: 1000;
  border-bottom: 1px solid var(--color-border-subtle);
}
.section--dark ~ .header, 
.header--dark {
  background-color: rgba(25, 16, 45, 0.95);
  border-bottom-color: var(--color-border-dark-subtle);
}
/* Fix header bg for hero since hero is also dark */
.hero-section + .header {
  /* If header is above hero, it needs to be dark or transparent. 
     Based on structure, header is always top. Hero is first section.
     Let's make header transparent initially or match hero bg? 
     Standard practice: Header matches page bg or is distinct. 
     Here: Header is paper by default. If hero is dark, we might want header to be dark too or just let it sit on top.
     To keep it simple and accessible: Header stays paper/light unless scrolled over dark content.
     Actually, the prompt says "Header sticky, right side primary button". 
     Let's make header consistent with the current section or always light/dark?
     Prompt: "Header sticky... scrolling adds separator or slight bg".
     I will set header to paper bg. Since Hero is dark, I'll add a class to header if needed, but simpler:
     Make header background match the body (paper). The Hero section will overlap it slightly or the header will just be on top of the dark hero.
     Better: Header background is transparent initially, then becomes solid on scroll? 
     Or just solid paper. Let's stick to solid paper for simplicity and contrast, 
     but since Hero is dark (#19102D), a light header on top might look disjointed.
     Let's make the header background match the Hero background (#19102D) initially?
     No, standard is usually consistent. Let's make header background: var(--color-paper).
     Wait, if Hero is dark, text in header must be visible.
     Let's define header as having its own context.
     Actually, I will make the header background: var(--color-paper). 
     And the Hero section will have a negative margin-top to go behind it, or just standard flow.
     Standard flow: Header covers top 72px. Hero starts below.
     But Hero is full screen often.
     Let's do: Header is fixed. Hero has padding-top: var(--header-height).
     Header bg: var(--color-paper).
     Text in header: var(--color-text-body).
     This works fine.
  */
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text-body);
  text-decoration: none;
}
.logo img {
  width: 32px;
  height: 32px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}
.nav-links a {
  color: var(--color-text-body);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-links a[aria-current="page"],
.nav-links a:hover {
  color: var(--color-brand);
}

/* Mobile Nav Toggle (Simplified for static) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

@media (max-width: 768px) {
  .nav-links {
    display: none; /* Simplified: In a real site, this would toggle */
  }
  .nav-toggle {
    display: block;
  }
  /* For static demo, we assume desktop view or simple mobile stack if JS enabled, 
     but here we just hide links on mobile for simplicity or use a simple stack.
     Let's show them stacked on mobile for accessibility without JS complexity. */
  .nav-links {
    display: flex;
    position: absolute;
    top: var(--header-height);
    left: 0;
    width: 100%;
    flex-direction: column;
    background-color: var(--color-paper);
    padding: 1rem;
    border-bottom: 1px solid var(--color-border-subtle);
    gap: 1rem;
  }
  .nav-container {
    flex-wrap: wrap;
  }
}

/* Logo Image Fix */
.logo img {
  object-fit: contain;
}

/* Text Measure Fix */
p {
  max-width: 40em;
}

/* --- Components: Cards & Panels --- */
.card {
  background-color: rgba(255, 255, 255, 0.6);
  padding: var(--gap);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  border: var(--card-border);
  /* Subtle distinction from bg */
}
.section--dark .card {
  background-color: rgba(244, 243, 247, 0.05);
}

.panel {
  background-color: var(--color-dark-bg);
  padding: var(--gap);
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
}
.panel--light {
  background-color: var(--color-paper);
}

.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);
}

/* --- Component: Table --- */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--body-size);
}
th, td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
}
th {
  font-weight: 700;
  color: var(--color-brand);
}
.section--dark th {
  color: var(--color-accent);
}
td:first-child {
  font-weight: 600;
}

/* --- Component: FAQ --- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.faq-item {
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: 1rem;
}
.faq-item summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--color-brand);
}
.faq-item[open] summary::after {
  content: "-";
}
.faq-item p {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  opacity: 0.9;
}

/* --- Component: Steps & Lists --- */
.step-list {
  counter-reset: step;
  list-style: none;
}
.step-list li {
  position: relative;
  padding-left: 3rem;
  margin-bottom: 2rem;
}
.step-list li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  background-color: var(--color-accent);
  color: var(--color-dark-bg);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn); /* Square per token */
  font-size: 0.9rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--gap);
}
.feature-card {
  background-color: var(--color-paper);
  padding: var(--gap);
  border: 1px solid var(--color-border-subtle);
}
.section--dark .feature-card {
  background-color: rgba(244, 243, 247, 0.05);
  border-color: var(--color-border-dark-subtle);
}

/* --- SVG Animation Classes --- */
.star-blink {
  animation: blink 4s infinite alternate ease-in-out;
}
.star-blink-delayed {
  animation: blink 4s infinite alternate ease-in-out 2s;
}
.line-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 6s infinite linear;
}
.float-element {
  animation: float 6s infinite ease-in-out;
}
.float-element-delayed {
  animation: float 6s infinite ease-in-out 3s;
}

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

@keyframes drawLine {
  0% { stroke-dashoffset: 1; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* 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;
  }
  .line-draw {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* --- News Cards --- */
.news-card {
  background-color: var(--color-paper);
  padding: 1.5rem;
  border: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.section--dark .news-card {
  background-color: rgba(244, 243, 247, 0.05);
  border-color: var(--color-border-dark-subtle);
}
.news-card time {
  font-size: 0.85rem;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
  display: block;
}
.section--dark .news-card time {
  color: var(--color-accent);
}
.news-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}
.news-card p {
  font-size: 0.95rem;
  margin-bottom: 0;
  flex-grow: 1;
}

/* --- Scenario Grid --- */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--gap);
}
.scenario-card {
  background-color: var(--color-paper);
  padding: var(--gap);
  border-left: 4px solid var(--color-brand);
}
.section--dark .scenario-card {
  background-color: rgba(244, 243, 247, 0.05);
  border-left-color: var(--color-accent);
}
.scenario-card ul {
  margin-top: 1rem;
  padding-left: 1.25rem;
}
.scenario-card li {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

/* --- Hero Specific --- */
.hero {
  padding-top: calc(var(--header-height) + var(--section-y));
  padding-bottom: var(--section-y);
  background-color: var(--color-dark-bg);
  color: var(--color-text-on-dark);
  position: relative;
  overflow: hidden;
}
.hero .container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: center;
}
.hero-content {
  max-width: 600px;
}
.hero-stats {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  font-size: 0.9rem;
  opacity: 0.8;
}
.hero-svg-container {
  position: relative;
  height: 400px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

@media (max-width: 900px) {
  .hero .container {
    grid-template-columns: 1fr;
  }
  .hero-svg-container {
    height: 300px;
    order: -1;
  }
}

/* --- Footer --- */
.footer {
  background-color: var(--color-dark-bg);
  color: var(--color-text-on-dark);
  padding: var(--section-y) 0;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--gap);
}
.footer-col h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-accent);
}
.footer-col ul {
  list-style: none;
}
.footer-col li {
  margin-bottom: 0.5rem;
}
.footer-col a {
  color: var(--color-text-on-dark);
  opacity: 0.7;
  font-size: 0.9rem;
}
.footer-col a:hover {
  opacity: 1;
  color: var(--color-accent);
}
.footer-bottom {
  margin-top: var(--section-y);
  padding-top: 2rem;
  border-top: 1px solid var(--color-border-dark-subtle);
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.5;
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}
