/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --bg:             #000000;
    --surface:        rgba(16, 16, 18, 0.90);
    --surface-btn:    rgba(255, 255, 255, 0.08);
    --border:         rgba(255, 255, 255, 0.07);
    --accent:         #0A84FF;
    --accent-dim:     rgba(10, 132, 255, 0.18);
    --accent-glow:    rgba(10, 132, 255, 0.40);
    --text-primary:   #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.42);
    --text-tertiary:  rgba(255, 255, 255, 0.18);
    --success:        #30D158;
    --font:           -apple-system, 'SF Pro Display', BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --sheet-radius:   28px;
    --ease:           cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;  /* Sağa/sola/yukarı/aşağı scroll bounce engelle */
    touch-action: none;         /* Varsayılan touch gesture'ları devre dışı bırak */
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

/* =============================================
   LAYOUT CONTAINER
   ============================================= */
#container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: pan-y;  /* Butonlar için touch olaylarına izin ver */
    background: radial-gradient(ellipse at 50% 38%, #0d1b2e 0%, #060912 55%, #000000 100%);
    transition: background 0.4s ease;
}

/* Arka plan temaları — container üzerinde */
body.bg-white #container {
    background: #f5f5f7;
}

body.bg-transparent #container {
    background:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #fff;
}

/* =============================================
   VIEWER AREA — controls dışındaki tüm yüksekliği kaplar
   ============================================= */
#viewer-area {
    flex: 1 1 auto;
    min-height: 0;        /* flex shrink için zorunlu */
    width: 100%;
    position: relative;   /* model-viewer'a absolute zemin */
    touch-action: none;   /* Tüm touch işlemler sadece model-viewer için */
    overscroll-behavior: none;
}

/* =============================================
   VIDEO OYNATICI
   ============================================= */
#video-player {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;   /* En-boy oranını korur, siyah bant ile */
    background: #000;
}

/* Arka plan seçici buton — kaldırıldı */

/* =============================================
   STATUS PILL (üst ortada yüzen)
   ============================================= */
#status-pill {
    position: fixed;
    top: max(18px, env(safe-area-inset-top, 18px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: rgba(20, 20, 22, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 100px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

#step-counter {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--accent);
}

#pill-divider {
    width: 1px;
    height: 12px;
    background: var(--border);
    border-radius: 1px;
}

#pill-label {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: var(--text-secondary);
}

/* =============================================
   PANZOOM INDICATOR
   ============================================= */
#panzoom-indicator {
    position: fixed;
    top: max(18px, env(safe-area-inset-top, 18px));
    right: 16px;
    z-index: 500;
    padding: 7px 14px;
    background: rgba(20, 20, 22, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.4px;
    display: none;
    pointer-events: none;
}

/* =============================================
   BOTTOM CONTROL SHEET
   ============================================= */
#controls {
    flex-shrink: 0;       /* viewer-area'ya yer bırak, küçülme */
    width: 100%;
    z-index: 1000;
    background: var(--surface);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border-top: 1px solid var(--border);
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    padding: 12px 24px 0;
    box-shadow: 0 -1px 0 rgba(255,255,255,0.04),
                0 -24px 64px rgba(0,0,0,0.65);
}

#sheet-handle {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 100px;
    margin: 0 auto 20px;
}

/* =============================================
   STEP DESCRIPTION
   ============================================= */
#step-description {
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.1px;
    line-height: 1.45;
    min-height: 20px;
    margin-bottom: 18px;
}

/* =============================================
   STEP PROGRESS DOTS
   ============================================= */
#step-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    margin-bottom: 22px;
}

.step-dot {
    height: 4px;
    border-radius: 100px;
    transition: width 0.35s var(--ease),
                background 0.35s var(--ease),
                opacity 0.35s var(--ease);
}

.step-dot.done   { width: 18px; background: var(--accent); opacity: 0.55; }
.step-dot.active { width: 30px; background: var(--accent); opacity: 1; }
.step-dot.todo   { width: 6px;  background: var(--text-tertiary); opacity: 1; }
.step-dot.finished { width: 20px; background: var(--success); opacity: 0.7; }

/* =============================================
   ACTION BAR
   ============================================= */
#action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 16px;
}

button {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s var(--ease),
                opacity    0.2s  var(--ease),
                background 0.2s  var(--ease),
                box-shadow 0.2s  var(--ease);
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

button:active:not(:disabled) {
    transform: scale(0.88);
}

/* Ghost (sıfırla) */
.btn-ghost {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-btn);
    color: var(--text-primary);
}

