/* Public manual viewer (data-manual.html, dashboard-guide.html).
   Loaded after styles.css for its fonts and --eve-* tokens. */

body[data-app="manual-viewer"] {
  height: auto;
  min-height: 100%;
  background: var(--eve-bg-00);
  color: var(--eve-text-10);
  font-size: 16px;
}

[data-app="manual-viewer"] :focus-visible {
  outline: 2px solid var(--eve-blue);
  outline-offset: 2px;
}

.manual-skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 60;
  padding: 8px 14px;
  border-radius: var(--eve-radius-sm);
  background: var(--eve-bg-card);
  color: var(--eve-blue-dark);
  font-weight: 600;
}

.manual-skip:focus {
  top: 10px;
}

/* --- Masthead --- */
.manual-masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 8px 24px;
  color: #fff;
  background: var(--eve-navy);
  box-shadow: 0 3px 12px rgba(15, 42, 61, 0.2);
}

.manual-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.manual-brand img {
  height: 38px;
  width: auto;
  flex: 0 0 auto;
}

.manual-brand span {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  line-height: 1.2;
}

.manual-brand strong {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.manual-brand small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.manual-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.manual-btn {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--eve-radius-sm);
  background: transparent;
  color: #fff;
  font: 600 13px/1.2 "DM Sans", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.manual-btn:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.1);
}

.manual-toc-toggle {
  display: none;
}

/* --- Layout --- */
.manual-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 48px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
}

.manual-toc {
  position: sticky;
  top: 60px;
  align-self: start;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 28px 4px 32px 0;
  font-size: 13.5px;
}

.manual-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px 12px;
  color: var(--eve-text-50);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.manual-toc-close {
  display: none;
  border: 0;
  background: none;
  color: var(--eve-text-40);
  font-size: 18px;
  cursor: pointer;
}

.manual-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.manual-toc a {
  display: block;
  padding: 5px 10px 5px 12px;
  border-left: 2px solid transparent;
  color: var(--eve-text-30);
  line-height: 1.35;
  text-decoration: none;
}

.manual-toc a:hover {
  color: var(--eve-blue-dark);
  background: var(--eve-blue-subtle);
}

.manual-toc a.is-active {
  border-left-color: var(--eve-blue);
  color: var(--eve-blue-dark);
  font-weight: 600;
  background: var(--eve-blue-subtle);
}

.manual-toc-h2 {
  margin-top: 4px;
}

.manual-toc-h2 > a {
  color: var(--eve-text-10);
  font-weight: 600;
}

.manual-toc-h3 > a {
  padding-left: 26px;
  font-size: 13px;
}

.manual-toc-backdrop {
  display: none;
}

.manual-content {
  min-width: 0;
  padding: 36px 0 24px;
}

.manual-content:focus {
  outline: none;
}

/* --- Article typography --- */
.manual-article {
  max-width: 820px;
  padding: 44px 56px 56px;
  border: 1px solid var(--eve-border-10);
  border-radius: var(--eve-radius-lg);
  background: var(--eve-bg-card);
  box-shadow: var(--eve-shadow-subtle);
  line-height: 1.7;
}

.manual-article > :first-child {
  margin-top: 0;
}

.manual-article :is(h1, h2, h3, h4, h5, h6) {
  position: relative;
  scroll-margin-top: 84px;
  color: var(--eve-text-00);
  line-height: 1.25;
}

.manual-article h1 {
  margin: 0 0 8px;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 40px;
  font-weight: 400;
}

.manual-article h1 + p {
  margin-top: 0;
  color: var(--eve-text-50);
  font-size: 14px;
}

.manual-article h2 {
  margin: 56px 0 16px;
  padding-top: 28px;
  border-top: 1px solid var(--eve-border-10);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 29px;
  font-weight: 400;
}

.manual-article h3 {
  margin: 36px 0 12px;
  font-size: 20px;
  font-weight: 700;
}

.manual-article h4 {
  margin: 28px 0 10px;
  color: var(--eve-blue-dark);
  font-size: 16.5px;
  font-weight: 700;
}

.manual-article :is(h5, h6) {
  margin: 22px 0 8px;
  font-size: 15px;
}

.manual-article p,
.manual-article ul,
.manual-article ol {
  margin: 0 0 16px;
}

.manual-article ul,
.manual-article ol {
  padding-left: 24px;
}

.manual-article li {
  margin: 4px 0;
}

.manual-article li > ul,
.manual-article li > ol {
  margin: 4px 0 0;
}

.manual-article a {
  color: var(--eve-blue-dark);
  text-decoration: underline;
  text-decoration-color: rgba(0, 122, 184, 0.35);
  text-underline-offset: 2px;
}

.manual-article a:hover {
  text-decoration-color: currentColor;
}

.manual-article strong {
  color: var(--eve-text-00);
}

.manual-article code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--eve-bg-10);
  color: var(--eve-data-blue-deep);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
}

.manual-article pre {
  overflow-x: auto;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--eve-radius);
  background: var(--eve-bg-10);
  line-height: 1.5;
}

.manual-article pre code {
  padding: 0;
  background: none;
}

