:root {
  --bg-default: #bbb;
  --op-color: blue;
  --font-family: sans-serif;
}

html {
  overscroll-behavior-y: none;
   /* see https://www.bram.us/2016/05/02/prevent-overscroll-bounce-in-ios-mobilesafari-pure-css/ */
}

body {
  font-family: var(--font-family);
  font-size: 100%;
}

.katex-preview.hybrid-preview {
  margin-top: 0;
  margin-bottom: 0;
  margin-left: 10px;
  padding: 4px 6px;
  background-color: #f5f5f5;
  border-radius: 3px;
  display: none;
}

#operand-editor a.hybrid-guide-link:link,
#operand-editor a.hybrid-guide-link:active,
#operand-editor a.katex-guide-link:link,
#operand-editor a.katex-guide-link:active {
  color: #0000EE;
}

#operand-editor a.hybrid-guide-link:visited,
#operand-editor a.katex-guide-link:visited {
  color: #551A8B;
}

#fixed-header {
  position: fixed;
  top: 0px;
  left: 0px;
  background-color: white;
  min-height: 32px;
  z-index: 1;
  width: 100%;
  padding: 4px;
  border-bottom: 1px solid var(--bg-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  box-sizing: border-box;
}

#fixed-header-left, #fixed-header-right {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}

#fixed-header-left {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  margin-right: 8px;
}

#fixed-header-right {
  flex: 0 0 auto;
  flex-shrink: 0;
  overflow: visible;
}

button {
  font-family: inherit;
}

button.header-button, button.hint-button {
  font-size: 80%;
  margin-left: 1em;
  margin-right: 1em;
}

.undo-redo-container button {
  font-size: 80%;
}

.undo-redo-container {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  margin-left: 1em;
  margin-right: 1em;
}

#page-container > div {
  padding: .2em .2em;
}

#problem-wrapper {
  grid-area: problem-wrapper;
}

#problem-statement img {
  max-width: 100%;
}
#data-wrapper {
  background: rgba(255, 255, 255, 0.75);
  grid-area: data-wrapper;
  font-size: 90%;
}
#data-wrapper .data-tab {
  font-size: inherit;
  padding: 0.1em;
  margin: 0;
}
#data-wrapper .data-tab-container {
  padding: 0;
  border: 0;
}

#ops {
  grid-area: ops;
  background: rgba(255, 255, 255, 0.75);
  padding: 0.2em;
}
#solution {
  grid-area: solution;
  background: rgba(255, 255, 255, 0.75);
  padding: 0.2em;
}

#solution .solution-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0.75em 0;
}

#footer {
  grid-area: footer;
}
#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #eee; /* Add background so content doesn't show through */
  border-top: 1px solid var(--bg-default);
  padding: 4px;
  z-index: 100; /* Lower z-index to allow dialogs to appear above footer */
}


#showSolution {
  font-weight: bold;
  background: lime;
}

#problem {
  background-color: rgba(255, 255, 255, 1);
  padding: .1em;
}

#problem .op,
#ops .op,
#data .op,
.op {
  color: var(--op-color);
  font-weight: bold;
  cursor: pointer;
}

#page-container {
  display: flex;
  background-color: var(--bg-default);
  padding: 1px;
}

#problem-wrapper {
  flex: 1 1 20%;
  min-width: 25em;
  box-sizing: border-box;
}

#solution-wrapper {
  flex: 1000 1000 0%;
  box-sizing: border-box;
}

#problem-grid {
  display: grid;
  grid:
    "data-wrapper"
    "problem";
  grid-gap: 1px;
}

#solution-grid {
  display: grid;
  grid:
    "ops solution";
  grid-template-rows: auto;
  grid-template-columns: minmax(max-content, max-content) 1fr;
  grid-gap: 1px
}

.rounded {
  font-weight: bold;
}

.rounded-post {
  padding-left: 0.5ch;
}

#default-kbd, #extended-kbd {
  display: grid;
  grid-template-columns: repeat(2, min-content);
  margin-bottom: 0.25em;
}

