/* ============================================================
   COMMON.CSS — общие стили для всех страниц
   Структура:
     1. COMMON      — базовые/общие стили
     2. ABOUTME     — стили страницы «Обо мне»
     3. TERMS       — стили страниц семестров
     4. INDEX       — стили главной страницы
     5. SEMESTERS   — стили страницы списка семестров
     6. MEDIA       — адаптация для планшетов и мобильных (все файлы)
     7. DARK MODE   — тёмная тема: сначала общие, затем мобильные
   ============================================================ */


/* ============================================================
   1. COMMON — базовые стили
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    overflow-y: scroll; /* принудительно включаем полосу прокрутки, иначе header прыгает на ширину прокрутки когда она появляется */
    /* overflow-x: hidden убираем — в Safari iOS ломает position:fixed у header */
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* занимаем весь экран */
    background-color: white;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden; /* не даём широким таблицам расширять страницу */
}

/* ----- Header ----- */

header {
    background-color: white;
    padding: 10px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #1896ad;
    position: fixed;   /* Фиксируем header */
    top: 0;
    left: 0;           /* Явно задаём left:0 чтобы не отлипал */
    right: 0;          /* и right:0 */
    width: 100%;
    z-index: 1000;
    /* Аппаратное ускорение — убирает мерцание/отлипание при скролле на мобильных */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

.header-container {
    width: 90%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    position: relative;
    padding-right: 40px; /* добавляем отступ для кнопки (30px + небольшой запас) */
}

.logo-container {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px solid #1896ad;
    border-radius: 8px;
    overflow: hidden; /* обрезаем лишнее, если вдруг вылезет за пределы */
    background-color: white;
    box-shadow: 4px 4px 8px rgba(24, 150, 173, 0.15);
}

/* для лого и надписи */
.logo-title-wrapper {
    display: flex; /* вдоль */
    align-items: center; /* по-вертикали */
    gap: 20px;
}

.header-text {
    color: #1896ad;
}

.header-text p {
    font-size: 0.7rem;
}

/* ----- Navigation ----- */

nav {
    display: flex;
    gap: 10px;
    align-items: center;
}

nav a {
    color: #1896ad;
    text-decoration: none; /* убираем подчеркивание */
    font-weight: 600; /* полужирный */
    padding: 10px 20px; /* отступы */
    border-radius: 30px;
    transition: all 0.3s ease;
    background-color: rgba(24, 150, 173, 0.1);
    white-space: nowrap; /* отключаем перенос текста */
    box-shadow: 4px 4px 4px rgba(24, 150, 173, 0.15);
}

nav a:hover {
    background-color: rgba(24, 150, 173, 0.25);
    transform: translateY(-2px);
}

nav a.active {
    background-color: #1896ad;
    color: white;
}

/* Выпадающее меню */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 160px;
    box-shadow: 8px 8px 8px rgba(24, 150, 173, 0.15);
    border-radius: 15px;
    overflow: hidden;
    z-index: 1010; /* above header */
    border: 1px solid rgba(24, 150, 173, 0.2);
    margin-top: 5px;
}

.dropdown-content a {
    color: #1896ad;
    padding: 6px 20px;
    text-decoration: none;
    display: block;
    text-align: left;
    background-color: white;
    border-radius: 0;
    white-space: nowrap;
    font-weight: 500;
}

.dropdown-content a:hover {
    background-color: rgba(24, 150, 173, 0.1);
    transform: none;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown > a::after {
    content: " ▼";
    font-size: 0.8em;
    margin-left: 5px;
}

/* ----- Body container ----- */

.body-container {
    flex: 1 0 auto; /* Растягивается на всё доступное пространство по высоте */
    width: 90%;
    max-width: 1200px;
    margin: 0 auto; /* центрируем */
    padding: 40px; /* зазоры по краям */
    margin-top: 130px; /* Отступ для фиксированного header, с запасом */
}

/* Заголовок h2 (semesters, about_me) */
h2 {
    color: #1896ad;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #1896ad;
    font-size: 2rem;
}

/* ----- Кнопки ----- */

/* Контейнер для кнопок, если больше одной */
.button-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 40px;
    flex-wrap: wrap;
}

