/* ==========================================================================
   IndrasNet OÜ — style.css
   A clean, auditable, DevOps/AISecOps aesthetic:
   - Accessibility-first (WCAG AA contrast)
   - Responsive grid & print styles
   - Strong typographic system
   - Utility classes for quick layout and emphasis
   - Tables, cards, badges, alerts for reports
   - Navigation + “back/next” buttons
   - Subtle animations (prefers-reduced-motion respected)
   - Dark mode via @media (prefers-color-scheme: dark)
   ========================================================================== */

/* Root tokens: colors, spacing, type scale */
:root {
  /* Brand palette */
  --brand-ink: #0a1a2b;        /* Deep navy */
  --brand-accent: #2d7ff9;     /* Ops blue */
  --brand-accent-2: #22c1c3;   /* Teal */

  /* Neutral palette */
  --bg: #eef2f7;               /* Background (light) */
  --bg-elev: #f9fbfe;          /* Elevated surfaces */
  --ink: #111827;              /* Body text */
  --muted: #5b6573;            /* Secondary text */
  --border: #d2d9e3;           /* Borders */

  /* Status colors */
  --ok: #14b8a6;               /* Success */
  --warn: #f59e0b;             /* Warning */
  --err: #e11d48;              /* Error */
  --info: #2d7ff9;             /* Info */

  /* Semantic highlights */
  --sec-blue-100: #e8f1ff;
  --sec-blue-200: #cfe3ff;
  --sec-blue-300: #a9c7ff;

  /* Shadows & radii */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 36px rgba(16, 24, 40, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Spacing scale (px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --fs-0: 14px;   /* Small */
  --fs-1: 16px;   /* Base */
  --fs-2: 18px;   /* Lead */
  --fs-3: 22px;   /* H3 */
  --fs-4: 26px;   /* H2 */
  --fs-5: 32px;   /* H1 */
}

/* Dark mode tokens */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1017;
    --bg-elev: #0f1621;
    --ink: #d8e0ea;
    --muted: #9aa5b1;
    --border: #1b2a3a;

    --brand-ink: #c7d2fe;
    --brand-accent: #5a9bff;
    --brand-accent-2: #22c1c3;

    --sec-blue-100: #101a2a;
    --sec-blue-200: #132037;
    --sec-blue-300: #1a2b4c;

    /* Shadows disabled in dark mode */
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }

  header,
  footer {
    background: linear-gradient(90deg, #0b111a 0%, #122033 35%, #1a2c4d 70%, #0a1a2b 100%);
  }
}

/* Base reset & document */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
}
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #e8eef7 0%, var(--bg) 35%, var(--bg) 100%);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-1);
  line-height: 1.6;
}

/* Reserve space for async header/footer fragments to reduce CLS */
#header { min-height: 200px; }
#footer { min-height: 160px; }

/* Accessible focus */
:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
/* Header & top nav */
header {
  background: linear-gradient(90deg, #eef2f7 0%, #cfd9e8 28%, #5473a6 62%, #0a1a2b 100%);
  color: #fff;
  padding: var(--space-7) var(--space-5) var(--space-5);
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
}
header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 18, 36, 0.55), rgba(8, 18, 36, 0.7));
  pointer-events: none;
}
header > * { position: relative; }

header h1 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-5);
  letter-spacing: 0.4px;
}

header p {
  margin: 0 0 var(--space-4);
  color: #e7efff;
}

/* Navigation list */
header nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}

header nav li { margin: 0; }

/* Navigation links */
header nav a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

