/* dementia.co.uk — distinct sub-brand, TDS-aligned accents */
:root {
  --primary: #0E4561;        /* deep teal-navy, calm and authoritative */
  --tds-blue: #28AAE1;       /* TDS accent */
  --tds-pink: #EC008C;       /* TDS accent (sparingly) */
  --bg: #FBF8F3;             /* warm cream */
  --card: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #E5E7EB;
  --soft: #F3F4F6;
  --max: 1140px;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15,69,97,.06), 0 1px 2px rgba(15,69,97,.04);
  --shadow-lg: 0 10px 30px rgba(15,69,97,.08), 0 4px 8px rgba(15,69,97,.04);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary);
  color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 1000;
}
.skip-link:focus { left: 0; }

/* Powered-by ribbon */
.powered-by {
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  letter-spacing: .02em;
  padding: 8px 0;
  text-align: center;
}
.powered-by a {
  color: var(--tds-blue);
  text-decoration: none;
  font-weight: 600;
}
.powered-by a:hover { text-decoration: underline; }

/* Header */
header.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex; align-items: baseline; gap: 8px;
  text-decoration: none; color: var(--primary);
}
.brand-mark {
  font-weight: 800; font-size: 22px; letter-spacing: -.01em;
}
.brand-mark .accent { color: var(--tds-blue); }
.brand-tag { font-size: 12px; color: var(--muted); }

nav.main-nav {
  display: flex; gap: 22px; align-items: center;
}
nav.main-nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}
nav.main-nav a:hover { color: var(--tds-blue); }
nav.main-nav a.cta {
  background: var(--tds-blue); color: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 600;
}
nav.main-nav a.cta:hover { background: var(--primary); color: #fff; }
.nav-toggle {
  display: none; background: none; border: 0; cursor: pointer; padding: 8px;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: var(--primary); margin: 4px 0; border-radius: 2px;
}

/* Breadcrumbs */
.breadcrumbs {
  max-width: var(--max);
  margin: 16px auto 0;
  padding: 0 20px;
  font-size: 14px;
  color: var(--muted);
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--tds-blue); }
.breadcrumbs span[aria-current="page"] { color: var(--text); }

/* Hero */
.hero {
  max-width: var(--max);
  margin: 24px auto 8px;
  padding: 0 20px;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.18;
  color: var(--primary);
  margin: 8px 0 12px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.hero p.lede {
  font-size: 18px;
  color: var(--text);
  max-width: 760px;
}

/* Page meta line */
.page-meta {
  font-size: 13px; color: var(--muted); margin-bottom: 8px;
  display: flex; flex-wrap: wrap; gap: 16px;
}
.page-meta b { color: var(--primary); }

/* Plain English summary */
.summary {
  background: #fff;
  border-left: 4px solid var(--tds-blue);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 18px 0 24px;
  box-shadow: var(--shadow);
}
.summary h2 {
  font-size: 14px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--tds-blue); margin: 0 0 6px;
}
.summary p { margin: 0; font-size: 17px; }

/* Main layout */
main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 40px;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; }
  nav.main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 0 12px;
  }
  nav.main-nav.open { display: flex; }
  nav.main-nav a {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
  }
  nav.main-nav a:last-child { border-bottom: 0; }
  nav.main-nav a.cta {
    margin: 12px 20px 0;
    text-align: center;
    border: 0;
  }
  header.site-header { position: relative; }
}

/* Hamburger -> X transition */
.nav-toggle.is-open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle.is-open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.is-open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}
.nav-toggle span {
  transition: transform .2s ease, opacity .2s ease;
}

article {
  background: var(--card);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 36px);
  box-shadow: var(--shadow);
}

article h2 {
  font-size: 24px;
  color: var(--primary);
  margin-top: 36px;
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: -.005em;
}
article h2:first-child { margin-top: 0; }
article h3 {
  font-size: 19px;
  color: var(--primary);
  margin-top: 24px;
  margin-bottom: 8px;
  font-weight: 600;
}
article p { margin: 0 0 14px; }
article ul, article ol { margin: 0 0 16px; padding-left: 22px; }
article li { margin-bottom: 6px; }
article a {
  color: var(--tds-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
article a:hover { color: var(--primary); }
article strong { color: var(--primary); }
article blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  background: var(--soft);
  border-left: 3px solid var(--tds-pink);
  border-radius: 6px;
  color: var(--text);
}

/* Inline note callout */
.callout {
  background: #F0F9FF;
  border-left: 4px solid var(--tds-blue);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 18px 0;
}
.callout.pink { background: #FFF5FA; border-left-color: var(--tds-pink); }
.callout strong { color: var(--primary); }

/* FAQ */
.faq { margin-top: 36px; }
.faq h2 { color: var(--primary); margin-bottom: 12px; }
.faq details {
  background: var(--soft);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  font-size: 16px;
  list-style: none;
  padding: 4px 0;
}
.faq summary::marker { display: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; float: right; color: var(--tds-blue); font-weight: 700;
}
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 8px 0 4px; }

/* Next steps */
.next-steps {
  margin-top: 32px;
  background: #FFF8F0;
  border: 1px solid #F4E4D1;
  border-radius: var(--radius);
  padding: 20px 24px;
}
.next-steps h2 {
  margin: 0 0 12px;
  font-size: 18px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.next-steps ol { margin: 0; padding-left: 22px; }
.next-steps li { margin-bottom: 8px; }

/* References */
.references { margin-top: 32px; font-size: 14px; color: var(--muted); }
.references h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin-bottom: 8px; }
.references ol { padding-left: 22px; }

/* Sidebar */
aside.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.side-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.side-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tds-blue);
}
.side-card ul { list-style: none; padding: 0; margin: 0; }
.side-card li { border-top: 1px solid var(--border); }
.side-card li:first-child { border-top: 0; }
.side-card a {
  color: var(--primary);
  text-decoration: none;
  display: block;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 500;
}
.side-card a:hover { color: var(--tds-blue); }

