/* ============================================================
   Drought Observatories — admin help theme
   Mirrors the CCL/admin design system (Arial, navy + orange).
   ============================================================ */

:root {
  /* Brand */
  --orange:        #faa73e;
  --orange-2:      #f39325;
  --orange-3:      #e07a12;
  --orange-tint:   #fff7ec;   /* selected */
  --orange-hover:  #fff3e1;   /* row hover */
  --orange-chip:   #fff6e8;
  --orange-chip-bd:#f4c98a;
  --orange-chip-tx:#a35a07;
  --orange-mark:   #fff3c4;

  /* Navy / text */
  --navy:          #1f3e5a;
  --navy-2:        #2c4d6b;
  --navy-3:        #273b4b;
  --link-hover:    #286e9f;

  --text:          #212529;
  --muted:         #666;
  --muted-2:       #888;
  --muted-3:       #adb0b8;

  /* Surfaces */
  --bg:            #fafafa;
  --surface:       #ffffff;
  --row-alt:       #f7f7f7;

  /* Lines */
  --line:          #e3e3e3;
  --line-2:        #eee;
  --line-3:        #ddd;
  --input-bd:      #bbb;

  /* State */
  --green:         #3aa655;
  --green-tx:      #2a8045;
  --danger:        #c0392b;

  --radius:        3px;
  --radius-sm:     2px;

  --container:     1400px;
}

* { box-sizing: border-box; }

html { font-size: 18px; }
body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;             /* = 18px */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #AC4800; text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

mark {
  background: var(--orange-mark);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

[hidden] { display: none !important; }

.ht-loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 62, 90, 0.26);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(1px);
}

.ht-loader-overlay[hidden] {
  display: none !important;
}

.ht-loader-card {
  min-width: 220px;
  padding: 18px 22px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #f0d3ad;
  box-shadow: 0 20px 48px rgba(31, 62, 90, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ht-loader-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #f4ddbf;
  border-top-color: var(--orange-2);
  animation: ht-spin .8s linear infinite;
}

.ht-loader-text {
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
}

@keyframes ht-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Header — editorial banner pattern
   ============================================================ */
.help-header {
  background: var(--orange);
  color: #fff;
}
.help-header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.help-brand { display: flex; align-items: center; gap: 14px; }
.help-brand-mark { color: #fff; opacity: 0.95; display: flex; }
.help-brand-eyebrow {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  opacity: 0.85; font-weight: 400;
}
.help-brand-title {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 22px; font-weight: 400; letter-spacing: 0; line-height: 1.1;
  color: #fff;
}
.help-breadcrumb {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  display: flex; align-items: center; gap: 8px;
}
.help-breadcrumb a { color: rgba(255,255,255,0.85); }
.help-breadcrumb a:hover { color: #fff; text-decoration: none; }
.help-breadcrumb .sep { opacity: 0.5; }
.help-breadcrumb .current { color: #fff; font-weight: 400; }

/* ============================================================
   Intro band — navy page-title pattern
   ============================================================ */
.help-intro {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.help-intro-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px 28px 22px;
}
.help-intro-eyebrow {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--orange-3); font-weight: 600; margin-bottom: 6px;
}
.help-intro h1 {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 28px; font-weight: 400; letter-spacing: 0;
  margin: 0 0 6px; line-height: 1.2; color: var(--navy);
}
.help-intro-lede {
  font-size: 15px; color: var(--muted); line-height: 1.55;
  margin: 0; max-width: 80ch; text-wrap: pretty;
}

/* ============================================================
   Toolbar (matches admin "above table" toolbar pattern)
   ============================================================ */
.help-toolbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.help-toolbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 12px 28px;
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}

.help-app-select {
  display: flex; align-items: center; gap: 10px;
}
.help-app-select label {
  font-size: 13px; color: var(--navy); font-weight: 400;
}
.help-app-select select {
  font-family: inherit; font-size: 14px;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 9px center;
  appearance: none;
  color: var(--text);
  min-width: 260px;
  cursor: pointer;
}
.help-app-select select:focus {
  outline: 0; border-color: var(--orange-2);
  box-shadow: 0 0 0 2px rgba(243, 147, 37, 0.15);
}
.help-app-select .select2-container {
  min-width: 260px;
}
.help-app-select .select2-container--default .select2-selection--single {
  height: 34px;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.help-app-select .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 32px;
  padding-left: 10px;
  padding-right: 34px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.help-app-select .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 32px;
  right: 6px;
}
.help-app-select .select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--muted-2) transparent transparent transparent;
}
.help-app-select .select2-container--default.select2-container--open .select2-selection--single,
.help-app-select .select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--orange-2);
  box-shadow: 0 0 0 2px rgba(243, 147, 37, 0.15);
}
.select2-dropdown.help-app-select-dropdown {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.select2-container--open {
  z-index: 99999;
}
.select2-container--default .select2-search--dropdown {
  padding: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 14px;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  outline: 0;
  border-color: var(--orange-2);
  box-shadow: 0 0 0 2px rgba(243, 147, 37, 0.15);
}
.select2-results__option {
  font-family: inherit;
  font-size: 14px;
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: var(--orange-hover);
  color: var(--text);
}
.select2-container--default .select2-results__option--selected {
  background: var(--orange-tint);
  color: var(--navy);
}
.select2-container--default .select2-results > .select2-results__options {
  max-height: 320px;
}
.select2-container--default .select2-results__group {
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
}

.help-app-launch {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px;
  padding: 6px 12px;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--navy);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s;
}
.help-app-launch:hover {
  border-color: var(--orange-2);
  color: var(--orange-2);
  background: var(--bg);
}
.help-app-launch:focus {
  outline: 0;
}
.help-app-launch:focus-visible {
  border-color: var(--orange-2);
  box-shadow: 0 0 0 3px rgba(243, 147, 37, 0.22);
}
.help-app-launch[hidden] { display: none; }
.help-app-launch-icon { flex: 0 0 auto; }

