/* Harvest · problem explorer (explorer.html, body.p-explorer).
   An app-like page: the trades and their problems in a sticky sidebar on the left, the picked
   problem on the right with a real product screen under it. Each screen sits in .hx-frame__in
   with its source page's class (.t-boss, .p-coldstores ...), so that page's styles apply.
   Phones: the sidebar becomes a sticky picker; a screen wider than the phone scrolls in its frame. */

.p-explorer { --hx-top: 72px; --hx-side: 300px; }
.p-explorer main { overflow-x: clip; }

.hx { display: grid; grid-template-columns: var(--hx-side) minmax(0, 1fr); border-top: 1px solid var(--line); min-height: calc(100vh - var(--hx-top)); }

/* ---------- Sidebar ---------- */
.hx-side {
  position: sticky; top: var(--hx-top); align-self: start; height: calc(100vh - var(--hx-top)); height: calc(100dvh - var(--hx-top));
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-sunk); border-right: 1px solid var(--line); scrollbar-width: thin;
}
.hx-side__head { padding: 28px 24px 18px; }
.hx-side__h { margin: 14px 0 0; font-size: 26px; line-height: 1.12; font-weight: 600; letter-spacing: -0.025em; color: var(--ink); text-wrap: balance; }
.hx-side__lead { margin: 10px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); text-wrap: pretty; }

.hx-nav { padding: 4px 12px 20px; display: grid; gap: 18px; }
.hx-group__h { margin: 0 0 4px; }
.hx-group__h a {
  display: flex; align-items: center; justify-content: space-between; padding: 6px 12px;
  font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-radius: 8px;
}
.hx-group__h a:hover { color: var(--ink); }
.hx-group__go { opacity: 0; transition: opacity .15s ease; }
.hx-group__h a:hover .hx-group__go, .hx-group__h a:focus-visible .hx-group__go { opacity: 1; }
.hx-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.hx-nav__a {
  position: relative; display: block; padding: 8px 12px; border-radius: 10px;
  font-size: 15px; line-height: 1.3; color: var(--ink-2); text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.hx-nav__a:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.hx-nav__a[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(18,18,17,.05); }
.hx-nav__a[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--carmine); }
.hx-nav__a:focus-visible, .hx-group__h a:focus-visible, .hx-side__foot a:focus-visible { outline: 2px solid var(--carmine); outline-offset: 1px; }

.hx-side__foot { margin-top: auto; padding: 18px 24px 22px; border-top: 1px solid var(--line); font-size: 14px; }
.hx-side__foot p { margin: 0; color: var(--muted); }
.hx-side__foot a { display: inline-flex; gap: 6px; margin-top: 2px; color: var(--ink); font-weight: 500; text-decoration: none; }
.hx-side__foot a:hover .mb-arrow { transform: translateX(3px); }
[dir=rtl] .hx-side__foot a:hover .mb-arrow { transform: translateX(-3px); }
.hx-side__foot .mb-arrow { transition: transform .15s ease; }

.hx-pick { display: none; }

/* ---------- One problem ---------- */
.hx-main { min-width: 0; padding: 32px clamp(24px, 4vw, 64px) 72px; }
.hx-p { max-width: 1240px; }
.hx-p__head { max-width: 860px; }
.hx-crumb { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; font: 500 12px/1.3 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hx-crumb a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.hx-crumb a:hover { border-color: var(--ink); }
.hx-p__h { margin: 12px 0 0; font-size: clamp(36px, 3.6vw, 52px); line-height: 1.02; font-weight: 600; letter-spacing: -0.035em; color: var(--ink); text-wrap: balance; outline: none; }
.hx-p__line { margin: 10px 0 0; font-size: clamp(18px, 1.5vw, 21px); line-height: 1.45; color: var(--ink-2); max-width: 52ch; text-wrap: pretty; }

.hx-p__body { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr); gap: clamp(28px, 4vw, 56px); margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.hx-k { margin: 0 0 8px; font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hx-p__text { display: grid; gap: 18px; align-content: start; }
.hx-say p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--ink); max-width: 62ch; text-wrap: pretty; }
.hx-note { margin: 0; padding: 10px 14px; max-width: 62ch; font-size: 14px; line-height: 1.5; color: var(--ink-2); background: var(--surface-sunk); border-radius: var(--radius-md, 10px); border-left: 3px solid var(--line-strong); }