.tds-panel {
  background: linear-gradient(135deg, var(--primary), #133e58);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
}
.tds-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--tds-blue);
}
.tds-panel p { margin: 0 0 12px; font-size: 15px; }
.tds-panel a.cta {
  display: inline-block;
  background: var(--tds-blue);
  color: #fff;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}
.tds-panel a.cta:hover { background: #fff; color: var(--primary); }

/* Footer */
footer.site-footer {
  background: var(--primary);
  color: #cfe3ef;
  padding: 32px 0 16px;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}
.footer-inner h4 {
  color: #fff;
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.footer-inner ul { list-style: none; padding: 0; margin: 0; }
.footer-inner li { margin-bottom: 6px; }
.footer-inner a {
  color: #cfe3ef;
  text-decoration: none;
  font-size: 14px;
}
.footer-inner a:hover { color: #fff; text-decoration: underline; }
.footer-bottom {
  max-width: var(--max);
  margin: 24px auto 0;
  padding: 16px 20px 0;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 13px;
  color: #9fbecd;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}
.footer-bottom a { color: #cfe3ef; text-decoration: none; }
.footer-bottom a:hover { color: #fff; }
.footer-bottom .powered-link { font-weight: 600; color: #fff; }

/* Tables */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 15px;
}
article th, article td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}
article th { background: var(--soft); color: var(--primary); font-weight: 600; }

/* Print friendliness */
@media print {
  header, footer, aside, .powered-by, .breadcrumbs { display: none; }
  main { grid-template-columns: 1fr; }
  article { box-shadow: none; padding: 0; }
}


/* Search */
.search-toggle {
  background: transparent;
  border: 1px solid var(--border, #d6d6d6);
  border-radius: 999px;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #0E4561;
  margin-left: 8px;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.search-toggle:hover {
  background: #28AAE1;
  color: #ffffff;
  border-color: #28AAE1;
}
.search-toggle:focus-visible {
  outline: 2px solid #28AAE1;
  outline-offset: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.search-overlay {
  position: fixed; inset: 0;
  background: rgba(14, 69, 97, 0.55);
  z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px;
  backdrop-filter: blur(2px);
  font-family: 'Montserrat', sans-serif;
}
.search-overlay[hidden] { display: none; }
.search-overlay-inner {
  background: #ffffff;
  border-radius: 12px;
  width: 100%; max-width: 720px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.25);
  padding: 18px 18px 22px;
  position: relative;
  max-height: 80vh;
  display: flex; flex-direction: column;
}
.search-close {
  position: absolute; top: 6px; right: 10px;
  background: transparent; border: 0;
  font-size: 32px; line-height: 1;
  color: #939598; cursor: pointer;
}
.search-close:hover { color: #EC008C; }

#search input[type="search"] {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 1.05rem;
  border: 2px solid #28AAE1;
  border-radius: 8px;
  outline: none;
  color: #0E4561;
}
#search input[type="search"]::placeholder { color: #939598; }

.search-meta {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #5b6770;
}
.search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}
.search-results li {
  border-bottom: 1px solid #eee;
}
.search-results li:last-child { border-bottom: 0; }
.search-results li a {
  display: block;
  padding: 12px 8px;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
}
.search-results li a:hover,
.search-results li.is-active a {
  background: #f5fafd;
}
.r-title {
  color: #0E4561;
  font-weight: 600;
  font-size: 1rem;
}
.r-section {
  color: #28AAE1;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.r-snippet {
  color: #333333;
  font-size: 0.92rem;
  margin-top: 6px;
  line-height: 1.45;
}
.r-snippet mark {
  background: #FFF4C4;
  color: #0E4561;
  padding: 0 2px;
  border-radius: 2px;
}

@media (max-width: 900px) {
  .search-overlay { padding: 4vh 8px 8px; }
  .search-overlay-inner { padding: 12px 12px 16px; max-height: 90vh; }
  .search-toggle { width: 36px; height: 36px; }
}
