/* The Glossary page: a filing drawer of terms. Each tab pulls a paper out
   of its folder. Colors, fonts and the navigation bar come from styles.css. */

.glossary {
  --folder: #F0F0EA;
  --paper: #FBFBF6;
  --row: 22px;      /* how much of each folder shows above the next one */
  --tab-h: 19px;
  max-width: 900px; margin: 0 auto; padding: 32px 16px 64px;
  line-height: 1.6; color: var(--ink-2);
}
.glossary h1 { margin: 0 0 6px; font-size: 32px; line-height: 1.2; color: var(--ink); letter-spacing: -0.02em; }
.glossary-head > p { margin: 0; max-width: 640px; font-size: 15px; color: var(--muted); }

/* As on Finances, the gray band sits behind just the heading and intro,
   ending in its line above the drawer. The heading and intro drift down
   as you scroll (see glossary.js) and are cut off at that line, so they
   sink out of sight there. */
body.glossary-page::before { display: none; }
.glossary-head { position: relative; padding-bottom: 28px; clip-path: inset(-100vh -100vmax 0 -100vmax); }
.glossary-head > * { will-change: transform, opacity; }
.glossary-head::before, .glossary-head::after {
  content: ""; position: absolute; left: 0; right: 0; z-index: -1;
  clip-path: inset(0 -100vmax);
}
.glossary-head::before { top: -32px; bottom: 0; background: var(--bg-band); box-shadow: 0 0 0 100vmax var(--bg-band); }
.glossary-head::after { bottom: 0; height: 1px; background: var(--card-border); box-shadow: 0 0 0 100vmax var(--card-border); }
/* On phones the Back row above the heading (nav.js) sits on the same band */
@media (max-width: 720px) {
  body.glossary-page .back-row { background: var(--bg-band); }
}

/* ---------- The drawer ---------- */