.manual-article blockquote {
  margin: 0 0 18px;
  padding: 12px 18px;
  border-left: 4px solid var(--eve-blue);
  border-radius: 0 var(--eve-radius) var(--eve-radius) 0;
  background: var(--eve-blue-subtle);
  color: var(--eve-text-20);
}

.manual-article blockquote > :last-child {
  margin-bottom: 0;
}

.manual-article hr {
  margin: 32px 0;
  border: 0;
  border-top: 1px solid var(--eve-border-10);
}

.manual-article img {
  max-width: 100%;
  height: auto;
}

/* Wide tables scroll inside the article instead of widening the page. */
.manual-article table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  margin: 0 0 20px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.manual-article th,
.manual-article td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--eve-border-10);
  text-align: left;
  vertical-align: top;
}

.manual-article th {
  position: sticky;
  top: 0;
  background: var(--eve-bg-10);
  color: var(--eve-text-10);
  font-weight: 700;
  white-space: nowrap;
}

.manual-article tbody tr:nth-child(even) td {
  background: var(--eve-bg-00);
}

.manual-article .help-mermaid {
  margin: 8px 0 24px;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--eve-border-10);
  border-radius: var(--eve-radius);
  background: var(--eve-bg-soft);
  text-align: center;
}

/* Copy-link control on headings */
.manual-anchor {
  margin-left: 8px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--eve-text-60);
  font: 600 0.8em/1.4 "DM Sans", system-ui, sans-serif;
  vertical-align: middle;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.manual-article :is(h2, h3, h4):hover .manual-anchor,
.manual-anchor:focus-visible {
  opacity: 1;
}

.manual-anchor:hover {
  color: var(--eve-blue-dark);
  background: var(--eve-blue-subtle);
}

@media (hover: none) {
  .manual-anchor { opacity: 0.6; }
}

.manual-status {
  color: var(--eve-text-40);
}

.manual-error {
  color: var(--eve-exceptional);
}

.manual-retry {
  border-color: var(--eve-blue-dark);
  color: var(--eve-blue-dark);
}

.manual-retry:hover {
  background: var(--eve-blue-subtle);
}

.manual-footer {
  max-width: 820px;
  padding: 20px 4px;
  color: var(--eve-text-50);
  font-size: 12.5px;
}

.manual-footer a {
  color: var(--eve-blue-dark);
}

.manual-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: var(--eve-radius);
  background: var(--eve-navy);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--eve-shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.manual-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --- Narrow screens: contents become a drawer --- */
@media (max-width: 960px) {
  .manual-layout {
    display: block;
    padding: 0 16px;
  }

  .manual-toc-toggle {
    display: inline-flex;
  }

  .manual-toc {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 55;
    width: min(320px, 86vw);
    max-height: none;
    padding: 18px 12px 24px 8px;
    background: var(--eve-bg-card);
    box-shadow: var(--eve-shadow-panel);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .manual-toc.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }

  .manual-toc-close {
    display: block;
  }

  .manual-toc-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(14, 36, 51, 0.45);
  }

  .manual-content {
    padding-top: 20px;
  }

  .manual-article {
    max-width: none;
    padding: 28px 22px 36px;
  }
}

@media (max-width: 640px) {
  .manual-masthead {
    flex-wrap: wrap;
    padding: 8px 16px;
  }

  .manual-brand small {
    display: none;
  }

  .manual-actions {
    justify-content: flex-start;
  }

  .manual-actions #manualDownload,
  .manual-actions #manualPrint {
    display: none;
  }

  .manual-article {
    padding: 22px 16px 28px;
    border-radius: var(--eve-radius);
    font-size: 15px;
  }

  .manual-article h1 { font-size: 31px; }
  .manual-article h2 { font-size: 24px; margin-top: 40px; }
  .manual-article h3 { font-size: 18px; }

  .manual-article :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: 116px;
  }
}

/* --- Print / Save as PDF --- */
@media print {
  @page { margin: 18mm 16mm; }

  body[data-app="manual-viewer"] {
    background: #fff;
    font-size: 10.5pt;
  }

  .manual-masthead,
  .manual-toc,
  .manual-toc-backdrop,
  .manual-anchor,
  .manual-toast,
  .manual-skip {
    display: none !important;
  }

  .manual-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .manual-content {
    padding: 0;
  }

  .manual-article {
    max-width: none;
    padding: 0;
    border: 0;
    box-shadow: none;
    line-height: 1.5;
  }

  .manual-article h2 {
    margin-top: 28px;
    break-before: auto;
  }

  .manual-article :is(h1, h2, h3, h4) {
    break-after: avoid;
  }

  .manual-article table {
    display: table;
    width: 100%;
    font-size: 8.5pt;
  }

  .manual-article th {
    position: static;
    white-space: normal;
  }

  .manual-article tr,
  .manual-article .help-mermaid,
  .manual-article blockquote,
  .manual-article pre {
    break-inside: avoid;
  }

  .manual-article .help-mermaid {
    overflow: visible;
    border: 0;
  }

  .manual-article .help-mermaid svg {
    max-width: 100% !important;
    height: auto;
  }

  .manual-article a {
    color: inherit;
  }

  .manual-footer {
    max-width: none;
    padding: 12px 0 0;
  }
}
