/* ══════════════════════════════════════════════════
   KÜPE AR PRO — style.css
   Mobil öncelikli, iOS Safari + Android Chrome uyumlu
   ══════════════════════════════════════════════════ */

/* ── Reset & Temel ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent; /* Mobilde tıklama flash'ı kaldır */
}

:root {
  --gold:      #c9a84c;
  --gold-lt:   #e8c97a;
  --bg:        #080c14;
  --surface:   rgba(8, 12, 20, 0.82);
  --text:      #e8e4dd;
  --text-dim:  #7a8394;
  --green:     #34c77b;
  --red:       #ff5e57;
  --amber:     #f6ad55;
  --radius:    12px;
  --ease:      cubic-bezier(.4, 0, .2, 1);

  /* iPhone safe area */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  /* iOS momentum scroll sorununu engelle */
  -webkit-overflow-scrolling: touch;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Ekranlar ── */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s var(--ease);
  z-index: 1;
  /* iOS Safari'de z-index sorununu önle */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ══════════════════════════════════
   BAŞLANGIÇ EKRANI
══════════════════════════════════ */
#screen-start { background: var(--bg); }

.start-box {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  padding: 40px 28px;
  max-width: 380px; width: 100%;
  padding-top: calc(40px + var(--safe-top));
}

.logo {
  font-size: 44px;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 32px rgba(201, 168, 76, 0.5);
  user-select: none;
}

h1 {
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  line-height: 1.1;
}
h1 em { font-style: normal; color: var(--gold); }

.tagline {
  color: var(--text-dim);
  text-align: center;
  font-size: 15px;
  line-height: 1.65;
}

.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: var(--gold);
  color: #080c14;
  border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 28px rgba(201, 168, 76, 0.35);
  transition: background 0.18s var(--ease), transform 0.12s;
  /* iOS'ta buton stilleri için */
  -webkit-appearance: none;
  touch-action: manipulation;
}
.btn-primary:hover  { background: var(--gold-lt); }
.btn-primary:active { transform: scale(0.97); }

.permission-note {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}

/* ══════════════════════════════════
   AR EKRANI
══════════════════════════════════ */
#screen-ar { background: #000; }

/* Video — tam ekran, ayna çevirme */
#ar-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* Ayna görüntü — CSS ile çevir (Canvas'ta tekrar çevirmeyeceğiz) */
  transform: scaleX(-1);
  /* GPU katmanı oluştur — performans için */
  will-change: transform;
  -webkit-transform: scaleX(-1);
}

/* Canvas — videonun tam üstünde */
#ar-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  /* Canvas içeriği JS'de ayna uyumlu çizilecek */
  pointer-events: none;
  will-change: contents;
}

/* ── Yükleme Overlay ── */
#ar-loading {
  position: absolute; inset: 0;
  background: rgba(8, 12, 20, 0.9);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  z-index: 30;
  transition: opacity 0.35s var(--ease);
  /* iOS blur desteği */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#ar-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 42px; height: 42px;
  border: 3px solid rgba(201, 168, 76, 0.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#ar-loading-msg {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  padding: 0 24px;
  white-space: pre-line; /* \n'leri satır sonu yap */
}

/* ── Üst Bar ── */
#ar-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  padding-top: calc(12px + var(--safe-top));
  background: linear-gradient(to bottom, rgba(8,12,20,.88) 0%, transparent 100%);
  z-index: 20;
}

.icon-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(201, 168, 76, 0.3);
  background: rgba(8, 12, 20, 0.55);
  color: var(--gold-lt);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: 0.18s var(--ease);
  /* iOS */
  -webkit-appearance: none;
  touch-action: manipulation;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover  { background: rgba(201, 168, 76, 0.18); border-color: var(--gold); }
.icon-btn:active { transform: scale(0.92); }

/* Durum göstergesi */
#ar-status {
  flex: 1;
  display: flex; align-items: center;
  justify-content: center; gap: 8px;
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 7px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
  background: var(--text-dim);
  transition: background 0.3s;
}
.status-dot.tracking {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 1.6s ease-in-out infinite;
}
.status-dot.lost   { background: var(--red); }
.status-dot.frozen { background: var(--amber); }
.status-dot.waiting{ background: var(--text-dim); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

#ar-status-text {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Gizlenmiş file input */
#ar-file-input { display: none; }

/* ── Alt Panel ── */
#ar-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 16px;
  padding-bottom: calc(20px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(8,12,20,.95) 65%, transparent 100%);
  z-index: 20;
}

.panel-row {
  display: flex; align-items: center; gap: 10px;
}
.panel-row--check { align-items: center; }

.sl-label {
  width: 64px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  flex-shrink: 0;
  user-select: none;
}

/* Range slider — cross-browser */
input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  touch-action: pan-x; /* Dikey kaydırmaya izin ver, yatay kontrol et */
}
/* Chrome / Edge / Safari */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(201,168,76,.5);
}
/* Firefox */
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%; border: none;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(201,168,76,.5);
}

.sl-val {
  width: 44px;
  font-size: 12px;
  color: var(--gold-lt);
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Upload satırı */
#upload-row { gap: 8px; }
.panel-icon { font-size: 16px; flex-shrink: 0; }
#upload-filename {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Checkbox */
input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}
.check-hint {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Responsive ── */

/* Çok kısa ekranlar (landscape telefon) */
@media (max-height: 500px) {
  #ar-panel { gap: 6px; padding-bottom: calc(10px + var(--safe-bottom)); }
  #upload-row { display: none; }
}

/* Geniş ekranlar — paneli ortala */
@media (min-width: 640px) {
  #ar-panel, #ar-topbar {
    max-width: 520px;
    left: 50%; right: auto;
    transform: translateX(-50%);
  }
}
