/* Quant IP brand system (see the company brand design document):
   Paper/Ink/Rule neutrals, Filing Navy as the primary brand color, Alpha
   green rationed to a single call-to-action per screen, and the
   BUY/HOLD/SELL signal colors reused semantically (Sell for errors, Hold
   for cautionary/idle notices) rather than a generic red/blue. Typography
   follows the doc's three roles: Sans for display/UI, Serif for long-form
   prose (used here only for the EULA text), Mono for tabular/data content.

   Dark theme: every rule below reads these as var(--x), never a literal
   color, so retheming is entirely confined to this block and the two
   override blocks right after it -- nothing else in this file changes.
   Precedence (low to high): the light values here -> the OS-preference
   media query -> an explicit [data-theme] override set by
   theme-toggle.js. A bare `:root` and a `:root` inside a media query have
   identical specificity, so the media query only wins because it's
   *conditional*, not because it's "stronger" -- that's what lets the
   explicit [data-theme] blocks (higher specificity, an attribute
   selector) override it in either direction regardless of source order. */
:root {
  color-scheme: light dark;

  --paper: #f4f5f7;
  --surface: #ffffff;
  --ink: #0e1a24;
  --ink-2: #3f4c57;
  --ink-3: #6b7783;
  --rule: #cdd3da;
  --rule-2: #e1e5ea;

  --navy: #12386b;
  --navy-hover: #0d2b52;
  --alpha: #1f8f6a;
  --alpha-hover: #187a5b;

  --sell: #c0432f;
  --sell-bg: #fbeae7;
  --hold: #b08425;
  --hold-bg: #fbf1df;

  --font-display: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Automatic: follows the OS/browser preference when there's no explicit
   [data-theme] override. A deep navy-black rather than a neutral gray --
   ties the dark palette back to Filing Navy instead of reading as a
   generic "invert everything" dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --paper: #0c1420;
    --surface: #131c2b;
    --ink: #e7ebf0;
    --ink-2: #aab4c2;
    --ink-3: #7b8798;
    --rule: #263244;
    --rule-2: #1b2532;

    --navy: #6fa1e0;
    --navy-hover: #8fb7ea;
    --alpha: #2fb088;
    --alpha-hover: #3fc79c;

    --sell: #ef7b64;
    --sell-bg: rgba(239, 123, 100, 0.14);
    --hold: #e0ac53;
    --hold-bg: rgba(224, 172, 83, 0.14);
  }
}

/* Explicit override from the theme toggle (localStorage via
   theme-toggle.js), winning over the OS preference in either direction --
   [data-theme="dark"] here duplicates the media query's values verbatim
   (same values, just not conditional on the OS) rather than sharing them,
   since CSS custom properties can't be composed across separate rules. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: #0c1420;
  --surface: #131c2b;
  --ink: #e7ebf0;
  --ink-2: #aab4c2;
  --ink-3: #7b8798;
  --rule: #263244;
  --rule-2: #1b2532;

  --navy: #6fa1e0;
  --navy-hover: #8fb7ea;
  --alpha: #2fb088;
  --alpha-hover: #3fc79c;

  --sell: #ef7b64;
  --sell-bg: rgba(239, 123, 100, 0.14);
  --hold: #e0ac53;
  --hold-bg: rgba(224, 172, 83, 0.14);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-display);
  background: var(--paper);
  color: var(--ink);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.auth-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(14, 26, 36, 0.08);
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 1.375rem;
  margin: 0 0 0.25rem;
  color: var(--ink);
}

.subtitle {
  color: var(--ink-3);
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.auth-form label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.6rem;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
}

.auth-form input[type="text"]:focus,
.auth-form input[type="password"]:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.auth-form button {
  margin-top: 1.25rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 8px;
  /* The one rationed Alpha (accent) element on this screen -- the single
     primary call to action, per the brand doc's "one Alpha element per
     screen" rule. Nothing else on this page uses this color. */
  background: var(--alpha);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-form button:hover {
  background: var(--alpha-hover);
}

/* ---------- EULA ---------- */

.eula-box {
  margin-top: 1rem;
  max-height: 12rem;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.eula-box:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.eula-heading {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 0.6rem;
}

.eula-box p {
  margin: 0 0 0.75rem;
}

.eula-box ol {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
}

.eula-box li {
  margin-bottom: 0.5rem;
}

.eula-agree {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink-2);
  cursor: pointer;
}

.eula-agree input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.alert {
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--sell-bg);
  color: var(--sell);
}

.alert-info {
  background: var(--hold-bg);
  color: var(--hold);
}

.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--ink-3);
}

.inline-form {
  display: inline;
}

.link-button {
  background: none;
  border: none;
  color: var(--navy);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0;
}

.link-button:hover {
  text-decoration: underline;
}

.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.breadcrumbs {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--ink-3);
}

.breadcrumbs a {
  color: var(--navy);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.crumb-sep {
  margin: 0 0.35rem;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}

.file-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 0;
  border-bottom: 1px solid var(--rule);
}

.file-table th a {
  display: block;
  padding: 0.6rem 1rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.file-table th a:hover {
  color: var(--navy);
  text-decoration: none;
}

.sort-arrow {
  font-size: 0.6rem;
  color: var(--navy);
}

.file-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--rule-2);
  font-size: 0.9rem;
}

.file-table tr:last-child td {
  border-bottom: none;
}

.file-table a {
  color: var(--ink);
  text-decoration: none;
}

.file-table a:hover {
  color: var(--navy);
  text-decoration: underline;
}

.folder-download {
  margin-left: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

.folder-download:hover {
  color: var(--navy);
  border-color: var(--navy);
  text-decoration: none;
}

/* Tabular data -- sizes, dates -- gets the brand's mono "Data" role, with
   tabular figures so columns of numbers actually line up. */
.col-size,
.col-mtime {
  color: var(--ink-3);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.empty {
  color: var(--ink-3);
  text-align: center;
  padding: 2rem 1rem;
}

.idle-banner {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--hold-bg);
  color: var(--hold);
  border: 1px solid var(--hold);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(14, 26, 36, 0.12);
  z-index: 1000;
  max-width: 90vw;
}

/* Fades in immediately, holds, then fades out on its own via a pure CSS
   animation -- no JS needed to show, hide, or time it. Used both for
   notices the server renders directly into the page (see base.html) and
   ones folder-download.js adds to the DOM itself; either way the same
   animation handles the appear/hold/disappear lifecycle. */
@keyframes toast-lifecycle {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0.5rem);
  }
  8%, 85% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(0.5rem);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 4rem;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(14, 26, 36, 0.12);
  z-index: 1000;
  max-width: 90vw;
  pointer-events: none;
  animation: toast-lifecycle 5s ease forwards;
}

.toast-error {
  background: var(--sell-bg);
  color: var(--sell);
  border: 1px solid var(--sell);
}
