/* The application page (docs/app.md).  Every rule is scoped to it.  Colors,
   shadows and buttons come from Material for MkDocs, so the page follows the
   site's palette. */
.hifuku-app .status { font-size: 0.75rem; color: var(--md-default-fg-color--light); }
/* A solid red: Material's deletion color is a translucent background. */
.hifuku-app .status.error { color: #b3261e; }

/* The controls. */
.hifuku-app .controls { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.hifuku-app .controls label { font-size: 0.75rem; }
.hifuku-app select { font: inherit; padding: 0.2rem 0.4rem; border-radius: 0.2rem;
  border: 1px solid var(--md-default-fg-color--lighter); background: var(--md-default-bg-color);
  color: var(--md-default-fg-color); }
.hifuku-app .controls .md-button { margin: 0; cursor: pointer; }
/* Material's md-button sets display, which would show a hidden button. */
.hifuku-app [hidden] { display: none !important; }
.hifuku-app .controls .md-button[disabled] { opacity: 0.45; cursor: default; pointer-events: none; }
/* The primary button glints while a run goes on.  The glint is a layer that
   moves by transform, which the browser animates apart from the page's
   script, so the work of a checkpoint does not make it stutter. */
.hifuku-app .md-button--primary { position: relative; overflow: hidden; }
.hifuku-app .md-button--primary.running::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 35%, rgb(255 255 255 / 0.35) 50%, transparent 65%);
  transform: translateX(-100%); will-change: transform;
  animation: hifuku-sheen 1.8s linear infinite;
}
@keyframes hifuku-sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
/* The help button, and the close button of the help note. */
.hifuku-app .help-button {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; cursor: pointer; font-weight: 700;
  border: 1px solid var(--md-default-fg-color--lighter); background: var(--md-default-bg-color);
  color: var(--md-default-fg-color--light);
}
.hifuku-app .help-button[aria-expanded="true"] { color: var(--md-primary-fg-color); border-color: var(--md-primary-fg-color); }
.md-typeset .hifuku-help[hidden] { display: none; }
.md-typeset .hifuku-help .help-close {
  float: right; border: 0; background: none; cursor: pointer; font-size: 1rem; line-height: 1;
  color: var(--md-default-fg-color--light);
}
.hifuku-app .readout { min-height: 2.6em; font-size: 0.75rem; color: var(--md-default-fg-color--light); }

