/* User Provided Stylesheet */

/* =========================================================================
   Tanager Hyperspectral Course — custom theme styles
   Framework: Jupyter Book v2 / MyST-MD (book-theme)
   Loaded via myst.yml -> site.options.style
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Design tokens
   ------------------------------------------------------------------------- */
:root {
  scroll-behavior: smooth;

  /* Accent: spectral teal -> turquoise */
  --ts-accent:        #14b8a6;          /* teal-500  */
  --ts-accent-strong: #0d9488;          /* teal-600 (hover) */
  --ts-accent-2:      #06b6d4;          /* cyan-500  */
  --ts-accent-soft:   rgba(20, 184, 166, 0.08);
  --ts-accent-border: rgba(20, 184, 166, 0.22);
  --ts-gradient: linear-gradient(135deg, #14b8a6 0%, #06b6d4 55%, #2dd4bf 100%);
  /* Slightly dimmer variant for button fills (less glare under white text) */
  --ts-gradient-btn: linear-gradient(135deg, #0d9488 0%, #0891b2 55%, #14b8a6 100%);

  /* Surfaces & text */
  --ts-card-bg:     #ffffff;
  --ts-card-border: #e6e8f0;
  --ts-surface:     #f7f8fb;
  --ts-muted:       #586173;

  /* Shape & depth */
  --ts-radius:    16px;
  --ts-radius-sm: 10px;
  --ts-shadow:        0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 26px -14px rgba(15, 23, 42, 0.20);
  --ts-shadow-hover:  0 2px 6px rgba(15, 23, 42, 0.06), 0 18px 40px -16px rgba(79, 70, 229, 0.34);
  --ts-ring: 0 0 0 3px var(--ts-accent-soft);
}

html.dark {
  --ts-accent:        #2dd4bf;          /* teal-400 — bright spectral teal for dark bg */
  --ts-accent-strong: #5eead4;          /* teal-300 */
  --ts-accent-2:      #22d3ee;          /* cyan-400 */
  --ts-accent-soft:   rgba(45, 212, 191, 0.14);
  --ts-accent-border: rgba(45, 212, 191, 0.30);
  --ts-gradient: linear-gradient(135deg, #2dd4bf 0%, #22d3ee 55%, #67e8f9 100%);
  --ts-gradient-btn: linear-gradient(135deg, #14b8a6 0%, #0891b2 55%, #22d3ee 100%);

  --ts-card-bg:     #161b26;
  --ts-card-border: #2a3140;
  --ts-surface:     #11151e;
  --ts-muted:       #9aa3b4;
  --ts-shadow:        0 1px 2px rgba(0, 0, 0, 0.30), 0 12px 30px -16px rgba(0, 0, 0, 0.65);
  --ts-shadow-hover:  0 2px 8px rgba(0, 0, 0, 0.40), 0 20px 44px -18px rgba(45, 212, 191, 0.35);
}

/* -------------------------------------------------------------------------
   2. Base typography (scoped to the article content area)
   ------------------------------------------------------------------------- */
article {
  --ts-measure: 46rem;
  font-size: 1.02rem;
  line-height: 1.72;
}

article p,
article li {
  letter-spacing: 0.002em;
}

/* Comfortable reading measure for prose, while letting figures/tables/grids
   span full width. */
article > p,
article > ul,
article > ol,
article > blockquote {
  max-width: var(--ts-measure);
}

/* Headings: stronger hierarchy + breathing room */
article h1,
article h2,
article h3,
article h4 {
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.25;
}

article h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 2.7rem); }
article h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.85rem);
  margin-top: 2.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--ts-card-border);
}
article h3 {
  font-size: 1.28rem;
  margin-top: 1.9rem;
}
article h4 { font-size: 1.08rem; margin-top: 1.5rem; }

/* -------------------------------------------------------------------------
   3. Links (prose only — not card wrappers / buttons)
   Distinct via colour AND underline so meaning never relies on colour alone.
   ------------------------------------------------------------------------- */
