/* guidelines.doctor — core styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --navy:       #0a1628;
  --navy-2:     #0f1f3d;
  --navy-3:     #162545;
  --navy-4:     #1e3058;
  --teal:       #00c2a8;
  --teal-dim:   #009e88;
  --teal-glow:  rgba(0,194,168,0.12);
  --teal-pale:  rgba(0,194,168,0.06);
  --amber:      #f0a843;
  --red:        #e05252;
  --green:      #3ecf8e;
  --text:       #e8edf5;
  --text-dim:   #8fa3c0;
  --text-faint: #4a607a;
  --border:     rgba(255,255,255,0.07);
  --border-teal:rgba(0,194,168,0.25);
  --card:       rgba(15,31,61,0.8);
  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --font:       'DM Sans', system-ui, sans-serif;
  --mono:       'DM Mono', monospace;
  --transition: 0.18s ease;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--navy-2); }
::-webkit-scrollbar-thumb { background: var(--navy-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal-dim); }

/* ── Typography ── */
h1,h2,h3,h4,h5 { font-weight: 600; line-height: 1.25; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--text); }
p { color: var(--text-dim); line-height: 1.7; }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.container--narrow { max-width: 820px; }

/* ── Header / Nav ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,22,40,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem; gap: 1rem;
}
.logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.logo span { color: var(--teal); }
.logo-icon {
  width: 30px; height: 30px;
  background: var(--teal); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
}
.nav-links { display: flex; gap: 0.25rem; align-items: center; }
.nav-links a {
  padding: 0.4rem 0.75rem; border-radius: 6px;
  font-size: 0.875rem; font-weight: 500; color: var(--text-dim);
  transition: var(--transition);
}
.nav-links a:hover, .nav-links a.active {
  background: var(--teal-pale); color: var(--teal);
}
.nav-fav-count {
  background: var(--teal); color: var(--navy); font-size: 0.7rem;
  font-weight: 700; border-radius: 99px; padding: 0.1rem 0.4rem;
  margin-left: 0.25rem; vertical-align: middle;
}

/* ── Hero ── */
.hero {
  padding: 3rem 1rem 2rem;
  text-align: center;
}
.hero__badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--teal-pale); border: 1px solid var(--border-teal);
  color: var(--teal); font-size: 0.75rem; font-weight: 600;
  padding: 0.3rem 0.8rem; border-radius: 99px; margin-bottom: 1.25rem;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.hero h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); margin-bottom: 0.75rem; }
.hero h1 em { color: var(--teal); font-style: normal; }
.hero p { font-size: 1.05rem; max-width: 560px; margin: 0 auto 2rem; }

/* ── Search ── */
.search-wrap {
  max-width: 580px; margin: 0 auto 2.5rem;
  position: relative;
}
.search-wrap input {
  width: 100%;
  background: var(--navy-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem 0.85rem 3rem;
  font-family: var(--font); font-size: 1rem; color: var(--text);
  outline: none; transition: var(--transition);
}
.search-wrap input:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-glow);
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none; font-size: 1rem;
}
.search-clear {
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 1rem; padding: 0.25rem;
  opacity: 0; pointer-events: none; transition: var(--transition);
}
.search-clear.visible { opacity: 1; pointer-events: all; }

/* ── Filters ── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  justify-content: center; margin-bottom: 2rem;
}
.filter-btn {
  background: var(--navy-2); border: 1.5px solid var(--border);
  color: var(--text-dim); border-radius: 99px;
  padding: 0.4rem 1rem; font-family: var(--font);
  font-size: 0.825rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.filter-btn:hover { border-color: var(--teal); color: var(--teal); }
.filter-btn.active {
  background: var(--teal); border-color: var(--teal);
  color: var(--navy); font-weight: 700;
}

/* ── Section headings ── */
.section-heading {
  font-size: 0.7rem; font-weight: 700; color: var(--text-faint);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;
}
.section-heading::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Grid ── */
.guidelines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem; margin-bottom: 3rem;
}
.no-results {
  grid-column: 1/-1; text-align: center;
  padding: 3rem 1rem; color: var(--text-faint);
}
.no-results .no-results-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex; flex-direction: column; gap: 0.5rem;
  position: relative; overflow: hidden;
  text-decoration: none; color: inherit;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--teal-dim));
  opacity: 0; transition: var(--transition);
}
.card:hover {
  border-color: var(--border-teal);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.card:hover::before { opacity: 1; }

.card__cat {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.2rem 0.6rem;
  border-radius: 99px; width: fit-content;
}
.card__title { font-size: 1rem; font-weight: 600; color: var(--text); }
.card__desc { font-size: 0.825rem; color: var(--text-dim); flex: 1; line-height: 1.5; }
.card__footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 0.25rem;
}
.card__tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  font-size: 0.68rem; background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); color: var(--text-faint);
  padding: 0.1rem 0.45rem; border-radius: 4px; font-weight: 500;
}
.card__fav {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 1rem; padding: 0.25rem;
  transition: var(--transition); line-height: 1;
}
.card__fav:hover, .card__fav.active { color: var(--amber); }
.card__fav.active { text-shadow: 0 0 8px rgba(240,168,67,0.5); }

