/* Patient body map (2026-10-19): the step 1 card, the sheet it opens and
   the figure's box. What sits beside the figure (problems, the ticket)
   lives in public/body-map-view.css, loaded after this. Colours, corners
   and type come from theme.css and styles.css; the figure's own drawing
   colours live in public/body-figure.js. */

/* The clinic's colour, tinted on this theme's own ground, so a selected
   state and the ticket read the same in light and dark. */
.bodymap-card,
.bodymap-dialog {
  --bm-tint: color-mix(in srgb, var(--accent) 14%, var(--ground));
  --bm-accent-text: color-mix(in srgb, var(--accent) 65%, var(--ink));
}

/* ------------------------------------------------------------ the card */
.bodymap-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  column-gap: 12px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    background-color 0.12s ease;
}
.bodymap-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
}
.bodymap-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.bodymap-card-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-card);
  background: var(--bm-tint);
}
.bodymap-card-mark svg {
  display: block;
  height: 48px;
  width: auto;
  overflow: visible;
}
.bodymap-card-mark .bf-body {
  fill: var(--ground);
  stroke: var(--accent);
  stroke-width: 3.2;
  stroke-linejoin: round;
}
.bodymap-card-mark .bf-lines {
  display: none;
}
.bodymap-card-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
}
.bodymap-card-dot {
  fill: var(--accent);
}
.bodymap-card-text {
  display: block;
  min-width: 0;
}
.bodymap-card-lead {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.bodymap-card-line {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-soft);
}
.bodymap-card:hover .bodymap-card-line {
  color: inherit;
}

/* ----------------------------------------------------------- the sheet */
/* While the sheet is open the page is exactly one window tall and still. */
html.bodymap-locked,
html.bodymap-locked body {
  height: 100%;
  overflow: hidden;
}
.bodymap-dialog {
  position: fixed;
  inset: var(--bm-top, 0px) 0 0 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px 24px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
}
.bodymap-dialog[open] {
  display: grid;
  place-items: center;
}
.bodymap-dialog::backdrop {
  background: var(--modal-backdrop);
  -webkit-backdrop-filter: blur(var(--modal-backdrop-blur));
  backdrop-filter: blur(var(--modal-backdrop-blur));
}
.bodymap-sheet {
  display: flex;
  flex-direction: column;
  width: min(900px, 100%);
  height: min(800px, 100%);
  overflow: hidden;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
}
.bodymap-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.bodymap-title {
  margin: 0;
  grid-column: 2;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.bodymap-title:focus,
.bodymap-q:focus {
  outline: none;
}
.bodymap-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.bodymap-icon:first-child {
  grid-column: 1;
}
.bodymap-icon:last-child {
  grid-column: 3;
}
.bodymap-icon:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.bodymap-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.bodymap-body {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  column-gap: 40px;
  align-items: center;
  align-content: safe center;
  flex: 1;
  min-height: 0;
  padding: 28px 32px;
  scroll-padding-bottom: 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------------------------------------------------------- the figure */
.bodymap-figcol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.bodymap-sheet[data-mode="spot"] .bodymap-sides {
  display: none;
}
.bodymap-sides {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  overflow: hidden;
}
.bodymap-sides button {
  min-width: 96px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  background: var(--ground);
  color: var(--ink-soft);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.bodymap-sides button + button {
  border-left: 1px solid var(--line-strong);
}
.bodymap-sides button[aria-pressed="true"] {
  background: var(--bm-tint);
  color: var(--ink);
}
.bodymap-sides button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.bodymap-host {
  width: 100%;
  height: min(520px, calc(100dvh - var(--bm-top, 0px) - 250px));
}
.bodymap-sheet[data-mode="spot"] .bodymap-host {
  /* The map's switch, gap and body together: the column keeps its height. */
  height: calc(min(520px, calc(100dvh - var(--bm-top, 0px) - 250px)) + 56px);
}
/* Zoomed, the skin turns to glass: the anatomy sits in its own well. */
.bodymap-sheet[data-zoom="1"] .bodymap-host {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.bodymap-dialog .bodyfig-rings {
  transition:
    opacity 0.25s ease,
    visibility 0s;
}
/* Rings are for the map; beside a spot's problems they step aside. */
.bodymap-sheet[data-mode="spot"] .bodyfig-rings {
  opacity: 0;
}
.bodymap-sheet[data-mode="spot"] .bodyfig-rings,
.bodymap-dialog .bodyfig--zoom .bodyfig-rings {
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0s 0.25s;
}

/* -------------------------------------------------------- the phone */
@media (max-width: 640px) {
  .bodymap-card-lead {
    font-size: 16px;
  }
  .bodymap-card-line {
    font-size: 15px;
  }
  .bodymap-dialog {
    padding: 0;
  }
  .bodymap-dialog[open] {
    place-items: stretch;
  }
  .bodymap-sheet {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .bodymap-body {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    align-content: safe center;
    row-gap: 24px;
    flex: 1;
    padding: 24px;
  }
  .bodymap-figcol {
    order: 1;
  }
  .bodymap-pane {
    order: 2;
  }
  .bodymap-sheet[data-mode="map"] .bodymap-pane {
    display: contents;
  }
  .bodymap-host {
    height: clamp(300px, calc(100dvh - var(--bm-top, 0px) - 272px), 560px);
  }
  .bodymap-sheet[data-mode="spot"] .bodymap-body {
    align-content: start;
    padding-top: 0;
    row-gap: 8px;
    scroll-padding-top: 348px;
  }
  .bodymap-sheet[data-mode="spot"] .bodymap-figcol {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 16px 0;
    background: var(--ground);
  }
  /* Near square, like the zoomed frame it shows. */
  .bodymap-sheet[data-mode="spot"] .bodymap-host {
    height: 300px;
  }
  .bodymap-sheet[data-mode="spot"][data-zoom="0"] .bodymap-figcol {
    display: none;
  }
  .bodymap-sheet[data-mode="spot"][data-zoom="0"] .bodymap-body {
    padding-top: 24px;
    scroll-padding-top: 0;
  }
}
