/*
 * This and the ::view-transition rule below make it so that the
 * page remains interactive during view transitions. Without this
 * you can't able to click anything while a view transition is
 * happening, which means you can't, for example, step through the
 * debugger at the pace you want.
 */
:root {
  view-transition-name: none;
}

::view-transition {
  pointer-events: none;
}

input {
  --c: var(--palette-orange);
  --l: 4px;
  --h: 30px;
  --w: 30px;

  width: 100%;
  height: var(--h);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: none;
  cursor: pointer;
  overflow: hidden;
}

input:focus-visible,
input:hover {
  --p: 25%;
}

input[type="range" i]::-webkit-slider-thumb {
  height: var(--h);
  width: var(--w);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c);
  border-image: linear-gradient(90deg, var(--c) 50%, #ababab 0) 0 1/calc(50% - var(--l)/2) 100vw/0 100vw;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  transition: .3s;
}

input[type="range"]::-moz-range-thumb {
  --h: 25px;
  --w: 25px;
  height: var(--h);
  width: var(--w);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c);
  border-image: linear-gradient(90deg, var(--c) 50%, #ababab 0) 0 1/calc(50% - var(--l)/2) 100vw/0 100vw;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  transition: .3s;
}

button {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  background-color: var(--button-color);
  color: var(--button-text-color);
  transition: background-color 0.2s ease;
  border: 0;
  border-radius: var(--button-border-radius);
  line-height: 1.5;
}

button:hover:not(:disabled) {
  background-color: var(--button-hover-color);
}

button:disabled {
  background-color: var(--button-disabled-color);
  cursor: not-allowed;
}

table code {
  font-weight: bold;
}

.inline-button-icon {
  color: var(--button-text-color);
  background-color: var(--button-color);
  padding: 0.1rem 0.4rem;
  border-radius: var(--button-border-radius);
  font-size: 0.85rem;
  min-width: 2.5rem;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  vertical-align: text-bottom;
}

.inline-button-icon svg:only-child {
  width: 1.2em;
  height: 1.2em;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
  font-family: var(--code-font);
  background-color: black;
  border-radius: 1rem;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls button {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  font-family: var(--code-font);
  background-color: var(--color-highlight);
  cursor: pointer;
}

.controls button:disabled {
  opacity: 0.5;
  background-color: var(--color-highlight);
  cursor: not-allowed;
}

.controls button:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--color-highlight), white 10%);
}

.controls select {
  padding: 0.5rem;
  width: fit-content;
  text-align: center;
  font-size: 1rem;
  font-family: var(--code-font);
  border: 1px solid var(--palette-grey);
  border-radius: var(--button-border-radius);
  background-color: var(--palette-grey);
  color: var(--background-color);
  cursor: pointer;
}

.controls .speed-select:focus {
  outline: 2px solid var(--palette-dark-blue);
  outline-offset: 2px;
}

/* -------------------- h- -------------------- */

h- {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  gap: 0.075rem;
  height: 1.5rem;
}

h- svg {
  align-self: center;
  width: 0.8em;
  height: 0.8em;
}

.debugger-container {
  --padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: var(--padding);
  background-color: black;
  padding: var(--padding);
  border-radius: calc(1rem + var(--padding));
  margin-top: 1rem;
  margin-bottom: 2rem;

  box-shadow: 0px 0px 5px 1px rgba(46, 52, 64, 0.5);
}

.debugger-container pre {
  border-top-left-radius: var(--button-border-radius);
  border-top-right-radius: var(--button-border-radius);
}

/* -------------------- s-debugger-controls -------------------- */

s-debugger-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--padding);
  width: 100%;
  font-family: var(--code-font);

  --padding: 0.5rem;
}

s-debugger-controls.controls {
  max-width: 100%;
}

s-debugger-controls .controls-left button:nth-of-type(1) {
  border-top-left-radius: 1rem;
}