.help-toolbar-spacer { flex: 1; }

.help-search {
  position: relative; display: flex; align-items: center;
  flex: 0 0 auto;
}
.help-search-label {
  font-size: 13px; color: var(--navy); margin-right: 8px;
}
.help-search-input-wrap {
  position: relative; display: inline-flex; align-items: center;
}
.help-search input {
  width: 240px;
  padding: 6px 30px 6px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.help-search input:focus {
  outline: 0; border-color: var(--orange-2);
  box-shadow: 0 0 0 2px rgba(243, 147, 37, 0.15);
}
.help-search input::placeholder { color: var(--muted-2); }
.help-search-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--muted-2); pointer-events: none;
  display: inline-flex; align-items: center;
}
.help-search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 5px;
  color: var(--muted-2);
  pointer-events: none;
}
.help-search.has-value .help-search-kbd { display: none; }
.help-search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; color: var(--muted-2); padding: 0;
  border-radius: 2px;
}
.help-search-clear:hover { background: var(--bg); color: var(--text); }
.help-search:not(.has-value) .help-search-clear { display: none; }

/* ============================================================
   Meta row
   ============================================================ */
.help-meta {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.help-meta-inner {
  max-width: var(--container); margin: 0 auto;
  padding: 8px 28px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted);
}
.help-meta-count strong { color: var(--navy); font-weight: 600; }
.help-meta-count em { font-style: normal; color: var(--orange-3); font-weight: 600; }
.help-meta-actions { display: flex; align-items: center; gap: 6px; }
.help-meta-actions button {
  background: transparent; border: 0;
  color: #AC4800; font-size: 13px; padding: 2px 4px;
}
.help-meta-actions button:hover:not(:disabled) {
  color: var(--link-hover); text-decoration: underline;
}
.help-meta-actions button:disabled { color: var(--muted-3); cursor: default; }
.help-meta-actions .dot { color: var(--muted-3); }

/* ============================================================
   List + entries (accordion as admin "card" pattern)
   ============================================================ */
.help-list {
  max-width: var(--container); margin: 0 auto;
  padding: 18px 28px 60px;
  display: flex; flex-direction: column; gap: 6px;
}

.help-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.help-entry:hover { border-color: var(--line-3); }
.help-entry.is-open {
  border-color: var(--orange-2);
}
.help-entry.is-open .help-entry-header {
  background: var(--orange-tint);
  border-bottom: 1px solid var(--line);
}

.help-entry-header {
  width: 100%;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  transition: background 0.15s;
}

.help-entry-toggle {
  width: 100%;
  background: transparent; border: 0;
  text-align: left;
  cursor: pointer;
  padding: 12px 18px;
  display: grid;
  grid-template-columns: 16px 1fr;
  column-gap: 14px;
  row-gap: 4px;
  align-items: start;
  font-family: inherit; color: inherit;
  min-width: 0;
}
.help-entry-toggle:focus {
  outline: 0;
}
.help-entry-toggle:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(243, 147, 37, 0.35);
}
.help-entry-header:hover { background: var(--orange-hover); }
.help-entry.is-open .help-entry-header:hover { background: var(--orange-tint); }

.help-entry-chevron {
  display: inline-flex; align-items: center; justify-content: center;
  height: 22px;
  color: var(--orange-3);
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}
.help-entry.is-open .help-entry-chevron { transform: rotate(0deg); }

.help-entry-title-block {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.help-entry-title-text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15.5px; font-weight: 600; letter-spacing: 0;
  color: var(--navy); line-height: 1.3;
}
.help-entry-short {
  font-size: 13.5px; color: var(--muted); line-height: 1.45;
}