/* Category colour palette */
.cat--emergency { background: rgba(224,82,82,0.12); color: #e05252; border: 1px solid rgba(224,82,82,0.2); }
.cat--medicine   { background: rgba(0,194,168,0.1);  color: var(--teal); border: 1px solid var(--border-teal); }
.cat--surgery    { background: rgba(240,168,67,0.1); color: var(--amber); border: 1px solid rgba(240,168,67,0.2); }
.cat--paediatrics{ background: rgba(100,160,255,0.1);color: #64a0ff; border: 1px solid rgba(100,160,255,0.2); }
.cat--prescribing { background: rgba(62,207,142,0.1);color: var(--green); border: 1px solid rgba(62,207,142,0.2); }
.cat--on-call    { background: rgba(160,120,255,0.1);color: #a078ff; border: 1px solid rgba(160,120,255,0.2); }

/* ── Guideline Page ── */
.guideline-header {
  padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.guideline-header__back {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--text-faint); font-size: 0.875rem; font-weight: 500;
  margin-bottom: 1rem; transition: var(--transition);
}
.guideline-header__back:hover { color: var(--teal); }
.guideline-header__meta {
  display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; margin-bottom: 0.75rem;
}
.guideline-title { font-size: clamp(1.5rem, 4vw, 2.1rem); margin-bottom: 0.5rem; }
.guideline-subtitle { font-size: 1rem; color: var(--text-dim); margin-bottom: 1rem; }
.guideline-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  font-family: var(--font); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); border: none;
}
.btn--ghost {
  background: var(--navy-3); border: 1px solid var(--border); color: var(--text-dim);
}
.btn--ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn--teal { background: var(--teal); color: var(--navy); }
.btn--teal:hover { background: var(--teal-dim); }
.btn--fav { background: var(--navy-3); border: 1px solid var(--border); color: var(--text-dim); }
.btn--fav.active { background: rgba(240,168,67,0.1); border-color: rgba(240,168,67,0.3); color: var(--amber); }

/* ── Guideline content ── */
.guideline-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0; min-height: calc(100vh - 140px);
}
.guideline-toc {
  position: sticky; top: 60px; height: fit-content;
  padding: 1.5rem 1rem 1.5rem 1rem;
  border-right: 1px solid var(--border);
  max-height: calc(100vh - 80px); overflow-y: auto;
}
.guideline-toc h3 {
  font-size: 0.65rem; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 700; margin-bottom: 0.75rem;
}
.toc-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.6rem; border-radius: 6px;
  font-size: 0.825rem; color: var(--text-dim); cursor: pointer;
  transition: var(--transition); margin-bottom: 0.1rem;
  border: none; background: none; width: 100%; text-align: left;
  font-family: var(--font);
}
.toc-link:hover { background: var(--teal-pale); color: var(--teal); }
.toc-link.active { background: var(--teal-pale); color: var(--teal); font-weight: 600; }
.toc-link .toc-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0; opacity: 0.5;
}

.guideline-body { padding: 1.5rem 1.5rem 3rem; }

/* ── Sections ── */
.section {
  margin-bottom: 2.5rem; scroll-margin-top: 80px;
}
.section-title {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--teal); margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.section-title .icon {
  width: 24px; height: 24px; background: var(--teal-pale);
  border: 1px solid var(--border-teal); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; flex-shrink: 0;
}

/* ── Content blocks ── */
.alert-box {
  background: rgba(224,82,82,0.08); border: 1px solid rgba(224,82,82,0.25);
  border-radius: var(--radius); padding: 1rem 1.125rem; margin-bottom: 1rem;
}
.alert-box--amber {
  background: rgba(240,168,67,0.08); border-color: rgba(240,168,67,0.25);
}
.alert-box--green {
  background: rgba(62,207,142,0.08); border-color: rgba(62,207,142,0.25);
}
.alert-box--teal {
  background: var(--teal-pale); border-color: var(--border-teal);
}
.alert-box__title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 0.4rem;
  color: #e05252;
}
.alert-box--amber .alert-box__title { color: var(--amber); }
.alert-box--green .alert-box__title { color: var(--green); }
.alert-box--teal .alert-box__title { color: var(--teal); }
.alert-box p, .alert-box ul, .alert-box li { font-size: 0.9rem; }

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem; margin-bottom: 1rem;
}
.info-tile {
  background: var(--navy-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.875rem;
}
.info-tile__label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 0.3rem;
}
.info-tile__value { font-size: 0.9rem; font-weight: 500; color: var(--text); }