#ext-kbd {  /* This is for the deprecated ext-kbd data tab */
  display: grid;
  grid-template-columns: repeat(6, min-content);
}

#ext-kbd {
  background: rgba(255, 255, 255, 0.8);
}

#ops-container .op {
  display: -moz-inline-grid;
  display: inline-grid;
  cursor: pointer;
  font-size: 120%;
  padding: .1em;
}

span.calc-key {
  background: white;
  margin: 0.2em;
  border-radius: 20%;
  box-shadow: 2px 2px gray;
  height: 1.7em;
  width: 1.7em;
}

span.calc-key:active {
  box-shadow: 1px 1px gray;
}

span.calc-key .op {
  justify-content: center;
}

span.calc-key img {
  align-self: center;
  width: 1.25em;
}

.op-highlight {
  background-color: rgba(255, 255, 0);
  border-radius: 4px;
  /* border: 1px solid rgb(255, 236, 152); */
  border-width: 2px;
}

.step-container,
.answer-container {
  display: flex;
  vertical-align: middle;
  /* flex-wrap: wrap; */
  align-items: center;
  margin-top: 0.5em;
}

#answers {
  margin-bottom: 0.5em;
}

.step-container.show-active .formula-box,
.answer-container.show-active .answer-box {
  border-width: 3px;
  position: relative;
}

.step-container.show-active .step-num {
  font-weight: bold;
}

.step-num {
  white-space: nowrap;
  margin-left: 0.5em;
  margin-right: 0.5em;
}

.answer-info > div {
  display: inline-block;
  vertical-align: middle;
}

.answer-label,
.answer-post {
  margin: 0.3em;
}

.answer-box {
  padding-top: 5px;
  padding-bottom: 5px;
  padding-left: 10px;
  padding-right: 10px;
  border: 2px solid green;
  background-color: white;
  width: -moz-fit-content;
  width: fit-content;
  min-width: 4em;
  text-align: center;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2em;
}

.answer-box::before {
  content: "\00a0";
  font-weight: bold;
  color: transparent;
}

.answer-box.ui-droppable-hover {
  background-color: #f0fff0;
}

.answer-box.not-calculated {
  color: darkred;
  background-color: #ffe0e0;
}

#submit-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  column-gap: 2rem;
  row-gap: 0.75rem;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.85rem;
}

.submit-actions-left {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.attempt-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  margin-left: auto;
  padding: 0.42rem 0.65rem;
  border-radius: 0.45rem;
  background: #f7f8fa;
  color: #20253d;
  font-size: 0.9rem;
  line-height: 1.25;
  white-space: nowrap;
}

.attempt-counter__primary {
  font-weight: 600;
}

#attempt-current {
  color: #2563eb;
  font-weight: 700;
}

.attempt-counter__divider {
  width: 1px;
  height: 1.2em;
  flex: 0 0 1px;
  background: #c5cad4;
}

.attempt-counter__secondary {
  color: #667085;
  font-size: 0.86rem;
}

@media (max-width: 560px) {
  .attempt-counter {
    flex-basis: 100%;
    justify-content: flex-end;
    margin-top: 0.15rem;
    white-space: normal;
  }
}

@media (max-width: 390px) {
  .attempt-counter {
    flex-wrap: wrap;
  }

  .attempt-counter__divider {
    display: none;
  }

  .attempt-counter__secondary {
    flex-basis: 100%;
    text-align: right;
  }
}

#submit-error-msg {
  color: red;
  display: none;
  font-size: 80%;
  font-style: italic;
  padding-left: 0.5em;
}

.tooltip {
  max-width: 200ch;
  white-space: nowrap;
  word-wrap: normal;
}
.tooltip .tooltip-inner {
  padding: 0.25em;
  white-space: nowrap;
  max-width: none;
}