/* Round (geri / ileri) */
.btn-round {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--surface-btn);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-round:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.13);
}
.btn-round:disabled {
    opacity: 0.20;
    cursor: not-allowed;
}

/* Play (büyük merkez) */
.btn-play {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 24px var(--accent-glow);
}
.btn-play:hover:not(:disabled) {
    box-shadow: 0 0 0 10px var(--accent-dim),
                0 8px 32px rgba(10, 132, 255, 0.55);
}
.btn-play:active:not(:disabled) {
    transform: scale(0.86);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-play.is-animating {
    background: rgba(255, 255, 255, 0.10);
    color: var(--text-secondary);
    box-shadow: none;
}
.btn-play:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Tamamlandı: play butonu yeşile döner */
#controls.is-finished .btn-play {
    background: var(--success);
    box-shadow: 0 4px 24px rgba(48, 209, 88, 0.4);
    animation: finish-pulse 0.5s ease;
}

/* Tüm kontrol panosu yeşil çerçeve */
#controls.is-finished {
    border-color: rgba(48, 209, 88, 0.45);
    box-shadow: 0 0 0 1px rgba(48, 209, 88, 0.2),
                0 8px 40px rgba(0,0,0,0.55);
}
#controls.is-finished #action-bar {
    background: rgba(48, 209, 88, 0.07);
    border-radius: 0 0 var(--sheet-radius) var(--sheet-radius);
}

@keyframes finish-pulse {
    0%   { transform: scale(1); box-shadow: 0 4px 24px rgba(48,209,88,0.4); }
    40%  { transform: scale(1.18); box-shadow: 0 0 0 16px rgba(48,209,88,0); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); box-shadow: 0 4px 24px rgba(48,209,88,0.4); }
}

/* =============================================
   SAFE AREA (iPhone home bar)
   ============================================= */
#safe-area-bottom {
    height: env(safe-area-inset-bottom, 8px);
    min-height: 8px;
}

/* =============================================
   ANIMASYON: Adım geçiş efekti
   ============================================= */
@keyframes fade-pulse {
    0%   { opacity: 1; }
    40%  { opacity: 0.35; }
    100% { opacity: 1; }
}
.step-change {
    animation: fade-pulse 0.3s ease;
}

/* =============================================
   RESPONSIVE - tablet/desktop
   ============================================= */
@media (min-width: 600px) {
    /* Desktop: viewer-area tam ekran, flex dışı — model-viewer canvas doğru ölçer */
    #viewer-area {
        position: fixed;
        inset: 0;
    }
    /* Controls floating card — viewer-area üstüne oturur */
    #controls {
        position: fixed;
        bottom: 28px;
        left: 50%;
        right: auto;
        width: auto;
        max-width: 440px;
        transform: translateX(-50%);
        border-radius: var(--sheet-radius);
        padding-bottom: 8px;
    }
    #safe-area-bottom { display: none; }
}

/* =============================================
   LANDSCAPE MOD — mobil yatay ekran
   (telefon landscape: genellikle max-height 500px altı)
   ============================================= */
@media screen and (orientation: landscape) and (max-height: 500px) {

    /* Video: ekranın tamamı, sağda panel için yer bırak */
    #viewer-area {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 200px;          /* panel genişliği kadar sağdan boş bırak */
        width: auto;
        height: auto;
    }

    /* Kontrol paneli: sağa yapışık dikey sidebar */
    #controls {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: 200px;
        border-top: none;
        border-left: 1px solid var(--border);
        border-radius: 0;
        padding: 12px 14px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0;
    }

    /* Tutacağı landscape'te gizle */
    #sheet-handle { display: none; }

    /* Açıklama metnini kompakt tut */
    #step-description {
        font-size: 11px;
        line-height: 1.4;
        margin-bottom: 10px;
        min-height: auto;
    }

    #step-dots { margin-bottom: 12px; }

    /* Butonları küçült */
    #action-bar  { margin-bottom: 0; padding: 0; }
    .btn-play    { width: 52px; height: 52px; }
    .btn-round   { width: 40px; height: 40px; }
    .btn-ghost   { width: 34px; height: 34px; }

    /* Safe area landscape'te gereksiz */
    #safe-area-bottom { display: none; }

    /* Üst elementler için safe-area inset azalt */
    #status-pill { top: max(8px, env(safe-area-inset-top, 8px)); }
}
