:root {
  --fg: #1a1a1a;
  --muted: #555;
  --bg: #ffffff;
  --panel: #f6f7f9;
  --border: #e2e5ea;
  --accent: #2b6cb0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
}

header {
  max-width: 1400px;
  margin: 0 auto 1.5rem;
}

header h1 {
  font-size: 1.6rem;
  margin: 0 0 0.3rem;
}

header p {
  margin: 0;
  color: var(--muted);
}

/* plot left (~2/3), description right (~1/3) */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.plot {
  min-width: 0;            /* let the plotly div shrink inside the grid cell */
}

.desc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
}

.desc h2 {
  font-size: 1.15rem;
  margin-top: 0;
}

/* wide display equations scroll within the column instead of overflowing */
.desc mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.desc h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.desc code {
  background: #eceff3;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.desc pre {
  background: #1e2430;
  color: #e6e9ef;
  padding: 0.85rem 1rem;
  border-radius: 6px;
  overflow-x: auto;          /* scroll long lines instead of overflowing */
  font-size: 0.85rem;
  line-height: 1.4;
}
.desc pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* stack on narrow screens */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* extension-chord site map (above the plot) */
.site-map-wrap { margin-bottom: 1rem; text-align: center; }
.site-map {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* extension-chord location table (in its own box, next to the site map) */
.site-table {
  overflow-x: auto;
}
.site-table table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.site-table th, .site-table td {
  text-align: left;
  padding: 0.28rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.site-table th { font-weight: 600; }
.site-table tr:last-child td { border-bottom: none; }

/* extension-chord dropdown controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}
.controls label { display: flex; align-items: center; gap: 0.4rem; }
.controls select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--fg);
}
.controls .combo { color: var(--muted); }

/* breadcrumb link back to the landing page */
.crumb {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}
.crumb a { color: var(--accent); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* component cards: the landing-page grid, repeated at the top of every
   dashboard so the three stay in place as you move between them. 1400px to line
   up with header and .layout; auto-fit (not auto-fill) so the three cards
   stretch to fill the row rather than leaving empty tracks on wide screens. */
.cards {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}
.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h2 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.card.disabled {
  opacity: 0.55;
  pointer-events: none;
}
.card .tag {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* the card for the dashboard currently open */
.card.is-active {
  border-color: var(--accent);
  background: #eaf1f9;
  /* inset ring rather than a thicker border, so the card does not change size */
  box-shadow: inset 0 0 0 1px var(--accent);
  cursor: default;
}
.card.is-active:hover { transform: none; }
.card.is-active h2 { color: var(--accent); }

/* dashboard pages: the page's own title, below the shared card nav */
.page-intro {
  max-width: 1400px;
  margin: 1.75rem auto 1.25rem;
}
.page-intro h2 { font-size: 1.3rem; margin: 0 0 0.3rem; }
.page-intro p { margin: 0; color: var(--muted); }

/* landing page: the slide deck and the full thesis, embedded below the cards
   in a two-tab switcher */
.documents {
  max-width: 1400px;
  margin: 2.25rem auto 0;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.9rem;
}

.tab {
  appearance: none;
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 0.55rem 1.1rem;
  /* buttons do not inherit the body font, so restate it to match .card h2 */
  font: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  /* pull down by the tablist's 1px rule so the active tab can cover it */
  margin-bottom: -1px;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--fg); background: var(--panel); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tab[aria-selected="true"] {
  color: var(--accent);
  background: var(--bg);
  border-color: var(--border);
  /* paint over the tablist rule beneath this tab so the tab and its panel read
     as one continuous surface */
  box-shadow: 0 1px 0 0 var(--bg);
  cursor: default;
}

.tab-panel[hidden] { display: none; }

.pdf-frame {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

/* the deck is 16:9, so this avoids letterboxing */
.pdf-frame--slides { aspect-ratio: 16 / 9; }

/* the thesis is portrait, where a 16:9 frame would shrink a page to an
   unreadable strip; a tall viewport keyed to the window suits it better */
.pdf-frame--thesis { height: 85vh; min-height: 420px; }

/* iOS Safari (and some mobile browsers) will not render a PDF in an iframe, so
   the direct link is always offered underneath rather than only as fallback
   content inside the frame. */
.pdf-fallback {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.pdf-fallback a { color: var(--accent); }
