/* ABOUTME: Custom styles for the OpenDLP docs site using Sortition Foundation branding */
/* ABOUTME: Overrides GOV.UK Frontend defaults with Sortition colour palette */

:root {
  --sortition-hot-pink: rgb(228, 15, 125);
  --sortition-white: #ffffff;
  --sortition-black: #000000;
  --sortition-dark-grey: #473d3d;
  --sortition-purple-red: #730045;
  --sortition-blood-red: #910d3f;
  --sortition-scarlet-red: #c7003a;
  --sortition-red: #ff0026;
  --sortition-burnt-orange: #fe5734;
  --sortition-buttermilk: #ffe2ae;
  --sortition-saffron-yellow: #fda135;
  --sortition-sap-green: #70a311;
  --sortition-woad-blue: #548eb4;
}

/* Allow browser to synthesize bold/italic for the fallback font stack.
   GOV.UK Frontend uses GDS Transport (proprietary), so we rely on the
   system sans-serif fallback with font-synthesis enabled. */
body {
  font-synthesis: weight style;
}

/* Header branding */
.govuk-header {
  background: var(--sortition-white);
  border-bottom: none;
}

/* Flex layout for header container so logo and nav sit side by side */
.govuk-header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.govuk-header__logo {
  display: flex;
  align-items: center;
  float: none;
  width: auto;
  flex-shrink: 0;
  gap: 12px;
}

.govuk-header__content {
  float: none;
}

.govuk-header__logotype-text {
  font-weight: 700;
  white-space: nowrap;
}

.govuk-header__link:link,
.govuk-header__link:visited {
  color: var(--sortition-black);
}

.govuk-header__link:hover {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: .1em;
  color: var(--sortition-burnt-orange);
}

.header-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-logo-link:hover {
  text-decoration: none;
}

.header-logo {
  height: 40px;
  width: auto;
}

/* On narrow viewports, stack header rows and let menu sit below the logo */
@media (max-width: 48.0525em) {
  .govuk-header__container {
    flex-wrap: wrap;
  }

  .govuk-header__content {
    position: static;
    width: 100%;
    padding-top: 5px;
  }

  .govuk-header__menu-button {
    position: static;
    display: inline-block;
    float: none;
  }
}

/* Hide mobile nav close button on desktop */
.govuk-header__navigation-close {
  display: none;
}

/* Orange accent bar between header and content */
.header-accent-bar {
  background: var(--sortition-white);
}

.header-accent-bar__line {
  border: 0;
  border-top: 4px solid var(--sortition-burnt-orange);
  margin: 0;
}

/* Mobile menu button colour fix for white header */
.govuk-header__menu-button {
  color: var(--sortition-black);
}

.govuk-header__menu-button:hover {
  color: var(--sortition-burnt-orange);
}

/* Focus styles using saffron yellow */
.govuk-skip-link:focus,
a:focus,
.govuk-header__link:focus,
.govuk-footer__link:focus,
.govuk-link:focus {
  outline: 3px solid var(--sortition-saffron-yellow);
  outline-offset: 0;
  background-color: var(--sortition-saffron-yellow);
  color: var(--sortition-black);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Hero section */
.hero-section {
  background: var(--sortition-burnt-orange);
  margin: 0 calc(-1 * var(--govuk-gutter-half, 15px));
  padding-left: var(--govuk-gutter-half, 15px);
  padding-right: var(--govuk-gutter-half, 15px);
}

/* Prevent horizontal overflow on mobile */
html, body {
  overflow-x: hidden;
}

.hero-section__title {
  color: var(--sortition-white);
  margin-bottom: 20px;
}

.hero-section__description {
  color: var(--sortition-white);
  max-width: 40em;
}

/* Feature cards */
.feature-card {
  border-top: 4px solid var(--sortition-burnt-orange);
  padding-top: 15px;
  margin-bottom: 30px;
}

/* Footer */
.govuk-footer {
  border-top: 1px solid #b1b4b6;
}

/* Markdown content styling within govuk-body containers */
.govuk-body h2 {
  font-family: "GDS Transport", arial, sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.25;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.govuk-body h3 {
  font-family: "GDS Transport", arial, sans-serif;
  font-weight: 700;
  font-size: 1.1875rem;
  line-height: 1.3;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
}

.govuk-body p {
  margin-bottom: 1em;
}

.govuk-body ul,
.govuk-body ol {
  margin-bottom: 1em;
  padding-left: 20px;
}

.govuk-body li {
  margin-bottom: 0.5em;
}

.govuk-body a {
  color: #1d70b8;
}

.govuk-body a:visited {
  color: #4c2c92;
}

.govuk-body strong {
  font-weight: 700;
}

.govuk-body hr {
  border: 0;
  border-top: 1px solid #b1b4b6;
  margin: 2em 0;
}

/* Side Navigation */
.side-navigation {
  padding-top: 0;
}

.side-navigation .govuk-list {
  margin-bottom: 0;
  padding-left: 0;
  list-style: none;
}

.side-nav-item {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.3;
}

.side-nav-item > a.govuk-link,
.side-nav-item > a.govuk-link:link,
.side-nav-item > a.govuk-link:visited {
  display: block;
  padding: 8px 0;
  text-decoration: none !important;
  color: #1d70b8;
}

.side-nav-item > a.govuk-link:visited {
  color: #4c2c92;
}

.side-nav-item > a.govuk-link:hover {
  text-decoration: underline !important;
  color: #003078;
}

.side-nav-item--active {
  font-weight: 700;
}

/* Section headers (non-collapsible parent items) */
.side-nav-section-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--sortition-black);
  margin-top: 20px;
  margin-bottom: 5px;
  padding: 0;
}