.hx-p__side { display: grid; gap: 16px; align-content: start; }
.hx-who { margin: 0; display: grid; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.hx-who > div { padding: 12px 14px; }
.hx-who > div + div { border-top: 1px solid var(--line); }
.hx-who dt { display: flex; align-items: center; gap: 7px; font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hx-who dt svg { width: 14px; height: 14px; color: var(--carmine); }
.hx-who dt i { width: 8px; height: 8px; margin: 0 3px; border-radius: 50%; background: var(--ink); }
.hx-who dd { margin: 5px 0 0; font-size: 15px; line-height: 1.45; color: var(--ink); }

.hx-tools { display: grid; gap: 8px; }
.hx-tools .hx-k { margin-bottom: 0; }
.hx-tool {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 14px 8px 8px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none;
  transition: border-color .15s ease;
}
.hx-tool:hover { border-color: var(--ink-2); }
.hx-tool:focus-visible, .hx-out:focus-visible, .hx-step__a:focus-visible { outline: 2px solid var(--carmine); outline-offset: 2px; }
.hx-tool .app-ico { width: 38px; height: 38px; margin: 0; border-radius: 10px; }
.hx-tool .app-ico svg { width: 18px; height: 18px; }
.hx-tool b { display: block; font-size: 15px; font-weight: 600; line-height: 1.2; }
.hx-tool small { display: block; font-size: 13px; color: var(--muted); }
.hx-tool .mb-arrow, .hx-out .mb-arrow, .hx-step__a .mb-arrow { transition: transform .15s ease; }
.hx-tool:hover .mb-arrow, .hx-out:hover .mb-arrow { transform: translateX(3px); }
[dir=rtl] .hx-tool:hover .mb-arrow, [dir=rtl] .hx-out:hover .mb-arrow { transform: translateX(-3px); }
.hx-out { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 2px 12px; padding: 2px 2px 0; color: var(--ink); text-decoration: none; }
.hx-out small { grid-column: 1 / -1; font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hx-out b { font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--line-strong); justify-self: start; }
.hx-out:hover b { border-color: var(--ink); }

/* ---------- The screens ---------- */
.hx-shots { display: grid; gap: 44px; margin-top: 40px; }
.hx-shot { margin: 0; min-width: 0; }
.hx-shot__cap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 14px; line-height: 1.45; color: var(--ink-2); max-width: 80ch; }
.hx-shot__n { font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
/* The frame scrolls sideways when a screen is wider than the pane; the padding leaves room for its shadow. */
.hx-frame { margin: 12px -6px 0; padding: 6px 6px 30px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.hx-frame__in { min-width: 0; }
.hx-shot--mid .hx-frame__in { max-width: 780px; }
.hx-shot--phone .hx-frame__in { max-width: 420px; }
/* Copied screens bring their page's rhythm; inside the frame they start flush. The laptop brings
   its own gutter and scroller, which the frame already gives it. */
.hx-frame .mg-lap__wrap { margin: 0; padding: 4px 20px 0; overflow: visible; }
.hx-frame .t-margin .mg-lap__base { margin: 0 -2%; }
.hx-frame__in > :first-child { margin-top: 0; }
.hx-frame__in > :last-child { margin-bottom: 0; }

/* ---------- Previous / next ---------- */
.hx-step { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; padding-top: 28px; border-top: 1px solid var(--line); }
.hx-step__a { display: grid; gap: 4px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none; transition: border-color .15s ease; }
.hx-step__a:hover { border-color: var(--ink-2); }
.hx-step__a small { font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hx-step__a b { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.hx-step__a--next { text-align: right; }

/* Without the script every problem shows, one under the other, and the sidebar links jump to them. */
.hx:not(.hx--js) .hx-p[hidden] { display: block; }
.hx:not(.hx--js) .hx-p + .hx-p { margin-top: 96px; padding-top: 48px; border-top: 1px solid var(--line); }

/* ---------- Tablet: a narrower sidebar, text over the side card ---------- */
/* ---------- Desktop: an app. The page stands still; the sidebar and the problem scroll on their own ---------- */
@media (min-width: 861px) {
  body.p-explorer { height: 100vh; height: 100dvh; overflow: hidden; }
  .p-explorer .hx { height: calc(100vh - var(--hx-top)); height: calc(100dvh - var(--hx-top)); min-height: 0; }
  .p-explorer .hx-side { position: static; height: 100%; }
  .p-explorer .hx-main { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}

@media (max-width: 1180px) {
  .p-explorer { --hx-side: 260px; }
  .hx-p__body { grid-template-columns: minmax(0, 1fr); }
  .hx-p__side { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

/* ---------- Phones and small tablets: a picker on top ---------- */
@media (max-width: 860px) {
  .hx { display: block; min-height: 0; }
  .hx-side { display: contents; }
  .hx-side__head { padding: 24px var(--gutter, 16px) 14px; }
  .hx-side__h { font-size: 28px; }
  .hx-nav, .hx-side__foot { display: none; }
  .hx-pick {
    position: sticky; top: var(--hx-top); z-index: 20; display: grid; gap: 6px;
    padding: 10px var(--gutter, 16px) 12px; background: var(--paper); border-bottom: 1px solid var(--line);
  }
  .hx-pick__k { font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .hx-pick__s {
    width: 100%; height: 46px; padding: 0 40px 0 14px; border: 1px solid var(--line-strong); border-radius: 12px;
    font: 500 16px/1 var(--font-sans); color: var(--ink); background-color: var(--surface);
    -webkit-appearance: none; appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
  }
  .hx-pick__s:focus-visible { outline: 2px solid var(--carmine); outline-offset: 2px; }
  .hx-main { padding: 28px var(--gutter, 16px) 56px; }
  .hx-p__h { font-size: clamp(34px, 9vw, 46px); }
  .hx-p__body { margin-top: 28px; padding-top: 22px; gap: 26px; }
  .hx-p__side { grid-template-columns: minmax(0, 1fr); }
  .hx-shots { margin-top: 36px; gap: 36px; }
  .hx-frame { margin-left: calc(-1 * var(--gutter, 16px)); margin-right: calc(-1 * var(--gutter, 16px)); padding-left: var(--gutter, 16px); padding-right: var(--gutter, 16px); }
  .hx-step { grid-template-columns: minmax(0, 1fr); }
  .hx-step__a--next { text-align: left; order: -1; }
}
