/* =====================================================================================
   IRviewer.css: the Infrared Spectroscopy Viewer's own rules (#ir-tool-wrapper).
   Load after rs-spec-viewer.css, which holds the card, controls, panels and spectrum box.
   This file: set-up forms, structure drawing, spectrum marks (fingerprint region, absorptions,
   peak labels), Deduce steps and structure cards, the data sheet window and Deduce in full
   screen. 29 Nov 2026. No important flags.
   ===================================================================================== */

/* ---- head and set-up ---- */

#ir-tool-wrapper #ir-study-context-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#ir-tool-wrapper #ir-view-config-explore .ir-config-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

#ir-tool-wrapper #ir-view-config-explore select {
  margin-bottom: 8px;
}

#ir-tool-wrapper .ir-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

#ir-tool-wrapper .ir-filter-grid > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

@container svview (min-width: 620px) {
  #ir-tool-wrapper #ir-view-config-explore .ir-config-panel {
    grid-template: auto auto / repeat(2, minmax(0, 300px));
    grid-auto-flow: column;
    column-gap: 16px;
  }
}

@container svview (min-width: 620px) {
  #ir-tool-wrapper #ir-view-config-explore select {
    margin-bottom: 0;
  }
}

@container svview (min-width: 620px) {
  #ir-tool-wrapper .ir-filter-grid {
    grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(0, 2fr);
    gap: 20px;
  }
}

@container svview (min-width: 620px) {
  #ir-tool-wrapper #ir-filter-fg-group {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* ---- workspace ---- */

#ir-tool-wrapper #btn-ir-ws-exit-explore {
  margin-left: auto;
}

#ir-tool-wrapper #ir-ws-toolbar-question {
  justify-content: space-between;
}

/* ---- structure drawing ---- */

#ir-tool-wrapper #ir-molecule-svg {
  display: block;
  width: 100%;
  height: 100%;
}

#ir-tool-wrapper #ir-molecule-zoom-group text {
  fill: var(--ink);
  font-family: inherit;
  font-weight: 800;
}

#ir-tool-wrapper #ir-molecule-zoom-group :is(line, path) {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
}

#ir-tool-wrapper #ir-molecule-zoom-group g.ir-faded {
  opacity: 0.18;
}

#ir-tool-wrapper #ir-molecule-zoom-group g:is(.ir-active-frag, .ir-highlight-locked) {
  opacity: 1;
}

#ir-tool-wrapper #ir-molecule-zoom-group g:is(.ir-active-frag, .ir-highlight-locked) text {
  fill: var(--accent);
  font-weight: 900;
}

#ir-tool-wrapper #ir-molecule-zoom-group g:is(.ir-active-frag, .ir-highlight-locked) :is(line, path) {
  stroke: var(--accent);
  stroke-width: 3;
}

#ir-tool-wrapper .ir-frag-hitbox {
  fill: transparent;
  stroke: transparent;
  pointer-events: all;
  cursor: pointer;
}

#ir-tool-wrapper .ir-frag-hitbox:hover {
  fill: rgba(211, 62, 22, 0.05);
  stroke: rgba(211, 62, 22, 0.16);
}

#ir-tool-wrapper.ir-deduce-unsolved .ir-absorption-note-slot {
  display: none;
}

/* ---- spectrum marks: fingerprint region, absorptions (blue when highlighted), teal peak labels ---- */

#ir-tool-wrapper .ir-fingerprint-region {
  fill: rgba(211, 62, 22, 0.08);
  stroke: rgba(211, 62, 22, 0.18);
  stroke-width: 1;
}

#ir-tool-wrapper .ir-fingerprint-label-bg {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(208, 212, 224, 0.95);
  stroke-width: 1;
  pointer-events: none;
}

#ir-tool-wrapper .ir-fingerprint-label {
  fill: rgba(57, 67, 98, 0.9);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

#ir-tool-wrapper .ir-absorption-hitbox {
  fill: transparent;
  pointer-events: all;
  cursor: pointer;
}

#ir-tool-wrapper .ir-absorption-zone {
  display: none;
  fill: rgba(91, 164, 207, 0.18);
  stroke: var(--zone);
  stroke-width: 1.5;
  pointer-events: none;
}

