/* -- DESIGN TOKENS -- */
:root {
  /* Colours */
  --color-bg: #FFFFFF;
  --color-text-primary: #111111;
  --color-text-body: #262626;
  --color-link: #2213FB;
  --color-divider: #E5E5E5;
  --color-scrollbar-bg: #111111;
  --color-scrollbar-line-white: #FFFFFF;
  --color-scrollbar-line-grey: #CCCCCC;
  --color-scrollbar-line-blue: #0088FF;
  --color-theme-btn: #111111;

  /* Layout */
  --container-width: 750px;
  --container-left: 300px;
  --container-top: 75px;
  --font-family: 'Outfit', sans-serif;
  --divider-width: 800px;
}

/* Dark mode overrides */
[data-theme="dark"] {
  --color-bg: #111111;
  --color-text-primary: #EEEEEE;
  --color-text-body: #BFBFBF;
  --color-divider: #2E2E2E;
  --color-scrollbar-line-white: #111111;
  --color-theme-btn: #FFFFFF;
}

html {
  scrollbar-width: none; /* Firefox */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

html::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

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

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -- CONTAINER -- */
.container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  gap: 40px;
  width: var(--container-width);
  margin-left: var(--container-left);
  padding-top: var(--container-top);
  padding-bottom: 150px;
}

/* -- BACK LINK -- */
.back-link {
  font-size: 16px;
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 10px;
  display: inline-block;
  font-weight: 400;
}

/* -- ARTICLE HEADER -- */
.article-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
}

.article-title {
  font-weight: 500;
  font-size: 32px;
  line-height: 38px;
  text-decoration: underline;
  color: var(--color-text-primary);
  text-underline-offset: 4px;
}

.article-subtitle {
  font-weight: 400;
  font-size: 18px;
  line-height: 24px;
  color: var(--color-text-body);
}

/* -- DIVIDERS -- */
.divider {
  width: var(--divider-width);
  height: 0;
  border: 0;
  border-top: 1px solid var(--color-divider);
  flex: none;
  margin: 10px 0;
}

/* -- SECTIONS -- */
.section-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

.section-title {
  font-weight: 500;
  font-size: 16px;
  line-height: 20px;
  text-decoration: underline;
  color: var(--color-text-primary);
  text-underline-offset: 3px;
  margin-bottom: 24px;
}

/* -- TYPOGRAPHY -- */
.article-paragraph {
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text-primary);
  text-align: justify;
  margin-bottom: 20px;
  width: 100%;
}

.article-paragraph strong {
  font-weight: 500;
}

.article-paragraph a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

blockquote {
  border-left: 2px solid var(--color-text-primary);
  padding-left: 20px;
  margin: 30px 0;
  font-style: italic;
  width: 100%;
}

blockquote p {
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text-primary);
  text-align: justify;
  margin-bottom: 0;
}

h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-top: 28px;
  margin-bottom: 14px;
  text-decoration: none;
}

/* -- LISTS -- */
ul, ol {
  width: 100%;
  padding-left: 24px;
  margin-bottom: 24px;
}

li {
  font-size: 16px;
  line-height: 24px;
  color: var(--color-text-primary);
  margin-bottom: 12px;
  text-align: justify;
}

li strong {
  font-weight: 500;
  color: var(--color-text-primary);
}

li a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* -- DIAGRAM FIGURES -- */
.diagram-figure {
  width: 100%;
  margin: 32px 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.diagram-figure img {
  width: 67.5%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--color-divider);
  background: #FAFAFA;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.widget-frame {
  display: inline-block;
  background: #CCCCCC;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--color-divider);
}

.widget-frame img {
  display: block;
  width: 100%;
  height: auto;
  border: none;
  background: none;
}

[data-theme="dark"] .widget-frame {
  background: #CCCCCC;
  border-color: #E5E5E5;
}

[data-theme="dark"] .widget-frame img {
  filter: none;
}

[data-theme="dark"] .diagram-figure img {
  border-color: #2E2E2E;
  background: #1A1A1A;
  filter: invert(0.88) hue-rotate(180deg);
}

