/* On-screen ruler, magnetic compass and protractor (#754): buttons in the question header, floating tools and a small control bar. */
@layer components {
  .measuring-tools {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .measuring-tools-fields {
    border: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin: 0;
    padding: 0;

    legend { padding: 0; }
  }
  .measuring-tools-field { align-items: center; display: inline-flex; font-weight: 400; gap: var(--space-1); }

  /* The tool is centred on the point JS gives it (left/top 0 plus a translate), so it can turn about its middle. */
  .measuring-tool {
    block-size: auto;
    inline-size: max-content;
    inset: 0 auto auto 0;
    position: fixed;
    touch-action: none;
    user-select: none;
    z-index: 1000;

    &:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
    svg { display: block; overflow: visible; }
  }
  /* Round, so the focus ring follows the dial instead of a square that turns with it. */
  .measuring-tool--compass { border-radius: 50%; }

  .measuring-tool__body {
    /* The warning pair: a pale amber surface with dark text in light mode, a dark amber one with light text in dark mode. */
    fill: var(--color-warning-surface);
    fill-opacity: 0.85;
    stroke: var(--color-warning-text);
    stroke-width: 0.4;
  }
  .measuring-tool__tick { stroke: var(--color-warning-text); stroke-width: 0.2; }
  .measuring-tool__mark { fill: none; stroke: var(--color-warning-text); stroke-width: 0.3; }
  .measuring-tool__label { fill: var(--color-warning-text); font-size: 3.4px; }
  .measuring-tool__label--inner { fill: var(--color-warning-text); font-size: 2.8px; opacity: 0.7; }
  .measuring-tool__rotate {
    cursor: grab;
    fill: var(--color-primary-tint);
    stroke: var(--color-primary);
    stroke-width: 1.5;
  }

  /* The magnetic compass: a red and white needle that always points to the top of the screen, and the student's direction arrow. */
  .measuring-tool__needle-north { fill: var(--color-danger); }
  .measuring-tool__needle-south { fill: var(--color-surface); stroke: var(--color-warning-text); stroke-width: 0.3; }
  .measuring-tool__arrow {
    fill: var(--color-primary);
    stroke: var(--color-primary);
    stroke-linejoin: round;
    stroke-width: 1;
  }

  .measuring-tools-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    inset: auto var(--space-4) var(--space-4) auto;
    position: fixed;
    z-index: 1001;

    &:empty { display: none; }
  }
  .measuring-tools-entry {
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 0.5rem);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.85rem;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
}