article p a,
article li a,
article td a {
  color: var(--ts-accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: var(--ts-accent-border);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
article p a:hover,
article li a:hover,
article td a:hover {
  color: var(--ts-accent-strong);
  text-decoration-color: currentColor;
}

/* -------------------------------------------------------------------------
   4. Code — inline chips + blocks
   ------------------------------------------------------------------------- */
article :not(pre) > code {
  background: var(--ts-accent-soft);
  color: var(--ts-accent-strong);
  border: 1px solid var(--ts-accent-border);
  border-radius: 6px;
  padding: 0.12em 0.4em;
  font-size: 0.88em;
  font-weight: 500;
  word-break: break-word;
}

article pre {
  border-radius: var(--ts-radius-sm);
  padding: 1rem 1.1rem;
  border: 1px solid var(--ts-card-border);
  border-left: 3px solid var(--ts-accent-border);
  box-shadow: var(--ts-shadow);
  overflow-x: auto;
  font-size: 0.92em;
  line-height: 1.6;
}
article pre code {
  background: none;
  border: 0;
  padding: 0;
  font-weight: inherit;
}

/* -------------------------------------------------------------------------
   5. Tables
   ------------------------------------------------------------------------- */
article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
  border: 1px solid var(--ts-card-border);
  border-radius: var(--ts-radius-sm);
  overflow: hidden;
}
article thead th {
  background: var(--ts-surface);
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid var(--ts-card-border);
}
article th,
article td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--ts-card-border);
  vertical-align: top;
}
article tbody tr:nth-child(even) { background: var(--ts-accent-soft); }
article tbody tr:hover { background: var(--ts-accent-soft); }
article tbody tr:last-child td { border-bottom: 0; }

/* Let wide tables scroll instead of overflowing on small screens. */
@media (max-width: 720px) {
  article table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* -------------------------------------------------------------------------
   6. Blockquotes
   ------------------------------------------------------------------------- */
article blockquote {
  border-left: 4px solid var(--ts-accent);
  background: var(--ts-accent-soft);
  border-radius: 0 var(--ts-radius-sm) var(--ts-radius-sm) 0;
  padding: 0.6rem 1.1rem;
  color: inherit;
  font-style: normal;
}

/* -------------------------------------------------------------------------
   7. Admonitions / callouts
   The book-theme already styles each kind well (coloured left rail, header,
   icon) on `.myst-admonition` / `.myst-admonition-<kind>`. We only refine the
   corner radius and give the course's custom `recommended` kind a distinct
   cyan treatment. The header text label always remains, so the meaning of a
   callout never relies on colour alone. `!important` is used because the theme
   sets these colours via Tailwind utilities directly on the elements.
   ------------------------------------------------------------------------- */
article .myst-admonition {
  border-radius: var(--ts-radius-sm);
}

/* Custom `recommended` admonition (authored as `:class: recommended`, which the
   theme renders as a default note + the extra `recommended` class). */
article .myst-admonition.recommended {
  border-left-color: var(--ts-accent-2) !important;
}
article .myst-admonition.recommended .myst-admonition-header {
  color: var(--ts-accent-2) !important;
  background: var(--ts-accent-soft) !important;
}
article .myst-admonition.recommended .myst-admonition-header-icon {
  color: var(--ts-accent-2) !important;
}

/* -------------------------------------------------------------------------
   8. Reusable components (applied in markdown via {.class})
   ------------------------------------------------------------------------- */

/* 8a. Hero action buttons — links inside {div}.ts-actions ------------------ */
.ts-actions { margin: 0.4rem 0 1.6rem; }
.ts-actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin: 0.3rem 0.55rem 0.3rem 0;
  padding: 0.62rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.97rem;
  text-decoration: none;
  border: 1px solid var(--ts-accent-border);
  background: var(--ts-card-bg);
  color: var(--ts-accent);
  transition: transform 0.12s ease, box-shadow 0.15s ease,
              background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ts-actions a:hover {
  transform: translateY(-1px);
  border-color: var(--ts-accent);
  background: var(--ts-accent-soft);
  color: var(--ts-accent-strong);
}
/* The first action is the primary call-to-action. */
.ts-actions a:first-of-type {
  background: var(--ts-gradient-btn);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--ts-shadow);
}
.ts-actions a:first-of-type:hover {
  color: #fff;
  box-shadow: var(--ts-shadow-hover);
}
.ts-actions a:focus-visible {
  outline: none;
  box-shadow: var(--ts-ring);
}

/* 8b. Gradient text helper ----------------------------------------------- */
.ts-gradient-text {
  background: var(--ts-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* -------------------------------------------------------------------------
   9. Cards & responsive card grid
   We use the theme's myst-card components for navigation. These rules refine
   the corner radius, shadow, and add an inset top-accent on hover.
   ------------------------------------------------------------------------- */
article .myst-grid { gap: 1rem; }

article .myst-card {
  border-radius: var(--ts-radius);
  border-color: var(--ts-card-border);
  box-shadow: var(--ts-shadow);
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
/* Clickable cards lift + gain an inset top-accent stripe on hover.
   Higher specificity beats the theme's hover:border-blue-500 without !important. */
article a.myst-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--ts-shadow-hover), inset 0 3px 0 var(--ts-accent);
  border-color: var(--ts-accent);
}
article .myst-card-title {
  font-size: 1.06rem;
  color: var(--ts-accent-strong);
}

/* -------------------------------------------------------------------------
   10. Misc polish
   ------------------------------------------------------------------------- */
article img { border-radius: var(--ts-radius-sm); }

/* Colab launch badge — MyST rewrites src to a hashed path and injects
   margin-left:auto inline; target via data-canonical-url + wrapper class */
.myst-jp-nb-block {
  text-align: left;
}
img[data-canonical-url*="colab-badge"] {
  border-radius: 4px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.thumbnail-enhanced {
  filter: contrast(1.2) saturate(1.3) brightness(1.8);
}

article hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ts-card-border) 20%, var(--ts-card-border) 80%, transparent);
  margin: 2.5rem 0;
}

