/* Håndapparat. Page layout in the kit's tokens, like the other modules; the
   radio in its own fixed colours, because black rubber and a backlit LCD look
   the same in either theme. */

.handheld {
  display: grid;
  grid-template-columns: minmax(16rem, 20rem) 1fr;
  gap: var(--s-6);
  align-items: start;
}
/* The kit gives .note its own display, which outranks the hidden
   attribute. */
.handheld [hidden] { display: none !important; }

.hh-side { position: sticky; top: var(--s-4); display: grid; gap: var(--s-3); }
.hh-thumb { display: grid; gap: var(--s-2); }
.hh-bench {
  display: grid; gap: var(--s-5) var(--s-6); min-width: 0;
  /* The parts in a narrow column beside the radio, the log under both. */
  grid-template-columns: minmax(8.5rem, 10rem) minmax(0, 1fr);
  grid-template-areas:
    "setup setup"
    "facts facts"
    "table radio"
    "log log";
  align-items: start;
}
.hh-bench .hh-radio-col { justify-items: start; }
.hh-bench .hh-radio-col .hh-radio { margin: 0; }
.hh-setup { grid-area: setup; }
.hh-facts { grid-area: facts; }
.hh-table { grid-area: table; }
.hh-radio-col { grid-area: radio; }
.hh-logsec { grid-area: log; }
.hh-bench section { display: grid; gap: var(--s-3); min-width: 0; }

.hh-h { font-size: var(--t-lg, 1.15rem); margin: 0; }
.hh-hint { color: var(--muted); margin: 0; max-width: 60ch; font-size: var(--t-sm); }
.hh-message { margin: 0; }
.hh-done { display: block; }
.hh-done h2 { margin: 0; font-size: var(--t-lg, 1.15rem); }
.hh-done p { margin: var(--s-1) 0 0; }

/* The checklist folds; its summary is the heading, the count, and -- only
   while folded -- the next step. */
.hh-check > summary {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--s-2);
  margin-bottom: var(--s-2); cursor: pointer; list-style: none;
}
.hh-check > summary::-webkit-details-marker { display: none; }
.hh-check > summary::before { content: "▾"; color: var(--muted); }
.hh-check:not([open]) > summary::before { content: "▸"; }
.hh-progress { color: var(--muted); }
.hh-next { flex-basis: 100%; color: var(--muted); }
.hh-check[open] .hh-next { display: none; }
.hh-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.hh-checklist li { display: grid; grid-template-columns: 1.4rem 1fr; column-gap: var(--s-2); align-items: start; }
.hh-ring {
  width: 1.1rem; height: 1.1rem; margin-top: 0.15rem;
  border: 2px solid var(--rule-strong); border-radius: 50%;
}
.hh-checklist li.is-done .hh-ring { background: var(--done); border-color: var(--done); }
.hh-checklist li.is-done .hh-step-label { color: var(--muted); }
.hh-step-next { grid-column: 2; color: var(--muted); font-size: var(--t-sm); }

/* The choices at the thumb. */
.hh-ask {
  display: grid; gap: var(--s-2);
  padding: var(--s-3); background: var(--surface);
  border: var(--rule-w) solid var(--rule-strong); border-radius: var(--radius-control);
}
.hh-ask-q { margin: 0; font-weight: var(--w-strong); }
.hh-ask-choices { display: grid; gap: var(--s-2); }
.hh-ask.is-grid .hh-ask-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hh-ask.is-grid .hh-ask-close { grid-column: 1 / -1; }
.hh-choice {
  min-height: 48px; height: auto; padding: var(--s-2) var(--s-3);
  justify-content: flex-start; text-align: left; white-space: normal; line-height: 1.3;
}
.hh-ask.is-grid .hh-choice { justify-content: center; text-align: center; padding: 0 var(--s-1); }
.hh-ask-close { min-height: 48px; }

/* Setting up: the exercise, the call sign, the facts of the repeater. */
/* The kit's segments are a little under a finger inside their track; these
   are pressed with one, so they get the whole 48 px. */
.hh-exercises { max-width: 36rem; }
.hh-exercises button { min-height: var(--tap, 48px); }
.hh-card { max-width: 40rem; margin: 0; grid-template-columns: 1fr 1fr; column-gap: var(--s-5); }
/* Two columns of facts: the last row closes each column. */
.hh-card > div:nth-last-child(2):nth-child(odd) { border-bottom: var(--rule-w) solid var(--rule); }
.hh-call { display: grid; gap: var(--s-1); justify-items: start; }
.hh-call input {
  width: 11rem; min-height: 48px; padding: 0 var(--s-3);
  font: inherit; font-size: 1.1rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink);
  background: var(--surface); border: var(--rule-w) solid var(--rule-strong);
  border-radius: var(--radius-control);
}
.hh-call input::placeholder { color: var(--muted); text-transform: none; letter-spacing: 0.04em; }

