/* ==========================================================================
   SUMWIN — сезонний перемикач «Зима / Літо»
   Палітра і шрифт — з теми sumwin.pp.ua (style.css):
   #2E2B2E вугільний · #FFFFFF · #F6F6FA холодний світлий · #D8D6D8 лінія
   #A3A6AF приглушений · #4B5B90 акцент (лише фокус) · Open Sans 300/600/800.
   Одна подія — один рух: плашка їде, календар заливається хвилею,
   фото відкриваються шторкою з того боку, куди поїхала плашка.
   ========================================================================== */

.sw-season {
    --ink: #2E2B2E;
    --paper: #FFFFFF;
    --mist: #F6F6FA;
    --rule: #D8D6D8;
    --mute: #A3A6AF;
    --mute-2: #848383;
    --focus: #4B5B90;
    --shade: rgba(46, 43, 46, 0.7);
    --ease-slide: cubic-bezier(0.65, 0, 0.25, 1);
    --t-slide: 0.55s;

    font-family: 'Open Sans', sans-serif;
    color: var(--ink);
    margin: 56px auto 72px;
}

/* --------------------------------------------------------------------------
   Шапка: назва + підказка зліва, перемикач справа, календар — на всю ширину
   -------------------------------------------------------------------------- */
.sw-season__head {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "title  switch"
        "hint   switch"
        "cal    cal";
    column-gap: 40px;
    align-items: end;
    margin-bottom: 20px;
}

.sw-season__title {
    grid-area: title;
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 400;
    line-height: 1.2;
    text-align: left;               /* тема центрує всі h1–h6 */
    text-transform: uppercase;      /* як .title теми */
}

.sw-season__hint {
    grid-area: hint;
    margin: 0;
    min-height: 1.5em;
    color: var(--mute-2);
    font-size: 15px;
    font-weight: 300;
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Перемикач: рамка, всередині їздить вугільна плашка
   -------------------------------------------------------------------------- */
.sw-season__switch {
    grid-area: switch;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--ink);
    background: var(--paper);
    isolation: isolate;
}

.sw-season__thumb {
    position: absolute;
    inset: 0 auto 0 0;
    width: 50%;
    background: var(--ink);
    z-index: -1;
    transition: translate var(--t-slide) var(--ease-slide);
}

.sw-season[data-sw-season="summer"] .sw-season__thumb {
    translate: 100% 0;
}

.sw-season__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 168px;
    height: 56px;
    padding: 0 28px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: 800 14px/1 'Open Sans', sans-serif;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.25s ease 0.12s, background-color 0.2s ease;
}

.sw-season__btn svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    stroke: currentColor;
    transition: rotate var(--t-slide) var(--ease-slide);
}

/* Відповідь на дію: сніжинка повертається на 60°, сонце — на 45° */
.sw-season__btn[data-season="winter"][aria-selected="true"] svg { rotate: 60deg; }
.sw-season__btn[data-season="summer"][aria-selected="true"] svg { rotate: 45deg; }

.sw-season__btn[aria-selected="true"] {
    color: var(--paper);
    cursor: default;
}

.sw-season__btn[aria-selected="false"]:hover {
    background-color: var(--mist);
}

.sw-season__btn:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    position: relative;
    z-index: 1;
}

/* --------------------------------------------------------------------------
   Календар-лінійка: 12 місяців, починаючи з поточного
   -------------------------------------------------------------------------- */
.sw-cal {
    grid-area: cal;
    margin-top: 28px;
}

.sw-cal__segs,
.sw-cal__months {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    column-gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Підписи сезонів над відрізками */
.sw-cal__seg {
    padding-bottom: 8px;
    overflow: hidden;
    color: var(--mute);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.sw-season[data-sw-season="winter"] .sw-cal__seg[data-season="winter"],
.sw-season[data-sw-season="summer"] .sw-cal__seg[data-season="summer"] {
    color: var(--ink);
    font-weight: 800;
}

/* Місяці: смужка + коротка назва */
.sw-cal__month {
    position: relative;
    padding-top: 10px;
    color: var(--mute);
    font-size: 12px;
    font-weight: 600;
    transition: color 0.3s ease calc(var(--i, 0) * 35ms);
}

.sw-cal__month::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--rule);
    transition: background-color 0.3s ease calc(var(--i, 0) * 35ms);
}