/* Text selection uses the course accent colour. */
::selection {
  background: rgba(20, 184, 166, 0.28);
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  article .ts-actions a,
  article .myst-card { transition: none; }
  article .ts-actions a:hover,
  article a.myst-card:hover { transform: none; }
  .ts-hero > * { animation: none !important; }
}

/* -------------------------------------------------------------------------
   11. Landing page — full-width hero & stats strip
   Activated via per-page frontmatter (hide_toc + hide_outline). Rules are
   class-scoped so they only fire on pages that actually use these divs.
   ------------------------------------------------------------------------- */

/* Hero entrance animation */
@keyframes ts-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 11a. Hero --------------------------------------------------------------- */
.ts-hero {
  position: relative;
  text-align: center;
  padding: 4rem 1.5rem 2.5rem;
  margin-bottom: 2.5rem;
  background: radial-gradient(ellipse 80% 50% at 50% -10%, var(--ts-accent-soft) 0%, transparent 65%);
  border-bottom: 1px solid var(--ts-card-border);
  overflow: hidden;
}

/* Accent bar — a thin solid teal line pinned to the hero bottom */
.ts-hero::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ts-accent);
}

/* Staggered fade-up entrance for each direct child of the hero */
.ts-hero > * {
  animation: ts-fade-up 0.5s ease-out both;
}
.ts-hero > *:nth-child(2) { animation-delay: 0.07s; }
.ts-hero > *:nth-child(3) { animation-delay: 0.14s; }
.ts-hero > *:nth-child(4) { animation-delay: 0.21s; }
.ts-hero > *:nth-child(5) { animation-delay: 0.28s; }

/* Logo sits above the title; responsive and centred. */
.ts-hero-logo {
  display: block;
  margin: 0 auto 1.25rem;
  width: clamp(280px, 42vw, 520px);
  max-width: 80%;
  height: auto;
}

/* MyST normalises the hero's raw <h1> to a content <h2>, so style both and
   strip the global `article h2` underline/spacing that would otherwise apply. */
.ts-hero h1,
.ts-hero h2 {
  font-size: clamp(2.6rem, 2rem + 3vw, 3.8rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 1rem;
  padding-bottom: 0;
  border-bottom: 0;
}

.ts-hero-tagline {
  max-width: 44rem;
  margin: 0 auto 1.8rem;
  font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);
  color: var(--ts-muted);
  line-height: 1.65;
}

.ts-hero-tagline p { margin: 0; }

.ts-hero .ts-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.8rem 0 0;
}

/* 11b. Stats strip -------------------------------------------------------- */
.ts-stats {
  display: flex;
  flex-wrap: wrap;
  max-width: 820px;
  margin: 0 auto 2.5rem;
  border: 1px solid var(--ts-card-border);
  border-radius: var(--ts-radius);
  overflow: hidden;
  background: var(--ts-card-bg);
  box-shadow: var(--ts-shadow);
}

.ts-stat {
  flex: 1;
  min-width: 150px;
  padding: 1.4rem 1rem;
  text-align: center;
  border-right: 1px solid var(--ts-card-border);
  transition: background 0.15s ease;
}

.ts-stat:hover { background: var(--ts-accent-soft); }

.ts-stat:last-child { border-right: none; }

