/* ================================================================== */
/*  Akort — stil                                                       */
/* ================================================================== */
:root {
  --bg-1: #0f1226;
  --bg-2: #171a35;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.10);
  --text: #eef0ff;
  --text-dim: #9aa0c3;
  --accent: #7c8cff;
  --good: #2fe6a2;
  --close: #ffcf5c;
  --off: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a2f5c 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 26px;
  /* Tek ekrana sığdırma: ekran yüksekliğini dolduran esnek sütun */
  min-height: 100vh;      /* eski tarayıcı yedeği */
  min-height: 100svh;     /* mobil tarayıcı çubuğu dahil güvenli yükseklik */
  display: flex;
  flex-direction: column;
}

/* ---- Başlık ---- */
.app-header { text-align: center; margin-bottom: 18px; }
.title {
  margin: 0;
  font-size: clamp(1.7rem, 6vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.title-icon { filter: drop-shadow(0 2px 6px rgba(124, 140, 255, 0.6)); }
.subtitle {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---- Enstrüman sekmeleri ---- */
.instruments {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.instrument-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s, border-color 0.2s;
}
.instrument-tab:hover { background: var(--surface-2); }
.instrument-tab:active { transform: scale(0.97); }
.instrument-tab.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(124, 140, 255, 0.25), rgba(124, 140, 255, 0.10));
  box-shadow: 0 0 0 1px rgba(124, 140, 255, 0.4) inset;
}
.tab-icon { font-size: 1.2rem; }

/* ---- Akort düzeni seçimi ---- */
.tuning-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.tuning-label { color: var(--text-dim); font-size: 0.82rem; white-space: nowrap; }
.tuning-select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  appearance: none;
  cursor: pointer;
}
.tuning-select:focus { outline: none; border-color: var(--accent); }

/* ---- Ölçüm paneli ---- */
.tuner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.readout { min-height: 84px; }
.note-name {
  font-size: clamp(3rem, 16vw, 4.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 1px;
  transition: color 0.2s;
}
.note-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.note-solfege { color: var(--text-dim); font-size: 0.95rem; font-weight: 600; }
.note-freq { color: var(--text-dim); font-size: 0.8rem; font-variant-numeric: tabular-nums; min-height: 1em; }

/* ---- Kadran / iğne ---- */
/* Tüm kadran geometrisi --r (yarıçap) değişkeninden türer; böylece
   kısa ekranlarda tek değeri değiştirerek orantılı küçültülebilir. */
.gauge { --r: 138px; margin: 8px auto 2px; }
.gauge-arc {
  position: relative;
  width: calc(var(--r) * 2);
  max-width: 88vw;
  height: calc(var(--r) + 8px);
  margin: 0 auto;
}
.gauge-arc::before {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  height: var(--r);
  border: 2px solid var(--border);
  border-bottom: none;
  border-radius: var(--r) var(--r) 0 0;
}

/* Radyal işaretler */
.tick {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 2px;
  height: calc(var(--r) - 8px);
  transform-origin: bottom center;
  background: linear-gradient(to top, transparent 80%, var(--border) 80%);
}
.tick--l2 { transform: translateX(-50%) rotate(-45deg); }
.tick--l1 { transform: translateX(-50%) rotate(-22.5deg); }
.tick--c  { transform: translateX(-50%) rotate(0deg); background: linear-gradient(to top, transparent 78%, var(--good) 78%); }
.tick--r1 { transform: translateX(-50%) rotate(22.5deg); }
.tick--r2 { transform: translateX(-50%) rotate(45deg); }

/* Ortadaki "akortlu" bölge parıltısı */
.gauge-zone {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 60px;
  height: 60px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 230, 162, 0.0) 40%, transparent 70%);
  transition: background 0.2s;
  pointer-events: none;
}
.gauge.in-tune .gauge-zone {
  background: radial-gradient(circle, rgba(47, 230, 162, 0.35) 0%, transparent 70%);
}