.sw-season[data-sw-season="winter"] .sw-cal__month[data-season="winter"],
.sw-season[data-sw-season="summer"] .sw-cal__month[data-season="summer"] {
    color: var(--ink);
}

.sw-season[data-sw-season="winter"] .sw-cal__month[data-season="winter"]::before,
.sw-season[data-sw-season="summer"] .sw-cal__month[data-season="summer"]::before {
    background: var(--ink);
}

/* Поточний місяць: вища смужка і позначка «зараз» */
.sw-cal__month.is-now::before {
    top: -4px;
    height: 7px;
}

.sw-cal__now {
    display: block;
    color: var(--ink);
    font-size: 11px;
    font-weight: 300;
    line-height: 1.3;
}

/* --------------------------------------------------------------------------
   Плитки (поведінка .season a / .mask / .name з теми)
   -------------------------------------------------------------------------- */
.sw-season__panel[hidden] {
    display: none;
}

.sw-season__grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    grid-auto-rows: 250px;
    gap: 10px;
}

.sw-season__grid > .sw-tile:first-child {
    grid-row: span 2;
}

.sw-tile {
    position: relative;
    display: block;
    overflow: hidden;
    background-color: var(--mist);
    background-size: cover;
    background-position: center;
    text-decoration: none;
    view-transition-class: sw-slot;
}

.sw-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.45) 92%);
}

.sw-tile .mask {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 2;
    width: 100%;
    height: 0;
    background: var(--shade);
    transition: height 0.45s ease-in-out;
}

.sw-tile .name {
    position: absolute;
    left: 22px;
    bottom: 20px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--paper);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sw-tile .name svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    opacity: 0;
    translate: -4px 4px;
    transition: opacity 0.3s ease, translate 0.3s ease;
}

.sw-tile:hover .mask,
.sw-tile:focus-visible .mask {
    height: 100%;
}

.sw-tile:hover .name svg,
.sw-tile:focus-visible .name svg {
    opacity: 1;
    translate: 0 0;
}

.sw-tile:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

/* Чипи категорій */
.sw-season__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.sw-chip {
    display: inline-block;
    padding: 9px 14px;
    border: 1px solid var(--rule);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sw-chip:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

.sw-chip:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Шторка: View Transitions (Chrome/Edge 111+, Safari 18+, Firefox 144+).
   Без підтримки — проста поява панелі через @starting-style.
   -------------------------------------------------------------------------- */
.sw-season__panel:not([hidden]) .sw-tile:nth-child(1) { view-transition-name: sw-slot-1; }
.sw-season__panel:not([hidden]) .sw-tile:nth-child(2) { view-transition-name: sw-slot-2; }
.sw-season__panel:not([hidden]) .sw-tile:nth-child(3) { view-transition-name: sw-slot-3; }
.sw-season__panel:not([hidden]) .sw-tile:nth-child(4) { view-transition-name: sw-slot-4; }
.sw-season__panel:not([hidden]) .sw-tile:nth-child(5) { view-transition-name: sw-slot-5; }
.sw-season__panel:not([hidden]) .sw-tile:nth-child(6) { view-transition-name: sw-slot-6; }
.sw-season__panel:not([hidden]) .sw-season__chips      { view-transition-name: sw-chips; }

/* Анімуємо лише плитки: решта сторінки жива й клікабельна */
html.sw-vt {
    view-transition-name: none;
}

html.sw-vt::view-transition {
    pointer-events: none;
}

html.sw-vt::view-transition-group(.sw-slot) {
    animation-duration: 0.75s;
}

html.sw-vt::view-transition-old(.sw-slot),
html.sw-vt::view-transition-new(.sw-slot) {
    mix-blend-mode: normal;
    height: 100%;
}

html.sw-vt::view-transition-old(.sw-slot) {
    animation: sw-dim 0.75s ease both;
}

html.sw-vt::view-transition-new(.sw-slot) {
    animation: sw-wipe-from-right 0.75s cubic-bezier(0.65, 0, 0.25, 1) both;
}

html.sw-vt.sw-vt--to-winter::view-transition-new(.sw-slot) {
    animation-name: sw-wipe-from-left;
}

/* Сходинка: плитки відкриваються одна за одною */
html.sw-vt::view-transition-new(sw-slot-2) { animation-delay: 70ms; }
html.sw-vt::view-transition-new(sw-slot-3) { animation-delay: 140ms; }
html.sw-vt::view-transition-new(sw-slot-4) { animation-delay: 210ms; }
html.sw-vt::view-transition-new(sw-slot-5) { animation-delay: 280ms; }
html.sw-vt::view-transition-new(sw-slot-6) { animation-delay: 350ms; }

/* Чипи: старі йдуть, потім з'являються нові — без подвійного накладання */
html.sw-vt::view-transition-group(sw-chips) {
    animation-duration: 0.45s;
}

html.sw-vt::view-transition-old(sw-chips) {
    animation: sw-fade-out 0.18s ease-in both;
}

html.sw-vt::view-transition-new(sw-chips) {
    animation: sw-fade-in 0.3s ease-out 0.2s both;
}

@keyframes sw-fade-out {
    to { opacity: 0; }
}

@keyframes sw-fade-in {
    from { opacity: 0; translate: 0 4px; }
}

@keyframes sw-wipe-from-right {
    from { clip-path: inset(0 0 0 100%); }
    to   { clip-path: inset(0 0 0 0); }
}

@keyframes sw-wipe-from-left {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0 0 0); }
}