#ir-tool-wrapper .ir-absorption-group:is(.ir-active-peak, .ir-highlight-locked) .ir-absorption-zone {
  display: block;
}

#ir-tool-wrapper .ir-absorption-group.ir-faded {
  opacity: 0.22;
}

#ir-tool-wrapper .ir-absorption-group:is(.ir-active-peak, .ir-highlight-locked) {
  opacity: 1;
}

#ir-tool-wrapper .ir-peak-label-bg {
  fill: #f7fbff;
  stroke: #9ccce5;
  stroke-width: 0.8;
  pointer-events: none;
}

#ir-tool-wrapper .ir-peak-label {
  fill: #0f6f7a;
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
}

#ir-tool-wrapper .ir-label-guide {
  stroke: #1b6f7b;
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.85;
  pointer-events: none;
}

#ir-tool-wrapper .ir-zoom-box {
  stroke: var(--blue);
  stroke-width: 1;
  pointer-events: none;
}

#ir-tool-wrapper :is(.ir-peak-label, .ir-peak-label-bg, .ir-fingerprint-label, .ir-fingerprint-label-bg) {
  transform-box: fill-box;
  transform-origin: center;
}

@container svspec (max-width: 820px) {
  #ir-tool-wrapper .ir-fingerprint-label {
    font-size: 13px;
  }
}

@container svspec (max-width: 620px) {
  #ir-tool-wrapper :is(.ir-fingerprint-label, .ir-fingerprint-label-bg) {
    transform: scale(1.4);
  }
}

@container svspec (max-width: 620px) {
  #ir-tool-wrapper :is(.ir-peak-label, .ir-peak-label-bg) {
    transform: scale(1.3);
  }
}

@container svspec (max-width: 440px) {
  #ir-tool-wrapper :is(.ir-fingerprint-label, .ir-fingerprint-label-bg) {
    transform: scale(2);
  }
}

@container svspec (max-width: 440px) {
  #ir-tool-wrapper :is(.ir-peak-label, .ir-peak-label-bg) {
    transform: scale(2.2);
  }
}

/* the y "0" at the origin moves up clear of the x "4000" (it is the 7th-from-last child of
   .ir-axis-group: 0, tick, 50, tick, 100, y title, x title) */

#ir-tool-wrapper .ir-axis-group > .ir-axis-label[text-anchor="end"]:nth-last-child(7) {
  translate: 0 -5px;
}

@container svspec (max-width: 620px) {
  #ir-tool-wrapper .ir-axis-group > .ir-axis-label[text-anchor="end"]:nth-last-child(7) {
    translate: 0 -8px;
  }
}

@container svspec (max-width: 440px) {
  #ir-tool-wrapper .ir-axis-group > .ir-axis-label[text-anchor="end"]:nth-last-child(7) {
    translate: 0 -12px;
  }
}

/* ---- Deduce ---- */

#ir-tool-wrapper .ir-clues-list {
  margin: 0;
  padding-left: 20px;
}

#ir-tool-wrapper.ir-deduce-unsolved .ir-molecule-wrapper {
  height: auto;
  overflow: visible;
  border: 0;
  cursor: default;
}

#ir-tool-wrapper .ir-hidden-structure-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
}

#ir-tool-wrapper .ir-hidden-structure-note strong {
  color: var(--ink);
  font-size: 1.05rem;
}

#ir-tool-wrapper .ir-hidden-structure-note span {
  font-size: 0.92rem;
  line-height: 1.4;
}

#ir-tool-wrapper .ir-hidden-structure-note .ir-btn {
  margin-top: 4px;
}

#ir-tool-wrapper .ir-deduce-choice-section {
  margin: 20px 0 0;
}

#ir-tool-wrapper .ir-deduce-choice-section h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  text-align: left;
}

#ir-tool-wrapper .ir-deduce-analysis-section {
  margin: 0 0 16px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--soft);
}

#ir-tool-wrapper :is(.ir-deduce-analysis-section p, .ir-deduce-step-note) {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

#ir-tool-wrapper .ir-deduce-analysis-section.complete {
  padding: 10px 14px;
  border-color: var(--info-line);
  background: var(--info-bg);
}

#ir-tool-wrapper .ir-deduce-analysis-section.complete p {
  margin: 0;
  color: var(--ink);
}

