:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.92);
  --bg-tldr: rgba(14, 116, 144, 0.14);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-accent: rgba(56, 189, 248, 0.4);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-secondary: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --shadow-lg: 0 0.625rem 1.875rem -0.625rem rgba(0, 0, 0, 0.6);
  --max-width: min(92vw, 88rem);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: clamp(96%, 46% + 0.45vw, 126%);
  line-height: 1.7;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 15% 0%, rgba(56, 189, 248, 0.08), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(129, 140, 248, 0.08), transparent 40%),
    var(--bg-primary);
}

/* Language Toggle Display Logic (Body & Footer) */
html[data-lang="fi"] main .lang-en,
html[data-lang="fi"] .site-footer .lang-en {
  display: none !important;
}
html[data-lang="en"] main .lang-fi,
html[data-lang="en"] .site-footer .lang-fi,
html:not([data-lang="fi"]) main .lang-fi,
html:not([data-lang="fi"]) .site-footer .lang-fi {
  display: none !important;
}

/* Zero-Shift Top Bar: Stack FI & EN in identical grid cell so width/height never move */
html[data-lang="fi"] .site-header .lang-en {
  visibility: hidden !important;
  pointer-events: none !important;
}
html[data-lang="en"] .site-header .lang-fi,
html:not([data-lang="fi"]) .site-header .lang-fi {
  visibility: hidden !important;
  pointer-events: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

code, pre {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.07);
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  color: #e2e8f0;
}

/* Top Navbar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(0.875rem);
  -webkit-backdrop-filter: blur(0.875rem);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.85rem clamp(1rem, 2.5vw, 2rem);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(0.75rem, 1.5vw, 1.5rem);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  text-decoration: none !important;
}

.brand-badge {
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 0.5625rem;
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  box-shadow: 0 0.25rem 0.75rem rgba(2, 132, 199, 0.35);
}

.brand-sub {
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.25rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
}

.brand-sub > span,
.nav-links a > span {
  grid-area: 1 / 1;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  flex-wrap: nowrap;
}

.nav-links a {
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.38rem 0.55rem;
  border-radius: 0.5rem;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-links a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-links a.active {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  font-weight: 600;
}

/* Language Toggle Pill */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.18rem;
  gap: 0.15rem;
}

.lang-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(129, 140, 248, 0.22));
  color: #fff;
  border: 1px solid var(--border-accent);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.25);
}

/* Main Content Container */
main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 2.5vw, 2rem) 4rem;
}

.page-hero {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.page-title {
  font-size: clamp(1.75rem, 3.2vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.6rem;
}

.page-meta {
  font-size: 0.95rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: center;
}

/* TL;DR Summary Box */
.tldr-box {
  background: var(--bg-tldr);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  margin-bottom: 2.25rem;
  box-shadow: var(--shadow-lg);
}

.tldr-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--accent-hover);
  margin-bottom: 0.85rem;
}

.tldr-box ul {
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.tldr-box li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--text-primary);
  font-size: 1.04rem;
}

.tldr-box li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--success);
  font-weight: 800;
}

/* Legal & Content Sections */
.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.doc-card h2 {
  font-size: 1.28rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sec-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.45rem;
  border-radius: 0.4375rem;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
}

.doc-card p {
  color: #d1d5db;
  margin-bottom: 0.85rem;
  font-size: 1.04rem;
}

.doc-card p:last-child {
  margin-bottom: 0;
}

.doc-card ul, .doc-card ol {
  margin: 0.6rem 0 0.9rem 1.35rem;
  color: #d1d5db;
  display: grid;
  gap: 0.45rem;
  font-size: 1.04rem;
}

/* Hub Grid Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  gap: clamp(1rem, 1.5vw, 1.6rem);
  margin-top: 1.5rem;
}

.hub-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  text-decoration: none !important;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  box-shadow: var(--shadow-lg);
}

.hub-card:hover {
  transform: translateY(-0.125rem);
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

.hub-card-tag {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.hub-card h3 {
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.hub-card p {
  font-size: 0.98rem;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}

.hub-card-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  text-align: left;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-weight: 600;
}

td {
  color: #d1d5db;
}

tr:last-child td {
  border-bottom: none;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: rgba(11, 15, 25, 0.9);
  padding: 2.25rem clamp(1rem, 2.5vw, 2rem);
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.4rem;
  font-size: 0.92rem;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

@media (max-width: 72rem) {
  .header-inner {
    grid-template-columns: 1fr auto;
  }
  .nav-links {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .doc-card {
    padding: 1.25rem 1.25rem;
  }
}
