:root {
  --base-font-size: 14px;
  --font-family: var(--swedac-font-family, "Inter", Arial, sans-serif);
  --default-line-height: 1.6;

  /* Swedac färgvariabler (används av navbar) */
  --swedac-dark-blue: #162943;
  --swedac-middle-blue: #d5dce1;
  --swedac-light-blue: #e7edf0;
  --swedac-yellow: #fbba00;
  --swedac-white: #fff;

  /* Navbar färgvariabler (ärver från swedac-färgerna) */
  --navbar-dark-blue: var(--swedac-dark-blue);
  --navbar-middle-blue: var(--swedac-middle-blue);
  --navbar-light-blue: var(--swedac-light-blue);
  --navbar-yellow: var(--swedac-yellow);
  --navbar-white: var(--swedac-white);

  /* Color variables */
  --primary-color: var(--swedac-dark-blue);
  --text-color: #333;
  --light-bg: #f9f9f9;
  --border-color: #ddd;
  --red-color: #b05050;
  --highlight-primary-color: rgb(255, 255, 191);
  --highlight-secondary-color: yellow;
}

html {
  font-size: var(--base-font-size);
  scroll-padding-top: 80px; /* Kompensera för fixerad navbar vid ankarlänkar */
}

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

::selection {
  background-color: var(--swedac-light-blue);
}

body {
  font-family: var(--font-family);
  line-height: var(--default-line-height);
  color: var(--text-color);
  background-color: var(--swedac-white);
  margin: 0;
  padding: 0;
  max-width: 1000px;
  margin: 0 auto;
  padding: 70px 2rem 2rem 2rem; /* Top padding för navbar (70px) */
}

/* Header and title styling */
header {
  display: none;

  border-bottom: 2px solid var(--primary-color);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}

main {
  max-width: 800px;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--primary-color);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

h1 {
  font-size: 1.6rem;
  color: black;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.3rem;
  color: #6c6c6c;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 1.2rem;
  font-weight: bold;
}

h5 {
  font-size: 1.1rem;
  font-weight: bold;
}

h6 {
  font-size: 1.0rem;
  font-weight: bold;
}

/* Content styling */
p {
  font-size: 1rem;
  margin-bottom: 0.7rem;
}

code {
  display: inline-flex;
  background-color: #fff;
  padding: 3px 5px;
  color: #000;
  font-family: 'Courier New', Courier, monospace;
  border-radius: 4px;
  border: solid 1px #c0c0c0;
}

data[id] {
  position: relative;
}

data[id]::after {
  content: '';
  position: absolute;
  top: -6px;
  right: -6px;
  width: 8px;
  height: 8px;
  background-color: var(--swedac-dark-blue);
  border-radius: 50%;
  border: 1.5px solid #fff;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

data[id]:hover::after {
  opacity: 1;
}

ul, ol {
  padding-left: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  list-style-position: inside;
}

/* Nested lists */
ol ol, ol ul, ul ol, ul ul {
  padding-left: 2rem;
  list-style-position: outside;
}

p + ol {
  margin-top: -0.3rem;
}

li {
  margin-bottom: 0.3rem;
}

li p {
  display: inline;
}

img, figure {
  max-width: 100%;
}

a {
  color: var(--primary-color);
  text-decoration: underline;
}

a:hover {
  text-decoration: underline;
}

blockquote {
  padding-left: 3rem;
  margin-left: 0;
  margin-right: 0;
  color: #555;
}

blockquote p {
  font-size: 0.85rem;
}

blockquote li {
  font-size: 0.85rem;
  margin-bottom: 0;
}

/* Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

th, td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  text-align: left;
}

th {
  background-color: var(--border-color);
  color: black;
}

tr:nth-child(even) {
  background-color: var(--light-bg);
}

/* Section anchor styling */
a.section-anchor {
  text-decoration: none;
}

a.section-anchor:hover {
  text-decoration: underline;
}

.section-anchor:target {
  background-color: var(--highlight-secondary-color);
}

/* Header anchor styling */
a.header-anchor {
  text-decoration: none;
}

a.header-anchor:hover {
  text-decoration: underline;
}

.header-anchor:target {
  background-color: var(--highlight-primary-color);
}

/*
p:has(.section-anchor:target) {
  background-color: var(--swedac-middle-blue);
}
*/

/* Horizontal line styling */
hr {
  margin-top: 2rem;
  margin-bottom: 4rem;
  border: none;
  border-top: 1px solid var(--border-color);
}

/* Section styling */
section {
  margin-bottom: 2rem;
}

/* Information boxes */
.info-box {
  background-color: rgba(22, 41, 67, 0.05);
  border-left: 4px solid var(--primary-color);
  padding: 1rem;
  margin: 1.5rem 0;
}

/* Footnotes styling */
.footnotes {
  margin-top: 2rem;
}

.footnotes li, .footnotes p {
  font-size: 0.8rem;
  line-height: 1.2;
}

.footnotes ol {
  padding-left: 0;
}

/* Alphabetical lists styling */
ol.alpha-list {
  list-style-type: lower-alpha;
  padding-left: 2rem;
  margin: 1rem 0;
}

/* Force uppercase for lists explicitly marked as uppercase */
ol.alpha-list-uppercase {
  list-style-type: upper-alpha !important;
}

ol.alpha-list li {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

ol.alpha-list li:last-child {
  margin-bottom: 0;
}

/* Nested alpha lists */
ol.alpha-list ol.alpha-list {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}


/* Additional utility classes */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

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

.container {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  color: #666;
  font-size: 0.9rem;
}

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 1rem;
}

.meta-icon {
  display: block;
  flex-shrink: 0;
}

.meta a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #666;
  font-weight: 600;
  text-decoration: underline;
  margin-right: 0.75rem;
}