.side-nav-section-title:first-child {
  margin-top: 0;
}

/* Collapsible section styling */
.side-nav-details {
  margin-bottom: 0;
  border: none;
  margin-top: 20px;
}

.side-nav-details:first-child {
  margin-top: 0;
}

.side-nav-details[open] {
  padding-bottom: 0;
}

.side-nav-summary {
  padding: 0;
  margin-bottom: 5px;
  cursor: pointer;
  list-style: none;
}

/* Hide default browser and GOV.UK disclosure triangles */
.side-nav-summary::-webkit-details-marker,
.side-nav-details > summary::-webkit-details-marker,
.side-nav-details .govuk-details__summary::-webkit-details-marker {
  display: none;
}

.side-nav-summary::marker,
.side-nav-details > summary::marker {
  display: none;
  content: "";
}

.side-nav-details > summary,
.side-nav-details .govuk-details__summary {
  list-style-type: none;
}

/* Override GOV.UK details arrow */
.side-nav-details .govuk-details__summary::before {
  display: none !important;
}

.side-nav-summary .govuk-details__summary-text {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--sortition-black);
  text-decoration: none;
}

.side-nav-summary .govuk-link,
.side-nav-summary .govuk-link:link,
.side-nav-summary .govuk-link:visited {
  text-decoration: none !important;
  color: inherit;
}

.side-nav-summary .govuk-link:hover {
  text-decoration: underline !important;
  color: var(--sortition-black);
}

/* Orange line on left when section is open */
.side-nav-item:has(.side-nav-details[open]) {
  border-left: 4px solid var(--sortition-burnt-orange);
  padding-left: 12px;
  margin-left: -16px;
}

/* Nested navigation content */
.side-nav-content {
  padding: 0 0 0 0;
  margin-left: 0;
  border-left: none;
}

.side-nav-content .govuk-list {
  margin-bottom: 0;
}

.side-nav-content .side-nav-item {
  font-size: 16px;
  line-height: 1.4;
}

.side-nav-content .side-nav-item > a {
  padding: 6px 0;
}

.side-nav-content .side-nav-item > a::before {
  content: "—";
  margin-right: 8px;
  color: var(--sortition-black);
}

/* Second-level section headers use link blue */
.side-nav-content .govuk-details__summary-text {
  color: #1d70b8;
}

/* Search box in header */
.header-search {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
  width: 250px;
}

/* Pagefind UI overrides to match GOV.UK styling */
.pagefind-ui {
  --pagefind-ui-scale: 1;
  --pagefind-ui-primary: var(--sortition-burnt-orange);
  --pagefind-ui-text: var(--sortition-black);
  --pagefind-ui-background: var(--sortition-white);
  --pagefind-ui-border: #0b0c0c;
  --pagefind-ui-border-width: 2px;
  --pagefind-ui-border-radius: 0;
  --pagefind-ui-font: "GDS Transport", arial, sans-serif;
}

/* Hide default Pagefind form wrapper padding */
.pagefind-ui .pagefind-ui__form {
  position: relative;
  margin: 0;
  padding: 0;
}

/* GOV.UK-style input */
.pagefind-ui .pagefind-ui__search-input {
  font-family: "GDS Transport", arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.25;
  padding: 5px 35px 5px 10px;
  border: 2px solid var(--sortition-black);
  border-radius: 0;
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.pagefind-ui .pagefind-ui__search-input:focus {
  outline: 3px solid var(--sortition-saffron-yellow);
  outline-offset: 0;
  box-shadow: inset 0 0 0 2px var(--sortition-black);
}

/* Search icon (magnifying glass) positioning */
.pagefind-ui::before {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b0c0c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 1;
}

.pagefind-ui {
  position: relative;
}

/* Hide default Pagefind search icon */
.pagefind-ui .pagefind-ui__search-input {
  background-image: none !important;
}

.pagefind-ui .pagefind-ui__button {
  display: none !important;
}

.pagefind-ui .pagefind-ui__form::before {
  display: none !important;
}

/* Clear button positioning */
.pagefind-ui .pagefind-ui__search-clear {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--sortition-black);
  cursor: pointer;
  padding: 5px;
  width: 24px;
  height: 24px;
  z-index: 2;
  align-items: center;
  justify-content: center;
}

