/* Learn Mermaid figure presentation and controls */

#learn-md-content .learn-mermaid-figure {
  --mermaid-zoom: 1;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  margin: 1.5rem 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #dbe2ea;
  border-radius: 0.75rem;
  background: #fff;
}

#learn-md-content .learn-mermaid-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

#learn-md-content .learn-mermaid-control {
  min-width: 2.25rem;
  padding: 0.38rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.42rem;
  background: #fff;
  color: #1e293b;
  font: 600 0.75rem/1.2 Inter, system-ui, sans-serif;
  cursor: pointer;
}

#learn-md-content .learn-mermaid-control:hover {
  border-color: #6366f1;
  color: #3730a3;
}

#learn-md-content .learn-mermaid-control:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.35);
  outline-offset: 2px;
}

#learn-md-content .learn-mermaid-figure > .mermaid {
  box-sizing: border-box;
  width: 100%;
  height: 360px;
  min-height: 360px;
  margin: 0;
  padding: 1.25rem;
  overflow: auto;
}

#learn-md-content .learn-mermaid-figure > .mermaid svg {
  transform: scale(var(--mermaid-zoom));
  transform-origin: center center;
  transition: transform 160ms ease;
}

#learn-md-content .learn-mermaid-caption {
  padding: 0.75rem 1rem;
  border-top: 1px solid #e5e7eb;
  color: #475569;
  background: #f8fafc;
  font: 500 0.82rem/1.45 Inter, system-ui, sans-serif;
  text-align: left;
}

#learn-md-content .learn-mermaid-figure:fullscreen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
}

#learn-md-content .learn-mermaid-figure:fullscreen > .mermaid {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 2rem;
  overflow: auto;
}

@media (max-width: 700px) {
  #learn-md-content .learn-mermaid-figure > .mermaid {
    height: 300px;
    min-height: 300px;
  }

  #learn-md-content .learn-mermaid-toolbar {
    flex-wrap: wrap;
  }
}

@media print {
  #learn-md-content .learn-mermaid-toolbar {
    display: none;
  }

  #learn-md-content .learn-mermaid-figure {
    break-inside: avoid;
    border: 0;
  }
}

/* =========================================================
   Zomniverse — Learn Image Viewer

   PATCH 2026-08-11 | IMAGE VIEWER CSS EXTRACTION

   Owns:
   - normal embedded image viewer
   - image toolbar
   - image controls
   - image stage
   - image zoom presentation
   - image caption presentation
   - normal print behavior

   Fullscreen presentation is owned separately by
   learn-image-fullscreen.css.
========================================================= */

#learn-md-content .learn-image-viewer {
  --learn-image-zoom: 1;

  position: relative;
  display: block;

  width: 100%;
  margin: 1rem 0;

  overflow: hidden;

  border: 1px solid #dbe2ea;
  border-radius: 0.65rem;

  background: #ffffff;
}


/* =========================================================
   TOOLBAR
========================================================= */

#learn-md-content .learn-image-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;

  gap: 0.4rem;

  padding: 0.5rem 0.6rem;

  border-bottom: 1px solid #e5e7eb;

  background: #f8fafc;
}


/* =========================================================
   CONTROLS
========================================================= */

#learn-md-content .learn-image-control {
  min-width: 2.25rem;

  padding: 0.38rem 0.65rem;

  border: 1px solid #cbd5e1;
  border-radius: 0.42rem;

  background: #ffffff;
  color: #1e293b;

  font:
    600
    0.75rem/1.2
    Inter,
    system-ui,
    sans-serif;

  cursor: pointer;

  transition:
    border-color 140ms ease,
    color 140ms ease,
    background-color 140ms ease,
    transform 140ms ease;
}

#learn-md-content .learn-image-control:hover {
  border-color: #6366f1;
  color: #3730a3;
}

#learn-md-content .learn-image-control:active {
  transform: scale(0.96);
}

#learn-md-content .learn-image-control:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.35);
  outline-offset: 2px;
}


/* =========================================================
   IMAGE STAGE
========================================================= */

#learn-md-content .learn-image-stage {
  display: grid;
  place-items: center;

  box-sizing: border-box;

  width: 100%;
  min-height: 220px;

  padding: 1rem;

  overflow: auto;

  cursor: zoom-in;

  background: #ffffff;
}


