/* =====================================================================
   v039 — Shared ink pickers + compact ink toolbars  (v039)
   ---------------------------------------------------------------------
   1) One colour board and one slider popover, shared by every ink surface
      (Original paper / Paper answer book / practice canvas).
   2) In portrait and on narrow screens the tool buttons drop their text
      labels, which is what made "Eraser"/"Highlighter" blow the bar out.
   Only overrides: no earlier stylesheet is touched.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Trigger buttons (small, identical everywhere)
   --------------------------------------------------------------------- */
.inkPickTrigger{
  position:relative;
  display:inline-flex!important;
  align-items:center;
  gap:5px;
  cursor:pointer;
}
.inkPickTrigger > .inkPickDot{
  width:15px!important;
  height:15px!important;
  border-radius:50%!important;
  background:var(--sw,#172033)!important;
  box-shadow:0 0 0 1.5px #cfd6e1!important;
  flex:0 0 auto;
}
.inkPickTrigger[aria-expanded="true"]{
  background:#eaf0ff!important;
  border-color:#c6d3ef!important;
}
.inkPickTrigger[aria-expanded="true"] .inkPickDot{
  box-shadow:0 0 0 2px #315efb!important;
}
/* numeric readout for slider triggers */
.inkPickTrigger [data-ink-value]{
  font-variant-numeric:tabular-nums;
  min-width:16px;
  text-align:right;
}
/* thickness bar inside a width trigger (height mirrors the live value) */
.inkPickTrigger .inkPickBar{
  display:block;
  width:13px;
  height:3px;
  border-radius:999px;
  background:#172033;
  flex:0 0 auto;
}
/* finger-mode chip internals */
.sourceFingerModeBtn .fingerGlyph{
  font-style:normal;
  line-height:1;
  font-size:12px;
}
.sourceFingerModeBtn .fingerWord{white-space:nowrap}

/* eraser glyph */
.inkPickTrigger .inkPickGlyph{
  font-style:normal;
  font-size:12px;
  line-height:1;
  color:#667388;
  flex:0 0 auto;
}

/* ---------------------------------------------------------------------
   2. The popover
   --------------------------------------------------------------------- */
.inkPick{
  position:fixed;
  z-index:1500;                 /* above the answer workspace (120), below dialogs (2000) */
  width:214px;
  padding:10px 11px 11px;
  background:#fff;
  border:1px solid #dde3ec;
  border-radius:12px;
  box-shadow:0 12px 32px rgba(16,25,40,.18),0 2px 6px rgba(16,25,40,.08);
  box-sizing:border-box;
  touch-action:none;           /* dragging the slider must not scroll the page */
}
.inkPick[hidden]{display:none!important}
.inkPickHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  font-size:10px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.07em;
  color:#8691a3;
  margin-bottom:8px;
}
.inkPickReadout{
  font-size:11px;
  font-weight:900;
  color:#315efb;
  text-transform:none;
  letter-spacing:0;
}