/* Cards, as Material draws its admonitions. */
.hifuku-app .card {
  background: var(--md-default-bg-color); border-radius: 0.4rem;
  box-shadow: var(--md-shadow-z1); padding: 0.6rem 0.8rem; min-width: 0;
}
.hifuku-app .card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  font-size: 0.65rem; font-weight: 700; color: var(--md-default-fg-color--light);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem;
}
/* The selected niche, beside the heading of the trace and the tree. */
.hifuku-app .card-head .pin { margin-right: auto; color: #e4572e; text-transform: none; letter-spacing: 0; }
/* A click focuses the chart (for Escape) without an outline; the keyboard
   still shows one. */
.hifuku-app canvas.simplex:focus:not(:focus-visible) { outline: none; }
.hifuku-app .toggle { font-weight: 400; text-transform: none; letter-spacing: 0; cursor: pointer; }

/* The progress of the run, along the top of the chart. */
.hifuku-app .progress { height: 3px; background: var(--md-default-fg-color--lightest);
  border-radius: 2px; overflow: hidden; margin-bottom: 0.4rem; }
.hifuku-app .progress .bar { height: 100%; width: 0; background: var(--md-primary-fg-color);
  transition: width 0.4s ease; }

/* One column on a narrow screen; on a wide one, the chart on the left and
   the trace above the tree on the right.  60em is Material's breakpoint for
   its sidebars. */
.hifuku-app .panels { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); margin-top: 0.4rem; }
.hifuku-app .side { display: grid; gap: 1rem; align-content: start; min-width: 0; }
@media screen and (min-width: 60em) {
  /* The right column stretches to the chart card's height: the trace card
     keeps its height, and the tree card takes the rest, the tree filling it.
     The column's content does not size the row (contain: size), so a drawn
     tree, whose viewBox gives it a height, cannot make both cards taller;
     only the width of the window does. */
  .hifuku-app .panels { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: stretch; }
  .hifuku-app .side { display: flex; flex-direction: column; contain: size; }
  .hifuku-app .side > .card:last-child { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .hifuku-app .tree-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .hifuku-app .tree-panel svg.tree { flex: 1; min-height: 12rem; height: auto; aspect-ratio: auto !important; }
}

/* The widgets in their cards. */
.hifuku-app canvas.simplex { display: block; margin: 0 auto; }
.hifuku-app svg.tree { width: 100%; aspect-ratio: 1; }
.hifuku-app svg.tree .edge { stroke: currentColor; }
.hifuku-app svg.tree text { fill: currentColor; font-family: var(--md-text-font-family, sans-serif); }
.hifuku-app .note { font-size: 0.7rem; color: var(--md-default-fg-color--light); margin: 0.3rem 0; }

/* Below 60em, the trace and the tree are in a bottom sheet, which a tap on a
   niche opens. */
.hifuku-app .sheet-head { display: none; }
@media screen and (max-width: 59.9375em) {
  /* A smaller heading and smaller controls, so the chart starts higher on
     the screen. */
  .md-content:has(.hifuku-app) .md-typeset h1 { font-size: 1.5em; margin-bottom: 0.6em; }
  .hifuku-app .controls { gap: 0.4rem 0.5rem; }
  .hifuku-app .controls label { display: flex; align-items: center; gap: 0.3rem; min-width: 0; }
  .hifuku-app .controls select { min-width: 0; max-width: 100%; }
  .hifuku-app .controls .md-button { padding: 0.25em 0.8em; font-size: 0.7rem; }
  .hifuku-app .help-button { width: 1.4rem; height: 1.4rem; }
  .hifuku-app .readout { margin: 0.4rem 0; }
  .hifuku-app .panels { margin-top: 0; }
  /* The sheet leaves room above it for the chart, which scrolls to just
     below the header when the sheet opens (main.js sets --chart-room). */
  .hifuku-app .chart { scroll-margin-top: 3rem; }
  .hifuku-app .side {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
    max-height: max(14rem, calc(100dvh - var(--chart-room, 50dvh))); overflow-y: auto;
    background: var(--md-default-bg-color); box-shadow: var(--md-shadow-z3);
    border-radius: 0.8rem 0.8rem 0 0; padding: 0.4rem 0.8rem 1rem; gap: 0.6rem;
    transform: translateY(100%); visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }
  .hifuku-app .side.open { transform: none; visibility: visible; transition: transform 0.25s ease; }
  /* Room below the chart, so it can scroll above an open sheet. */
  .hifuku-app .panels:has(.side.open) { padding-bottom: 50vh; }
  .hifuku-app .side .card { box-shadow: none; padding: 0.2rem 0; }
  .hifuku-app .sheet-head { display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: var(--md-default-bg-color); }
  .hifuku-app .grip { width: 2.5rem; height: 0.25rem; border-radius: 1rem;
    background: var(--md-default-fg-color--lighter); margin: 0 auto; }
  .hifuku-app .sheet-close { padding: 0.2rem 0.6rem; font-size: 0.7rem; }
  .hifuku-app .side svg.tree { max-height: 30vh; }
}

/* Text for screen readers only. */
.hifuku-app .visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Under reduced motion, nothing slides: the glint becomes a slow, soft
   change of brightness, the progress bar steps, and the bottom sheet fades
   in place. */
@keyframes hifuku-pulse { from { opacity: 0; } 50% { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .hifuku-app .md-button--primary.running::after {
    transform: none; background: rgb(255 255 255 / 0.12);
    animation: hifuku-pulse 3s ease-in-out infinite;
  }
  .hifuku-app .progress .bar { transition: none; }
}
/* Material turns every transition off under reduced motion, so the sheet
   fades in with an animation; it closes at once. */
@keyframes hifuku-fade-in { from { opacity: 0; } to { opacity: 1; } }
@media screen and (max-width: 59.9375em) and (prefers-reduced-motion: reduce) {
  .hifuku-app .side { transform: none; }
  .hifuku-app .side.open { animation: hifuku-fade-in 0.2s ease-out; }
}