/* =========================================================
   IMAGE MEDIA
========================================================= */

#learn-md-content .learn-image-stage > img,
#learn-md-content .learn-image-stage > a > img {
  display: block;

  max-width: 100%;
  height: auto;

  margin: auto;

  transform:
    scale(
      var(--learn-image-zoom)
    );

  transform-origin:
    center center;

  transition:
    transform 160ms ease;
}


/* =========================================================
   CAPTION
========================================================= */

#learn-md-content .learn-image-viewer + em {
  display: block;

  margin-top: 0.5rem;

  color: #64748b;

  font-size: 0.85rem;
  line-height: 1.5;

  text-align: center;
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {
  #learn-md-content
  .learn-image-stage > img,

  #learn-md-content
  .learn-image-stage > a > img,

  #learn-md-content
  .learn-image-control {
    transition: none;
  }
}


/* =========================================================
   PRINT
========================================================= */

@media print {

  #learn-md-content .learn-image-toolbar {
    display: none !important;
  }

  #learn-md-content .learn-image-viewer {
    overflow: visible;

    border: 0;
    border-radius: 0;

    background: transparent;

    box-shadow: none;

    break-inside: avoid;
  }

  #learn-md-content .learn-image-stage {
    min-height: 0;

    padding: 0;

    overflow: visible;
  }

  #learn-md-content .learn-image-stage > img,
  #learn-md-content .learn-image-stage > a > img {
    transform: none !important;
  }
}

/* =========================================================
   TEST OVERRIDE 2026-08-11 | PUBLICATION FIGURE VIEWERS
   Minimal journal-style image + Mermaid presentation with
   floating SVG controls and publication-style legends.
========================================================= */


/* =========================================================
   SHARED FIGURE SHELL
========================================================= */

#learn-md-content .learn-image-viewer,
#learn-md-content .learn-mermaid-figure {
  position: relative;

  /* margin: 1.8rem 0 0.55rem; */

  overflow: hidden;

  border: 1px solid #d9dee7;
  border-radius: 7px;

  background: #ffffff;

  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.025);
}


/* =========================================================
   FLOATING TOOLBARS
   Removes the old top bar completely.
========================================================= */

#learn-md-content .learn-image-toolbar,
#learn-md-content .learn-mermaid-toolbar {
  position: absolute;
  z-index: 20;

  top: 10px;
  right: 10px;

  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 3px;

  margin: 0;
  padding: 4px;

  border: 1px solid rgba(203, 213, 225, 0.72);
  border-radius: 8px;

  background: rgba(255, 255, 255, 0.88);

  box-shadow:
    0 2px 8px rgba(15, 23, 42, 0.07);

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  opacity: 0.72;

  transition:
    opacity 140ms ease,
    box-shadow 140ms ease;
}

#learn-md-content .learn-image-viewer:hover .learn-image-toolbar,
#learn-md-content .learn-mermaid-figure:hover .learn-mermaid-toolbar,
#learn-md-content .learn-image-toolbar:focus-within,
#learn-md-content .learn-mermaid-toolbar:focus-within {
  opacity: 1;

  box-shadow:
    0 3px 12px rgba(15, 23, 42, 0.10);
}


/* =========================================================
   SHARED ICON BUTTONS
========================================================= */

#learn-md-content .learn-image-control,
#learn-md-content .learn-mermaid-control {
  position: relative;

  display: grid;
  place-items: center;

  width: 28px;
  height: 28px;
  min-width: 28px;

  margin: 0;
  padding: 0;

  border: 0;
  border-radius: 5px;

  background: transparent;
  color: #475569;

  /* Hide existing words but preserve the real buttons/ARIA. */
  font-size: 0;
  line-height: 0;

  cursor: pointer;

  transition:
    color 130ms ease,
    background-color 130ms ease,
    transform 130ms ease;
}

#learn-md-content .learn-image-control::before,
#learn-md-content .learn-mermaid-control::before {
  content: "";

  display: block;

  width: 15px;
  height: 15px;

  background-color: currentColor;

  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;

  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