/* Its own stacking layer, so the folders stay under the navigation bar's menus */
.drawer { position: relative; z-index: 0; margin-top: 36px; }
/* glossary.js sets the height and places each folder with --top and --inset */
.cabinet { position: relative; }
.folder {
  position: absolute; left: var(--inset); right: var(--inset); top: var(--top); height: 46px;
  background: var(--folder) var(--grain); border: 1px solid var(--ink); border-bottom: 0;
}
/* Folder tabs stick up from the folder's top edge, at --x across it */
.file-tab, .letter-tab {
  position: absolute; left: var(--x); bottom: calc(100% - 1px); height: var(--tab-h);
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  border: 1px solid var(--ink); border-bottom: 0; border-radius: 6px 6px 0 0;
  font-family: var(--mono); font-size: 11px; line-height: 1; white-space: nowrap; overflow: hidden;
}
.file-tab {
  width: 30%; background: var(--folder); color: var(--ink); cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.file-tab:hover { transform: translateY(-3px); background: var(--paper); }
.file-tab:focus-visible { outline: 2px solid var(--color-2); outline-offset: 2px; }
/* The folder whose paper is out */
.file-tab[aria-expanded="true"] { background: var(--paper); }
.file-tab .tab-no { color: var(--muted); }
.file-tab .tab-name { overflow: hidden; text-overflow: ellipsis; font-family: var(--sans); font-weight: 500; font-size: 12px; }
/* Black letter dividers */
.letter-tab {
  width: 18%; justify-content: space-between; background: var(--ink); color: var(--bg);
  font-weight: 700;
}
.letter-tab .tab-count { font-weight: 400; opacity: 0.7; }
.folder.is-divider { background: #E6E6DE var(--grain); }

/* The drawer front, over the bottom of the last folders */
/* In front of every folder (glossary.js stacks them 1, 2, 3...; the drawer
   is its own stacking layer, so this can't cover the paper) */
.drawer-front {
  position: relative; z-index: 1000; margin-top: -10px; min-height: 250px; padding: 40px 20px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 36px;
  background: #E2E2DA var(--grain); border: 1px solid var(--ink); border-radius: 4px 4px 10px 10px;
}
.drawer-label {
  padding: 6px 18px; border: 1px solid var(--ink); background: var(--color-2) var(--grain); color: #fff;
  font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 0.18em;
}
.drawer-handle {
  width: 140px; height: 14px; border: 1px solid var(--ink); border-radius: 8px;
  background: linear-gradient(var(--bg), #C8C8C0);
}
.drawer-note { margin: auto 0 0; font-size: 12px; color: var(--muted); }

/* ---------- The paper ---------- */

.dim {
  position: fixed; inset: 0; z-index: 90; background: rgba(40, 40, 30, 0.38);
}
.paper {
  position: fixed; z-index: 91; top: 88px; left: calc(50% - min(330px, 50% - 16px));
  width: min(660px, 100% - 32px); max-height: calc(100vh - 120px); overflow-y: auto;
  padding: 28px 30px 22px; transform-origin: top left;
  background: var(--paper) var(--grain); border: 1px solid var(--ink); border-radius: 3px;
  box-shadow: 0 20px 50px rgba(27, 26, 23, 0.28);
}
.paper:focus { outline: none; }
.paper-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--ink);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.paper-close:hover { background: var(--surface); }
.paper-close:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.paper-filed {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-2);
}
.paper-title {
  margin: 4px 0 14px; padding: 0 44px 12px 0; border-bottom: 1px solid var(--ink);
  font-size: 28px; line-height: 1.2; color: var(--ink); letter-spacing: -0.02em;
}
/* The paper's own title is shown above, so the term's heading isn't */
.term > h2 { display: none; }
.term p { margin: 0 0 12px; font-size: 15px; }
.term p:last-child { margin-bottom: 0; }
.term strong { color: var(--ink); }
.term a { color: var(--ink); }

/* Worked examples with live numbers */
.example {
  margin: 4px 0 14px; padding: 12px 16px; background: var(--surface);
  border-left: 3px solid var(--color-2);
}
.example-label {
  margin-bottom: 4px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.example p { margin: 0; }
.example b { font-family: var(--mono); font-weight: 500; color: var(--ink); }

/* Little labels like INDEX, USD, Ctrl K */
.tag {
  display: inline-block; padding: 0 7px; border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--mono); font-size: 12px; line-height: 20px; color: var(--muted); white-space: nowrap;
}
.up { color: var(--up); }
.down { color: var(--down); }

/* Related terms: each files this paper back and pulls that one out */
.paper-see {
  margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.paper-see-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
#paper-see { display: contents; }
.see-link {
  padding: 3px 10px; border: 1px solid var(--ink); border-radius: 6px 6px 0 0; border-bottom-width: 0;
  background: var(--folder); color: var(--ink); font: 500 13px var(--sans); cursor: pointer;
}
.see-link:hover { background: var(--surface); }
.see-link:focus-visible { outline: 2px solid var(--color-2); outline-offset: 2px; }

/* Ticker codes table */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.ticker-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ticker-table th {
  padding: 8px; text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.ticker-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ticker-table tr:last-child td { border-bottom: 0; }
.ticker-table .group-row td {
  padding-top: 16px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.ticker-code { font-family: var(--mono); font-weight: 500; color: var(--ink); white-space: nowrap; }
.ticker-table a { color: var(--ink); font-weight: 500; }

/* While a paper is out, the page behind it doesn't scroll */
body.paper-open { overflow: hidden; }

/* ---------- Phones: a straight stack of tabs, papers full screen ---------- */

@media (max-width: 600px) {
  .glossary { padding-top: 24px; }
  .glossary-head::before { top: -24px; }
  .glossary h1 { font-size: 28px; }
  .cabinet { height: auto !important; display: flex; flex-direction: column; }
  .folder {
    position: relative; left: auto; right: auto; top: auto; height: 44px; margin-top: -1px;
    display: flex; align-items: stretch; border-bottom: 1px solid var(--ink);
  }
  .folder.is-divider { height: 30px; margin-top: 10px; }
  .file-tab, .letter-tab {
    position: static; width: 100%; height: auto; border: 0; border-radius: 0; padding: 0 14px;
  }
  .file-tab .tab-name { font-size: 14px; }
  .file-tab:hover { transform: none; }
  .file-tab:focus-visible { outline-offset: -3px; }
  .drawer-front { margin-top: 14px; min-height: 200px; padding-top: 32px; gap: 28px; border-radius: 10px; }

  .paper {
    top: 0; left: 0; width: 100%; height: 100%; max-height: none;
    padding: 24px 18px 28px; border: 0; border-radius: 0; box-shadow: none;
  }
  .paper-title { font-size: 24px; }
}
