/* ===== planlat.com — haftalık çizelge (WeekGrid), ürün penceresi, lejant, imza hareket =====
   site.css'ten SONRA yüklenir; aynı adlı eski kuralları (appwin, legend) sıra üstünlüğüyle ezer.
   Tablo hiçbir genişlikte kaymaz: table-layout fixed, dar kutuda önce isim sütunu daralır (container query). */

/* ---------- Haftalık çizelge ---------- */
/* Sekme ve rozet metni: açık temada 4.5 kontrast için koyu ton. */
.week-grid { position: relative; width: 100%; min-width: 0; container: weekgrid / inline-size; --wg-tab-text: var(--muted); --wg-tag-text: var(--accent); }
:root[data-theme="light"] .week-grid { --wg-tab-text: var(--text); --wg-tag-text: var(--link-hover); }

/* Hafta sekmeleri: saf CSS (radio + label + :checked ~). Radio görünmez ama klavyeyle seçilir (ok tuşları). */
.wg-radio { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.wg-tabs { display: flex; gap: 4px; margin-bottom: 10px; padding: 4px; border-radius: var(--r-md); background: var(--inset); }
.wg-tabs label {
    flex: 1 1 0; min-width: 0; min-height: 36px; padding: 0 6px;
    display: flex; align-items: center; justify-content: center; gap: .35em;
    border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--wg-tab-text); font: 600 0.8rem/1.1 var(--f-mono); font-variant-numeric: tabular-nums;
    transition: background-color .2s, color .2s, box-shadow .2s;
}
.wg-tabs label:hover { color: var(--text); }
.wg-radio:nth-of-type(1):checked ~ .wg-tabs label:nth-child(1),
.wg-radio:nth-of-type(2):checked ~ .wg-tabs label:nth-child(2),
.wg-radio:nth-of-type(3):checked ~ .wg-tabs label:nth-child(3),
.wg-radio:nth-of-type(4):checked ~ .wg-tabs label:nth-child(4),
.wg-radio:nth-of-type(5):checked ~ .wg-tabs label:nth-child(5),
.wg-radio:nth-of-type(6):checked ~ .wg-tabs label:nth-child(6) {
    background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-2), inset 0 -2px 0 var(--accent);
}
.wg-radio:nth-of-type(1):focus-visible ~ .wg-tabs label:nth-child(1),
.wg-radio:nth-of-type(2):focus-visible ~ .wg-tabs label:nth-child(2),
.wg-radio:nth-of-type(3):focus-visible ~ .wg-tabs label:nth-child(3),
.wg-radio:nth-of-type(4):focus-visible ~ .wg-tabs label:nth-child(4),
.wg-radio:nth-of-type(5):focus-visible ~ .wg-tabs label:nth-child(5),
.wg-radio:nth-of-type(6):focus-visible ~ .wg-tabs label:nth-child(6) { outline: 2px solid var(--accent); outline-offset: 2px; }

.wg-panes { display: grid; gap: 12px; }
.wg-radio ~ .wg-panes > .wg-pane { display: none; }
.wg-radio:nth-of-type(1):checked ~ .wg-panes > .wg-pane:nth-child(1),
.wg-radio:nth-of-type(2):checked ~ .wg-panes > .wg-pane:nth-child(2),
.wg-radio:nth-of-type(3):checked ~ .wg-panes > .wg-pane:nth-child(3),
.wg-radio:nth-of-type(4):checked ~ .wg-panes > .wg-pane:nth-child(4),
.wg-radio:nth-of-type(5):checked ~ .wg-panes > .wg-pane:nth-child(5),
.wg-radio:nth-of-type(6):checked ~ .wg-panes > .wg-pane:nth-child(6) { display: block; }
.wg-pane { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }

