/* =================================================================
   styles.css — стили Telegram Web App «Абитуриент колледжа СКФУ»

   Концепция: академический минимализм с цветовой палитрой
   фирменного стиля СКФУ (тёмно-синий + золото).
   ================================================================= */

/* ---------- CSS-переменные (легко менять цвета и метрики) ---------- */
:root {
    /* Палитра СКФУ */
    --color-primary:        #0c2461;   /* тёмно-синий */
    --color-primary-dark:   #061238;
    --color-primary-light:  #1e3a8a;
    --color-accent:         #c89b3c;   /* золото */
    --color-accent-soft:    #e8c97a;

    /* Нейтральные */
    --color-bg:             #f6f4ef;   /* кремовый фон */
    --color-surface:        #ffffff;
    --color-surface-alt:    #faf8f3;
    --color-text:           #1a1a2e;
    --color-text-muted:     #6b7180;
    --color-border:         #e6e2d8;

    /* Состояния */
    --color-success:        #16a34a;
    --color-error:          #dc2626;

    /* Telegram-переменные (используются по умолчанию, если бот в Telegram) */
    --tg-bg:    var(--tg-theme-bg-color, var(--color-bg));
    --tg-text:  var(--tg-theme-text-color, var(--color-text));

    /* Метрики */
    --radius-sm:   8px;
    --radius:      14px;
    --radius-lg:   22px;
    --shadow-sm:   0 1px 2px rgba(12, 36, 97, .06);
    --shadow:      0 4px 18px rgba(12, 36, 97, .08);
    --shadow-lg:   0 12px 40px rgba(12, 36, 97, .12);

    /* Шрифты */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body:    'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    /* Высота нижней навигации: примерно 56px + safe-area
       (используется и в padding контента, и в самой навигации) */
    --nav-height: calc(56px + var(--safe-bottom));
}

/* ---------- Базовый сброс ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--color-text);
    background: var(--color-bg);
    /* Декоративная сетка-фон */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(200, 155, 60, .04) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(12, 36, 97, .04) 0%, transparent 50%);
    overflow-x: hidden;
    /* min-height фиксирует поведение в Telegram WebApp */
    min-height: 100vh;
    min-height: 100dvh;  /* dynamic viewport height — учитывает адресную строку */
}

/* ============================ ШАПКА ============================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-primary);
    color: #fff;
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-mark {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    /* SVG-щит сам по себе с прозрачным фоном, без скруглений */
    object-fit: contain;
    /* Тонкая тень для глубины */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .3));
}

.logo-text { display: flex; flex-direction: column; gap: 2px; }

.logo-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    line-height: 1;
}

.logo-subtitle {
    font-size: 12px;
    opacity: 0.75;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ============================ ЭКРАНЫ ============================ */
.screen {
    display: none;
    /* Нижний отступ = высота nav + воздух. Применяется К КАЖДОМУ экрану,
       чтобы последняя карточка в любом разделе не пряталась под навигацию. */
    padding: 20px 18px calc(var(--nav-height) + 40px);
    max-width: 720px;
    margin: 0 auto;
    animation: fadeUp .35s ease-out;
}

.screen.active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);  }
}

/* ============================ ГЛАВНАЯ ============================ */
.hero {
    padding: 18px 0 24px;
    position: relative;
}

.hero-badge {
    display: inline-block;
    padding: 6px 14px;
    background: var(--color-primary);
    color: var(--color-accent-soft);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(26px, 7vw, 36px);
    line-height: 1.1;
    margin: 0 0 12px;
    color: var(--color-primary-dark);
    letter-spacing: -0.5px;
}

.hero-title em {
    font-style: italic;
    color: var(--color-accent);
}

.hero-text {
    font-size: 15px;
    color: var(--color-text-muted);
    max-width: 460px;
    margin: 0;
}

/* ============================ МЕНЮ-СЕТКА ============================ */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

.menu-card {
    appearance: none;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 18px 16px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 110px;
    position: relative;
    transition: transform .15s ease, box-shadow .15s ease,
                border-color .15s ease;
    font-family: inherit;
    color: inherit;
}

.menu-card:hover, .menu-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--color-primary-light);
}

.menu-icon { font-size: 28px; line-height: 1; }

.menu-label {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
    margin-top: auto;
}

.menu-arrow {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--color-text-muted);
    font-size: 18px;
    transition: transform .15s ease;
}

.menu-card:hover .menu-arrow { transform: translateX(3px); }

.menu-card-wide { grid-column: 1 / -1; }

.menu-card.accent {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: #fff;
    border-color: transparent;
}

.menu-card.accent .menu-arrow { color: var(--color-accent-soft); }

/* =================== ВНУТРЕННИЕ ЭКРАНЫ =================== */
.back-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--color-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 12px;
    transition: opacity .15s;
}

.back-btn:hover { opacity: .7; }

.screen-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 30px;
    line-height: 1.15;
    margin: 0 0 8px;
    color: var(--color-primary-dark);
    letter-spacing: -0.5px;
}

.screen-subtitle {
    color: var(--color-text-muted);
    font-size: 14px;
    margin: 0 0 22px;
}

.content-block {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow-sm);
}

.content-block + .content-block { margin-top: 14px; }

.content-block h3 {
    font-family: var(--font-display);
    font-size: 19px;
    margin: 0 0 12px;
    color: var(--color-primary);
}

.content-block h3:not(:first-child) { margin-top: 22px; }

.content-block ul {
    padding-left: 0;
    list-style: none;
    margin: 0;
}

