/* Base Reset & Typography */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font: 400 0.85rem/1.4 "Inter", "SF Pro Display", -apple-system,
    BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  color: #334155;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-top: 50px;
}

/* Header */
#siteHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.5rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#siteHeader a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s ease;
}

#siteHeader a:hover {
  opacity: 0.8;
}

#siteHeader img {
  max-height: 28px;
  height: auto;
  width: auto;
  object-fit: contain;
  margin-right: 6px;
}

/* Main */
main {
  flex: 1;
  max-width: 490px;
  width: 90%;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}

/* Typography */
h1 {
  text-align: center;
  margin: 0.75rem 0 0.4rem;
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.025em;
}

h2 {
  text-align: center;
  margin: 1rem 0 0.75rem;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 600;
  color: #475569;
  position: relative;
  padding-bottom: 0.4rem;
}

h2::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  border-radius: 1px;
}

p.intro {
  text-align: center;
  color: #64748b;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
}

a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* Sections */
section {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.8rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

section:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* Forms */
fieldset {
  border: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  align-items: end;
  margin: 0;
  padding: 0;
}

fieldset button {
  grid-column: 1 / -1;
  justify-self: center;
  width: fit-content;
  min-width: 100px;
}

label,
legend {
  font-weight: 500;
  font-size: 0.8rem;
  color: #475569;
  margin-bottom: 0.2rem;
  display: block;
}

select,
button,
input[type="range"] {
  font: inherit;
  border-radius: 6px;
  transition: all 0.2s ease;
}

select {
  padding: 0.5rem 0.6rem;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 0.8rem;
}

select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

button {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

button:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

input[type="range"] {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  cursor: pointer;
}

input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  background: #fff;
}

input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-color: #3b82f6;
}

input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.8rem;
  grid-column: 1 / -1;
  justify-self: center;
}

/* Chord Suffix Buttons */
#chord-suffix-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
  gap: 0.4rem;
  padding: 0.8rem;
  background: rgba(248, 250, 252, 0.8);
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#chord-suffix-buttons button {
  font-size: 0.7rem;
  padding: 0.4rem 0.6rem;
  white-space: nowrap;
  background: #fff;
  color: #475569;
  border: 1px solid #e2e8f0;
  font-weight: 500;
  min-width: auto;
}

#chord-suffix-buttons button:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

#chord-suffix-buttons button[aria-pressed="true"] {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-color: #3b82f6;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.25);
}

/* Display Areas */
#scale-display,
#diatonic-list,
#scale-info,
#fretboard {
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas,
    "Courier New", monospace;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 8px;
  padding: 0.8rem;
  margin: 0.8rem 0;
  overflow-x: auto;
  white-space: pre-wrap;
  font-size: 0.8rem;
  line-height: 1.3;
  color: #475569;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#fretboard {
  text-align: center;
  font-size: 0.75rem;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fretboard visualizer improvements */
#fretboard pre {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  width: 100%;
  font-size: 0.7rem;
  line-height: 1.1;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.8rem;
  color: #64748b;
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  background: rgba(248, 250, 252, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Utilities */
.center-wrapper {
  text-align: center;
  margin: 0.8rem 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Responsive */
@media (max-width: 768px) {
  #siteHeader {
    padding: 0.5rem 0.8rem;
  }

  main {
    width: 95%;
    padding: 0 0.6rem 1.5rem;
  }

  fieldset {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  fieldset button {
    grid-column: 1;
    width: 90%;
    min-width: auto;
  }

  h1 {
    font-size: 1.5rem;
    margin: 0.6rem 0 0.4rem;
  }

  h2 {
    font-size: 1rem;
  }

  #chord-suffix-buttons {
    grid-template-columns: repeat(3, 1fr);
    padding: 0.6rem;
    gap: 0.3rem;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 55px;
  }

  main {
    width: 100%;
    padding: 0 0.4rem 1.2rem;
  }

  section {
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    border-radius: 8px;
  }

  #chord-suffix-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
    padding: 0.4rem;
  }

  #chord-suffix-buttons button {
    padding: 0.35rem 0.4rem;
    font-size: 0.65rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  h2 {
    font-size: 0.9rem;
  }

  #fretboard {
    font-size: 0.65rem;
    padding: 0.6rem;
  }

  #fretboard pre {
    font-size: 0.6rem;
  }
}

/* Focus states for accessibility */
button:focus,
select:focus,
input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Loading states */
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button:disabled:hover {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  transform: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Smooth scrolling for better UX */
@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}