ul.criteria, ol.steps {
  padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 0.4rem;
}
ul.criteria li, ol.steps li {
  display: flex; align-items: flex-start; gap: 0.6rem;
  font-size: 0.9rem; color: var(--text-dim); padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
ul.criteria li:last-child, ol.steps li:last-child { border-bottom: none; }
ul.criteria li::before {
  content: '→'; color: var(--teal); flex-shrink: 0; font-weight: 700;
}
ol.steps { counter-reset: steps; }
ol.steps li::before {
  counter-increment: steps;
  content: counter(steps);
  background: var(--teal-pale); color: var(--teal);
  border: 1px solid var(--border-teal);
  min-width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0; margin-top: 0.1rem;
}

.drug-table {
  width: 100%; border-collapse: collapse; font-size: 0.875rem; margin-bottom: 1rem;
}
.drug-table th {
  text-align: left; font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-faint); font-weight: 700;
  padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border);
}
.drug-table td {
  padding: 0.6rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
}
.drug-table tr:hover td { background: var(--teal-pale); color: var(--text); }
.drug-name { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 0.825rem; }

.key-takeaways {
  background: var(--teal-pale); border: 1px solid var(--border-teal);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
}
.key-takeaways ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.key-takeaways li {
  font-size: 0.9rem; color: var(--text); display: flex;
  align-items: flex-start; gap: 0.5rem;
}
.key-takeaways li::before {
  content: '✓'; color: var(--teal); font-weight: 700; flex-shrink: 0;
}

.refs { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.refs li { font-size: 0.8rem; color: var(--text-faint); display: flex; gap: 0.4rem; }
.refs li::before { content: '[' counter(ref) ']'; counter-increment: ref; color: var(--teal); font-family: var(--mono); flex-shrink: 0; }
.refs { counter-reset: ref; }

/* ── Sidebar ── */
.sidebar-page {
  display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem;
  max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem;
}
.sidebar-card {
  background: var(--navy-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem;
}
.sidebar-card h3 {
  font-size: 0.7rem; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 700; margin-bottom: 0.875rem;
}

/* ── Recently viewed / Favourites ── */
.mini-list { display: flex; flex-direction: column; gap: 0.25rem; }
.mini-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.5rem; border-radius: 6px;
  font-size: 0.825rem; color: var(--text-dim); cursor: pointer;
  transition: var(--transition); text-decoration: none;
}
.mini-item:hover { background: var(--teal-pale); color: var(--teal); }
.mini-item .mini-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--teal); flex-shrink: 0;
}
.empty-state { font-size: 0.825rem; color: var(--text-faint); text-align: center; padding: 1rem; }

/* ── Print ── */
@media print {
  .site-header, .guideline-toc, .guideline-actions, .card__fav { display: none; }
  .guideline-layout { grid-template-columns: 1fr; }
  body { background: white; color: black; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .guideline-layout { grid-template-columns: 1fr; }
  .guideline-toc { display: none; }
  .sidebar-page { grid-template-columns: 1fr; }
  .nav-links .hide-mobile { display: none; }
  .guidelines-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .hero { padding: 1.5rem 1rem 1rem; }
  .hero h1 { font-size: 1.5rem; }
  .info-grid { grid-template-columns: 1fr; }
  .guideline-title { font-size: 1.35rem; }
}

/* ── Misc ── */
.badge {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 0.15rem 0.5rem; border-radius: 4px;
}
.badge--red { background: rgba(224,82,82,0.15); color: #e05252; }
.badge--amber { background: rgba(240,168,67,0.15); color: var(--amber); }
.badge--green { background: rgba(62,207,142,0.15); color: var(--green); }

.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

.stats-bar {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  justify-content: center; padding: 1rem 0 2rem;
}
.stat { text-align: center; }
.stat__num { font-size: 1.5rem; font-weight: 700; color: var(--teal); display: block; }
.stat__label { font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Favourites/Recently viewed page ── */
.page-header { padding: 2rem 1rem 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--navy-3); border: 1px solid var(--border-teal);
  color: var(--text); padding: 0.65rem 1.25rem; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; z-index: 9999;
  box-shadow: var(--shadow); transition: transform 0.3s ease;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Mobile sticky search bar ── */
@media (max-width: 640px) {
  .search-wrap {
    position: sticky;
    top: 57px;
    z-index: 80;
    background: rgba(10,22,40,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.5rem 0;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-bottom: 1px solid var(--border);
  }
}

/* ── Guideline layout wider screens ── */
@media (min-width: 1024px) {
  .guideline-layout {
    grid-template-columns: 240px 1fr;
  }
}

/* ── Card hover on touch devices ── */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: none;
  }
  .card:active {
    border-color: var(--border-teal);
    background: var(--navy-3);
  }
}

/* ── Focus visible ── */
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ── Smooth section reveal ── */
.section {
  animation: fadeUp 0.3s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.10s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.20s; }
.section:nth-child(5) { animation-delay: 0.25s; }
.section:nth-child(6) { animation-delay: 0.30s; }
.section:nth-child(7) { animation-delay: 0.35s; }