header nav a:hover { background: rgba(255, 255, 255, 0.14); }
header nav a.active { background: var(--brand-accent); color: #fff; }

/* Main container */
main {
  flex: 1;
  max-width: 1000px;
  margin: var(--space-7) auto;
  background: var(--bg-elev);
  background-image:
    radial-gradient(1200px 400px at 10% -10%, rgba(42, 113, 255, 0.08), transparent 60%),
    radial-gradient(900px 300px at 100% 0%, rgba(34, 193, 195, 0.06), transparent 55%);
  background-repeat: no-repeat;
  padding: var(--space-7) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* Sections */
section { margin-bottom: var(--space-7); }
section h2 {
  font-size: var(--fs-4);
  color: var(--brand-ink);
  border-bottom: 2px solid var(--sec-blue-200);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
}
section h3 {
  font-size: var(--fs-3);
  color: var(--brand-accent);
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}
p.lead { font-size: var(--fs-2); color: var(--muted); }

/* Lists */
ul { margin: var(--space-3) 0 var(--space-5); padding-left: var(--space-6); }
ul li { margin-bottom: var(--space-2); }

/* Tables — Horizon Europe friendly */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table thead th {
  background: var(--sec-blue-100);
  color: var(--brand-ink);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
table tbody tr:hover { background: rgba(42, 113, 255, 0.06); }

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
}
.card h3 { margin-top: 0; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-4);
}
.card-grid .card { grid-column: span 6; }
@media (max-width: 800px) {
  .card-grid .card { grid-column: span 12; }
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-0);
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--sec-blue-100);
  color: var(--brand-ink);
}
.badge.success { background: #e9f7ef; color: var(--ok); border-color: #d1f2e6; }
.badge.warn    { background: #fff7e6; color: var(--warn); border-color: #ffecbf; }
.badge.error   { background: #fdecea; color: var(--err); border-color: #f7c5c0; }
.badge.info    { background: #e6f0ff; color: var(--info); border-color: #cfe0ff; }

/* Alerts */
.alert {
  border-left: 6px solid var(--info);
  background: #eef5ff;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  margin: var(--space-5) 0;
}
.alert.success { border-left-color: var(--ok); background: #eefaf3; }
.alert.warn    { border-left-color: var(--warn); background: #fff8ec; }
.alert.error   { border-left-color: var(--err); background: #fff1f0; }

/* Navigation buttons (bottom) */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  max-width: 1000px;
  margin: 0 auto var(--space-7);
  padding: 0 var(--space-6);
}
.nav-buttons a {
  display: inline-block;
  background: #0a1a2b;
  border: 1px solid #1c3656;
  color: #fff;
  padding: 10px 16px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.nav-buttons a:hover {
  background: #091524;
}
.nav-buttons a.secondary {
  background: var(--brand-ink);
}

/* Footer */
footer {
  margin-top: auto; 
  background: linear-gradient(90deg, #eef2f7 0%, #cfd9e8 28%, #5473a6 62%, #0a1a2b 100%);
  color: #e6f0ff;
  text-align: center;
  padding: var(--space-6) var(--space-5);
  border-top: 1px solid var(--border);
  position: relative;
}
footer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 18, 36, 0.55), rgba(8, 18, 36, 0.7));
  pointer-events: none;
}
footer > * { position: relative; }
footer a { color: #cfe0ff; text-decoration: underline; }
footer p { margin: 6px 0; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}
.footer-links a {
  color: #e7efff;
  text-decoration: none;
  font-weight: 600;
}
.footer-links a:hover { text-decoration: underline; }
.footer-sep {
  color: rgba(231, 239, 255, 0.6);
}

/* Code & preformatted blocks */
code, pre, .mono {
  font-family: var(--font-mono);
}
pre {
  background: var(--sec-blue-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
}

/* Utilities: containers, spacing, text */
.container { max-width: 1000px; margin: 0 auto; padding: 0 var(--space-6); }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mt-6 { margin-top: var(--space-6) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }
.mb-6 { margin-bottom: var(--space-6) !important; }
.text-muted { color: var(--muted) !important; }
.text-center { text-align: center !important; }

/* Accessibility helpers */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* Print styles: clean report */
@media print {
  header, .nav-buttons, footer { display: none !important; }
  main {
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
    background: #fff;
    color: #000;
  }
  section h2 { border-bottom: 2px solid #000; color: #000; }
  a { color: #000; text-decoration: underline; }
}

/* Motion safety */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

/* Responsive tweaks */
@media (max-width: 600px) {
  header { padding: var(--space-6) var(--space-4); }
  header nav { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
  main { margin: var(--space-6) var(--space-2); padding: var(--space-6) var(--space-4); }
  .nav-buttons { padding: 0 var(--space-4); }
  #header { min-height: 180px; }
  #footer { min-height: 140px; }
  table thead { display: none; }
  table, table tbody, table tr, table td {
    display: block;
    width: 100%;
  }
  table tr { margin-bottom: var(--space-3); }
  table td { border: none; padding: var(--space-2) 0; }
  table td::before {
    content: attr(data-label);
    font-weight: 700;
    display: block;
    color: var(--muted);
    margin-bottom: 4px;
  }
}

/* Optional: AI/DevOps visual cues (labels, tags) */
.label {
  display: inline-block;
  font-size: var(--fs-0);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--muted);
}
.label.sec { color: var(--brand-accent-2); border-color: var(--brand-accent-2); }
.label.audit { color: var(--brand-accent); border-color: var(--brand-accent); }

/* Anchor hover underline for clarity */
a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* Health check: style for /healthz endpoint */
.healthz {
  font-family: var(--font-mono);
  font-size: var(--fs-2);
  color: var(--ok);
  padding: var(--space-6);
  text-align: center;
}