#learn-md-content .learn-image-control:hover,
#learn-md-content .learn-mermaid-control:hover {
  border: 0;

  background: #f1f5f9;
  color: #4338ca;
}

#learn-md-content .learn-image-control:active,
#learn-md-content .learn-mermaid-control:active {
  transform: scale(0.9);
}

#learn-md-content .learn-image-control:focus-visible,
#learn-md-content .learn-mermaid-control:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.38);
  outline-offset: 1px;
}


/* =========================================================
   ZOOM OUT SVG
========================================================= */

#learn-md-content
.learn-image-control[data-learn-image-action="zoom-out"]::before,

#learn-md-content
.learn-mermaid-control[data-mermaid-action="zoom-out"]::before {
  -webkit-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 11h14v2H5z'/%3E%3C/svg%3E");

  mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 11h14v2H5z'/%3E%3C/svg%3E");
}


/* =========================================================
   RESET SVG
========================================================= */

#learn-md-content
.learn-image-control[data-learn-image-action="reset"]::before,

#learn-md-content
.learn-mermaid-control[data-mermaid-action="reset"]::before {
  -webkit-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5a7 7 0 1 1-6.32 4H8L4.5 5.5 1 9h2.58A9 9 0 1 0 12 3v2z'/%3E%3C/svg%3E");

  mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5a7 7 0 1 1-6.32 4H8L4.5 5.5 1 9h2.58A9 9 0 1 0 12 3v2z'/%3E%3C/svg%3E");
}


/* =========================================================
   ZOOM IN SVG
========================================================= */

#learn-md-content
.learn-image-control[data-learn-image-action="zoom-in"]::before,

#learn-md-content
.learn-mermaid-control[data-mermaid-action="zoom-in"]::before {
  -webkit-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6z'/%3E%3C/svg%3E");

  mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6z'/%3E%3C/svg%3E");
}


/* =========================================================
   FULLSCREEN SVG
========================================================= */

#learn-md-content
.learn-image-control[data-learn-image-action="fullscreen"]::before,

#learn-md-content
.learn-mermaid-control[data-mermaid-action="fullscreen"]::before {
  -webkit-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h6v2H6v4H4V4zm10 0h6v6h-2V6h-4V4zM4 14h2v4h4v2H4v-6zm14 0h2v6h-6v-2h4v-4z'/%3E%3C/svg%3E");

  mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h6v2H6v4H4V4zm10 0h6v6h-2V6h-4V4zM4 14h2v4h4v2H4v-6zm14 0h2v6h-6v-2h4v-4z'/%3E%3C/svg%3E");
}


/* =========================================================
   FIGURE CANVAS
========================================================= */

#learn-md-content .learn-image-stage,
#learn-md-content .learn-mermaid-figure > .mermaid {
  box-sizing: border-box;

  border: 0;

  background: #ffffff;

  /* Gives floating controls breathing room without a toolbar bar. */
  padding-top: 3.25rem;
}

#learn-md-content .learn-mermaid-figure > .mermaid {
  height: 390px;
  min-height: 390px;

  padding-right: 1.5rem;
  padding-bottom: 1.5rem;
  padding-left: 1.5rem;
}


/* =========================================================
   PUBLICATION FIGURE LEGENDS
   Removes the old bottom caption bar.
========================================================= */

#learn-md-content .learn-mermaid-caption,
#learn-md-content .learn-image-viewer + em {
  display: block;

  margin: 0.55rem 0 1.8rem;
  padding: 0 0.15rem;

  border: 0;

  background: transparent;
  color: #303846;

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size: 0.88rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.5;

  text-align: left;
}


/* Mermaid caption currently sits inside the figure.
   Visually detach it from the old bottom-bar treatment. */

#learn-md-content .learn-mermaid-caption {
  margin: 0;
  padding: 0.65rem 0.5rem 6px;

  border-top: 0;

  background: #ffffff;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 700px) {

  #learn-md-content .learn-image-toolbar,
  #learn-md-content .learn-mermaid-toolbar {
    top: 7px;
    right: 7px;
  }

  #learn-md-content .learn-image-control,
  #learn-md-content .learn-mermaid-control {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }

  #learn-md-content .learn-mermaid-figure > .mermaid {
    height: 330px;
    min-height: 330px;
  }
}