/* help.css — the "?" Help (js/31-help.js). Every Help style is in this file,
   the hardware skin's (body.hw-ui) included, so the other stylesheets stay as
   they are. Colors, type and radii come from the tokens in main.css :root and
   the hardware tokens in hardware.css.
   Size rules kept here: no text under 15px; a control is at least 32px tall
   (36px inside the panel), and takes a tap 44px tall at 820px wide and below. */

/* ---------- the "?" in the header ---------- */
.help-btn {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 34px; height: 34px; padding: 0;
  font: 700 17px/1 var(--font-display);
  color: var(--accent); background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%; cursor: pointer;
  transition: background-color .14s, transform .08s;
}
.help-btn[hidden] { display: none; }
.help-btn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.help-btn:active { transform: translateY(1px); }
.help-btn:focus-visible, #cmpHelp:focus-visible, #mebHelp:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-btn.is-paused, #cmpHelp.is-paused, #mebHelp.is-paused { opacity: .45; }
body.hw-ui .help-btn {
  border: none; border-radius: var(--hw-r-key);
  background: var(--hw-key-grad); color: #E8C36B;
  box-shadow: 0 2px 0 #17120f, 0 3px 6px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .07);
}
body.hw-ui .help-btn:hover { background: var(--hw-key-grad); color: #F3D489; }
/* Room for the "?" in a header that was already full. Beside the logo the
   tab strip, the jewel and Get Pro leave 31px at 1280 in the hardware skin,
   so from 901 to 1399px the row's gaps close a little and the hardware key is
   narrow. Two short ranges would still have dropped the tab row under the
   logo: 1245 to 1279px (the jewel, a decoration, steps aside there) and 1400
   to 1459px (the version pill, which main.css already hides below 1400 and
   which is in the footer too, stays hidden until 1460). */
@media (min-width: 901px) and (max-width: 1399px) {
  .brand-right { gap: 6px; }
  body.hw-ui .help-btn { width: 28px; }
}
@media (min-width: 1245px) and (max-width: 1279px) {
  body.hw-ui .brand-header .hw-jewel { display: none; }
}
@media (min-width: 1400px) and (max-width: 1459px) {
  .brand-header .version-pill { display: none; }
}
/* At 820px and below the "?" stays the size of the row it sits in, so the
   header is no taller than it was; the area that takes a tap is 44px square. */
@media (max-width: 820px) {
  .help-btn { position: relative; margin-block: -3px; }
  .help-btn::after { content: ''; position: absolute; inset: -6px; }
}

/* The Practice Builder's "? Help" (put into its toolbar by js/31-help.js). It
   keeps the look and size of the buttons beside it. In the phone dock the
   area that takes a tap reaches past its edges, so it is 44px tall for a
   finger without standing taller than its neighbors. (From 741 to 820px the
   Builder's toolbar row cuts off anything taller than itself, so there the
   button is 32px, 2px more than the buttons beside it.) */
#composerPane #cmpHelp { position: relative; min-height: 32px; }
@media (max-width: 740px) {
  /* its place in the phone dock (the row with Tools and Close) is set in css/composer.css */
  #cmpHelp::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
}

/* Edit mode on a phone hides the header (main.css, 740px and below), so
   js/31-help.js also puts a "? Help" in the Edit bar. It shows only there,
   at the end of the dock beside Done, with the same 44px tap area. */
#mebHelp { display: none; }
@media (max-width: 740px) {
  #mapEditBar #mebHelp { display: inline-flex; order: 49; position: relative; }
  #mebHelp::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
}

/* A link to one Help topic from a page of the app (a[data-help-link], see js/31-help.js) */
.help-link {
  display: inline-flex; align-items: center; min-height: 32px;
  font: 600 15px/1.3 var(--font-ui); color: var(--accent);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.help-link:hover { text-decoration-thickness: 2px; }
.help-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
body.hw-ui .help-link { color: #E8C36B; }
body.hw-ui .help-link:hover { color: #F3D489; }
@media (max-width: 820px) { .help-link { min-height: 44px; } }
.dh-help { margin-left: 14px; }                   /* beside the Dashboard's Quick Check button */
/* On a phone the link drops under the button: line it up with the button's left edge. */
@media (max-width: 700px) { .dh-help { display: flex; width: fit-content; margin: 4px 0 0; } }
#welcome .wl-help { margin: -6px 0 12px; }        /* under the Quick Check scorecard's ratings */

/* The note shown when the "?" is pressed during a round */
.hp-note {
  position: fixed; z-index: 9700; box-sizing: border-box;
  padding: 12px 14px;
  font: 500 15px/1.5 var(--font-ui); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--elev-3, 0 12px 32px rgba(0, 0, 0, .5));
}
.hp-note[hidden] { display: none; }

/* ---------- the panel ---------- */
.hp {
  /* Safari before 26 ignores scrollbar-color and would draw a white scroll bar track on the dark panel. */
  color-scheme: dark;
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 9700;
  width: min(460px, 100vw); box-sizing: border-box;
  display: flex; flex-direction: column;
  container-type: inline-size; container-name: hp;
  font: 400 16px/1.6 var(--font-ui); color: var(--ink);
  background: var(--panel);
  border-left: 1px solid var(--border-strong);
  box-shadow: -14px 0 36px rgba(0, 0, 0, .45);
  text-align: left;
}
.hp[hidden] { display: none; }
.hp[data-side="left"] {
  right: auto; left: 0;
  border-left: none; border-right: 1px solid var(--border-strong);
  box-shadow: 14px 0 36px rgba(0, 0, 0, .45);
}
/* The larger window: in the middle of the screen, over a dimmed app. The text
   keeps a reading width (about 80 letters a line), and pictures get the room. */
.hp[data-side="large"] {
  inset: 0; margin: auto;
  width: min(1040px, calc(100vw - 48px)); height: min(940px, calc(100vh - 48px));
  border: 1px solid var(--border-strong); border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  font-size: 17px;
}
.hp[data-side="large"] .hp-bar { padding: 14px 20px; }
.hp[data-side="large"] .hp-body { padding: 26px max(28px, calc((100% - 760px) / 2)) 56px; }
.hp-scrim { display: none; position: fixed; inset: 0; z-index: 9699; background: rgba(8, 6, 5, .62); }
.hp[data-side="large"]:not([hidden]) + .hp-scrim { display: block; }
.hp *, .hp-light * { box-sizing: border-box; }

.hp-bar {
  flex: 0 0 auto; display: grid; gap: 8px;
  padding: 12px 14px;
  background: var(--bg-warm);
  border-bottom: 1px solid var(--rule);
}
.hp-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }

.hp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto;
  min-height: 36px; padding: 6px 12px;
  font: 600 15px/1.2 var(--font-ui); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background-color .14s, color .14s, transform .08s;
}
.hp-btn[hidden] { display: none; }
.hp-btn:hover { background: var(--surface-3); }
.hp-btn:active { transform: translateY(1px); }
.hp-btn:focus-visible, .hp-row:focus-visible, .hp-pic:focus-visible, .hp summary:focus-visible, .hp-text a:focus-visible, .hp-crumb a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.hp-btn svg { flex: 0 0 auto; }
.hp-close { color: var(--accent); }
.hp-icon { width: 36px; padding: 0; }
/* Where Help sits: left, right, or the larger window. The one in use is lit. */
.hp-place { flex: 0 0 auto; display: flex; gap: 4px; }
.hp-place .hp-btn[aria-pressed="true"] {
  color: var(--accent); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
}

.hp-search {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 10px;
  color: var(--ink-dim);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px;
}
.hp-search:focus-within { border-color: var(--accent); }
.hp-search input {
  flex: 1 1 auto; min-width: 0; height: 34px; padding: 0;
  font: 400 16px/1.2 var(--font-ui); color: var(--ink);
  background: transparent; border: none; outline: none;
  -webkit-appearance: none; appearance: none;
}
.hp-search input::placeholder { color: var(--ink-dim); opacity: 1; }

.hp-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: 18px 20px 44px;
  scrollbar-color: var(--border-strong) transparent;
}
.hp-body:focus { outline: none; }

