/* css/style.css */

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a1a;
  color: #e0e0e0;
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== Layout ===== */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.ad-banner {
  background: #1a1a2e;
  text-align: center;
  padding: 8px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-content {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 16px;
  padding: 16px;
}

.ad-sidebar {
  display: none;
  width: 160px;
  flex-shrink: 0;
}

.ad-sidebar .ad-unit {
  background: #1a1a2e;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tuner-container {
  flex: 1;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Tuning Preset Selector ===== */
.preset-selector {
  display: flex;
  gap: 6px;
  padding: 8px 0 16px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}

.preset-selector::-webkit-scrollbar {
  display: none;
}

.preset-btn {
  background: #111;
  color: #888;
  border: 1px solid #222;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.preset-btn:hover {
  border-color: #00d4ff;
  color: #ccc;
}

.preset-btn.active {
  background: #0f3460;
  color: #00d4ff;
  border-color: #00d4ff;
}

/* ===== Note Display ===== */
.note-display {
  text-align: center;
  padding: 16px 0 8px;
}

.note-name {
  font-size: 4rem;
  font-weight: bold;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: #00d4ff;
  text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
  transition: color 0.3s, text-shadow 0.3s;
  line-height: 1;
}

.note-name.in-tune {
  color: #00cc66;
  text-shadow: 0 0 30px rgba(0, 204, 102, 0.5);
}

.note-name.close {
  color: #ffaa00;
  text-shadow: 0 0 20px rgba(255, 170, 0, 0.3);
}

.note-name.out-of-tune {
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}

.note-freq {
  font-size: 0.9rem;
  color: #888;
  font-family: monospace;
  margin-top: 4px;
}

/* ===== Tuning Meter ===== */
.meter-container {
  width: 100%;
  max-width: 400px;
  padding: 16px 0;
}

.meter-bar {
  position: relative;
  height: 40px;
  border-radius: 20px;
  background: linear-gradient(
    90deg,
    #ff4444 0%, #ff4444 15%,
    #ffaa00 15%, #ffaa00 30%,
    #00cc66 30%, #00cc66 70%,
    #ffaa00 70%, #ffaa00 85%,
    #ff4444 85%, #ff4444 100%
  );
  opacity: 0.25;
  overflow: hidden;
}

.meter-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 40px;
  background: #00d4ff;
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.1s ease-out;
  box-shadow: 0 0 10px #00d4ff;
  z-index: 1;
}

.meter-indicator.in-tune {
  background: #00cc66;
  box-shadow: 0 0 15px #00cc66, 0 0 30px rgba(0, 204, 102, 0.3);
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #555;
  margin-top: 4px;
  padding: 0 4px;
}

/* ===== Cents Display ===== */
.cents-display {
  text-align: center;
  padding: 8px 0;
}

.cents-value {
  font-size: 1.5rem;
  font-family: monospace;
  font-weight: bold;
  transition: color 0.3s;
}

.cents-value.in-tune { color: #00cc66; }
.cents-value.close { color: #ffaa00; }
.cents-value.out-of-tune { color: #ff4444; }

.cents-status {
  font-size: 0.85rem;
  margin-top: 2px;
  transition: color 0.3s;
}

.cents-status.in-tune { color: #00cc66; }
.cents-status.close { color: #ffaa00; }
.cents-status.out-of-tune { color: #ff4444; }

/* ===== String Buttons ===== */
.string-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 0;
}

.string-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #333;
  background: transparent;
  color: #888;
  font-size: 0.8rem;
  font-family: monospace;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.string-btn:hover {
  border-color: #555;
  color: #ccc;
}

.string-btn.active {
  border-color: #00d4ff;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.string-btn.locked {
  border-color: #00d4ff;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.2);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.string-btn.tuned {
  border-color: #00cc66;
  color: #00cc66;
  background: rgba(0, 204, 102, 0.1);
}

/* ===== Ad Mid Section ===== */
.ad-mid {
  background: #1a1a2e;
  min-height: 250px;
  width: 100%;
  max-width: 336px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Start/Stop Button ===== */
.start-btn {
  background: linear-gradient(135deg, #00d4ff, #0099cc);
  color: #000;
  border: none;
  padding: 14px 48px;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  margin: 16px 0;
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.start-btn.listening {
  background: linear-gradient(135deg, #ff4444, #cc0033);
  color: #fff;
}

/* ===== Error Message ===== */
.error-message {
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid #ff4444;
  color: #ff6666;
  padding: 12px 20px;
  border-radius: 8px;
  text-align: center;
  margin: 16px 0;
  font-size: 0.9rem;
  display: none;
}

.error-message.visible {
  display: block;
}

/* ===== Guide Content ===== */
.guide-section {
  width: 100%;
  max-width: 700px;
  margin: 32px auto 0;
  padding: 0 16px;
}

.guide-section h2 {
  font-size: 1.4rem;
  color: #e0e0e0;
  margin: 24px 0 12px;
  padding-top: 16px;
  border-top: 1px solid #1a1a2e;
}

.guide-section h3 {
  font-size: 1.1rem;
  color: #ccc;
  margin: 16px 0 8px;
}

.guide-section p, .guide-section li {
  color: #999;
  font-size: 0.95rem;
  line-height: 1.7;
}

.guide-section ul {
  padding-left: 20px;
}

.ad-infeed {
  background: #1a1a2e;
  min-height: 120px;
  margin: 20px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Language Selector ===== */
.lang-selector {
  text-align: center;
  padding: 24px 16px;
  border-top: 1px solid #1a1a2e;
  margin-top: 32px;
}

.lang-selector select {
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #333;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 16px;
  color: #555;
  font-size: 0.8rem;
}

/* ===== Desktop Layout ===== */
@media (min-width: 768px) {
  .ad-sidebar {
    display: flex;
    flex-direction: column;
  }

  .tuner-container {
    max-width: 500px;
  }

  .note-name {
    font-size: 5rem;
  }

  .meter-container {
    max-width: 450px;
  }

  .string-btn {
    width: 52px;
    height: 52px;
    font-size: 0.85rem;
  }
}

/* ===== Idle state (before tuning starts) ===== */
.note-name.idle {
  color: #333;
  text-shadow: none;
}

.meter-indicator.idle {
  opacity: 0.3;
  box-shadow: none;
}