/* İğne */
.needle {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 4px;
  height: calc(var(--r) - 14px);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  background: linear-gradient(to top, var(--accent), #b9c2ff);
  border-radius: 4px;
  transition: transform 0.09s ease-out, background 0.2s;
  box-shadow: 0 0 12px rgba(124, 140, 255, 0.5);
}
.needle-hub {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 16px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 3px var(--bg-1);
}
.gauge.in-tune .needle { background: linear-gradient(to top, var(--good), #b6ffe4); box-shadow: 0 0 16px rgba(47, 230, 162, 0.7); }
.gauge.close   .needle { background: linear-gradient(to top, var(--close), #ffe9b0); box-shadow: 0 0 14px rgba(255, 207, 92, 0.6); }
.gauge.off     .needle { background: linear-gradient(to top, var(--off), #ffb3b3); box-shadow: 0 0 14px rgba(255, 107, 107, 0.6); }
.gauge.in-tune .note-name { color: var(--good); }

.gauge-scale {
  display: flex;
  justify-content: space-between;
  width: calc(var(--r) * 2);
  max-width: 88vw;
  margin: 2px auto 0;
  color: var(--text-dim);
  font-size: 0.66rem;
  letter-spacing: 0.3px;
}

/* ---- Cent + ipucu ---- */
.cents-line { margin-top: 8px; }
.cents-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cents-unit { color: var(--text-dim); font-size: 0.8rem; margin-left: 3px; }

.hint {
  margin-top: 8px;
  min-height: 1.4em;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.2s;
}
.hint.good  { color: var(--good); }
.hint.close { color: var(--close); }
.hint.off   { color: var(--off); }

/* ---- Seviye ---- */
.level {
  height: 5px;
  margin: 14px auto 0;
  width: 70%;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--good), var(--close), var(--off));
  transition: width 0.08s linear;
}

/* ---- Teller ---- */
.strings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 6px;
}
.string-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 62px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.2s, background 0.2s;
}
.string-chip:active { transform: scale(0.95); }
.chip-note { font-size: 1.05rem; font-weight: 700; }
.chip-solfege { font-size: 0.72rem; color: var(--text-dim); }
.chip-label { font-size: 0.62rem; color: var(--accent); font-weight: 600; }
.string-chip.active {
  border-color: var(--good);
  background: linear-gradient(180deg, rgba(47, 230, 162, 0.22), rgba(47, 230, 162, 0.08));
  box-shadow: 0 0 0 1px rgba(47, 230, 162, 0.4) inset;
}
.string-chip.playing {
  border-color: var(--accent);
  animation: pulse 0.6s ease infinite alternate;
}
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(124,140,255,0.5); } to { box-shadow: 0 0 14px 2px rgba(124,140,255,0.5); } }

.tap-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin: 4px 0 18px;
}

/* ---- Kontroller ---- */
.controls { text-align: center; }
.btn {
  border: none;
  border-radius: 14px;
  padding: 15px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--accent), #5a68e0);
  box-shadow: 0 8px 20px rgba(90, 104, 224, 0.35);
  transition: transform 0.12s, filter 0.2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn.active {
  background: linear-gradient(180deg, #ff7a7a, #e05a5a);
  box-shadow: 0 8px 20px rgba(224, 90, 90, 0.35);
}

.ref-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.ref-row input[type='range'] { width: 130px; accent-color: var(--accent); }
.ref-value { font-variant-numeric: tabular-nums; }

/* ---- Durum / alt bilgi ---- */
.status {
  text-align: center;
  min-height: 1.2em;
  margin: 14px 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.status.error { color: var(--off); }

.app-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.72rem;
  opacity: 0.8;
}

/* ================================================================== */
/*  Mobil: tek ekrana (kaydırmasız) sığdırma                          */
/* ================================================================== */
@media (max-width: 600px) {
  .app { padding: 12px 12px 16px; }

  .app-header { margin-bottom: 6px; }
  .subtitle { display: none; } /* sekmeler zaten enstrümanları gösteriyor */

  .instruments { margin-bottom: 8px; gap: 6px; }
  .instrument-tab { padding: 7px 6px; font-size: 0.84rem; gap: 6px; }
  .tab-icon { font-size: 1.05rem; }

  .tuning-row { margin-bottom: 8px; }
  .tuning-label { font-size: 0.78rem; }
  .tuning-select { padding: 8px 10px; }

  /* Ölçüm paneli kalan boşluğu doldurur, içerik dikeyde ortalanır */
  .tuner {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px 12px;
  }
  .readout { min-height: 0; }
  .note-name { font-size: clamp(2.1rem, 6svh, 3.4rem); }
  .note-meta { margin-top: 2px; }
  .note-solfege { font-size: 0.85rem; }
  .cents-line { margin-top: 4px; }
  .cents-value { font-size: 1.25rem; }
  .hint { margin-top: 4px; min-height: 1.2em; font-size: 0.86rem; }
  .level { margin-top: 8px; }

  /* Kadranı ekran yüksekliğine göre sürekli ölçekle (tek satır teller) */
  .gauge { --r: clamp(64px, 15svh, 140px); margin: 6px auto 2px; }

  .strings { margin: 10px 0 0; gap: 6px; }
  .string-chip { min-width: 47px; padding: 7px 6px; gap: 0; }
  .chip-note { font-size: 0.98rem; }

  .controls { margin-top: 10px; }
  .btn { padding: 12px 26px; }
  .ref-row { margin-top: 8px; }
  .status { margin-top: 6px; min-height: 0; }

  /* Tek ekranda yer açmak için ikincil öğeleri gizle */
  .tap-hint,
  .app-footer { display: none; }
}

/* Kısa ekranlarda son kırpma */
@media (max-height: 630px) {
  .instruments { margin-bottom: 6px; }
  .instrument-tab { padding: 6px 5px; }
  .tuning-row { margin-bottom: 6px; }
  .strings { margin-top: 8px; }
  .controls { margin-top: 8px; }
  .ref-row { margin-top: 6px; }
  .gauge { --r: clamp(58px, 12svh, 110px); }
}

/* Çok kısa ekranlarda başlığı da kıs */
@media (max-height: 560px) {
  .title { font-size: 1.4rem; }
  .app-header { margin-bottom: 2px; }
  .btn { padding: 10px 24px; }
}

/* Dar ekranlar: telleri ve sekmeleri biraz daha küçült */
@media (max-width: 340px) {
  .instrument-tab { font-size: 0.78rem; padding: 6px 4px; }
  .string-chip { min-width: 44px; padding: 6px 5px; }
  .chip-note { font-size: 0.92rem; }
}