/* Where the person was when Help opened */
.hp-where {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  margin: 0 0 14px; padding: 8px 12px;
  font: 600 15px/1.4 var(--font-ui); color: var(--ink);
  background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
}
.hp-where span { font-weight: 400; color: var(--ink-dim); }
.hp-crumb { margin: 0 0 4px; font-size: 15px; }
.hp-title {
  margin: 0 0 12px;
  font: 700 24px/1.25 var(--font-display); color: var(--ink);
}
.hp-title:focus { outline: none; }
.hp-sub, .hp-text h3 {
  margin: 28px 0 8px; padding-top: 16px;
  font: 700 17px/1.3 var(--font-display); color: var(--ink);
  border-top: 1px solid var(--rule);
}

/* ---------- a topic's text ---------- */
.hp-text p { margin: 0 0 12px; }
.hp-text a, .hp-crumb a, .hp-body > p a {
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}
.hp-text a:hover, .hp-crumb a:hover, .hp-body > p a:hover { color: #F3D489; }
.hp-text strong { font-weight: 700; color: var(--ink); }
.hp-text ul, .hp-text ol { margin: 0 0 14px; padding-left: 24px; }
.hp-text li { margin: 0 0 7px; padding-left: 2px; }
.hp-text li::marker { color: var(--accent); font-weight: 700; }
.hp-text code {
  padding: 1px 6px;
  font: 500 15px/1.4 var(--font-mono); color: var(--ink);
  background: var(--bg); border: 1px solid var(--rule); border-radius: 5px;
  overflow-wrap: anywhere;
}

/* Pictures: a tap opens one larger */
.hp-fig { margin: 16px 0 18px; }
.hp-pic {
  position: relative; display: block; width: 100%; padding: 0;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px;
  overflow: hidden; cursor: zoom-in;
}
.hp-pic img { display: block; width: 100%; height: auto; }
.hp-pic::after {
  content: 'Open larger';
  position: absolute; right: 8px; bottom: 8px;
  padding: 3px 10px;
  font: 600 15px/1.4 var(--font-ui); color: var(--ink);
  background: rgba(26, 22, 20, .88); border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
}
.hp-fig-tall .hp-pic { width: min(100%, 300px); }
.hp-fig figcaption {
  margin-top: 8px; padding-left: 10px;
  font-size: 15px; line-height: 1.5; color: var(--ink-dim);
  border-left: 2px solid var(--accent-deep);
}

/* Tables. Two columns stay a table; three and four become short rows when the
   panel is narrow (it always is, except in a very wide sheet). */
.hp-tbl { margin: 14px 0 18px; }
.hp-tbl table { width: 100%; border-collapse: collapse; font-size: 15.5px; line-height: 1.5; }
.hp-tbl th {
  padding: 8px 10px 8px 0; text-align: left; vertical-align: bottom;
  font: 700 15px/1.3 var(--font-display); color: var(--ink-dim);
  border-bottom: 1px solid var(--border-strong);
}
.hp-tbl td {
  padding: 9px 10px 9px 0; vertical-align: top;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}
.hp-tbl th:last-child, .hp-tbl td:last-child { padding-right: 0; }
.hp-tbl .hp-cols-2 td:first-child { width: 38%; font-weight: 600; }
@container hp (max-width: 820px) {
  .hp-tbl .hp-cols-3 thead, .hp-tbl .hp-cols-4 thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .hp-tbl .hp-cols-3, .hp-tbl .hp-cols-3 tbody, .hp-tbl .hp-cols-4, .hp-tbl .hp-cols-4 tbody { display: block; }
  .hp-tbl .hp-cols-3 tr, .hp-tbl .hp-cols-4 tr {
    display: block; padding: 10px 0;
    border-bottom: 1px solid var(--rule);
  }
  .hp-tbl .hp-cols-3 tr:first-child, .hp-tbl .hp-cols-4 tr:first-child { border-top: 1px solid var(--border-strong); }
  .hp-tbl .hp-cols-3 td, .hp-tbl .hp-cols-4 td { display: block; padding: 2px 0; border: none; }
  .hp-tbl .hp-cols-3 td:empty, .hp-tbl .hp-cols-4 td:empty { display: none; }
  .hp-tbl .hp-cols-3 td:first-child, .hp-tbl .hp-cols-4 td:first-child { font-weight: 700; font-size: 16px; color: var(--ink); }
  .hp-tbl .hp-cols-3 td + td[data-label]:not([data-label=""])::before,
  .hp-tbl .hp-cols-4 td + td[data-label]:not([data-label=""])::before {
    content: attr(data-label) ': '; font-weight: 700; color: var(--ink-dim);
  }
}

/* ---------- lists of topics ---------- */
.hp-rows { list-style: none; margin: 0 0 6px; padding: 0; }
.hp-rows li { margin: 0; padding: 0; }
.hp-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px;
  min-height: 44px; padding: 8px 8px 8px 10px;
  color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--rule); border-radius: 6px;
}
.hp-row:hover { background: var(--surface-2); }
.hp-row-t { grid-column: 1; font-weight: 600; font-size: 16px; line-height: 1.35; }
.hp-row-s { grid-column: 1; font-size: 15px; line-height: 1.45; color: var(--ink-dim); }
.hp-row svg { grid-column: 2; grid-row: 1 / span 2; color: var(--accent); }
.hp-count { margin: 0 0 8px; font-size: 15px; color: var(--ink-dim); }

