/* Basic.css  */
/*
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  font-display: swap;
  src: url("./fonts/opensans.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF,
    U+FFFD;
}

@font-face {
  font-family: "SF Mono Regular";
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  font-display: swap;
  src: url("./fonts/SFMono-Regular.otf") format("otf");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF,
    U+FFFD;
}
*/

* {
  box-sizing: border-box;
}

:root {
  --sans: 400 16px/1.5 "Open Sans", sans-serif;
  --mono: "OCR A Std", monospace;
  --c1: #76f; /*button, link*/
  --c2: #333;
  --c3: #10002e;
  --c4: #fff;
  --c5: #fff;
  --m1: 8px;
  --rc: 8px;
}

/* fix table */

table {
  table-layout: fixed;
  /*  white-space: pre;*/
}

.hscroll {
  overflow-x: auto;
}

.example {
  white-space: nowrap;
}

html {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

/* General settings */

body {
  margin: 0;
  padding: 0;
  padding-top: 16px;
  padding-bottom: 32px;
  font-family: var(--sans);
  font-weight: 400;
  font-style: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  background-color: #000;
  color: var(--c4);
}

.normal {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

pre[class*="language-"] {
  position: relative;
  overflow: auto;
  background-color: #2f005e;
  color: chartreuse;
  font-family: var(--sans);
  font-size: 14px;

  /* make space  */
  margin: 5px 0;
  padding: 1.75rem 0 1.75rem 1rem;
  border-radius: 10px;
}

pre[class*="language-"] button {
  position: absolute;
  top: 5px;
  right: 5px;

  font-size: 0.9rem;
  padding: 0.15rem;
  background-color: #828282;

  border: ridge 1px #7b7b7c;
  border-radius: 5px;
  text-shadow: #c4c4c4 0 0 2px;
}

pre[class*="language-"] button:hover {
  cursor: pointer;
  background-color: #bcbabb;
}

.katex {
  font-size: 1.1em;
  line-height: 0.1;
  text-indent: 0;
  text-rendering: auto;
  border-color: currentColor;
  color: var(--c4);
}

.katex-display {
  font-size: 1.1em;
  line-height: 1.1;
  display: block;
  margin: 1em 0;
  text-align: center;
}

img,
iframe {
  border: none;
  max-width: 100%;
}

a {
  color: var(--c1);
  text-decoration: none;
}

a:hover {
  color: var(--c1);
  text-decoration: underline;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 0;
  margin: 20px 0 0 0;
  border-bottom: 2px solid var(--c1);
}

.tab-btn {
  padding: 12px 24px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #888;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: #aaa;
  background: rgba(119, 102, 255, 0.1);
}

.tab-btn.active {
  color: var(--c1);
  border-bottom-color: var(--c1);
  background: rgba(119, 102, 255, 0.1);
}

/* Tab Content */
.tab-content {
  margin-top: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/*pre {font: 1em/1.6 var(--mono); background: var(--c2); padding: 1em; overflow: auto}*/
/*pre {font: 1em/1.6 var(--mono); overflow: auto} */
*,
*:before,
*:after {
  box-sizing: border-box;
}

pre[class*="language-"] {
  position: relative;
  overflow: auto;

  /* make space  */
  margin: 5px 0;
  padding: 1.75rem 0 1.75rem 1rem;
  border-radius: 10px;
}

pre[class*="language-"] button {
  position: absolute;
  top: 5px;
  right: 5px;

  font-size: 0.9rem;
  padding: 0.15rem;
  background-color: #828282;

  border: ridge 1px #7b7b7c;
  border-radius: 5px;
  text-shadow: #c4c4c4 0 0 2px;
}

pre[class*="language-"] button:hover {
  cursor: pointer;
  background-color: #bcbabb;
}

main {
  display: grid;
  max-width: 600px;
  margin: 20px auto;
}

blockquote {
  border-left: 5px solid var(--c2);
  padding: 1em 1.5em;
  margin: 0;
}

hr {
  border: 0;
  border-bottom: 1px solid var(--c4);
}

/* Headlines */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0.6em 0;
  font-weight: normal;
}

h1 {
  font-size: 2.625em;
  line-height: 1.2;
  color: #76f;
}

h2 {
  font-size: 1.625em;
  line-height: 1.2;
}

h3 {
  font-size: 1.3125em;
  line-height: 1.24;
}

h4 {
  font-size: 1.1875em;
  line-height: 1.23;
}

h5,
h6 {
  font-size: 1em;
  font-weight: bold;
}

/* Table */

table {
  border-collapse: collapse;
  border-spacing: 0;
  border: none;
}

th,
td {
  text-align: left;
  vertical-align: top;
  border: none;
  padding: 0.4em;
}

thead,
tfoot {
  background: var(--c2);
}

thead th {
  position: sticky;
  top: 0;
  background: var(--c2);
}

#table-scales td {
  cursor: pointer;
}

#table-ji-tunings td {
  cursor: pointer;
}