/* Dölj analog-version-only element som standard */
.analog-version-only {
  display: none;
}

.dates {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.dates dt,
.dates dd {
  display: inline;
  margin: 0;
}

.dates dd::after {
  content: '';
  display: inline-block;
  width: 8px;
}

.doc-id-mobile {
  display: none;
}

@media (max-width: 768px) {
  /* Grundläggande anpassningar för mindre skärmar */
  body {
    padding: 70px 1rem 1rem 1rem; /* Behåll top padding för navbar på mobil */
    font-size: 0.95rem;
  }

  body.page-foreskrift {
    padding-top: 90px !important;
  }

  .dates {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
  }

  .dates dt,
  .dates dd {
    display: block;
  }

  .dates dd::after {
    display: none;
  }

  .doc-id-mobile {
    display: block;
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.6rem;
  }

  h1 {
    font-size: 1.3rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  h4, h5, h6 {
    font-size: 0.95rem;
  }

  /* Justera tabeller för små skärmar */
  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.5rem;
  }

  /* Minska margins och padding */
  ul, ol {
    padding-left: 0.25rem;
  }

  blockquote {
    padding-left: 1.5rem;
  }

  footer {
    margin-top: 2rem;
    font-size: 0.85rem;
  }

  .disclaimer {
    font-size: 0.85rem;
    padding: 0.75rem;
  }

  button, a.button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  /* Dölj analog version-knappen på mobil */
  #toggle-analog {
    display: none;
  }
}

.disclaimer {
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--red-color);
  border: 1px solid var(--red-color);
  border-radius: 6px;
  border-style: dotted;
  padding: 1rem;
  max-width: 800px;
  margin-top: 0.5rem;
}

.disclaimer a {
  color: var(--red-color);
}

.notice-konsoliderad {
  font-size: 0.825rem;
  line-height: 1.3;
  color: var(--primary-color);
  border: 1px dotted var(--primary-color);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  max-width: 800px;
  margin-top: 0.5rem;
  background-color: var(--swedac-light-blue);
}

.notice-konsoliderad a {
  color: var(--primary-color);
}

.disclaimer-line {
  display: block;
}

@media (max-width: 768px) {
  .disclaimer-line {
    display: inline;
  }
}

/* Anchor links */
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor {
  visibility: visible;
}
.anchor {
  visibility: hidden;
  margin-left: 0.5em;
  text-decoration: none;
}

/* Button styling */
button, a.button {
  background-color: var(--swedac-dark-blue);
  color: var(--swedac-white);
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-family);
  font-size: 1rem;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

button:hover, a.button:hover {
  background-color: rgba(22, 41, 67, 0.8);
  text-decoration: none;
}

/* Focus outline for interactive elements */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--navbar-yellow);
  outline-offset: 2px;
}

/* Remove outline from target elements to avoid duplication */
.section-anchor:target,
.header-anchor:target {
  outline: none;
}

/* Hide print-only elements on screen */
.only-print {
  display: none;
}

#toggle-analog:focus {
  outline: none;
}

/* Navbar header separator - non-selectable */
.navbar-header-separator {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Övergång med animation mellan sidor */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
}

::view-transition-old(root) {
  animation-name: fade-out;
}

::view-transition-new(root) {
  animation-name: fade-in;
}

@keyframes fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