/* Tablo */
.wg-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font: 700 13px/1 var(--f-mono); }
.wg-col-name { width: 150px; }
.wg-col-total { width: 58px; }
.wg-compact .wg-col-name { width: 124px; }
.wg-table th, .wg-table td { padding: 0; text-align: center; border-right: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); }
.wg-table tr > :last-child { border-right: 0; }
.wg-table tbody tr:last-child > * { border-bottom: 0; }
.wg-table thead th { padding: 6px 2px; vertical-align: middle; background: var(--inset); color: var(--muted); font-weight: 500; line-height: 1.15; }
.wg-day-name { display: block; font: 500 10.5px/1.1 var(--f-body); color: var(--muted); }
.wg-day-num { display: block; margin-top: 3px; font: 700 13px/1 var(--f-mono); color: var(--text); }
.wg-day-flag { display: block; margin-top: 3px; font: 600 9.5px/1 var(--f-body); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-table thead th.is-weekend { background: var(--c-weekend-head); }
.wg-table thead th.is-holiday, .wg-table thead th.is-halfday { background: var(--c-holiday); }
.wg-table thead th.is-holiday .wg-day-num, .wg-table thead th.is-halfday .wg-day-num { color: var(--gold); }
/* Ay dışı gün: takvimdeki tarih görünür ama sönük; hücre taralı ve boş. */
.wg-table thead th.is-out { background: var(--inset); }
.wg-table thead th.is-out .wg-day-num { color: var(--muted); font-weight: 500; }

.wg-table td { height: 38px; background: var(--c-empty); color: var(--c-empty-text); }
.wg-table td.is-weekend { background: var(--c-weekend); }
.wg-table td.is-holiday { background: var(--c-holiday); }
.wg-table td.is-out { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--soft) 6px 7px), var(--inset); }
/* Hücre renkleri app'teki ScheduleTable ile aynı (--c-* değişkenleri iki temada tanımlı). */
.wg-table td.c-day { background: var(--c-day); color: #3b2f00; }
.wg-table td.c-night { background: var(--c-night); color: #fff; }
.wg-table td.c-leave { background: var(--c-leave); color: #fff; }
.wg-table td.c-sick { background: var(--c-sick); color: #fff; }
.wg-table td.c-annual { background: var(--c-annual); color: #fff; }
.wg-table td.c-locked { background: var(--c-locked); color: #fff; }
.wg-table td.c-manual { position: relative; }

.wg-table .wg-name {
    padding: 0 12px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: var(--surface); color: var(--text); font: 600 13px/1 var(--f-body);
}
.wg-table thead .wg-name { background: var(--inset); color: var(--muted); font-weight: 500; }
.wg-senior { margin-left: 6px; padding: 2px 5px; border-radius: 4px; background: var(--accent-soft); color: var(--wg-tag-text); font: 600 9.5px/1 var(--f-body); letter-spacing: 0.02em; vertical-align: 1px; }
.wg-table .wg-total { padding: 0 6px; background: var(--inset); color: var(--text); font-variant-numeric: tabular-nums; }

.wg-compact .wg-table { font-size: 12px; }
.wg-compact .wg-table thead th { padding: 5px 2px; }
.wg-compact .wg-table td { height: 36px; }
.wg-compact .wg-table .wg-name { padding: 0 10px; font-size: 12px; }

/* Dar kutu: önce isim sütunu daralır (isim kısalır), gün hücreleri sıkışmaz. */
@container weekgrid (max-width: 560px) {
    .wg-col-name, .wg-compact .wg-col-name { width: 96px; }
    .wg-col-total { width: 44px; }
    .wg-table, .wg-compact .wg-table { font-size: 12px; }
    .wg-table .wg-name, .wg-compact .wg-table .wg-name { padding: 0 8px; font-size: 12px; }
    .wg-senior { display: none; }
}
@container weekgrid (max-width: 400px) {
    .wg-col-name, .wg-compact .wg-col-name { width: 74px; }
    .wg-table .wg-name, .wg-compact .wg-table .wg-name { padding: 0 6px; font-size: 11.5px; }
    .wg-day-name { font-size: 9.5px; }
    .wg-day-num { font-size: 12px; }
    .wg-day-flag, .wg-tab-month { display: none; }
    .wg-tabs label { padding: 0 2px; font-size: 0.74rem; }
}

/* ---------- Ürün penceresi (AppWindow): yan panel genişte sağda, darda tablonun altında ---------- */
.appwin { container: appwin / inline-size; }
.appwin-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 26%); }
.appwin-body > .week-grid { padding: 14px; }
.appwin-body .wg-pane { border-radius: var(--r-sm); }
.appwin-side { min-width: 0; padding: 16px; border-left: 1px solid var(--line); background: var(--inset-2); }
@container appwin (max-width: 719px) {
    .appwin-body { grid-template-columns: minmax(0, 1fr); }
    .appwin-side { border-left: 0; border-top: 1px solid var(--line); }
    .appwin-toolbar .tb-btn:not(.tb-primary) { display: none; }
}
@container appwin (min-width: 420px) and (max-width: 719px) {
    .appwin-side .hours { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
}

/* Adım görseli (ana sayfa "Planlatın"): buton + 3 kişilik hafta; kutu yüksekliği içeriğe göre (site.css .step-visual). */
.step-plan .week-grid { align-self: stretch; }

/* ---------- Lejant: tek satır, sarılabilir, küçük çipler ---------- */
.legend { gap: 6px 14px; font-size: 0.8rem; }
.legend li { gap: 6px; white-space: nowrap; }
.legend .cell { width: 20px; height: 20px; border-radius: 4px; font-size: 10.5px; }

/* "Tüm vardiyalar dolu" yalnız hero'da değil, pencerenin olduğu her yerde belirir. */
.anim .in .side-ok { opacity: 1; transition: opacity .5s 1.2s; }

/* ---------- İmza hareket: "liste kendini dolduruyor" (yalnız Fill="true") ----------
   Plan hücreleri (S/A, .wg-plan) gün gün dolar; istek/izin hücreleri baştan görünür.
   Destekleyen tarayıcıda kaydırmaya bağlı (view timeline); desteklemeyende site.js görünürlük sınıfı (.in)
   bir kez oynatır. anim sınıfı yoksa (JS yok) ya da calm'da dolu hâl. */
.anim [data-reveal="fill"] { opacity: 1; transform: none; }
.wg-fill { --wg-step: 140ms; }
.anim .wg-fill td.wg-plan { opacity: 0; }
.anim .wg-fill.in td.wg-plan {
    animation: wg-cell .4s cubic-bezier(.2, .9, .3, 1.2) both;
    animation-delay: calc(var(--grid-base, 150ms) + var(--d, 0) * var(--wg-step));
}
@keyframes wg-cell { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }

@supports (animation-timeline: view()) {
    .wg-fill .wg-table { view-timeline: --wg-view block; }
    .anim .wg-fill td.wg-plan, .anim .wg-fill.in td.wg-plan {
        animation: wg-cell linear both;
        animation-timeline: --wg-view;
        animation-range: entry calc(var(--d, 0) * 10%) entry calc(var(--d, 0) * 10% + 40%);
    }
    /* Hero ilk ekranda zaten görünür: orada zaman tabanlı kalır ("Planlat"a basılır, sonra dolar). */
    .anim .hero-shot .wg-fill td.wg-plan { animation: none; opacity: 0; }
    .anim .hero-shot .wg-fill.in td.wg-plan {
        animation: wg-cell .4s cubic-bezier(.2, .9, .3, 1.2) both;
        animation-delay: calc(var(--grid-base, 150ms) + var(--d, 0) * var(--wg-step));
    }
}

/* Hareketi azalt: animasyon yok, dolu hâl. */
html.anim.calm .week-grid.wg-fill td.wg-plan { opacity: 1; animation: none; transform: none; }