#table-ed-tunings td {
  cursor: pointer;
}

.data tr:nth-child(even) {
  background-color: rgb(20%, 10%, 30%);
}

table.clickable tr.selected {
  background-color: #76f;
}

/* Rounded Corners*/

/*pre,code,input,select,textarea,button,img {border-radius: none}*/

/* Forms */

input,
select,
textarea {
  font-size: 1em;
  color: var(--c4);
  background: var(--c2);
  border: 1;
  padding: 0.2em;
}

button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
  -webkit-appearance: none;
  appearance: none;
  font-size: 1em;
  display: inline-block;
  color: var(--c5);
  background: var(--c1);
  border: 0;
  margin: 4px;
  padding: 0.6em;
  cursor: pointer;
  text-align: center;
  font: 1em var(--sans);
}

button:hover,
button:focus,
input:hover,
textarea:hover,
select:hover {
  opacity: 0.8;
}

/* Infinite Grid */

section {
  display: flex;
  flex-flow: row wrap;
}

[style*="--c:"],
section > section,
aside,
article {
  flex: var(--c, 1);
  margin: var(--m1);
}

/* Cards */

article {
  background: var(--c2);
  border-radius: var(--rc);
  padding: 1em;
  box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.3);
}

[style*="--c:"]:first-child,
section > section:first-child,
article:first-child {
  margin-left: 0;
}
[style*="--c:"]:last-child,
section > section:last-child,
article:last-child {
  margin-right: 0;
}

audio {
  width: 300px;
  height: 40px;
}

audio::-webkit-media-controls-play-button,
audio::-webkit-media-controls-panel {
  background-color: #ddd;
  color: #ddd;
}

/* Tooltip container */
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
}

/* Tooltip text */
.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: #555;
  color: #fff;
  text-align: center;
  padding: 5px 0;
  border-radius: 6px;

  /* Position the tooltip text */
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;

  /* Fade in tooltip */
  opacity: 0;
  transition: opacity 0.3s;
}

/* Tooltip arrow */
.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

* {
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c2: #333;
    --c3: #10002e;
    --c4: #fff;
  }
}

html {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

svg {
  min-width: 10px;
  max-width: 100%;
  /* touch-action: none; */
}


#lattice:active {
  cursor: grabbing;
}

.controls {
  margin-bottom: 10px;
  padding: 10px;
}

/* Mobile drag handle (hidden on desktop) */
.mobile-drag-handle {
  display: none;
}

/* Mobile responsive styles */
@media (max-width: 600px) {
  table {
    table-layout: auto;
    width: 100%;
  }

  input[type="text"],
  input[type="number"] {
    max-width: 100%;
    box-sizing: border-box;
  }

  .data {
    font-size: 14px;
  }

  pre[class*="language-"] {
    font-size: 12px;
    overflow-x: auto;
  }

  .tables-row {
    flex-direction: column;
  }

  .table-column {
    width: 100% !important;
    min-width: 0;
  }

  /* Mobile tab navigation - sticky at top */
  .tab-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #000;
    margin: 10px -20px 0 -20px;
    padding: 0 20px;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 10px 16px;
  }

  /* Convert main table to block layout on mobile for better sticky behavior */
  .tab-panel > table {
    display: block;
  }

  .tab-panel > table > tbody {
    display: block;
  }

  .tab-panel > table > tbody > tr {
    display: flex;
    flex-direction: column; /* Visualization at bottom on mobile */
  }

  .tab-panel > table > tbody > tr > td {
    display: block;
    width: 100%;
  }

  /* Make visualization column sticky at bottom on mobile */
  .visualization-column {
    position: sticky;
    bottom: 0;
    align-self: flex-end;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--c3);
    z-index: 10;
    padding: 0;
    border-top: 4px solid #76f;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
  }

  /* Mobile drag handle */
  .mobile-drag-handle {
    display: block;
    flex-shrink: 0;
    background-color: var(--c3);
    z-index: 11;
    padding: 8px 0;
    margin: 0;
    width: 100%;
    text-align: center;
    cursor: grab;
    touch-action: none;
  }

  .mobile-drag-handle:active {
    cursor: grabbing;
  }

  .drag-handle-bar {
    width: 60px;
    height: 4px;
    background-color: #76f;
    border-radius: 2px;
    margin: 0 auto;
    box-shadow: 0 0 8px rgba(119, 102, 255, 0.5);
  }

  /* Direct child hr (between drag handle and content) */
  .visualization-column > hr {
    flex-shrink: 0;
    margin: 0;
    border: none;
    border-top: 1px solid rgba(119, 102, 255, 0.3);
  }

  .visualization-column > div[id$="-visualization"] {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 0;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  /* Allow scrolling on visualization SVGs */
  .visualization-column svg {
    touch-action: auto;
  }

  /* Make internal hr separators (inside visualization) very subtle */
  div[id$="-visualization"] hr {
    border: none;
    border-top: 1px solid rgba(119, 102, 255, 0.15);
    margin: 15px 0;
  }

  /* Ensure error section stays in flow and doesn't float */
  .visualization-column #measure-error-result {
    position: relative;
    z-index: 1;
    background-color: var(--c3);
  }

  /* Ensure visualization content doesn't have positioning that causes floating */
  .visualization-column div[id$="-viz-container"],
  .visualization-column div[id$="-viz-controls"] {
    position: relative;
    z-index: 1;
    background-color: var(--c3);
  }
}