/* colour grid */
.inkPickGrid{
  display:grid;
  grid-template-columns:repeat(8,1fr);
  gap:6px;
}
.inkPickSwatch{
  width:100%;
  aspect-ratio:1/1;
  min-width:0;
  padding:0;
  border:none!important;
  border-radius:50%!important;
  background:var(--sw)!important;
  box-shadow:0 0 0 1px rgba(16,25,40,.16)!important;
  cursor:pointer;
  transition:transform .09s ease;
}
.inkPickSwatch:hover{transform:scale(1.12)}
.inkPickSwatch.is-current{box-shadow:0 0 0 2px #315efb!important}

/* custom colour row */
.inkPickCustom{
  display:flex;
  align-items:center;
  gap:7px;
  margin-top:10px;
  padding-top:9px;
  border-top:1px solid #eef1f6;
  font-size:9px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.07em;
  color:#8691a3;
  cursor:pointer;
}
.inkPickColorInput{
  width:30px;
  height:24px;
  padding:0;
  border:1px solid #dde3ec!important;
  border-radius:6px!important;
  background:#fff;
  cursor:pointer;
  flex:0 0 auto;
}
.inkPickColorInput::-webkit-color-swatch-wrapper{padding:2px}
.inkPickColorInput::-webkit-color-swatch{border:none;border-radius:4px}

/* slider preview */
.inkPickPreview{
  height:46px;
  display:grid;
  place-items:center;
  margin-bottom:9px;
  border-radius:9px;
  background:
    linear-gradient(90deg,rgba(49,94,251,.05) 1px,transparent 1px) 0 0/14px 14px,
    #f7f9fc;
  border:1px solid #eef1f6;
  overflow:hidden;
}
.inkPickPreviewMark{
  display:block;
  background:#172033;
  border-radius:999px;
}
.inkPickPreviewMark--line{width:82%;height:3px}
.inkPickPreviewMark--dot{width:24px;height:24px;background:#8fa1bd;opacity:.55}

/* the slider itself — big enough for a finger */
.inkPickRange{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:26px;
  margin:0;
  background:transparent;
  cursor:pointer;
  display:block;
}
.inkPickRange::-webkit-slider-runnable-track{
  height:6px;
  border-radius:999px;
  background:linear-gradient(90deg,#c9d6f5,#e6ecf8);
}
.inkPickRange::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:22px;
  height:22px;
  margin-top:-8px;
  border-radius:50%;
  background:#fff;
  border:2px solid #315efb;
  box-shadow:0 2px 6px rgba(16,25,40,.18);
}
.inkPickRange::-moz-range-track{
  height:6px;border-radius:999px;background:#dde5f3;
}
.inkPickRange::-moz-range-thumb{
  width:20px;height:20px;border-radius:50%;
  background:#fff;border:2px solid #315efb;
}
.inkPickRange:focus-visible{outline:2px solid #315efb;outline-offset:3px;border-radius:8px}

/* ---------------------------------------------------------------------
   3. Tablet portrait: keep one compact row
   ---------------------------------------------------------------------
   v033 turns the primary tool group into a 2-column grid with 46px-tall
   full-width buttons below 980px. That is right for a phone, but it also
   caught iPad portrait (820px), where it stretched each button to ~366px
   and pushed the colour/width controls off screen.
   Below, phones (<=600px) keep that roomy grid; tablets (601-1080px) get a
   single icon row instead.
   --------------------------------------------------------------------- */
@media (min-width:601px) and (max-width:900px),
       (min-width:601px) and (orientation:portrait) and (max-width:1080px){
  body.ial-v030 .inkToolbar .toolGroup,
  body.ial-v030 .paperInkToolbar .inkPrimaryTools,
  body.ial-v030 .sourceInkToolbar .inkPrimaryTools{
    display:flex!important;
    grid-template-columns:none!important;
    width:auto!important;
    gap:3px!important;
    flex:0 0 auto;
  }
  body.ial-v030 .inkToolbar .toolGroup .inkTool,
  body.ial-v030 .paperInkToolbar .inkPrimaryTools .paperInkToolBtn,
  body.ial-v030 .sourceInkToolbar .inkPrimaryTools .paperInkToolBtn{
    width:auto!important;
    min-height:34px!important;
    min-width:34px!important;
  }
  /* undo the mobile reordering so the row reads Pen, Eraser, ... , Hand */
  body.ial-v030 #handTool,
  body.ial-v030 #paperHandBtn,
  body.ial-v030 .sourceInkToolbar [data-source-tool="hand"],
  body.ial-v030 #penTool,
  body.ial-v030 #paperPenBtn,
  body.ial-v030 .sourceInkToolbar [data-source-tool="pen"]{order:0!important}
}

/* ---------------------------------------------------------------------
   4. Narrow: drop the text labels that made the bar too wide
   --------------------------------------------------------------------- */
@media (max-width:900px),(orientation:portrait) and (max-width:1080px){
  /* tool buttons become icon-only (the title attribute still names them).
     !important is needed: an earlier rule
     `body.ial-v030 .sourceInkToolbar .paperInkToolBtn span{display:inline-flex}`
     inside @media(max-width:980px) outranks a plain class selector. */
  body.ial-v030 .inkToolbarV018 .paperInkToolBtn > span,
  .inkToolbarV018 .paperInkToolBtn > span,
  .inkToolbar .inkTool > span{
    display:none!important;
  }
  .inkToolbarV018 .paperInkToolBtn,
  .inkToolbar .inkTool{
    min-width:34px!important;
    padding:5px 9px!important;
    justify-content:center;
    font-size:13px!important;
  }
  /* The finger-mode chip is a state, not an action: keep its glyph visible so
     you can still tell scrolling from writing once the words are gone. */
  .inkToolbarV018 .sourceFingerModeBtn{
    min-width:34px!important;
    padding:5px 8px!important;
    justify-content:center;
  }
  .inkToolbarV018 .sourceFingerModeBtn .fingerWord{display:none!important}
  .inkToolbarV018 .sourceFingerModeBtn .fingerGlyph{font-size:13px}
  .inkToolbarV018 .sourceFingerModeBtn[data-finger-mode="draw"]{
    background:#edf2ff!important;
    color:#315efb!important;
    border-color:#bdccec!important;
  }
  /* "Color" / "Width" captions are noise once the buttons are icons */
  .inkMiniLabel,.toolLabel{display:none!important}
  /* Let a long bar wrap instead of scrolling sideways out of reach.
     v031 pins the Original toolbar to `height:56px!important;flex-wrap:nowrap`
     which clips the multi-row layout; this needs both the higher specificity of
     the body.ial-v030 prefix and !important to win. */
  body.ial-v030 .paperSourceInkToolbar,
  body.ial-v030 .paperInkToolbar,
  .inkToolbarV018{
    height:auto!important;
    min-height:56px!important;
    flex-wrap:wrap!important;
    row-gap:5px!important;
    padding-top:6px!important;
    padding-bottom:6px!important;
    overflow-x:hidden!important;
    overflow-y:visible!important;
  }
  .inkToolbarV018 .inkToolbarDivider{height:22px}
  /* practice toolbar uses different class names */
  .inkToolbar{flex-wrap:wrap!important;row-gap:5px!important}
  .inkToolbar .toolDivider{height:22px}
  /* the popover must fit a narrow screen */
  .inkPick{width:min(214px,calc(100vw - 24px))}
}

/* Very short landscape windows (split view) also need the compact form */
@media (max-height:520px){
  body.ial-v030 .inkToolbarV018 .paperInkToolBtn > span,
  .inkToolbarV018 .paperInkToolBtn > span,
  .inkToolbar .inkTool > span{display:none!important}
  .inkMiniLabel,.toolLabel{display:none!important}
}