s-debugger-controls .controls-right button:last-of-type {
  border-top-right-radius: 1rem;
}

/* -------------------- s-debugger -------------------- */

s-debugger {
  --padding: 1rem;
}

s-debugger pre {
  background-color: #272822;
  color: #f8f8f2;
  margin: 0;
  padding: 0;
}

s-debugger pre code .line.selected {
  background-color: color-mix(in srgb, var(--palette-grey), white 10%);
  animation: flash 0.2s ease-out;
}

@keyframes flash {
  0% {
    filter: brightness(1.8);
  }

  100% {
    filter: brightness(1);
  }
}

s-debugger pre code {
  display: block;
  width: 100%;
  line-height: 1;
  overflow-x: auto;
}

s-debugger pre code .line:first-of-type {
  margin-top: var(--padding);
}

s-debugger pre code .line:last-of-type {
  margin-bottom: var(--padding);
}

s-debugger pre code .line {
  display: inline-block;
  line-height: 1.5;
  padding-left: var(--padding);
  padding-right: var(--padding);
  width: 100%;
  min-width: 100%;
}

s-debugger .debugger-modal {
  position: absolute;
  top: 0;
  left: 0;
  background-color: color-mix(in srgb, var(--palette-grey), white 20%);
  color: white;
  font-family: var(--code-font);
  z-index: 1000;
  border-radius: 1rem;
  padding: 1rem;
}

/* -------------------- s-array -------------------- */

