/* Algoritma Takibi — örnek listesi ve adım adım değişken takibi.
   Renkler adım türünü anlatır: girdi mavi, işlem mor, çıktı yeşil, karar turuncu. */

.alg-app {
    --alg-girdi: var(--sky);
    --alg-islem: var(--violet);
    --alg-cikti: var(--emerald);
    --alg-karar: var(--amber);
    --alg-ucu: var(--slate);
}

/* ---------- üst başlık ---------- */
.alg-top { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.alg-top-ad { display: flex; align-items: center; gap: .85rem; }
.alg-top-ikon {
    display: grid; place-items: center;
    width: 3.1rem; height: 3.1rem; border-radius: 1rem;
    background: linear-gradient(145deg, var(--violet), var(--sky));
    font-size: 1.6rem; box-shadow: var(--shadow);
}
.alg-top h1 { font-size: 1.6rem; }
.alg-top p { margin-top: .15rem; font-size: .9rem; }

/* ---------- örnek listesi ---------- */
.alg-giris { padding: 1.25rem; }
.alg-giris p + p { margin-top: .6rem; }

.alg-grup .section-title { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.alg-ornek-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .9rem; }

.alg-ornek {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    grid-template-areas: "no ad" ".  git";
    gap: .35rem .75rem;
    align-items: start;
    padding: 1rem 1.1rem;
    text-align: left;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.alg-ornek:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 18px 36px -18px hsl(226 50% 30% / .35);
}
.alg-ornek-no {
    grid-area: no;
    display: grid; place-items: center;
    width: 2.5rem; height: 2.5rem; border-radius: .75rem;
    background: hsl(226 80% 94%); color: hsl(226 64% 38%);
    font-family: var(--font-display); font-size: 1.1rem; font-weight: 800;
}
.alg-ornek-ad { grid-area: ad; font-weight: 700; font-size: .98rem; line-height: 1.3; }
.alg-ornek-git { grid-area: git; font-size: .85rem; font-weight: 800; color: var(--primary); }

.alg-ornek.soon { border-style: dashed; box-shadow: none; background: hsl(0 0% 100% / .6); cursor: default; }
.alg-ornek.soon .alg-ornek-no { background: var(--muted); color: var(--muted-foreground); }
.alg-ornek.soon .alg-ornek-ad { color: var(--muted-foreground); font-weight: 600; }

/* ---------- örnek başlığı ve girdiler ---------- */
.alg-basi { padding: 1.25rem; }
.alg-basi-ust { display: flex; align-items: center; gap: .75rem; }
.alg-basi-no {
    flex: 0 0 auto;
    display: grid; place-items: center;
    width: 2.6rem; height: 2.6rem; border-radius: .8rem;
    background: linear-gradient(145deg, var(--primary), var(--violet));
    color: #fff; font-family: var(--font-display); font-size: 1.2rem; font-weight: 800;
}
.alg-basi-ust h2 { font-size: 1.25rem; }
.alg-basi-ozet { margin-top: .6rem; color: var(--muted-foreground); font-size: .95rem; }
.alg-basi .week-topics { margin-top: .7rem; }

.alg-girdi-kutu {
    margin-top: 1rem;
    padding: .85rem 1rem;
    border: 1px dashed var(--input);
    border-radius: 1rem;
    background: hsl(199 89% 97%);
}
.alg-girdi-bas { display: block; font-weight: 800; font-size: .85rem; color: hsl(200 80% 30%); }
.alg-girdi-liste { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin-top: .6rem; }
.alg-g { display: grid; gap: .2rem; font-size: .8rem; font-weight: 700; color: var(--muted-foreground); }
.alg-g .input { width: 7rem; font-weight: 800; }

/* ---------- üç bölmeli düzen ---------- */
.alg-duzen {
    display: grid;
    grid-template-columns: minmax(0, 17rem) minmax(0, 1fr) minmax(0, 20rem);
    gap: 1rem;
    margin-top: 1rem;
    align-items: start;
}
.alg-panel { padding: 1rem; }
.alg-panel h3 { font-size: 1.05rem; }
.alg-panel-bas { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.alg-yan { display: grid; gap: 1rem; }

/* ---------- akış şeması ---------- */
.alg-sema svg { width: 100%; height: auto; }

.alg-d rect, .alg-d polygon {
    fill: var(--card);
    stroke: var(--border);
    stroke-width: 1.5;
    transition: fill .25s, stroke .25s;
}
.alg-d text {
    fill: var(--muted-foreground);
    font-family: var(--font-body);
    font-weight: 700;
    text-anchor: middle;
    transition: fill .25s;
}
.alg-ok { stroke: var(--alg-ucu); stroke-width: 1.5; opacity: .5; }
#alg-ucu path { fill: var(--alg-ucu); opacity: .5; }

.alg-d.is-gecildi rect, .alg-d.is-gecildi polygon { fill: hsl(255 40% 97%); stroke: hsl(255 30% 84%); }
.alg-d.is-gecildi text { fill: var(--foreground); opacity: .65; }

.alg-d.is-aktif rect, .alg-d.is-aktif polygon { stroke-width: 2.5; }
.alg-d.is-aktif text { fill: #fff; }
.alg-d-terminal.is-aktif rect { fill: var(--slate); stroke: var(--slate); }
.alg-d-islem.is-aktif rect { fill: var(--alg-islem); stroke: var(--alg-islem); }
.alg-d-girdi.is-aktif polygon { fill: var(--alg-girdi); stroke: var(--alg-girdi); }
.alg-d-cikti.is-aktif polygon { fill: var(--alg-cikti); stroke: var(--alg-cikti); }
.alg-d-karar.is-aktif polygon { fill: var(--alg-karar); stroke: var(--alg-karar); }
.alg-d.is-aktif { animation: alg-nabiz 1.6s ease-in-out infinite; }

/* ---------- kod ---------- */
.alg-diller { display: flex; gap: .25rem; padding: .2rem; border-radius: .7rem; background: var(--muted); }
.alg-dil {
    padding: .3rem .65rem;
    border: 0; border-radius: .55rem;
    background: transparent;
    font-size: .8rem; font-weight: 800;
    color: var(--muted-foreground);
    cursor: pointer;
}
.alg-dil:hover { color: var(--foreground); }
.alg-dil.is-aktif { background: #fff; color: var(--foreground); box-shadow: var(--shadow-sm); }

.alg-kod { margin-top: .75rem; }
.alg-satirlar {
    margin: 0; padding: 0;
    list-style: none;
    counter-reset: alg-satir;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .88rem;
}
.alg-satirlar li {
    counter-increment: alg-satir;
    display: grid;
    grid-template-columns: 2.2rem 1fr;
    gap: .5rem;
    padding: .2rem .5rem .2rem 0;
    border-left: 3px solid transparent;
    border-radius: .35rem;
    transition: background .2s, border-color .2s;
}
.alg-satirlar li::before {
    content: counter(alg-satir);
    text-align: right;
    color: var(--muted-foreground);
    opacity: .6;
    font-size: .78rem;
    line-height: 1.6;
}
.alg-satirlar code { white-space: pre-wrap; word-break: break-word; }
.alg-satirlar li.is-aktif {
    background: hsl(226 80% 96%);
    border-left-color: var(--primary);
    font-weight: 700;
}
.alg-kod-not:not(:empty) { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--border); }

/* ---------- değişkenler ---------- */
.alg-degiskenler { display: grid; gap: .6rem; margin-top: .7rem; }
.alg-v {
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: .85rem;
    background: hsl(255 40% 98%);
    transition: border-color .2s, background .2s;
}
.alg-v-bas { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.alg-v-bas b { font-family: ui-monospace, Consolas, monospace; font-size: .95rem; }
.alg-v-tur { font-size: .72rem; font-weight: 700; color: var(--muted-foreground); }
.alg-v-deger {
    margin-top: .15rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.15;
    word-break: break-word;
}
.alg-tanimsiz { font-family: var(--font-body); font-size: .95rem; font-weight: 600; color: var(--muted-foreground); }
.alg-v-onceki { font-size: .75rem; font-weight: 700; color: var(--muted-foreground); }
.alg-v.is-yeni { border-style: dashed; }
.alg-v.is-degisti {
    border-color: var(--alg-islem);
    background: hsl(226 80% 97%);
    animation: alg-parla .7s ease-out;
}
.alg-v.is-degisti .alg-v-deger { color: hsl(226 64% 42%); }

/* ---------- ekran (çıktı) ---------- */
.alg-ekran {
    margin-top: .7rem;
    padding: .7rem .8rem;
    min-height: 5.5rem;
    max-height: 14rem;
    overflow: auto;
    border-radius: .85rem;
    background: #0d1222;
    color: #d8e2ff;
    font-family: ui-monospace, Consolas, monospace;
    font-size: .85rem;
    line-height: 1.6;
}
.alg-e-satir { white-space: pre-wrap; word-break: break-word; }
.alg-e-satir + .alg-e-satir { margin-top: .1rem; }
.alg-e-istem { color: #93a4d4; }
.alg-e-girdi { color: #ffd166; font-weight: 700; border-bottom: 1px dotted #ffd16688; }
.alg-e-bos { color: #5b688f; font-style: italic; }

/* ---------- adım listesi ---------- */
.alg-adimlar {
    margin: .7rem 0 0; padding: 0;
    list-style: none;
    display: grid; gap: .2rem;
    max-height: 16rem; overflow: auto;
}
.alg-adimlar button {
    display: flex; align-items: center; gap: .55rem;
    width: 100%; padding: .35rem .45rem;
    border: 0; border-radius: .55rem;
    background: transparent;
    text-align: left;
    font-size: .82rem;
    cursor: pointer;
}
.alg-adimlar button:hover { background: var(--muted); }
.alg-adimlar .n {
    flex: 0 0 auto;
    display: grid; place-items: center;
    width: 1.4rem; height: 1.4rem; border-radius: .45rem;
    background: var(--muted);
    font-size: .72rem; font-weight: 800;
    color: var(--muted-foreground);
}
.alg-adimlar .t { font-family: ui-monospace, Consolas, monospace; }
.alg-adimlar li.is-gecildi button { opacity: .7; }
.alg-adimlar li:not(.is-aktif):not(.is-gecildi) button { opacity: .45; }
.alg-adimlar li.is-aktif button { background: hsl(226 80% 96%); font-weight: 800; }
.alg-adimlar li.is-aktif .n { background: var(--primary); color: #fff; }

/* adım türü renkleri: hem adım listesinde hem alt şeritte */
.alg-t-basla, .alg-t-bitir { color: var(--slate); }
.alg-t-tanim, .alg-t-islem { color: hsl(226 64% 45%); }
.alg-t-girdi { color: hsl(200 85% 35%); }
.alg-t-cikti { color: hsl(163 88% 28%); }
.alg-t-karar, .alg-t-dongu { color: hsl(32 90% 35%); }

/* ---------- ders notu ---------- */
.alg-notlar { margin-top: 1rem; padding: 1rem 1.25rem; }
.alg-notlar summary { font-family: var(--font-display); font-weight: 800; cursor: pointer; }
.alg-notlar ul { margin: .7rem 0 0; padding-left: 1.2rem; display: grid; gap: .4rem; font-size: .92rem; }
.alg-notlar code { font-size: .85em; padding: .05rem .3rem; border-radius: .3rem; background: var(--muted); }

/* ---------- alt kontrol şeridi ---------- */
.alg-kontrol {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-top: 1rem;
    padding: .85rem 1.1rem 1rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + .25rem);
    background: hsl(0 0% 100% / .92);
    backdrop-filter: saturate(1.4) blur(10px);
    box-shadow: 0 -6px 24px -14px hsl(252 40% 20% / .35);
}
.alg-kontrol-metin { min-height: 3.2rem; }
.alg-adim-baslik { font-family: ui-monospace, Consolas, monospace; font-weight: 800; font-size: .95rem; }
.alg-kontrol-metin p { font-size: .92rem; color: var(--muted-foreground); }
.alg-kontrol-metin code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; padding: .05rem .3rem; border-radius: .3rem; background: var(--muted); }
.alg-adim-not { margin-top: .3rem; font-size: .85rem; color: hsl(32 70% 32%); }

.alg-kontrol-dugmeler { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; }
.alg-hiz-etiket .select { width: 5rem; height: 2.5rem; }
.alg-sayac {
    margin-left: auto;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--muted-foreground);
}
.alg-bar { height: .4rem; margin-top: .75rem; border-radius: 999px; background: var(--muted); overflow: hidden; }
.alg-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--violet)); transition: width .25s; }
.alg-tus { margin-top: .5rem; }

/* ---------- dar ekran ---------- */
@media (max-width: 1100px) {
    .alg-duzen { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .alg-yan { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
}

@media (max-width: 719.98px) {
    .alg-duzen { grid-template-columns: minmax(0, 1fr); }
    .alg-yan { grid-column: auto; grid-template-columns: minmax(0, 1fr); }
    .alg-sema-panel { order: 3; }
    .alg-kontrol { padding: .7rem .8rem .85rem; }
    .alg-kontrol-dugmeler .btn { flex: 1 1 auto; }
    .alg-sayac { width: 100%; text-align: right; }
    .alg-tus { display: none; }
}

/* ---------- hareket ---------- */
@keyframes alg-parla {
    from { transform: scale(.97); box-shadow: 0 0 0 .35rem hsl(226 64% 44% / .22); }
    to { transform: scale(1); box-shadow: 0 0 0 0 hsl(226 64% 44% / 0); }
}
@keyframes alg-nabiz {
    0%, 100% { opacity: 1; }
    50% { opacity: .82; }
}


/* ---------- akis semasi: baglar ve tam ekran ---------- */
.alg-bag { fill: none; stroke: var(--alg-ucu); stroke-width: 1.5; opacity: .45; }
.alg-bag.is-aktif { stroke: var(--primary); opacity: 1; stroke-width: 2.5; }
.alg-bag-etiket {
    fill: var(--muted-foreground);
    font-family: var(--font-body);
    font-size: 10.5px;
    font-weight: 800;
    text-anchor: middle;
}
.alg-bag-etiket.is-aktif { fill: var(--primary); }

.alg-sema { margin-top: .6rem; overflow-x: auto; }

.alg-buyuk {
    position: fixed; inset: 0; z-index: 60;
    display: grid; place-items: center;
    padding: 1rem;
    background: hsl(252 40% 10% / .6);
    backdrop-filter: blur(3px);
    animation: fade-in .15s ease-out;
}
.alg-buyuk-ic {
    display: flex; flex-direction: column; gap: .6rem;
    width: 100%; max-width: 64rem; max-height: 94vh;
    padding: 1rem 1.25rem 1.25rem;
    border-radius: 1.25rem;
    background: var(--card);
    box-shadow: 0 25px 50px -12px hsl(252 40% 10% / .45);
}
.alg-buyuk-ust { display: flex; align-items: center; gap: .75rem; }
.alg-buyuk-ust h3 { font-size: 1.15rem; margin-right: auto; }
/* modal gövdesi: solda şema, sağda değişkenler ve ekran */
.alg-buyuk-govde {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 20rem);
    gap: 1rem;
}
.alg-buyuk-sema { min-height: 0; overflow: auto; }
.alg-buyuk-sema svg { width: 100%; height: auto; max-height: 68vh; }

.alg-buyuk-yan { display: grid; grid-template-rows: auto auto; gap: .75rem; min-height: 0; align-content: start; }
.alg-buyuk-kutu { min-height: 0; display: flex; flex-direction: column; }
.alg-buyuk-kutu h4 {
    margin: 0;
    font-family: var(--font-display);
    font-size: .95rem;
    font-weight: 800;
}
.alg-buyuk-yan .alg-degiskenler { overflow: auto; max-height: 34vh; padding-right: .2rem; }
.alg-buyuk-yan .alg-ekran { max-height: 22vh; }
.alg-buyuk-metin { font-size: .92rem; color: var(--muted-foreground); }
.alg-buyuk-metin code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; padding: .05rem .3rem; border-radius: .3rem; background: var(--muted); }
.alg-buyuk-dugmeler { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- dizi hucreleri ---------- */
.alg-v-dizi { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }
.alg-h {
    position: relative;
    display: grid; place-items: center;
    min-width: 2.1rem; padding: .85rem .3rem .2rem;
    border: 1px solid var(--border); border-radius: .5rem;
    background: #fff;
    font-family: ui-monospace, Consolas, monospace;
    font-size: .85rem; font-weight: 700;
}
.alg-h i {
    position: absolute; top: .1rem;
    font-style: normal; font-size: .6rem; font-weight: 800;
    color: var(--muted-foreground);
}
.alg-h.is-degisti { border-color: var(--alg-islem); color: hsl(226 64% 42%); }
.alg-h.is-vurgu { border-color: var(--primary); background: hsl(226 80% 95%); box-shadow: 0 0 0 2px hsl(226 64% 44% / .25); }

.alg-g .input.alg-g-genis { width: 16rem; font-weight: 700; }

@media (max-width: 860px) {
    /* dar ekranda alt alta: satırlar içeriğe göre uzasın, gövdenin kendisi kaysın */
    .alg-buyuk-govde { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; overflow: auto; }
    .alg-buyuk-sema { height: 42vh; }                       /* şema kendi kutusunda kaysın */
    .alg-buyuk-yan, .alg-buyuk-kutu { min-height: auto; }   /* değişkenler ve ekran içeriğe göre uzasın */
    .alg-buyuk-yan .alg-degiskenler { max-height: none; overflow: visible; }
    .alg-buyuk-yan .alg-ekran { max-height: 10rem; }
}