.formula-box {
  padding-top: .15em;
  padding-bottom: .15em;
  padding-left: .25em;
  padding-right: .25em;
  background-color: white;
  border-width: 1px;
  border-style: solid;
  border-color: gray;
  width: 10em;
  min-width: -webkit-fit-content;
  min-width: fit-content;
  min-height: 1.2em;
  line-height: normal;
  text-align: left;
  white-space: nowrap;
  /* Remove focus styling - formula boxes show active state, not focus state */
  outline: none !important;
}

.formula-box::before {
  content: "\200b";
  font-weight: bold;
  visibility: hidden;
}

/* Remove focus-within styling that might be triggered by cursor focus */
.formula-box:focus-within {
  outline: none !important;
  box-shadow: none !important;
  border-color: gray !important; /* Keep normal border */
}

.formula-placeholder {
  background-color: red;
  margin-left: 8px;
  margin-right: 8px;
  width: 2px;
  height: 1.2em;
  vertical-align: middle;
  display: inline-block;
}

.sortable-ghost {
  display: none !important;
}

.args {
  padding-top: 5px;
  padding-bottom: 5px;
  padding-left: 8px;
  padding-right: 8px;
  width: fit-content;
  min-width: 20px;
  min-height: 20px;
  text-align: left;
}

.formula-box span {
  cursor: pointer;
}

.formula-box span.operator,
.formula-box span.fn {
  margin-left: 1px;
  margin-right: 1px;
}

.formula-box span.operand {
  margin-left: 2px;
  margin-right: 2px;
}

span.units {
  font-size: 80%;
  margin-left: 0.2em;
  color: purple;
}

.result {
  margin-left: .5em;
  margin-right: .5em;
  display: none;
  white-space: nowrap;
}

.result > span:first-child {
  cursor: pointer;
  font-weight: bold;
  color: var(--op-color);
}

.sigfigs {
  font-size: 80%;
}

#page-container button.hint-button {
  font-size: 80%;
}

/* fix summernote tables */
table.table.table-bordered {
  border-collapse: collapse;
  margin-left: 0.5em;
}
table.table.table-bordered td {
  border: 1px solid;
  padding: 0.5ch;
}
table.table.table-bordered td>p {
  margin: 0;
}

#periodic_table {
  padding: 0.2em;
}

div.periodic {
  display: flex;
  gap: 0.2em;
  flex-wrap: wrap;
}

div.element{
  border: 2px solid black;
  width: fit-content;
  padding: 0.2em;
  background: white;
}

.atomicNumber,
.atomicWeight {
  font-size: 60%;
}

.elemAbbrev {
  font-size: 100%;
  font-weight: bold;
}

.elemName {
  font-size: 60%;
}

.trig-functions span {
  padding: 5px;
}

.correct {
  color: green;
  font-style: oblique;
}

.incorrect {
  color: red;
  font-style: oblique;
}

.courtesy {
  color: black;
  background-color: gold;
  font-style: oblique;
}

button {
  font-size: 75%;
}

button.showStrategy {
  float: right;
  margin-right: 4px;
  margin-top: 4px;
  padding-top: 2px;
  padding-bottom: 2px;
}

#font-control {
  letter-spacing: -0.3ch;
}

#font-control-sizer {
  position: absolute;
  font-size: 1cm;
  right: 10px;
  padding: 0px 10px;
  z-index: 1;
  background-color: white;
  display: none;
}

.font-control-button {
  padding: 10px;
  cursor: pointer;
}

p.summernoteP {
  margin: 0.5em;
}

.katex {
  font-size: 1.0em !important;
  font-style: italic !important;
}

.rounding fieldset {
  border: 1px solid gray;
  padding: 2px;
  display: inline-grid;
  vertical-align: middle;
}

.rounding legend {
  font-size:60%;
  margin-bottom: 0;
  margin-top: 0;
}

button.precision {
  background: white;
  border: 1px solid gray;
  border-radius: 15%;
  box-shadow: 2px 2px gray;
  margin: 3px;
}

button.precision:hover {
  cursor: pointer;
}