/* Responsive table columns */
.tables-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-column {
  flex: 1;
  min-width: 150px;
  max-width: 100%;
}

/* Audio Controls */

#audio-controls,
#build-audio-controls,
#measure-audio-controls,
#approximate-audio-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

#audio-controls strong,
#build-audio-controls strong,
#measure-audio-controls strong,
#approximate-audio-controls strong {
  margin-right: 4px;
}

/* Error Controls */
#measure-error-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#measure-error-controls > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

/* Button groups - responsive wrapping */
.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.waveform-btn {
  opacity: 0.6;
}

.waveform-btn.active {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--c4);
}

/* Intervals table alternating shading */
#intervals tr:nth-child(even) {
  background-color: rgb(20%, 10%, 30%);
}

#intervals tr:nth-child(odd) {
  background-color: rgb(10%, 5%, 20%);
}

/* Chord Visualization */
#visualization {
  margin: 10px 0;
}

#viz-controls {
  margin: 8px 0;
}

#viz-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.viz-panel {
  background-color: rgb(15%, 8%, 25%);
  border-radius: 8px;
  padding: 10px;
}

.viz-label {
  font-size: 0.9em;
  margin-bottom: 5px;
  color: #aaa;
}

.viz-panel svg {
  display: block;
  width: 100%;
  height: 60px;
}

.viz-line {
  stroke: #76f;
  stroke-width: 2;
}

.viz-point {
  fill: #76f;
}

.viz-root {
  fill: #fff;
}

.viz-axis {
  stroke: #444;
  stroke-width: 1;
}

.viz-tick {
  stroke: #666;
  stroke-width: 1;
}

.viz-label-text {
  fill: #888;
  font-size: 10px;
}

.viz-target {
  fill: none;
  stroke: #f76;
  stroke-width: 2;
}

.viz-target-root {
  fill: none;
  stroke: #faa;
  stroke-width: 2;
}

.viz-target-free {
  fill: none;
  stroke: #fb4;
  stroke-width: 2;
  stroke-dasharray: 3 2;
}

/* Delta input row (Approximate tab) */
.delta-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 6px 0;
}

.delta-input {
  width: 50px;
  text-align: center;
  font-size: 1em;
  padding: 0.2em;
}

.delta-separator {
  font-size: 1.2em;
  color: #aaa;
  user-select: none;
}

/* Approximate results table */
#approximate-results {
  margin-top: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

#approximate-results table {
  width: 100%;
  table-layout: auto;
  font-size: 0.9em;
}

#approximate-results th {
  position: sticky;
  top: 0;
  background: var(--c3);
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #666;
}

#approximate-results td {
  padding: 4px 8px;
  white-space: nowrap;
}

#approximate-results tr:nth-child(even) {
  background-color: rgb(20%, 10%, 30%);
}

#approximate-results tr:nth-child(odd) {
  background-color: rgb(10%, 5%, 20%);
}

#approximate-progress {
  margin-left: 8px;
  color: #aaa;
}

.approx-play-btn,
.approx-play-target-btn {
  padding: 0.2em 0.5em;
  font-size: 0.85em;
  margin: 1px;
}