.pagefind-ui .pagefind-ui__search-clear:hover {
  color: var(--sortition-burnt-orange);
}

.pagefind-ui .pagefind-ui__search-clear:focus {
  outline: 3px solid var(--sortition-saffron-yellow);
  background: var(--sortition-saffron-yellow);
}

/* Floating results dropdown */
.pagefind-ui .pagefind-ui__drawer {
  position: absolute;
  top: 100%;
  right: 0;
  width: 400px;
  max-width: 90vw;
  background: var(--sortition-white);
  border: 2px solid var(--sortition-black);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  max-height: 70vh;
  overflow-y: auto;
  margin-top: 2px;
}

.pagefind-ui .pagefind-ui__results-area {
  padding: 10px;
}

.pagefind-ui .pagefind-ui__message {
  font-size: 14px;
  padding: 10px 0;
}

.pagefind-ui .pagefind-ui__result {
  border-top: 1px solid #b1b4b6;
  padding: 10px 0;
}

.pagefind-ui .pagefind-ui__result:first-child {
  border-top: none;
}

.pagefind-ui .pagefind-ui__result-link {
  color: #1d70b8;
  font-weight: 700;
  text-decoration: underline;
}

.pagefind-ui .pagefind-ui__result-link:visited {
  color: #4c2c92;
}

.pagefind-ui .pagefind-ui__result-link:hover {
  color: #003078;
}

.pagefind-ui .pagefind-ui__result-link:focus {
  outline: 3px solid var(--sortition-saffron-yellow);
  background: var(--sortition-saffron-yellow);
  color: var(--sortition-black);
  text-decoration: none;
}

.pagefind-ui .pagefind-ui__result-excerpt {
  font-size: 14px;
  color: #505a5f;
  margin-top: 5px;
}

/* Mobile menu toggle - hidden on desktop */
.mobile-menu__toggle {
  display: none;
}

/* Mobile adjustments */
@media (max-width: 48.0525em) {
  .header-search {
    width: 100%;
    margin-top: 10px;
  }

  .pagefind-ui .pagefind-ui__drawer {
    width: 100%;
    left: 0;
    right: 0;
  }

  /* Mobile menu styles */
  .mobile-menu {
    margin-bottom: 20px;
  }

  .mobile-menu__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 0;
    background: none;
    border: none;
    border-bottom: 1px solid #b1b4b6;
    cursor: pointer;
    font-family: "GDS Transport", arial, sans-serif;
    font-size: 19px;
    font-weight: 700;
    color: var(--sortition-black);
    text-align: left;
  }

  .mobile-menu__toggle:hover {
    color: var(--sortition-burnt-orange);
  }

  .mobile-menu__toggle:focus-visible {
    outline: 3px solid var(--sortition-saffron-yellow);
    outline-offset: 0;
    background-color: var(--sortition-saffron-yellow);
  }

  .mobile-menu__toggle-icon {
    width: 20px;
    height: 20px;
    position: relative;
  }

  .mobile-menu__toggle-icon::before,
  .mobile-menu__toggle-icon::after {
    content: "";
    position: absolute;
    background: currentColor;
    left: 50%;
    top: 50%;
  }

  /* Plus icon - horizontal line */
  .mobile-menu__toggle-icon::before {
    width: 12px;
    height: 2px;
    transform: translate(-50%, -50%);
  }

  /* Plus icon - vertical line (hidden when open) */
  .mobile-menu__toggle-icon::after {
    width: 2px;
    height: 12px;
    transform: translate(-50%, -50%);
  }

  /* When open, hide vertical line to show minus */
  .mobile-menu__toggle[aria-expanded="true"] .mobile-menu__toggle-icon::after {
    display: none;
  }

  /* Hide navigation by default on mobile */
  .mobile-menu .side-navigation {
    display: none;
    padding-top: 15px;
  }

  /* Show navigation when menu is open */
  .mobile-menu--open .side-navigation {
    display: block;
    border-bottom: 1px solid #b1b4b6;
    padding-bottom: 15px;
    margin-bottom: 15px;
  }
}




/* Sticky layout for desktop content pages */
@media (min-width: 48.0625em) {
  /* position: sticky can be broken by overflow-x: hidden on parent elements */
  html, body {
    overflow-x: visible;
  }

  .govuk-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--sortition-white);
  }

  .header-accent-bar {
    position: sticky;
    top: 70px; /* Approx header height */
    z-index: 1000;
    background: var(--sortition-white);
    border-bottom: 1px solid #b1b4b6; /* Subtle separation when scrolling */
  }

  .sidebar-column {
    position: sticky;
    top: 90px; /* Header + Accent bar + small margin */
    height: calc(100vh - 110px);
    overflow-y: auto;
    z-index: 10;
    /* Ensure scrollbar doesn't overlap content too much */
    padding-right: 15px;
  }

  /* Smooth scroll for anchor links and offset for sticky header */
  html {
    scroll-behavior: smooth;
    scroll-padding-top: 110px;
  }
}