.ts-stat p:first-child {
  font-size: 1.9rem;
  font-weight: 800;
  background: var(--ts-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  margin: 0 0 0.35rem;
}

.ts-stat p + p {
  font-size: 0.78rem;
  color: var(--ts-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0;
}

@media (max-width: 560px) {
  .ts-stat {
    min-width: 45%;
    border-bottom: 1px solid var(--ts-card-border);
  }
}

/* 11c. TanagerSpec companion callout ------------------------------------- */
.ts-companion {
  display: flex;
  flex-direction: row-reverse;   /* logo (first in DOM) → right; text + buttons → left */
  align-items: center;
  gap: 2rem;
  margin: 1.5rem auto 3rem;
  padding: 1.5rem;
  border: 1px solid var(--ts-card-border);
  border-radius: var(--ts-radius);
  background: var(--ts-card-bg);
  box-shadow: var(--ts-shadow);
}

.ts-companion-logo {
  flex: 0 0 280px;
}

.ts-companion-logo .ts-module-logo {
  display: block;
  margin: 0 auto;
}

.ts-module-logo-dark { display: none !important; }

html.dark .ts-module-logo-light,
body.dark .ts-module-logo-light,
.dark .ts-module-logo-light,
[data-theme="dark"] .ts-module-logo-light {
  display: none !important;
}

html.dark .ts-module-logo-dark,
body.dark .ts-module-logo-dark,
.dark .ts-module-logo-dark,
[data-theme="dark"] .ts-module-logo-dark {
  display: block !important;
}

.ts-companion-copy {
  flex: 1;
}

.ts-companion-copy p {
  margin: 0 0 1rem;
  color: var(--ts-muted);
  line-height: 1.65;
}

.ts-companion-copy p:first-child {
  color: inherit;
}

/* Multi-button row inside the companion callout.
   MyST wraps consecutive inline links in a single <p>, so we make that <p>
   the flex row — the <a> tags become the actual flex items. */
.ts-companion-actions {
  margin-top: 1.25rem;
}

article .ts-companion-actions p {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

/* All companion buttons — reset any prose-link overrides */
article .ts-companion-actions a {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none !important;
  border: 1.5px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.15s ease,
              background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Primary button — first <a> inside the <p> */
article .ts-companion-actions a:first-child {
  background: var(--ts-gradient-btn);
  color: #ffffff !important;
  border-color: transparent;
  box-shadow: var(--ts-shadow);
}

article .ts-companion-actions a:first-child:hover {
  color: #ffffff !important;
  box-shadow: var(--ts-shadow-hover);
  transform: translateY(-1px);
}

/* Secondary buttons (GitHub, Docs) */
article .ts-companion-actions a:not(:first-child) {
  background: var(--ts-card-bg);
  color: var(--ts-accent) !important;
  border-color: var(--ts-accent-border);
}

article .ts-companion-actions a:not(:first-child):hover {
  background: var(--ts-accent-soft);
  border-color: var(--ts-accent);
  color: var(--ts-accent-strong) !important;
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .ts-companion {
    flex-direction: column;
    text-align: center;
  }

  .ts-companion-logo {
    flex-basis: auto;
  }

  article .ts-companion-actions p {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* 11d. Centred content column --------------------------------------------
   With both sidebars hidden the article spans the full viewport, so we
   re-introduce a comfortable, centred reading column for everything below
   the full-bleed hero (intro prose, module card grid, aim, etc.). */
.ts-landing-body {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Centre the prose inside the column without forcing it edge-to-edge.
   (The global `article > p` measure no longer applies once content is
   nested in this wrapper, so restore a readable measure here.) */
.ts-landing-body > p,
.ts-landing-body > ul,
.ts-landing-body > ol {
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
}

/* 11e. Landing body — section heading overrides ----------------------- */
/* Override the global article h2 underline border for landing sections. */
.ts-landing-body h2 {
  margin-top: 3.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0;
  border-bottom: 0;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.75rem);
}

/* 11f. Aim highlight block -------------------------------------------- */
.ts-aim {
  margin: 0.25rem 0 2rem;
  padding: 1.5rem 1.75rem;
  border-left: 4px solid var(--ts-accent);
  background: var(--ts-accent-soft);
  border-radius: 0 var(--ts-radius-sm) var(--ts-radius-sm) 0;
}
.ts-aim > p {
  margin: 0;
  line-height: 1.75;
}

/* Hide the per-page author byline inherited from myst.yml project.authors */
.authors,
.article-authors { display: none; }

/* 11g. Authorship card ----------------------------------------------- */
.ts-authorship {
  margin: 0.25rem 0 2.5rem;
  padding: 1.75rem 2rem;
  border: 1px solid var(--ts-card-border);
  border-radius: var(--ts-radius);
  background: var(--ts-card-bg);
  box-shadow: var(--ts-shadow);
}
.ts-authorship > p { line-height: 1.75; }

/* 11i. Author byline — lay multiple affiliations side by side ---------
   The book-theme renders each affiliation as its own block <div>, so two
   affiliations stack vertically. Flow them inline and insert a comma between
   them. The comma is prepended to each item after the first (never after the
   last, never when there is a single affiliation). Using `::before` rather
   than `::after` avoids the trailing space the theme leaves inside each item,
   which would otherwise render as "Manitoba , Planet". */
.myst-fm-affiliation-col {
  display: flex;
  flex-wrap: wrap;
}
.myst-fm-affiliation-item + .myst-fm-affiliation-item::before {
  content: ", ";
}

/* 11h. Hero badges strip --------------------------------------------- */
.ts-hero-badges {
  margin: 0.8rem auto 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  align-items: center;
}

article .ts-hero-badges p {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
}

article .ts-hero-badges img {
  height: 21px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.1rem;
  margin-left: 0.1rem;
}