.diagram-caption {
  font-size: 13px;
  line-height: 18px;
  color: var(--color-text-body);
  font-style: italic;
  text-align: center;
  opacity: 0.7;
}

/* -- SCROLL WIDGET & THEME TOGGLE -- */
.scroll-wrapper {
  position: fixed;
  right: 180px;
  top: 75px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 100;
  pointer-events: none;
  transform: scale(0.75);
  transform-origin: top right;
}

.scroll-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0px 12px;
  gap: 12px;
  width: 54px;
  height: 144px;
  background: var(--color-scrollbar-bg);
  border-radius: 18px;
  box-shadow: 0px -1.5px 36px rgba(0, 0, 0, 0.05), 3px 3px 36px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.scroll-line {
  width: 24px;
  height: 2px;
  border-radius: 1px;
  flex: none;
  background-color: var(--color-scrollbar-line-white);
  transition: background-color 0.25s cubic-bezier(0.25, 1, 0.5, 1), transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

.scroll-line.grey {
  background-color: var(--color-scrollbar-line-grey);
}

.scroll-line.white {
  background-color: var(--color-scrollbar-line-white);
}

.scroll-line.active {
  background-color: var(--color-scrollbar-line-blue) !important;
  transform: scaleY(1.6);
}

/* Dark mode overrides for scroll lines inside the pill */
[data-theme="dark"] .scroll-pill {
  background: #FFFFFF;
}

[data-theme="dark"] .scroll-line.grey {
  background-color: #666666;
}

[data-theme="dark"] .scroll-line.white {
  background-color: var(--color-scrollbar-bg);
}

/* -- THEME TOGGLE -- */
.theme-toggle {
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 50%;
  background: var(--color-theme-btn);
  box-shadow: 0px -1.5px 36px rgba(0, 0, 0, 0.05), 3px 3px 36px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  transition: background 0.3s ease;
}

.theme-toggle svg {
  width: 22.4px;
  height: 22.4px;
}

.moon-path {
  stroke: #FFFFFF;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .moon-path {
  stroke: var(--color-scrollbar-bg);
}

/* -- TABLET (481px - 1024px) -- */
@media (min-width: 481px) and (max-width: 1024px) {
  .container {
    --container-width: 500px;
    --container-left: auto;
    margin: 0 auto;
    padding-top: var(--container-top);
  }

  .divider {
    width: 500px;
  }

  .scroll-wrapper {
    right: 40px;
    top: 100px;
  }
}

/* -- MOBILE (<= 480px) -- */
@media (max-width: 480px) {
  :root {
    --container-width: calc(100% - 48px);
    --container-left: 24px;
    --container-top: 60px;
    --divider-width: 100%;
  }

  .container {
    width: var(--container-width);
    margin-left: var(--container-left);
    margin-right: var(--container-left);
    padding-right: 60px; /* Space for the scroll pill */
    padding-bottom: 60px;
  }

  .divider {
    width: 100%;
  }

  .scroll-wrapper {
    right: 24px;
    top: 250px;
    transform: none;
    -webkit-transform: none;
  }

  .scroll-pill {
    padding: 0px 8px;
    gap: 8px;
    width: 40px;
    height: 96px;
    border-radius: 12px;
    box-shadow: 0px -1px 24px rgba(0, 0, 0, 0.05), 2px 2px 24px rgba(0, 0, 0, 0.25);
  }

  .scroll-line {
    width: 24px;
    height: 1.5px;
  }

  .scroll-line.active {
    transform: scaleY(1.33);
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .theme-toggle svg {
    width: 14px;
    height: 14px;
  }
}

/* -- REDUCED MOTION -- */
@media (prefers-reduced-motion: reduce) {
  .scroll-line {
    transition: none;
  }
}

/* -- WIDGET STRETCH RULES -- */
#widget-policy {
  width: 100%;
  max-width: 610px;
  margin-top: 2rem;
  margin-bottom: 2.5rem;
}

#widget-monitoring {
  width: 100%;
  max-width: 294px;
  margin-top: 2rem;
  margin-bottom: 2.5rem;
}

#widget-emergency {
  width: 100%;
  max-width: 426px;
  margin-top: 2rem;
  margin-bottom: 2.5rem;
}