button.precision:active {
  box-shadow: 1px 1px gray;
}

span.step-info-container {
  font-size: 70%;
  color: darkred;
  background: white;
  border-radius: 2ch;
  padding-top: 0.25em;
  padding-bottom: 0.25em;
  padding-left: 0.5em;
  padding-right: 0.5em;
  box-shadow: .2em .2em .4em grey;
  cursor: pointer;
}

span.step-info-container:hover {
  box-shadow: .2em .2em .4em darkgrey;
  background: #f5f5f5;
}

span.step-info-wrapper {
  display: flex;
  align-items: center;
}

label, input.text, input.number {
  display: block;
}

input.text, input.number, textarea, select {
  margin-bottom: 12px;
  width: 95%;
  padding: 0.4em;
}

#symbol_display,
#units,
#description,
#rubric-step-description,
#answer-label,
#answer-post,
#data-step-description,
#data-step-units {
  margin-bottom: 0;
}

#pte-version-select {
  width: fit-content;
  padding: 1px 2px;
}

textarea {
  resize: vertical;
}

.note-editable {
  font-family: var(--font-family);
}

span.operand {
  color: var(--op-color);
  font-weight: bold;
}

.note-editable span.operand.op-err {
  color: red;
}

fieldset {
  border: 0;
  margin-top: 0.5rem;
}

fieldset legend {
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-size: 1.25rem;
}

fieldset legend ~ * {
  margin-left: 1rem;
}

fieldset.dialog {
  padding: 0;
  border-width: 0;
  margin-top: 10px;
}

fieldset.fieldset-group {
  border-width: 1px;
}

fieldset.fieldset-group label {
  display: inline;
}

h1 {
  font-size: 1.2em;
  margin: 0.6em 0;
}

.modal .is-invalid {
  padding: 0.3em;
}

.validateTips {
  border: 1px solid transparent;
  padding: 0.1em;
  font-style: italic;
}

.hint {
  display: none;
  font-style: italic;
}

.insertion-cursor {
    position: absolute;
    width: 1px;
    height: 1em;
    background: black;
    animation: blink 1s step-end infinite;
    pointer-events: none;
    /* Remove focus styling - cursor should be a visual indicator only */
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}
@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
}

/* Keyboard focus styles for operators and operands */
span.op:focus, 
span.operand:focus,
span.op.keyboard-focused,
span.operand.keyboard-focused {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    background-color: rgba(0, 95, 204, 0.1);
    border-radius: 2px;
    position: relative;
    z-index: 10;
}

/* Selected state styling for answer containers (not focus - selected as target via navigation) */
.answer-container.active .answer-box {
    border: 3px solid #28a745;
    border-radius: 4px;
    position: relative;
    z-index: 10;
}

/* Skip link styling for keyboard users (also defined in site.css, which loads on every page; kept here for pages that load this file but not site.css) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 4px;
}

.skip-link:focus {
    top: 6px;
}

/* Active state styling for step containers - keep only the thick border, no focus-style outline */
/* The thick border from .show-active is sufficient visual indicator for active receiver */

/* Explicitly remove any focus styling from step containers and formula boxes - they should not appear focusable */
.step-container:focus,
.step-container.active:focus,
.step-container .formula-box:focus,
.formula-box:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Enhanced focus for high contrast and accessibility */
@media (prefers-contrast: high) {
    span.op:focus, 
    span.operand:focus,
    span.op.keyboard-focused,
    span.operand.keyboard-focused {
        outline: 3px solid #000;
        background-color: yellow;
        color: black;
    }
    
    /* High contrast active state styling */
    .answer-container.active .answer-box,
    .step-container.active .formula-box {
        outline: 3px solid #000;
        background-color: #ffffcc;
    }
}