.back-link {
    display: inline-block;
    margin-top: 30px;
    color: #1896ad;
    text-decoration: none;
    font-weight: 600;
    padding: 10px 25px;
    border-radius: 30px;
    background-color: rgba(24, 150, 173, 0.1);
    transition: all 0.3s ease;
    box-shadow: 4px 4px 4px rgba(24, 150, 173, 0.15);
}

.back-link:hover {
    background-color: rgba(24, 150, 173, 0.25);
    transform: translateY(-2px);
}

/* ----- Footer ----- */

footer {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background-color: rgba(24, 150, 173, 0.25);
    font-size: 0.85rem;
    color: #1896ad;
    padding: 5px 20px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer-left, .footer-center, .footer-right {
    flex: 1;
}

.footer-center {
    text-align: center;
}

.footer-right {
    text-align: right;
}

footer a {
    color: #1896ad;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ----- Кнопка переключения темы ----- */

.theme-toggle-canvas {
    position: absolute;
    right: -20px; /* сдвигаем вправо за пределы контейнера */
    top: 0;
    width: 34px;
    height: 34px;
    cursor: pointer;
    background-color: transparent;
    transition: opacity 0.3s ease;
    border: none;
    box-shadow: none;
}

.theme-toggle-canvas:hover {
    opacity: 0.7;
}


/* ============================================================
   2. стили страницы «Обо мне»
   ============================================================ */

/* Основной контейнер (фото + текст) */
.about-content {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    align-items: flex-start;
    box-shadow: 0 5px 20px rgba(24, 150, 173, 0.08);
    border: 1px solid rgba(24, 150, 173, 0.15);
    padding: 20px;
    border-radius: 15px;
}

/* Текстовый блок */
.text-block {
    margin-top: 30px;
    flex: 1;
    min-width: 400px;
    text-align: justify;
}

.text-block p {
    margin-bottom: 15px;
    text-align: justify;
    text-indent: 30px;
}

.text-block .citatum {
    font-size: 0.7rem;
    text-align: right;
    color: #1896ad;
    margin: 0;
    padding: 0;
    font-style: italic;
}

/* Списки */
.text-block ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

/* Контейнер для фото */
.image-block {
    flex: 0 0 350px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Фото */
.image-block img {
    max-width: 100%;
    z-index: 999;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.3s ease;
    margin-top: 10px;
    margin-bottom: 30px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); /* Тень вокруг*/    
}

.image-block img:hover {
    transform: scale(1.02);
}

/* Контейнер для кнопок email */
.email-buttons {
    display: flex;
    gap: 15px;
    justify-content: right;
    width: 100%;
}

/* ----- Модальное окно (увеличенное фото) ----- */
.modal {
    display: none;
    position: fixed;
    z-index: 1200; /* above header (1000) and dropdowns (1010) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(250, 250, 250, 0.95); /* светлая тема: серое + рамка */
    backdrop-filter: blur(8px); /*blur*/
    -webkit-backdrop-filter: blur(8px); /* blur for Safari */    
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    overflow: hidden;    /*блокировка прокрутки когда активен modal*/
}

.modal[style*="display: block"] {
    opacity: 1;
}

/* Контейнер модального окна */
.modal-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* Изображение в модальном окне */
.modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); /* тень для светлой темы */
}

/* photo-trigger */
.photo-trigger {
    cursor: pointer;
}

.photo-trigger:focus-visible {
    outline: 2px solid #1896ad;
    outline-offset: 2px;
}

/* ----- Кнопка зума в модальном окне ----- */
#modal-zoom-btn {
    display: none; /* показывается только когда картинка больше окна */
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1300; /* above modal overlay */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #1896ad;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    transition: background-color 0.2s ease, transform 0.15s ease;
}