s-array {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

[data-name=j] {
  --color: var(--palette-orange);
  color: var(--palette-orange) !important;
}

[data-name=i] {
  --color: var(--palette-pink);
  color: var(--palette-pink) !important;
}

[data-name=n] {
  --color: var(--palette-red);
  color: var(--palette-red) !important;
}

[data-name=a] {
  --color: var(--palette-green);
  color: var(--palette-green) !important;
}

s-array .grid {
  --num-items: 5;
  --num-rows: 2;
  --item-row: 2;
  --top-row: 1;
  --bottom-row: 3;

  display: grid;
  justify-items: center;
  align-items: center;
  gap: clamp(0.15rem, 0.25vh, 0.5rem) clamp(0.1rem, 2vw, 0.5rem);
}

s-array .grid .label {
  grid-row: var(--item-row);
  grid-column: 1;
}

s-array .grid .equals {
  width: fit-content;
  grid-row: var(--item-row);
  grid-column: 2;
}

s-array .grid .item {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-row: var(--item-row);
  font-family: var(--code-font);
  font-size: clamp(1rem, 8vw, 3rem);
  width: clamp(1rem, 12vw, 4rem);
  height: clamp(1rem, 12vw, 4rem);
  border-radius: 0.5rem;
}

s-array .label {
  font-family: var(--code-font);
  text-align: right;
  font-size: 1.5rem;
}

s-array .annotation {
  view-transition-name: match-element;
  display: flex;
  visibility: hidden;
  justify-content: center;
  font-family: var(--code-font);
  font-size: 1.2rem;
  text-align: center;
  grid-column: 3;
}

s-array .annotation.top {
  align-items: flex-end;
  grid-row: var(--top-row);
}

s-array .annotation.bottom {
  align-items: flex-start;
  grid-row: var(--bottom-row);
}

/* -------------------- s-hero -------------------- */

s-hero {
  display: flex;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: var(--max-width);
  z-index: -1;
  line-height: 1;
  padding: 0;
}

s-hero svg {
  width: 100%;
  height: 100%;
  line-height: 1;
  padding: 0;
  margin: auto;
}

s-hero .growth-line {
  fill: none;
  stroke-linecap: round;
  opacity: 0;
}

s-hero .constant-line {
  stroke: var(--color-highlight);
}

s-hero .log-line {
  stroke: #3b82f6;
}

s-hero .linear-line {
  stroke: #10b981;
}

s-hero .n-log-n-line {
  stroke: #f59e0b;
}

s-hero .quadratic-line {
  stroke: #ef4444;
}

s-hero .cubic-line {
  stroke: #8b5cf6;
}

s-hero .factorial-line {
  stroke: #ec4899;
}

s-hero .big-text {
  font-family: var(--heading-font);
  font-weight: bold;
  fill: var(--color);
  font-size: 0px;
}

s-hero .big-text tspan {
  font-size: var(--font-size);
}

s-hero .o-text {
  opacity: 0;
  font-family: var(--heading-font);
  fill: var(--color);
  font-weight: bold;
  clip-path: url(#o-clip);
}

/* -------------------- s-code-timer -------------------- */

s-code-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  margin: 1rem auto;
  font-family: var(--code-font);

  --border-radius: 1rem;
  --text-color: var(--background-color);
  --hover-color: color-mix(in srgb, var(--palette-grey), white 10%);
  --disabled-color: color-mix(in srgb, var(--palette-grey), white 30%);
}

s-code-timer .timer-title {
  font-family: var(--code-font);
  font-size: 1.5rem;
  color: var(--palette-grey);
  margin-bottom: 0.5rem;
  text-align: center;
}

s-code-timer .timer-controls {
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

s-code-timer .run-button {
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: bold;
  transition: background-color 0.2s ease;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  flex-shrink: 0;
}

s-code-timer .timer-display {
  font-size: 1.2rem;
  padding: 0.75rem 1.5rem;
  text-align: center;
  border: 2px solid var(--palette-grey);
  border-left: none;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  background-color: white;
  color: var(--palette-grey);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

s-code-timer .timer-display.running {
  color: var(--palette-orange);
  border-color: var(--palette-orange);
  background-color: color-mix(in srgb, var(--palette-orange), white 95%);
}

s-code-timer .timer-display.completed {
  color: var(--palette-green);
  border-color: var(--palette-green);
  background-color: color-mix(in srgb, var(--palette-green), white 95%);
}

/* -------------------- s-code-timer-bar-graph -------------------- */

s-code-timer-bar-graph {
  display: block;
  width: 100%;
  margin: 1rem auto;

  --border-radius: 8px;
  --gap: 0.3rem;
  --bar-color: var(--palette-dark-blue);
}

s-code-timer-bar-graph .chart-container {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 200px;
  padding-top: 1rem;
  padding-bottom: 1rem;
  gap: var(--gap);
}

s-code-timer-bar-graph .bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  flex: 1;
  width: 100%;
  max-width: 8ch;
  gap: var(--gap);
}

s-code-timer-bar-graph .bar-value-container {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-grow: 1;
}

s-code-timer-bar-graph .bar-value {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.1rem;
  background-color: var(--bar-color);
  color: white;
  font-family: var(--code-font);
  font-size: 1rem;
  font-weight: bold;
  width: 100%;
  min-height: 0.5rem;
  border-radius: var(--button-border-radius);
  transition: background-color 0.2s ease;
}

s-code-timer-bar-graph .bar-container.active .bar-value {
  background-color: var(--palette-green);
}

s-code-timer-bar-graph .bar-value:empty {
  padding: 0;
}

s-code-timer-bar-graph button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  font-size: 0.9rem;
  font-family: var(--code-font);
  width: 100%;
  min-height: 2.25rem;
  gap: 0.1rem;
}

s-code-timer-bar-graph button svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* -------------------- s-sort-grid -------------------- */


s-sort-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

s-sort-grid .controls {
  padding: 0.5rem;
}

s-sort-grid svg {
  width: 100%;
}

s-sort-grid>svg text {
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: var(--code-font);
  font-weight: bold;
  fill: white;
}

s-sort-grid>svg path {
  stroke-width: 8;
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* -------------------- s-higher-or-lower -------------------- */

s-higher-or-lower {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

s-higher-or-lower .title {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
}

s-higher-or-lower .guess-counter {
  font-size: 1;
  text-align: center;
}

s-higher-or-lower .guess-number {
  font-size: 8rem;
  font-weight: bold;
  text-align: center;
  font-family: var(--code-font);
}

s-higher-or-lower .buttons {
  --padding: 0.5rem;

  display: flex;
  justify-content: center;
  gap: var(--padding);
}

s-higher-or-lower button {
  color: white;
  border: none;
  padding: var(--padding) calc(var(--padding) * 2);
  font-weight: bold;
}

s-higher-or-lower button:disabled {
  opacity: 0.5;
}

s-higher-or-lower .lower-button {
  background-color: var(--palette-red);
}

s-higher-or-lower .correct-button {
  background-color: var(--palette-green);
}

s-higher-or-lower .higher-button {
  background-color: var(--palette-pink);
}

s-higher-or-lower .play-again-button {
  background-color: var(--palette-dark-blue);
}

/* Confetti styles */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  pointer-events: none;
  z-index: 1000;
}

.confetti.square {
  border-radius: 2px;
}

.confetti.circle {
  border-radius: 50%;
}

/* -------------------- s-higher-or-lower-table -------------------- */

s-higher-or-lower-table {
  display: block;
  margin: 2rem 0;
}

s-higher-or-lower-table .slider-container {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  padding: 0.5rem;
}

s-higher-or-lower-table .slider-container label {
  flex-shrink: 0;
  font-weight: bold;
  font-family: var(--code-font);
}

s-higher-or-lower-table .slider-container input {
  flex-grow: 1;
}

s-higher-or-lower-table .target-display {
  font-family: var(--code-font);
  font-size: 1.2em;
  color: var(--palette-orange);
  min-width: 3ch;
  text-align: center;
}

s-higher-or-lower-table .target-slider {
  width: 100%;
}

s-higher-or-lower-table .guess-table {
  width: 100%;
}

s-higher-or-lower-table .guess-table th,
s-higher-or-lower-table .guess-table td {
  padding: 0.75rem 1rem;
  text-align: center;
  border: 1px solid var(--border-color);
}

s-higher-or-lower-table .guess-table th {
  background-color: var(--code-background-color);
  font-weight: bold;
}

s-higher-or-lower-table .guess-table tbody tr:hover:not(.empty-row) {
  background-color: var(--code-background-color);
}

s-higher-or-lower-table .empty-row {
  opacity: 0.3;
}

s-higher-or-lower-table .response.lower {
  color: var(--palette-red);
  font-weight: bold;
}

s-higher-or-lower-table .response.higher {
  color: var(--palette-pink);
  font-weight: bold;
}

s-higher-or-lower-table .response.correct {
  color: var(--palette-green);
  font-weight: bold;
}

/* -------------------- s-bubble-sort-viewer -------------------- */

s-bubble-sort-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
  width: 100%;
}

s-bubble-sort-viewer .controls {
  padding: 0.5rem;
}

s-bubble-sort-viewer .status {
  font-family: var(--code-font);
  font-size: 1.2rem;
  text-align: center;
  min-height: 1.5rem;
  font-weight: bold;
  color: var(--text-color);
}

s-bubble-sort-viewer .bubble-sort-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(0.1rem, 2vw, 0.5rem);
  padding: 1rem;
  min-height: 5rem;
}

s-bubble-sort-viewer .bubble-sort-grid .item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--code-font);
  font-size: clamp(1rem, 8vw, 3rem);
  width: clamp(1rem, 12vw, 4rem);
  height: clamp(1rem, 12vw, 4rem);
  border-radius: 0.5rem;
  background-color: var(--palette-grey);
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

s-bubble-sort-viewer .bubble-sort-grid .item.comparing {
  outline: 2px dashed var(--palette-grey);
  outline-offset: 1px;
}

s-bubble-sort-viewer .bubble-sort-grid .item.swapping {
  outline: 2px dashed var(--palette-grey);
  outline-offset: 1px;
}

s-graph {
  display: block;
  line-height: 0;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}