#ir-tool-wrapper .ir-deduce-structure-section {
  display: none;
}

#ir-tool-wrapper .ir-absorption-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px 10px;
  margin: 0 0 12px;
}

#ir-tool-wrapper .ir-absorption-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.25;
  cursor: pointer;
}

#ir-tool-wrapper .ir-absorption-option:has(input:checked) {
  border-color: var(--blue);
  background: var(--info-bg);
}

#ir-tool-wrapper .ir-absorption-option small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
}

#ir-tool-wrapper .ir-absorption-check-feedback {
  display: none;
}

#ir-tool-wrapper .ir-absorption-check-feedback.success {
  border-color: var(--info-line);
  background: var(--info-bg);
  color: var(--ink);
}

#ir-tool-wrapper .ir-deduce-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  width: 100%;
}

#ir-tool-wrapper .ir-isomer-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--soft);
  text-align: center;
  cursor: pointer;
}

#ir-tool-wrapper .ir-isomer-card:hover {
  border-color: var(--blue);
  background: #fff;
}

#ir-tool-wrapper .ir-isomer-card.active {
  border-color: var(--accent);
  background: var(--err-bg);
}

#ir-tool-wrapper .ir-isomer-card.correct {
  border-color: var(--ok-edge);
  background: var(--ok-bg);
}

#ir-tool-wrapper .ir-structural-formula {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 36px;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#ir-tool-wrapper .ir-isomer-name {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

/* ---- windows: data sheet, cheat sheet, confirm ---- */

#ir-tool-wrapper .ir-datasheet-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 2147483647;
  width: min(1100px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 16px;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
}

#ir-tool-wrapper .ir-datasheet-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  padding-right: 44px;
  cursor: move;
  user-select: none;
}

#ir-tool-wrapper .ir-datasheet-titlebar h3 {
  margin: 0;
  font-size: 1.05rem;
}

#ir-tool-wrapper .ir-datasheet-wrapper {
  width: 100%;
  max-height: calc(100vh - 130px);
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--soft);
  cursor: grab;
}

#ir-tool-wrapper .ir-datasheet-content {
  min-width: 720px;
  padding: 16px;
  transform-origin: top left;
}

#ir-tool-wrapper .ir-datasheet-note {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--info-line);
  border-radius: 0 12px 12px 0;
  background: var(--info-bg);
  color: var(--muted);
}

#ir-tool-wrapper .ir-datasheet-resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  border-right: 3px solid var(--edge);
  border-bottom: 3px solid var(--edge);
  cursor: nwse-resize;
}

/* ---- full screen in Deduce: the steps sit beside the spectrum ---- */

#ir-tool-wrapper:fullscreen:is(.ir-deduce-unsolved, .ir-deduce-solved) .ir-container {
  float: left;
  width: 58%;
  grid-template: "clues" "spec" "mt" "mol" "reset" "note" "rep" / minmax(0, 1fr);
}

/* round 5: Reveal answer has moved to the steps (beside the spectrum in full screen) */

#ir-tool-wrapper:fullscreen:is(.ir-deduce-unsolved, .ir-deduce-solved) .ir-panel-spectrum {
  margin: 0 0 12px;
}

#ir-tool-wrapper:fullscreen.ir-deduce-unsolved .ir-molecule-wrapper {
  height: auto;
}

#ir-tool-wrapper:fullscreen .ir-deduce-choice-section {
  display: flow-root;
  margin: 0 0 0 calc(58% + 24px);
}

#ir-tool-wrapper:fullscreen #ir-table-container {
  clear: both;
  padding-top: 12px;
}

/* ---- 29 Nov 2026 accessibility fixes ---- */

/* (g) unavailable filter choices: no fade; italic text, and the checkbox itself is disabled */

#ir-tool-wrapper .ir-checkbox-group label.ir-unavailable {
  color: var(--muted);
  font-style: italic;
  cursor: not-allowed;
}

/* (g) structure cards: set-aside cards keep full-contrast text, with a dashed edge and a tag;
   the tag also says "Correct" or "Not this one", so the state is not shown by colour alone */

#ir-tool-wrapper .ir-isomer-card.ir-rejected {
  border-style: dashed;
  background: #fff;
}