/* Старе фото не зникає, а темнішає — як маска #2E2B2E на плитках теми */
@keyframes sw-dim {
    to { filter: brightness(0.45) saturate(0.7); }
}

/* Запасний варіант без View Transitions */
html:not(.sw-vt) .sw-season__panel {
    transition: opacity 0.35s ease;
}

@starting-style {
    html:not(.sw-vt) .sw-season.is-ready .sw-season__panel:not([hidden]) {
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   Адаптив — брейкпоінти теми (1000 / 740)
   -------------------------------------------------------------------------- */
@media (max-width: 1000px) {
    .sw-season {
        margin: 36px auto 48px;
    }
    .sw-season__head {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "switch"
            "hint"
            "cal";
        row-gap: 14px;
    }
    .sw-season__title {
        margin: 0;
        font-size: 22px;
    }
    .sw-season__switch {
        justify-self: start;
    }
    .sw-season__grid {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 190px;
    }
    .sw-cal {
        margin-top: 6px;
    }
}

@media (max-width: 740px) {
    .sw-season__switch {
        justify-self: stretch;
    }
    .sw-season__btn {
        min-width: 0;
        height: 50px;
        padding: 0 12px;
        font-size: 13px;
        gap: 10px;
    }
    .sw-season__hint {
        font-size: 14px;
    }
    .sw-cal__segs,
    .sw-cal__months {
        column-gap: 2px;
    }
    .sw-cal__seg {
        font-size: 12px;
    }
    .sw-cal__seg[data-span="1"] {
        visibility: hidden;     /* однокоміркове «зима» не вміщується */
    }
    .sw-cal__month {
        font-size: 10px;
        letter-spacing: -0.2px;
    }
    .sw-season__grid {
        grid-auto-rows: 145px;  /* як .season a теми на мобільному */
        gap: 6px;
    }
    .sw-tile .name {
        left: 14px;
        bottom: 13px;
        font-size: 14px;
    }
    .sw-chip {
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* --------------------------------------------------------------------------
   Менше руху — за налаштуваннями системи
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .sw-season__thumb,
    .sw-season__btn,
    .sw-season__btn svg,
    .sw-cal__month,
    .sw-cal__month::before,
    .sw-cal__seg,
    .sw-tile .mask,
    .sw-tile .name svg,
    html:not(.sw-vt) .sw-season__panel {
        transition: none;
    }
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }
}