.hp-part {
  margin: 0 0 10px;
  background: var(--bg-warm); border: 1px solid var(--rule); border-radius: var(--radius-sm);
}
.hp-part > summary {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 6px 14px;
  cursor: pointer; list-style: none; border-radius: var(--radius-sm);
}
.hp-part > summary::-webkit-details-marker { display: none; }
.hp-part > summary::before {
  content: ''; flex: 0 0 auto; width: 8px; height: 8px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg); transition: transform .14s;
}
.hp-part[open] > summary::before { transform: rotate(45deg); }
.hp-part > summary:hover { background: var(--surface-2); }
.hp-part-t { flex: 1 1 auto; min-width: 0; font: 700 16px/1.3 var(--font-display); color: var(--ink); }
.hp-part-n { flex: 0 0 auto; font-size: 15px; color: var(--ink-dim); }
.hp-part .hp-rows { margin: 0; padding: 0 6px 6px; border-top: 1px solid var(--rule); }
.hp-part .hp-rows li:last-child .hp-row { border-bottom: none; }

.hp-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin: 28px 0 0; padding-top: 16px;
  border-top: 1px solid var(--rule);
}
.hp-said { min-width: 0; font-size: 15px; color: var(--ink-dim); overflow-wrap: anywhere; }

/* ---------- a picture, opened larger ---------- */
.hp-light { color-scheme: dark;
  position: fixed; inset: 0; z-index: 9710;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 16px 16px;
  font: 400 16px/1.5 var(--font-ui); color: var(--ink);
  background: rgba(14, 11, 10, .94);
}
.hp-light[hidden] { display: none; }
.hp-light-bar { flex: 0 0 auto; align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hp-light-tip { min-width: 0; font-size: 15px; line-height: 1.35; color: var(--ink-dim); }
.hp-light.zoom .hp-light-tip { visibility: hidden; }
.hp-light-view {
  flex: 1 1 auto; min-height: 0; max-width: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.hp-light-view img {
  display: block; max-width: 100%; max-height: 100%;
  border: 1px solid var(--border-strong); border-radius: 8px;
  cursor: zoom-in;
}
.hp-light.zoom .hp-light-view { display: block; align-self: stretch; }
.hp-light.zoom .hp-light-view img { max-width: none; max-height: none; cursor: zoom-out; }
.hp-light-cap { flex: 0 0 auto; max-width: 760px; margin: 0; font-size: 15px; color: var(--ink-dim); text-align: center; }
.hp-light-cap a { color: var(--accent); }

/* ---------- 820px and below: Help is a full sheet ---------- */
@media (max-width: 820px) {
  .hp, .hp[data-side="left"], .hp[data-side="large"] {
    inset: 0; margin: 0; width: 100%; height: auto;
    border: none; border-radius: 0; box-shadow: none;
    font-size: 16px;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  }
  .hp[data-side="large"]:not([hidden]) + .hp-scrim, .hp-place { display: none; }
  .hp[data-side="large"] .hp-bar { padding: 10px 12px; }
  .hp[data-side="large"] .hp-body { padding: 16px 16px 56px; }
  .hp-bar { padding: 10px 12px; }
  .hp-bar-row { gap: 6px; }
  .hp-btn { min-height: 44px; padding: 8px 10px; }
  /* Back to the app, Start here and All topics share the row and fill it. With larger text
     the row wraps and every button keeps its full name. */
  .hp-bar-row > .hp-btn { flex: 1 1 auto; }
  .hp-bar-row > .hp-back { flex: 0 0 auto; }
  .hp-icon { width: 44px; }
  .hp-search { min-height: 44px; }
  .hp-search input { height: 42px; }
  .hp-body { padding: 16px 16px 56px; }
  .hp-row { min-height: 48px; }
  .hp-part > summary { min-height: 48px; }
  .hp-light { padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); }
}

/* A narrow phone (under 367px) has no room for the three in one row: Back to the app
   takes the first row, and Start here and All topics share the second. */
@container hp (max-width: 366px) {
  .hp-bar-row > .hp-close { flex-basis: 100%; }
}

/* ---------- hardware skin ---------- */
body.hw-ui .hp { background: var(--hw-panel-grad); border-color: #0f0c0a; }
body.hw-ui .hp-bar { background: var(--hw-counter-grad); border-bottom: 1px solid #0f0c0a; box-shadow: 0 1px 0 rgba(255, 255, 255, .05); }
body.hw-ui .hp-btn {
  border: none; border-radius: var(--hw-r-key);
  background: var(--hw-key-grad); color: #E8C36B;
  box-shadow: 0 2px 0 #17120f, 0 3px 6px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .07);
}
body.hw-ui .hp-btn:hover { background: var(--hw-key-grad); color: #F3D489; }
body.hw-ui .hp-place .hp-btn[aria-pressed="true"] {
  color: #F3D489; background: var(--hw-well-grad);
  box-shadow: var(--hw-shadow-well), 0 0 0 1px color-mix(in srgb, #E8C36B 55%, transparent);
}
body.hw-ui .hp[data-side="large"] { border-radius: var(--hw-r-well); }
body.hw-ui .hp-search {
  border: none; border-radius: var(--hw-r-key);
  background: var(--hw-well-grad); box-shadow: var(--hw-shadow-well);
}
body.hw-ui .hp-search:focus-within { box-shadow: var(--hw-shadow-well), 0 0 0 1px var(--accent); }
body.hw-ui .hp-where {
  color: #2b1f0e; background: var(--hw-tape-grad);
  border-left: none; border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
}
body.hw-ui .hp-where span { color: #5a4630; }
body.hw-ui .hp-part {
  border: none; border-radius: var(--hw-r-well);
  background: var(--hw-groove-grad); box-shadow: var(--hw-shadow-groove);
}
body.hw-ui .hp-part > summary { border-radius: var(--hw-r-well); }
body.hw-ui .hp-pic { border-color: #0f0c0a; border-radius: var(--hw-r-key); box-shadow: var(--hw-shadow-well); }
body.hw-ui .hp-note { background: var(--hw-panel-grad); border-color: #0f0c0a; border-radius: var(--hw-r-well); }