.help-entry-actions {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 2px; flex-shrink: 0;
  padding: 12px 18px 12px 0;
}
.help-entry-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted-2);
  background: transparent;
  border: 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}
.help-entry-copy {
  font-size: 12px; color: #AC4800;
  background: transparent; border: 0;
  padding: 2px 4px;
  font-family: inherit;
  border-radius: 2px;
}
.help-entry-copy:hover { background: var(--orange-hover); color: var(--orange-3); }
.help-entry-copy.copied { color: var(--green-tx); }

/* App-of-origin chips (multiple per entry in "All applications" view) */
.help-entry-apps {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 320px;
  justify-content: flex-end;
}
.help-entry-app {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--orange-chip-tx);
  background: var(--orange-chip);
  border: 1px solid var(--orange-chip-bd);
  padding: 1px 7px;
  border-radius: var(--radius);
  white-space: nowrap;
  line-height: 1.5;
}
.help-entry-app-more {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line-3);
  cursor: help;
}

/* Body */
.help-entry-body {
  background: var(--surface);
  padding: 14px 22px 18px 48px;
}
.help-entry-main { font-size: 14.5px; color: var(--text); max-width: 80ch; line-height: 1.55; }
.help-entry-main p { margin: 0 0 10px; text-wrap: pretty; }
.help-entry-main p:last-child { margin-bottom: 0; }
.help-entry-main ul { margin: 0 0 10px; padding-left: 22px; }
.help-entry-main li { margin: 3px 0; }
.help-entry-main code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 5px; border-radius: var(--radius-sm);
}
.help-entry-main em { color: var(--text); font-style: italic; }
.help-entry-main strong { color: var(--navy); font-weight: 600; }
.help-entry-main a { color: #AC4800; }
.help-entry-main a:hover { color: var(--link-hover); }

/* Keywords block — matches admin keyword chip spec */
.help-entry-keywords {
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--line-2);
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.help-entry-keywords-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted-2); font-weight: 600;
}
.help-entry-keywords-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kw {
  font-size: 11.5px;
  background: #eef4fa;
  border: 1px solid #c9dcee;
  color: var(--navy);
  border-radius: var(--radius);
  padding: 2px 8px;
}

/* ============================================================
   Empty state
   ============================================================ */
.help-empty {
  text-align: center; padding: 56px 20px; color: var(--muted);
}
.help-empty-glyph { font-size: 32px; color: var(--muted-3); margin-bottom: 6px; }
.help-empty-title {
  font-size: 16px; color: var(--navy); font-weight: 600;
  margin-bottom: 4px;
  font-family: Arial, Helvetica, sans-serif;
}
.help-empty-sub { font-size: 14px; }
.linklike { background: 0; border: 0; color: #AC4800; padding: 0; font: inherit; cursor: pointer; }
.linklike:hover { color: var(--link-hover); text-decoration: underline; }

/* ============================================================
   Footer
   ============================================================ */
.help-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  margin-top: 32px;
}
.help-footer-inner {
  max-width: var(--container); margin: 0 auto;
  padding: 22px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.help-footer-title {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15.5px; font-weight: 600; color: var(--navy);
}
.help-footer-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.help-footer-cta {
  background: var(--orange-2);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.help-footer-cta:hover { background: var(--orange-3); text-decoration: none; }

/* ============================================================
   Server-rendered list: collapse + filter visibility
   ============================================================ */
.help-entry:not(.is-open) .help-entry-body { display: none; }
.help-entry.is-filtered-out { display: none; }

/* ============================================================
   Deep-link target pulse — short, subtle (admin motion guidance)
   ============================================================ */
.help-entry.is-target {
  animation: pulse-target 1.0s ease-out 1;
}
@keyframes pulse-target {
  0%   { box-shadow: 0 0 0 0 rgba(243,147,37,0.35); }
  100% { box-shadow: 0 0 0 6px rgba(243,147,37,0); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  html { font-size: 16px; }
  .help-header-inner { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 18px; }
  .help-intro-inner { padding: 18px 18px 16px; }
  .help-intro h1 { font-size: 22px; }
  .help-toolbar-inner { padding: 10px 18px; gap: 8px; }
  .help-app-select select { width: 100%; min-width: 0; }
  .help-app-select .select2-container { width: 100% !important; min-width: 0; }
  .help-search input { width: 100%; }
  .help-search { flex: 1 1 100%; }
  .help-toolbar-spacer { display: none; }
  .help-meta-inner { padding: 8px 18px; }
  .help-list { padding: 14px 18px 40px; }
  .help-entry-header { grid-template-columns: 1fr; }
  .help-entry-toggle { padding: 10px 14px; }
  .help-entry-actions { padding: 0 14px 10px 44px; margin-top: 6px; }
  .help-entry-body { padding: 12px 14px 16px 42px; }
  .help-footer-inner { flex-direction: column; align-items: flex-start; padding: 18px; }
}
