/* ---------------------------------------------------------------------- */
/* Custom theme polish for the Web Dev Book (CSC336 + CSC337)             */
/* ---------------------------------------------------------------------- */

:root {
  --wdb-radius: 0.6rem;
}

/* ---- Top nav tab dropdown menus ----------------------------------------- */
/* Pairs with overrides/partials/tabs-item.html, which adds .md-tabs__submenu
   markup for any top-level tab with more than one child. Desktop only --
   .md-tabs itself is hidden below the tablet breakpoint, where the drawer
   sidebar already lists everything, so no touch/click handling is needed. */

.md-tabs__item--dropdown {
  position: relative;
}

/* Material sets .md-tabs { overflow: auto } so the tab bar can scroll
   horizontally when tabs overflow it -- that same rule clips our vertical
   dropdown regardless of the submenu's own positioning.
   Setting only overflow-y: visible while leaving overflow-x: auto does NOT
   work here: per the CSS Overflow spec, when overflow-x and overflow-y
   differ and neither is "clip", a "visible" value on one axis is force-
   computed to "auto" -- which still clips. So this drops horizontal
   scrolling on the tab bar entirely (6 top-level tabs fit comfortably at
   any width wide enough to show .md-tabs at all -- it's hidden below the
   tablet breakpoint regardless) in favor of the dropdown actually working. */
.md-tabs,
.md-tabs__list {
  overflow: visible;
}

/* .md-tabs__list also sets `contain: content`, which forces paint clipping
   at its own bounds independent of `overflow` -- must be lifted too, or the
   dropdown stays invisible no matter what overflow says. */
.md-tabs__list {
  contain: none;
}

.md-tabs__submenu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  min-width: 15rem;
  max-height: 75vh;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem 0;
  list-style: none;
  background: var(--md-default-bg-color);
  border-radius: 0 0 var(--wdb-radius) var(--wdb-radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.md-tabs__item--dropdown:hover .md-tabs__submenu,
.md-tabs__item--dropdown:focus-within .md-tabs__submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.md-tabs__submenu li a {
  display: block;
  padding: 0.5rem 1.1rem;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--md-default-fg-color);
  opacity: 0.8;
  text-decoration: none;
  white-space: nowrap;
}

.md-tabs__submenu li a:hover {
  background: var(--md-code-bg-color);
  color: var(--md-accent-fg-color);
  opacity: 1;
}

/* ---- Landing page hero + course cards ---------------------------------- */

.wdb-hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.wdb-hero h1 {
  font-size: 2.2rem;
  margin-bottom: 0.4rem;
}

.wdb-hero p {
  font-size: 1.1rem;
  opacity: 0.8;
  max-width: 42rem;
  margin: 0 auto;
}

.wdb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2.5rem;
}

.wdb-card {
  position: relative;
  display: block;
  padding: 1.25rem 1.4rem;
  border-radius: var(--wdb-radius);
  border: 1px solid var(--md-default-fg-color--lightest);
  background: var(--md-code-bg-color);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.wdb-card-link {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.wdb-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  border-color: var(--md-accent-fg-color);
}

.wdb-card h3 {
  margin: 0 0 0.35rem;
  color: var(--md-default-fg-color);
}

.wdb-card p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.75;
}

.wdb-card .wdb-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}

/* ---- Unit / lecture overview tables ------------------------------------ */

.md-typeset table:not([class]) th {
  background-color: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}

/* ---- Key takeaways / callout polish ------------------------------------ */

.md-typeset .admonition,
.md-typeset details {
  border-radius: var(--wdb-radius);
}

/* ---- Mermaid diagrams: keep them comfortably sized and centered -------- */

.md-typeset .mermaid {
  display: flex;
  justify-content: center;
  margin: 1.2rem 0;
}

/* ---- Content images: frame screenshots so they stand out from body text */

.md-typeset img {
  display: block;
  box-sizing: border-box;
  max-width: 100%;
  margin: 1.5rem auto;
  padding: 8px;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: var(--wdb-radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  background: var(--md-default-bg-color);
}

/* Logos/icons that happen to sit inside typeset content (rare) shouldn't get
   the screenshot treatment -- opt out with this class if ever needed. */
.md-typeset img.wdb-bare {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: none;
}

/* ---- Live CSS demos: a screenshot-style frame for genuinely running,
   embedded HTML/CSS examples (animations, transitions, hover effects) that
   a static image can't show. Same framing as .md-typeset img above, so a
   live demo sits in the page exactly like a screenshot would. */

.wdb-live-demo {
  display: block;
  box-sizing: border-box;
  max-width: 100%;
  margin: 1.5rem auto;
  padding: 28px;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: var(--wdb-radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  background: var(--md-default-bg-color);
  text-align: center;
}

.wdb-live-demo .wdb-live-caption {
  margin: 16px 0 0;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--md-default-fg-color--light);
}

/* ---- Lecture chapter nav badge ------------------------------------------ */

.wdb-lecture-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1.5rem;
}

.wdb-lecture-meta span {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--md-code-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
}