.content-block ul li {
    position: relative;
    padding: 9px 0 9px 28px;
    border-bottom: 1px dashed var(--color-border);
    font-size: 14px;
}

.content-block ul li:last-child { border-bottom: none; }

.content-block ul li::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 16px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
}

.content-block p { margin: 10px 0; }

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--color-border);
    gap: 12px;
    font-size: 14px;
}

.info-row:last-child { border-bottom: none; }

.info-row-label {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.info-row-value {
    font-weight: 600;
    text-align: right;
}

/* =================== СПИСОК СПЕЦИАЛЬНОСТЕЙ =================== */
.specialties-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.specialty-card {
    appearance: none;
    text-align: left;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.specialty-card:hover {
    border-left-color: var(--color-primary);
    box-shadow: var(--shadow);
    transform: translateX(2px);
}

.specialty-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.specialty-info { flex: 1; min-width: 0; }

.specialty-code {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.specialty-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-primary-dark);
    margin-bottom: 4px;
}

.specialty-meta {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* =================== ДЕТАЛЬНАЯ СПЕЦИАЛЬНОСТЬ =================== */
.detail-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 24px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.detail-header::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(200, 155, 60, .25) 0%, transparent 70%);
    pointer-events: none;
}

.detail-icon { font-size: 50px; margin-bottom: 8px; }

.detail-code {
    font-size: 12px;
    color: var(--color-accent-soft);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.detail-name {
    font-family: var(--font-display);
    font-size: 24px;
    line-height: 1.2;
    margin: 0;
}

/* =================== СТОИМОСТЬ =================== */
.cost-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.cost-info { flex: 1; min-width: 0; }

.cost-code {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 1px;
}

.cost-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2px;
}

.cost-price {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--color-primary);
    white-space: nowrap;
}

/* =================== FAQ =================== */
.faq-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
    transition: box-shadow .15s;
}

.faq-item.open { box-shadow: var(--shadow); }

.faq-question {
    appearance: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    padding: 16px 18px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
}

.faq-icon { font-size: 22px; flex-shrink: 0; }

.faq-text { flex: 1; }

.faq-toggle {
    margin-left: auto;
    color: var(--color-accent);
    font-size: 18px;
    transition: transform .25s ease;
    flex-shrink: 0;
}

.faq-item.open .faq-toggle { transform: rotate(45deg); }

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
}

.faq-answer-inner {
    padding: 0 18px 16px 52px;
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.6;
    white-space: pre-line;
}

/* =================== ФОРМА ВОПРОСА =================== */
.ask-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.question-input {
    width: 100%;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-surface-alt);
    resize: vertical;
    min-height: 130px;
    transition: border-color .15s;
}

.question-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: #fff;
}

.char-counter {
    text-align: right;
    color: var(--color-text-muted);
    font-size: 12px;
    margin: 6px 0 14px;
}

.submit-btn {
    appearance: none;
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: 15px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 15px;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: transform .15s, box-shadow .15s;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.submit-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.ask-result {
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: none;
}

.ask-result.success {
    display: block;
    background: rgba(22, 163, 74, .08);
    color: var(--color-success);
    border: 1px solid rgba(22, 163, 74, .25);
}

.ask-result.error {
    display: block;
    background: rgba(220, 38, 38, .08);
    color: var(--color-error);
    border: 1px solid rgba(220, 38, 38, .25);
}

/* =================== НИЖНЯЯ НАВИГАЦИЯ =================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    /* Высота навигации = 56px (8px + контент + 8px) + safe-area */
    padding: 8px 0 calc(8px + var(--safe-bottom));
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(12, 36, 97, .05);
    /* Подстраховка для iOS - предотвращает поднятие nav при появлении клавиатуры */
    transform: translateZ(0);
}

.nav-item {
    appearance: none;
    background: transparent;
    border: none;
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--color-text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    transition: color .15s;
}

.nav-item.active { color: var(--color-primary); }

.nav-item:hover { color: var(--color-primary-light); }

/* =================== ЗАГРУЗЧИК =================== */
.loader {
    position: fixed;
    inset: 0;
    background: rgba(246, 244, 239, .85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.loader.hidden { display: none; }

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =================== ССЫЛКИ И УТИЛИТЫ =================== */
.tel-link, .mail-link {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dashed var(--color-accent);
}

.tel-link:hover, .mail-link:hover { color: var(--color-accent); }

/* =================== АДАПТИВ ДЛЯ МАЛЕНЬКИХ ЭКРАНОВ =================== */
@media (max-width: 360px) {
    .menu-card { min-height: 95px; padding: 14px 12px; }
    .menu-icon { font-size: 24px; }
    .menu-label { font-size: 13px; }
    .hero-title { font-size: 24px; }
    .screen-title { font-size: 26px; }
}

/* =================== ТЁМНАЯ ТЕМА (если Telegram в dark mode) =================== */
body.tg-dark {
    --color-bg:          #15171c;
    --color-surface:     #1e2128;
    --color-surface-alt: #252830;
    --color-text:        #f0f0f5;
    --color-text-muted:  #8b92a3;
    --color-border:      #2d3140;
    --color-primary:     #4267b2;
    --color-primary-light: #5b7bd0;
    --color-primary-dark:  #2a4a8c;
}

body.tg-dark .hero-title { color: #f5f5f5; }
body.tg-dark .screen-title { color: #f5f5f5; }
body.tg-dark .question-input { background: var(--color-surface-alt); color: #f0f0f5; }