#ir-tool-wrapper .ir-card-tag {
  align-self: center;
  margin-top: 4px;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--err-text);
  font-size: 0.8rem;
  font-weight: 800;
}

#ir-tool-wrapper .ir-isomer-card.correct .ir-card-tag {
  border-color: var(--ok-edge);
  color: var(--ok-text);
}

/* (d) keyboard focus on an absorption or a bond: the same 3px ring colour, drawn round the band or bond */

#ir-tool-wrapper :is(.ir-absorption-group, .ir-frag-hitbox):focus {
  outline: none;
}

#ir-tool-wrapper .ir-absorption-group:focus-visible .ir-absorption-zone {
  display: block;
  stroke: var(--focus);
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
}

#ir-tool-wrapper .ir-frag-hitbox:focus-visible {
  stroke: var(--focus);
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
}

/* (e) a sideways drag on the spectrum zooms with a finger too; an up-and-down swipe still scrolls the page */

#ir-tool-wrapper #ir-spectrum-svg {
  touch-action: pan-y;
}

/* 30 Nov 2026 (round 4): the round 2 picker widths are gone; the pickers have a row of their own (rs-spec-viewer.css) */

/* ---- 30 Nov 2026 (round 5) ---- */

/* full screen: the hidden-structure box is one short block (its Full screen button and the line about full
   screen are not needed there), so the spectrum and the steps keep the room */

#ir-tool-wrapper:fullscreen .ir-hidden-structure-note {
  gap: 2px;
  padding: 8px 12px;
}

#ir-tool-wrapper:fullscreen .ir-hidden-structure-note :is(span:nth-of-type(2), button) {
  display: none;
}

/* full screen Explore (and Deduce once solved): the note box under the structure keeps its room, so a note
   appearing on hover never makes the card scroll or anything move (control standard: reserve the tallest state) */

#ir-tool-wrapper:fullscreen:not(.ir-deduce-unsolved) :is(.ir-absorption-note-slot, .sv-note-slot) {
  display: block;
  min-height: var(--sv-fs-note, 120px);
}

/* full screen Step 1: the absorption choices in two columns beside the spectrum */

#ir-tool-wrapper:fullscreen .ir-absorption-option-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  margin-bottom: 0;
}

#ir-tool-wrapper:fullscreen .ir-absorption-option {
  min-height: 40px;
  padding: 4px 10px;
  font-size: 0.88rem;
  line-height: 1.2;
}

/* full screen Deduce: the instructions line says what Step 1 and Step 2 say beside the spectrum, so it is left out there */

#ir-tool-wrapper:fullscreen:is(.ir-deduce-unsolved, .ir-deduce-solved) #ir-instructions {
  display: none;
}

#ir-tool-wrapper:fullscreen .ir-deduce-analysis-section {
  margin-bottom: 8px;
  padding: 10px 14px;
}

#ir-tool-wrapper:fullscreen .ir-deduce-analysis-section p {
  margin-bottom: 8px;
}

#ir-tool-wrapper:fullscreen .ir-absorption-check-feedback:is(.error, .success) {
  margin-top: 8px;
  padding: 8px 12px;
}

/* ---- 3 Dec 2026 (round 5): full screen on a screen 1100 px wide or less (for example 1024 x 768): the
   spectrum column takes half the width, not 58%, so the Step 1 choices wrap less and Step 1 with its
   feedback fits the screen (it was 17 px too tall at 1024 x 768); the spectrum stays at least 380 px wide ---- */

@media (max-width: 1100px) {
  #ir-tool-wrapper:fullscreen:is(.ir-deduce-unsolved, .ir-deduce-solved) .ir-container {
    width: 50%;
  }
}

@media (max-width: 1100px) {
  #ir-tool-wrapper:fullscreen .ir-deduce-choice-section {
    margin-left: calc(50% + 20px);
  }
}

/* 5 Dec 2026 (particle standard): displayed formula letters stay ink; the data colours some atoms (Cl, O, N) */

#ir-molecule-zoom-group text[fill="#2ecc71"], #ir-molecule-zoom-group text[fill="#e74c3c"], #ir-molecule-zoom-group text[fill="#2980b9"], #ir-molecule-zoom-group text[fill="#8e44ad"] {
  fill: #25242f;
}

