/* Authority AI — the map legend (overlay + keys).
   Fully scoped: no global rules, so it is safe to load on the entrance without changing it. */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..600;1,9..144,300..600&family=Inter:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap");

.legend, .legend-key {
  --lg-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --lg-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --lg-sans: "Inter", system-ui, -apple-system, sans-serif;
}

/* The LEGEND key (header on inner pages; floating corner on the entrance). */
.legend-key {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; margin: 0;
  background: none; border: 0; cursor: pointer; text-decoration: none;
  font-family: var(--lg-mono); font-size: 11px; letter-spacing: 0.22em; line-height: 1; color: #8FA3BC;
}
.legend-key:hover { color: #E7ECF5; }
.legend-key:focus-visible { outline: 2px solid #6FA8FF; outline-offset: 3px; }
.legend-key kbd { font-family: var(--lg-mono); font-size: 10px; letter-spacing: 0; border: 1px solid rgba(143, 163, 188, 0.4); padding: 1px 5px; border-radius: 0; background: none; color: inherit; }
.dawn .legend-key { color: #6E675D; }
.dawn .legend-key:hover { color: #1C1A17; }
.dawn .legend-key kbd { border-color: rgba(28, 26, 23, 0.25); }

.legend-float {
  position: fixed; right: 36px; bottom: 32px; z-index: 900; opacity: 0;
  transition: opacity 1s ease 1.6s;
}
.legend-float.ready { opacity: 1; }

/* The overlay. */
.legend {
  position: fixed; inset: 0; z-index: 1000; display: none; flex-direction: column; box-sizing: border-box;
  background: rgba(3, 6, 14, 0.94); color: #E7ECF5; padding: 40px 80px 32px;
  font-family: var(--lg-sans); font-size: 16px; line-height: 1.5; text-align: left;
  overflow-y: auto; opacity: 0; transition: opacity 0.28s ease;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.legend *, .legend *::before, .legend *::after { box-sizing: border-box; }
.legend.open { display: flex; }
.legend.shown { opacity: 1; }
.legend a:focus-visible, .legend button:focus-visible { outline: 2px solid #6FA8FF; outline-offset: 4px; }

.legend .legend-top { display: flex; justify-content: space-between; align-items: center; }
.legend .wordmark { display: inline-flex; flex-direction: column; gap: 8px; text-decoration: none; color: #E7ECF5; min-height: 44px; justify-content: center; }
.legend .wordmark b { font-family: var(--lg-mono); font-size: 12px; letter-spacing: 0.2em; font-weight: 500; }
.legend .wordmark i { display: flex; align-items: center; }
.legend .wordmark i::before { content: ""; width: 120px; height: 1px; background: #6FA8FF; }
.legend .wordmark i::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #6FA8FF; }

.legend .legend-close { background: none; border: 0; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; gap: 10px; font-family: var(--lg-mono); font-size: 11px; letter-spacing: 0.2em; color: #8FA3BC; padding: 0; }
.legend .legend-close:hover { color: #E7ECF5; }
.legend .legend-close kbd { font-family: var(--lg-mono); font-size: 10px; letter-spacing: 0.04em; border: 1px solid rgba(143, 163, 188, 0.4); padding: 1px 6px; background: none; color: inherit; }

.legend .legend-head { margin-top: 56px; display: flex; align-items: baseline; gap: 24px; flex-wrap: wrap; }
.legend .legend-head h2 { margin: 0; font-family: var(--lg-mono); font-weight: 500; font-size: 12px; letter-spacing: 0.26em; color: #8FA3BC; }
.legend .legend-head p { margin: 0; font-family: var(--lg-serif); font-style: italic; font-weight: 300; font-size: 20px; color: #B9C6D8; }

.legend nav { margin-top: 20px; border-bottom: 1px solid rgba(143, 163, 188, 0.18); }
.legend .row {
  display: grid; grid-template-columns: 48px 32px 200px minmax(0, 1fr) 24px; align-items: center; gap: 0 20px;
  min-height: 84px; border-top: 1px solid rgba(143, 163, 188, 0.18); text-decoration: none; color: #E7ECF5;
}
.legend .row .n, .legend .row .name { font-family: var(--lg-mono); letter-spacing: 0.2em; }
.legend .row .n { font-size: 11px; color: #8FA3BC; }
.legend .row .name { font-size: 12px; }
.legend .row .line { font-family: var(--lg-serif); font-weight: 300; font-size: 28px; line-height: 1.25; color: #D5DDEA; }
.legend .row .arrow { color: #8FA3BC; transition: transform 0.2s ease, color 0.2s ease; }
.legend .row:hover .line, .legend .row:focus-visible .line { color: #FFFFFF; }
.legend .row:hover .arrow, .legend .row:focus-visible .arrow { color: #6FA8FF; transform: translateX(4px); }
.legend .row[aria-current="page"] .name::after { content: " · HERE"; color: #6FA8FF; }

.legend .legend-foot { margin-top: auto; padding-top: 32px; display: flex; justify-content: space-between; gap: 16px; }
.legend .legend-foot a { font-family: var(--lg-mono); font-size: 11px; letter-spacing: 0.18em; color: #8FA3BC; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.legend .legend-foot a:hover { color: #E7ECF5; }

body.legend-locked { overflow: hidden; }

@media (max-width: 820px) {
  .legend { padding: 24px 20px; }
  .legend .legend-head { margin-top: 36px; }
  .legend .row { grid-template-columns: 1fr; gap: 4px; padding: 16px 0; min-height: 0; }
  .legend .row .n, .legend .row svg, .legend .row .arrow { display: none; }
  .legend .row .line { font-size: 22px; }
  .legend-float { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .legend, .legend-float, .legend .row .arrow { transition: none; }
  .legend-float { opacity: 1; }
}
