/*
 * autoindex.css - Session 11
 *
 * Re-styles Nginx's default autoindex output so the 26+ content folders
 * (yank/, stars/, MISSION_REPORTS/, Daily Bulletins/, etc.) render in the
 * canonical 306bg.us design system.
 *
 * Architecture: Nginx's `add_before_body` and `add_after_body` directives
 * wrap the autoindex output with `_autoindex-header.html` and
 * `_autoindex-footer.html`. Sub_filter directives in the nginx config strip
 * the autoindex's own `<html>`, `<head>`, `<body>` wrappers. The remaining
 * `<h1>Index of /path/</h1>`, `<hr>`, `<pre>` block sits inside our
 * `<main class="autoindex-page">` and is styled here.
 */

main.autoindex-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 32px 40px;
}

/* The auto-generated <h1>Index of /path/</h1> becomes the page title.
   Add a small "Archive Folder" kicker via ::before. */
main.autoindex-page > h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin: 0 0 32px;
  font-style: italic;
  position: relative;
  padding-top: 28px;
}
main.autoindex-page > h1::before {
  content: 'Archive Folder';
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rust);
  font-style: normal;
  font-weight: 500;
}

/* Hide the auto-generated <hr> separators - their job is taken by
   the bordered <pre> container below. */
main.autoindex-page > hr {
  display: none;
}

/* The <pre> contains the file listing. Treat it as a card. */
main.autoindex-page > pre {
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  padding: 22px 26px;
  margin: 0 0 32px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-soft);
  overflow-x: auto;
  white-space: pre;
}

/* Links inside the listing - the file names and the ../ parent link. */
main.autoindex-page > pre a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
  transition: color 0.12s, border-bottom-color 0.12s;
}
main.autoindex-page > pre a:hover,
main.autoindex-page > pre a:focus-visible {
  color: var(--rust);
  border-bottom-color: var(--rust);
}
main.autoindex-page > pre a:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

/* The parent-directory link gets a subtle visual lead. */
main.autoindex-page > pre a[href="../"] {
  color: var(--quiet);
  font-style: italic;
}
main.autoindex-page > pre a[href="../"]:hover {
  color: var(--rust);
  font-style: italic;
}

/* Footer actions - back-link buttons. */
.autoindex-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 40px 0 8px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.autoindex-actions .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  transition: background 0.15s;
}
.autoindex-actions .back-link:hover,
.autoindex-actions .back-link:focus-visible {
  background: var(--rust);
  color: var(--paper);
}
.autoindex-actions .back-link.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.autoindex-actions .back-link.secondary:hover,
.autoindex-actions .back-link.secondary:focus-visible {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* The autoindex emits a <title> inside <head> that browsers may move
   into <head>. If for any reason a stray <title> ends up in the body
   (older parser quirks), hide it. */
main.autoindex-page > title {
  display: none;
}

@media (max-width: 720px) {
  main.autoindex-page {
    padding: 40px 18px 32px;
  }
  main.autoindex-page > h1 {
    margin-bottom: 24px;
  }
  main.autoindex-page > pre {
    padding: 16px 18px;
    font-size: 12.5px;
    line-height: 1.7;
  }
  .autoindex-actions {
    margin-top: 28px;
  }
  .autoindex-actions .back-link {
    padding: 9px 14px;
    font-size: 10.5px;
  }
}

@media print {
  .autoindex-actions,
  .utility-bar,
  .site-footer,
  .main-nav {
    display: none !important;
  }
  main.autoindex-page > pre {
    border: 1px solid #999;
    background: transparent;
    color: #000;
  }
}