#modal-zoom-btn:hover {
    background-color: rgba(255, 255, 255, 0.82);
    transform: scale(1.1);
}

#modal-zoom-btn svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* zoom percent label — shown to the left of the zoom button while in pan mode */
#modal-zoom-pct {
    display: none;
    position: fixed;
    top: 40px;                    /* center of the button: 18px + 44px/2 */
    transform: translateY(-50%);  /* pull up by own half-height → perfect centering */
    right: 72px;                  /* 18px margin + 44px button + 10px gap */
    z-index: 1300; /* above modal overlay */
    font-size: 1.5rem;
    font-weight: 600;
    color: #1896ad;
    background-color: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    pointer-events: none; /* never intercepts clicks */
    white-space: nowrap;
}


/* ============================================================
   3. стили страниц семестров
   ============================================================ */

/* Список ссылок */
.links-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 30px auto;
    text-align: left;
    max-width: 800px;
}

/* Элементы списка ссылок */
.links-list li a {
    display: block;
    padding: 12px 18px;
    background-color: rgba(24, 150, 173, 0.05);
    border-left: 4px solid #1896ad;
    border-radius: 0 8px 8px 0;
    color: #1896ad;
    text-decoration: none;
    font-weight: 500;
    transition: 0.2s;
    word-break: break-word;
}

.links-list li a:hover {
    background-color: rgba(24, 150, 173, 0.1);
    padding-left: 24px;
}

/* Для внешних ссылок */
.links-list li a[href^="http"] {
    position: relative;
    padding-right: 35px;
}

.links-list li a[href^="http"]::after {
    content: "↗";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.links-list li a[href^="http"]:hover::after {
    opacity: 1;
}


/* ============================================================
   4. стили главной страницы
   ============================================================ */

/* Блок «Добро пожаловать» */
.welcome-section {
    position: relative;
    background: linear-gradient(135deg, #f0f9fa 0%, white 100%);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 40px; /* отступ снизу до следующего блока */
    border: 1px solid rgba(24, 150, 173, 0.2);
    min-height: 250px;
}

.welcome-section p {
    font-size: calc(0.7rem + 0.25vw);
    margin-bottom: 10px;
}

.welcome-section h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #1896ad;
}

/* Блок кнопок-ссылок */
.main-blocks {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* формируем 3 блока */
    gap: 30px;
}

/* Блоки с информацией */
.info-block {
    border-radius: 15px;
    padding: 30px 25px;
    box-shadow: 0 5px 20px rgba(24, 150, 173, 0.08);
    border: 1px solid rgba(24, 150, 173, 0.15);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    font-size: calc(0.6rem + 0.25vw);
    position: relative;
}

/* Делаем активной ссылкой весь блок-кнопку */
.info-block .block-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.info-block:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(24, 150, 173, 0.15);
    border-color: #1896ad;
}

.info-block h3 {
    color: #1896ad;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(24, 150, 173, 0.2);
    font-size: calc(1rem + 0.25vw);
}

.info-block p {
    color: #666;
    margin-bottom: 20px;
    flex-grow: 1;
}

/* Кнопка «перейти» */
.block-link {
    display: inline-block;
    color: white;
    background-color: #1896ad;
    text-decoration: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    align-self: flex-start;
}


/* ============================================================
   5. стили страницы списка семестров
   ============================================================ */

/* Список семестров */
.semesters-list {
    list-style: none;
    max-width: 900px;
    margin: 0 auto;
}

/* Элемент списка */
.semester-item {
    margin-bottom: 20px;
    background-color: white;
    border-radius: 15px;
    border: 1px solid rgba(24, 150, 173, 0.2);
    transition: all 0.3s ease;
}

.semester-item:hover {
    box-shadow: 0 8px 25px rgba(24, 150, 173, 0.15);
    border-color: #1896ad;
    transform: translateY(-3px);
}