/* The parts on the table. */
.hh-parts { display: grid; gap: var(--s-2); }
.hh-part {
  display: grid; grid-template-columns: 2.5rem auto; grid-template-rows: auto auto;
  column-gap: var(--s-2); align-items: center; text-align: left;
  min-height: 56px; padding: var(--s-1) var(--s-3) var(--s-1) var(--s-2);
  font: inherit; color: var(--ink);
  background: var(--surface); border: var(--rule-w) solid var(--rule-strong);
  border-radius: var(--radius-control); cursor: pointer;
}
.hh-part:hover { border-color: var(--ink); }
.hh-part[aria-pressed="true"] {
  border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--tint);
}
.hh-part svg { grid-row: 1 / 3; width: 2.5rem; height: 2.5rem; }
.hh-part-name { font-weight: var(--w-strong); white-space: nowrap; }
.hh-part-state { color: var(--muted); font-size: var(--t-sm); min-height: 1em; }
.hh-part-state:empty { display: none; }
.hh-ic-pack { fill: #4a4f57; }
.hh-ic-tab { fill: #8a8f96; }
.hh-ic-line { stroke: #4a4f56; stroke-width: 1.5; }
.hh-ic-whip { fill: #3a3e45; }
.hh-ic-boot { fill: #4a4f57; }

/* VOL and SQL, the knobs on top of the radio. */
.hh-knobs { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.hh-knob { display: flex; align-items: center; gap: var(--s-1); }
.hh-knob-name { width: 2.4rem; font-weight: var(--w-strong); letter-spacing: 0.04em; }
.hh-knob-value { min-width: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.hh-step {
  width: 48px; height: 48px; padding: 0;
  font: inherit; font-size: 1.4rem; line-height: 1; color: var(--ink);
  background: var(--surface); border: var(--rule-w) solid var(--rule-strong);
  border-radius: var(--radius-control); cursor: pointer;
}
.hh-step:hover { border-color: var(--ink); }

/* The QSO as it is said. */
.hh-log { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); max-width: 40rem; }
.hh-log li { display: grid; gap: 2px; padding-left: var(--s-3); border-left: 3px solid var(--rule-strong); }
.hh-log li.is-them { border-left-color: var(--accent); }
.hh-log-who { color: var(--muted); font-size: var(--t-sm); font-variant-numeric: tabular-nums; }

/* ---- the radio itself, in fixed colours */
.hh-radio { display: block; width: 100%; max-width: 20rem; height: auto; margin: 0 auto; touch-action: manipulation; }
.hh-radio .is-gone { display: none; }
.hh-body { fill: url(#hh-body-grad); stroke: #858b94; stroke-width: 2; }
.hh-face { fill: url(#hh-face-grad); stroke: #2c2f34; stroke-width: 1.5; }
.hh-shine { stroke: #7a8089; stroke-width: 2; stroke-linecap: round; opacity: 0.6; }
.hh-grille { stroke: #24272b; stroke-width: 4; stroke-linecap: round; }
.hh-engrave { fill: #d3d7dc; font: 600 8px var(--font-text, sans-serif); text-anchor: middle; letter-spacing: 0.08em; }
.hh-whip { fill: #2e3034; stroke: #7d838c; stroke-width: 1.2; }
.hh-boot { fill: #44484f; stroke: #858b94; stroke-width: 1.2; }
.hh-boot-rib { stroke: #2c2f34; stroke-width: 1.5; }
.hh-sma { fill: #c9b47a; stroke: #8c7a48; stroke-width: 1; }
.hh-sma-thread { stroke: #8c7a48; stroke-width: 1; }
.hh-knob-body { fill: #44484f; stroke: #858b94; stroke-width: 1.2; }
.hh-knob-rib { stroke: #2c2f34; stroke-width: 1.5; }
.hh-knob-top { fill: #6a7078; stroke: #8f959e; stroke-width: 1; }
.hh-knob-mark { stroke: #ffffff; stroke-width: 2; stroke-linecap: round; }
.hh-pack { fill: #3c4047; stroke: #858b94; stroke-width: 2; }
.hh-pack-none { fill: none; stroke: #8a8f96; stroke-width: 2; stroke-dasharray: 5 4; }
.hh-pack-label { fill: #e2e5e9; font: 700 9px var(--font-text, sans-serif); text-anchor: middle; letter-spacing: 0.1em; }
.hh-pack-label.is-none { fill: var(--muted); }

.hh-bezel { fill: #23262a; stroke: #6b717a; stroke-width: 1; }
/* Lit: a green backlight with dark segments. Off: the same glass, unlit. */
.hh-lcd { fill: url(#hh-lcd-grad); }
.hh-radio.is-off .hh-lcd { fill: #a4ab96; }
.hh-radio.is-off .hh-lcd-content { display: none; }
.hh-seg { fill: #1c2416; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.hh-seg-s { font-size: 9px; font-weight: 700; }
.hh-seg-shift { font-size: 14px; font-weight: 700; }
.hh-seg-freq { font-size: 31px; font-weight: 600; text-anchor: middle; letter-spacing: -0.02em; }
.hh-seg-sub { text-anchor: end; font-weight: 600; }
.hh-seg-fill { fill: #1c2416; }
.hh-batt-outline { fill: none; stroke: #1c2416; stroke-width: 1.2; }
[data-lcd-bars].is-blink { animation: hh-blink 1s steps(2, start) infinite; }
@keyframes hh-blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { [data-lcd-bars].is-blink { animation: none; } }

.hh-key rect { fill: #61666f; stroke: #2a2d31; stroke-width: 1.5; }
.hh-key.is-fn rect { fill: #6e5d40; }
.hh-key text { fill: #ffffff; font: 700 15px var(--font-text, sans-serif); text-anchor: middle; pointer-events: none; }
.hh-key.is-fn text { font-size: 10px; letter-spacing: 0.06em; fill: #ffdca3; }
.hh-key, .hh-ptt { cursor: pointer; outline: none; }
.hh-key:active rect, .hh-key.is-down rect { fill: #7b818b; }
.hh-key:focus-visible rect, .hh-ptt:focus-visible .hh-ptt-bar { stroke: var(--accent); stroke-width: 3; }
.hh-hit { fill: transparent; }
.hh-ptt-bar { fill: #3a3e45; stroke: #858b94; stroke-width: 1.5; }
.hh-ptt-rib { stroke: #23262a; stroke-width: 1.5; }
.hh-ptt-label { fill: var(--muted); font: 700 10px var(--font-text, sans-serif); text-anchor: middle; letter-spacing: 0.12em; }
.hh-ptt:active .hh-ptt-bar, .hh-radio.is-tx .hh-ptt-bar { fill: #a3402f; }

/* Between a phone and a wide desktop the page is what the menu rail leaves
   over, so the layout follows the room it actually has, not the screen: a
   narrower checklist and the facts in one column first, then the parts
   above the radio rather than beside it. Before the phone rules below,
   which win on a phone. */
.hh-frame { container: hh / inline-size; }
@container hh (max-width: 51rem) {
  .handheld { grid-template-columns: 16rem minmax(0, 1fr); }
  .hh-card { grid-template-columns: 1fr; }
  .hh-card > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}
@container hh (max-width: 44rem) {
  .hh-bench {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "setup" "facts" "radio" "table" "log";
  }
  .hh-parts { display: flex; flex-wrap: wrap; }
}

@media (max-width: 760px) {
  .handheld {
    grid-template-columns: 1fr; gap: var(--s-4);
    padding-bottom: calc(var(--hh-thumb-h, 6rem) + var(--s-5));
  }
  .hh-side { position: static; }
  .hh-bench {
    grid-template-columns: minmax(0, 1fr);
    /* The radio, which is what the student works, straight after the
       choice of exercise; the parts, the facts and the log after it. */
    grid-template-areas: "setup" "radio" "table" "facts" "log";
    gap: var(--s-5);
  }
  .hh-knobs { justify-content: space-between; }
  .hh-parts { display: flex; flex-wrap: wrap; }
  .hh-card { grid-template-columns: 1fr; }
  .hh-card > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
  .hh-bench .hh-radio-col { justify-items: stretch; }
  .hh-bench .hh-radio-col .hh-radio { margin: 0 auto; }
  /* The answer to a press, and the choices, at the bottom of the screen
     above the menu, wherever the page is scrolled. */
  .hh-thumb {
    position: fixed; z-index: 15;
    left: var(--s-3); right: var(--s-3); bottom: calc(var(--s-3) + env(safe-area-inset-bottom));
    max-height: 70vh; overflow-y: auto;
  }
  body:has(.tabbar) .hh-thumb { bottom: calc(var(--tabbar-h) + var(--s-2) + env(safe-area-inset-bottom)); }
  .hh-message { border: var(--rule-w) solid var(--rule-strong); }
  .hh-ask { box-shadow: 0 -2px 12px rgb(0 0 0 / 0.12); }
}