/* Motion preferences - reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .insertion-cursor {
        animation: none;
        opacity: 1;
    }
}

/* Enhance focus indication for better visibility in all contexts */
span.op:focus-visible, 
span.operand:focus-visible,
span.op.keyboard-focused,
span.operand.keyboard-focused {
    /* Ensure minimum 3:1 contrast ratio as per WCAG 2.1 AA */
    outline: 2px solid #003d82; /* Darker blue for better contrast */
    outline-offset: 2px;
    background-color: rgba(0, 61, 130, 0.15); /* Slightly more opaque for visibility */
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8); /* White inner border for edge cases */
}

/* Focus visible only for keyboard navigation, not mouse clicks */
span.op:focus:not(:focus-visible),
span.operand:focus:not(:focus-visible) {
    outline: none;
    background-color: transparent;
}

/* Grade report accordion card headers give no visual cue when tab-focused
   (Bootstrap's default focus box-shadow is stripped by the shadow-none utility) */
.strategyAnalysis .card-header button:focus-visible {
    outline: 2px solid #003d82;
    outline-offset: -2px;
}

/* Ensure sufficient color contrast for all text elements */
.step-container, .answer-container {
    color: #000; /* Ensure black text for maximum contrast */
}

/* Improve visibility of cursor positioning in light/dark themes */
.insertion-cursor {
    background: currentColor; /* Uses the text color for better theme adaptation */
}

/* Active step containers have interactive styling */
.step-container.active, .answer-container.active {
    background-color: rgba(0, 95, 204, 0.05); /* Slightly more visible blue for interactive containers */
    border-radius: 6px;
}

/* ============================
   Operand Search Dropdown Styles
   ============================*/

/* Operand search wrapper positioning */
#operand-search-wrapper {
    position: fixed !important;
    z-index: 10000 !important;
    width: 200px;
}

#operand-search-wrapper .ts-wrapper {
    position: relative !important;
}

#operand-search-wrapper .ts-control {
    border: 2px solid #007bff;
    border-radius: 4px;
    min-height: 32px;
    font-size: 14px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#operand-search-wrapper .ts-control.focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#operand-search-wrapper .ts-control input {
    font-size: 14px;
}

/* TomSelect dropdown customization for operand search */
#operand-search-wrapper .operand-search-dropdown.ts-dropdown,
div.operand-search-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
    border: 2px solid #007bff;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: white !important;
    background-color: white !important;
    opacity: 1 !important;
    max-height: 200px;
    z-index: 10001 !important;
}

#operand-search-wrapper .operand-search-dropdown .ts-dropdown-content {
    max-height: 180px;
    overflow-y: auto;
}

#operand-search-wrapper .operand-search-dropdown .option {
    padding: 8px 12px !important;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer !important;
    transition: background-color 0.2s ease;
}

#operand-search-wrapper .operand-search-dropdown .option:hover,
#operand-search-wrapper .operand-search-dropdown .option.active {
    background-color: #f8f9fa !important;
}

#operand-search-wrapper .operand-search-dropdown .option.selected {
    background-color: #007bff !important;
    color: white !important;
}

#operand-search-wrapper .operand-search-dropdown .option:last-child {
    border-bottom: none;
}

/* Ensure div dropdown has white background */
div.operand-search-dropdown {
    background: white !important;
    background-color: white !important;
}

/* Style for operand values in the dropdown */
.operand-search-option {
    padding: 5px 0;
}

.operand-search-value {
    font-weight: bold;
    color: #0062cc; /* darkened from #007bff to clear 4.5:1 AA contrast on white */
    font-size: 1.1em;
}

.operand-search-description {
    color: #666;
    font-size: 0.9em;
    margin-top: 2px;
}

.operand-search-item {
    font-weight: bold;
    color: #0062cc; /* darkened from #007bff to clear 4.5:1 AA contrast on white */
}

/* Force TomSelect dropdown positioning */
body > .operand-search-dropdown.ts-dropdown {
    position: fixed !important;
    z-index: 10001 !important;
}

/* Ensure clicks work on dropdown options */
.operand-search-dropdown .option {
    pointer-events: auto !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.operand-search-dropdown .option * {
    pointer-events: none !important;
}