/* Ссылка-обёртка семестра */
.semester-link {
    display: flex;
    align-items: center;
    gap: 20px;
    text-decoration: none;
    padding: 25px;
    border-radius: 15px;
}

/* Информационный блок */
.semester-info {
    flex-grow: 1;
}

/* Заголовок семестра */
.semester-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1896ad;
    margin-bottom: 8px;
}

/* Описание семестра */
.semester-desc {
    color: #666;
    font-size: 1rem;
    margin-bottom: 8px;
}

/* Год обучения */
.semester-year {
    color: #999;
    font-size: 0.9rem;
    display: inline-block;
    padding: 3px 12px;
    background-color: rgba(24, 150, 173, 0.1);
    border-radius: 20px;
}

/* Кнопка перехода в конкретный семестр */
.semester-status {
    color: white;
    background-color: #1896ad;
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.semester-status.disabled {
    background-color: #999;
}


/* ============================================================
   6. адаптация для планшетов и мобильных
   ============================================================ */

/* ----- Планшеты ----- */
@media (max-width: 1100px) {
    .about-content {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .image-block {
        flex: 0 0 auto;
        width: auto;
        max-width: 100%;
    }

    .image-block img {
        margin-bottom: 0;
        max-width: 300px;
    }

    .text-block {
        min-width: unset;
        width: 100%;
        margin-top: 0;
    }
}

/* ----- Мобильные ----- */
@media (max-width: 768px) {

    /* common: header */
    header {
        position: relative !important;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0;
        padding: 10px 0;
    }

    .header-container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 5px 10px;
        padding-right: 35px; /* чуть меньше на мобильных */
    }

    .logo-title-wrapper {
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 10px;
    }

    .logo-container {
        flex-shrink: 0;
    }

    .header-text h3 {
        font-size: 1rem;
    }

    .header-text p {
        font-size: 0.6rem;
    }

    /* common: nav */
    nav {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    nav a {
        padding: 7px 14px;
        font-size: 0.85rem;
    }

    .dropdown-content {
        position: absolute;
        box-shadow: 8px 8px 8px rgba(24, 150, 173, 0.15);
        margin-top: 5px;
        border: 1px solid rgba(24, 150, 173, 0.2);
    }

    .dropdown-content a {
        padding-left: 20px;
    }

    /* common: body-container */
    .body-container {
        margin-top: 0;
        padding: 20px 10px;
        width: 100%;
        max-width: 100%;
    }

    .body-container h2 {
        margin: 0 0 30px 0;
        padding: 0 0 15px 0;
        border-bottom: 2px solid #1896ad;
        font-size: 1.3rem;
    }

    /* common: кнопки */
    .button-container {
        gap: 10px;
        margin-top: 20px;
    }

    .back-link {
        font-size: 0.8rem;
    }

    /* common: footer */
    footer {
        font-size: 0.4rem;
        padding: 5px 8px;
    }

    /* common: кнопка темы */
    .theme-toggle-canvas {
        width: 30px;
        height: 30px;
        right: -15px;
        top: 5px;
    }

    /* aboutme: текст */
    .text-block {
        margin-top: 0;
        min-width: unset;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .text-block p {
        font-size: 0.8rem;
        line-height: 1.6;
        margin-bottom: 20px;
        text-align: justify;
        text-indent: 20px;
    }

    .text-block li {
        font-size: 0.9rem;
        line-height: 1.6;
        margin-bottom: 5px;
    }

    /* aboutme: контейнер */
    .about-content {
        flex-direction: column;
        gap: 10px;
        margin: 0;
        padding: 15px;
    }

    /* aboutme: фото */
    .image-block {
        flex: 0 0 auto;
        width: 100%;
        align-items: center;
        margin: 0;
        padding: 0;
    }

    .image-block img {
        max-width: 250px;
        margin: 0 0 0 0;
        z-index: auto;
    }

    /* aboutme: email-кнопки */
    .email-buttons {
        flex-direction: row;
        justify-content: right;
        gap: 15px;
        margin: 0;
        padding: 0;
    }

    /* aboutme: списки */
    ul {
        margin-left: 20px;
        margin-bottom: 20px;
        margin-top: 0;
        padding-left: 0;
    }

    /* index: блоки */
    .main-blocks {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .welcome-section {
        padding: 20px 15px;
        min-height: unset; /* убираем min-height */
        margin-bottom: 25px;
    }

    .welcome-section h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }

    .welcome-section p {
        font-size: 1rem;
    }

    .info-block {
        padding: 20px 15px;
        font-size: 0.8rem;
    }

    /* semesters */
    .semester-link {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .semester-status {
        width: 100%;
    }

    .semester-title {
        font-size: 1.2rem;
    }

    .semester-desc {
        font-size: 0.9rem;
    }
}


/* ============================================================
   7. DARK MODE — тёмная тема
   Класс dark-mode на <html>. Хранится в sessionStorage — живёт пока открыт браузер,
   сбрасывается при закрытии. Применяется на всех страницах сразу.
   ============================================================ */

/* ----- 7.1 Общие ----- */

:root.dark-mode body {
    background-color: #2c3e50;
    color: #ecf0f1;
}

:root.dark-mode header {
    background-color: #2c3e50;
    border-bottom-color: #1896ad;
}

:root.dark-mode .logo-container {
    background-color: #2c3e50;
}

:root.dark-mode .header-text {
    color: #1896ad;
}

:root.dark-mode nav a {
    color: #ecf0f1;
    background-color: rgba(255, 255, 255, 0.1);
}

:root.dark-mode nav a.active {
    background-color: #1896ad;
    color: white;
}

:root.dark-mode .dropdown-content {
    background-color: #34495e;
    border-color: rgba(24, 150, 173, 0.4);
}

:root.dark-mode .dropdown-content a {
    color: #ecf0f1;
    background-color: #34495e;
}

:root.dark-mode .dropdown-content a:hover {
    background-color: rgba(24, 150, 173, 0.2);
}

:root.dark-mode footer {
    background-color: rgba(24, 150, 173, 0.15);
}

/* aboutme: тёмная тема */
html.dark-mode .about-content {
    border-color: rgba(24, 150, 173, 0.3);
}

html.dark-mode .text-block p {
    color: #ecf0f1;
}

html.dark-mode .text-block .citatum {
    color: #1896ad;
}

/* aboutme: модальное окно — тёмная тема */
html.dark-mode .modal {
    background-color: rgba(44, 62, 80, 0.97); /*затемнение*/
    backdrop-filter: blur(8px); /*blur*/
    -webkit-backdrop-filter: blur(8px); /*blur for safari*/
    border: 1px solid rgba(255, 255, 255, 0.1);
}

html.dark-mode .modal img {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

html.dark-mode #modal-zoom-btn {
    background-color: rgba(44, 62, 80, 0.7);
    color: #ecf0f1;
}

html.dark-mode #modal-zoom-btn:hover {
    background-color: rgba(44, 62, 80, 0.92);
}

html.dark-mode #modal-zoom-pct {
    background-color: rgba(44, 62, 80, 0.7);
    color: #ecf0f1;
}

/* index: тёмная тема */
html.dark-mode .welcome-section {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

html.dark-mode .info-block {
    background-color: #34495e;
    border-color: rgba(255, 255, 255, 0.1);
}

html.dark-mode .info-block h3 {
    color: #5bc0de;
}

html.dark-mode .info-block p {
    color: #bdc3c7;
}

/* semesters: тёмная тема */
html.dark-mode .semester-item {
    background-color: #34495e;
    border-color: rgba(24, 150, 173, 0.3);
}

html.dark-mode .semester-title {
    color: #5bc0de;
}

html.dark-mode .semester-desc {
    color: #bdc3c7;
}

