/* Inter Variable */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/Inter.ttf') format('truetype');
}

/* IBM Plex Sans Variable */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url('../fonts/IBM.ttf') format('truetype');
}

/* ==================== ROOT VARIABLES ==================== */
:root {
    /* Цвета - общие */
    --accent-primary: rgba(255, 255, 255, 0.15);
    --accent-black: #000;
    --bg-dark: #0a0a0a;
    --bg-gradient-start: #0a0a0a;
    --bg-gradient-end: #1a1a1a;
    --color-text-primary: #fff;
    --color-text-muted: #666;
    --color-text-secondary: #d0d0d0;
    --color-text-dimmed: rgba(255, 255, 255, 0.6);
    
    /* Прозрачные overlay */
    --color-overlay-light: rgba(255, 255, 255, 0.06);
    --color-overlay-medium: rgba(255, 255, 255, 0.08);
    --color-overlay-dark: rgba(0, 0, 0, 0.3);
    
    /* Границы */
    --color-border-subtle: rgba(255, 255, 255, 0.1);
    --color-border-medium: rgba(255, 255, 255, 0.12);
    --color-border-strong: rgba(255, 255, 255, 0.15);
    
    /* Фоны градиентов */
    --gradient-glow: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    --gradient-fade-dark: rgba(10, 10, 10, 0.9);
    
    /* Пикер - фоны для градиентов */
    --picker-bg-solid: rgba(10, 10, 10, 1);
    --picker-bg-fade: rgba(10, 10, 10, 0.8);
    
    /* Шрифты */
    --font-primary: "IBM Plex Sans", sans-serif;
    --font-display: "Inter", sans-serif;
    
    /* Размеры десктоп - конвертер */
    --picker-height: 320px;
    --picker-item-height: 60px;
    --picker-padding-vertical: 130px;
    --picker-fade-height: 130px;
    --picker-font-size: 1.125rem;
    --picker-font-size-selected: 1.75rem;
    
    --extra-value-size: 1.75rem;
    --extra-label-size: 0.85rem;
    
    --section-title-size: 1.5rem;
    
    /* Размеры десктоп - калькулятор */
    --result-size-desktop: 9rem;
    --unit-size-desktop: 3rem;
    --picker-height-desktop: 180px;
    --picker-item-height-desktop: 60px;
    
    /* Размеры мобильные - конвертер */
    --picker-height-mobile: 280px;
    --picker-item-height-mobile: 50px;
    --picker-padding-vertical-mobile: 115px;
    --picker-fade-height-mobile: 115px;
    --picker-font-size-mobile: 0.95rem;
    --picker-font-size-selected-mobile: 1.35rem;
    
    --extra-value-size-mobile: 1.35rem;
    --extra-label-size-mobile: 0.75rem;
    
    --section-title-size-mobile: 1.2rem;
    --picker-column-title-mobile: 0.7rem;
    
    /* Размеры мобильные - калькулятор */
    --result-size-tablet: 6rem;
    --result-size-mobile: 5rem;
    --unit-size-tablet: 2rem;
    --unit-size-mobile: 1.5rem;
    --picker-height-mobile-calc: 150px;
    
    /* Отступы */
    --spacing-section: 60px;
    --spacing-gap-desktop: 1rem;
    --spacing-gap-mobile: 0.5rem;
    --spacing-title-bottom: 2.2rem;
    --spacing-extra-top: 25px;
    
    /* Радиусы */
    --radius-small: 8px;
    --radius-medium: 15px;
    --radius-large: 20px;
    --radius-pill: 25px;
    
    /* Переходы */
    --transition-fast: 0.3s ease;
    --transition-smooth: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --transition-picker: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    
    /* Тени */
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.4);
    --text-shadow-glow: 0 0 20px rgba(255, 255, 255, 0.15);
    --text-shadow-strong: 0 0 10px rgba(255, 255, 255, 0.2);
    
    /* Прочее */
    --max-width: 600px;
    --letter-spacing-label: 0.1em;
}

/* ==================== ОБЩИЕ СТИЛИ ==================== */
html, body {
    font-family: var(--font-primary);
    color: var(--color-text-primary);
    background: var(--bg-dark);
}

h1, h2 {
    font-family: var(--font-display);
}

/* ==================== DISABLE SCROLLING (ДЛЯ ОБЕИХ СТРАНИЦ) ==================== */
html.calculator, body.calculator,
html.converter, body.converter {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* ==================== СТИЛИ ДЛЯ КОНВЕРТЕРА ЗЕРНИСТОСТИ ==================== */
.converter-section {
    padding: 0;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.converter-section::before {
    content: '';
    position: absolute;
    top: 20%;
    left: -15%;
    width: 400px;
    height: 400px;
    background: var(--gradient-glow);
    border-radius: 50%;
    filter: blur(100px);
    z-index: 1;
}

.converter-section .container {
    position: relative;
    z-index: 2;
}

.picker-wrapper {
    gap: var(--spacing-gap-desktop);
    max-width: var(--max-width);
    margin: 0 auto;
}

.picker-column-title {
    font-size: var(--extra-label-size);
    font-weight: 600;
    letter-spacing: var(--letter-spacing-label);
    color: var(--color-text-secondary);
    margin-bottom: 15px;
    text-align: center;
    text-transform: uppercase;
    padding: 8px 12px;
    background: var(--color-overlay-light);
    border-radius: var(--radius-medium);
    border: 1px solid var(--color-border-subtle);
}

.picker-column-converter {
    position: relative;
    height: var(--picker-height);
    overflow: hidden;
    background: var(--color-overlay-dark);
    border-radius: var(--radius-medium);
    border: 1px solid var(--color-border-subtle);
    backdrop-filter: blur(5px);
    touch-action: pan-y;
    min-width: 0;
    flex: 1;
    isolation: isolate;
}

.picker-scroll {
    position: absolute;
    width: 100%;
    transition: transform var(--transition-picker);
    padding: var(--picker-padding-vertical) 0;
    z-index: 10;
}

.picker-item-converter {
    height: var(--picker-item-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--picker-font-size);
    color: var(--color-text-dimmed);
    transition: all var(--transition-fast);
    user-select: none;
    cursor: pointer;
    font-weight: 500;
    position: relative;
}

.picker-item-converter.selected {
    color: var(--color-text-secondary);
    font-size: var(--picker-font-size-selected);
    font-weight: 700;
    text-shadow: var(--text-shadow-strong);
    background: var(--color-overlay-medium);
}

.picker-highlight {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: var(--picker-item-height);
    background: var(--color-overlay-light);
    border-top: 2px solid var(--color-border-strong);
    border-bottom: 2px solid var(--color-border-strong);
    pointer-events: none;
    z-index: 8;
}

.picker-fade-top,
.picker-fade-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--picker-fade-height);
    pointer-events: none;
    z-index: 5;
}

.picker-fade-top {
    top: 0;
    background: linear-gradient(
        to bottom,
        var(--picker-bg-solid) 0%,
        var(--picker-bg-fade) 30%,
        transparent 100%
    );
}

.picker-fade-bottom {
    bottom: 0;
    background: linear-gradient(
        to top,
        var(--picker-bg-solid) 0%,
        var(--picker-bg-fade) 30%,
        transparent 100%
    );
}

.section-title {
    font-size: var(--section-title-size);
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-title-bottom);
    text-align: center;
    text-shadow: var(--text-shadow-glow);
    line-height: 1.3;
}

.extra-pickers-row {
    max-width: var(--max-width);
    margin: var(--spacing-extra-top) auto 0 auto;
    gap: var(--spacing-gap-desktop);
}

.extra-picker-col {
    background: var(--color-overlay-dark);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-medium);
    padding: 0.7rem 0.5rem;
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.extra-label {
    font-size: var(--extra-label-size);
    font-weight: 600;
    letter-spacing: var(--letter-spacing-label);
    color: var(--color-text-secondary);
    margin-bottom: 0.2rem;
}

.extra-value {
    color: var(--color-text-secondary);
    font-size: var(--extra-value-size);
    font-weight: 700;
}

/* ==================== СТИЛИ ДЛЯ КАЛЬКУЛЯТОРА ПОДВОДА ==================== */
.edge-calculator-section {
    padding: 0;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edge-calculator-section::before {
    content: '';
    position: absolute;
    top: 20%;
    left: -15%;
    width: 400px;
    height: 400px;
    background: var(--gradient-glow);
    border-radius: 50%;
    filter: blur(100px);
    z-index: 1;
}

.edge-calculator-section .container {
    position: relative;
    z-index: 2;
}

.result-container {
    max-width: 600px;
    margin: 0 auto 30px auto;
    order: 1;
}

.result-value-container {
    position: relative;
    overflow: visible;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
}

.result-value {
    font-size: var(--result-size-desktop);
    font-weight: 900;
    font-family: var(--font-display);
    display: inline-block;
    transition: all var(--transition-smooth);
    line-height: 1;
    letter-spacing: -0.02em;
}

.result-unit {
    font-size: var(--unit-size-desktop);
    font-weight: 700;
    font-family: var(--font-display);
    display: inline-block;
    transition: all var(--transition-fast);
    line-height: 1;
    align-self: flex-end;
    padding-bottom: 8px;
}

.result-value.spin {
    animation: slotSpin 0.4s ease-out;
}

@keyframes slotSpin {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-40px) scale(0.8);
        opacity: 0;
    }
    51% {
        transform: translateY(40px) scale(0.8);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.picker-container {
    border-radius: var(--radius-large);
    padding: 20px;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 2;
    order: 2;
}

.picker-wrapper-calc {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.picker-column-wrapper {
    flex: 1;
    max-width: 280px;
}

.picker-column-title-calc {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px;
    background: var(--color-overlay-light);
    border-radius: var(--radius-medium);
    border: 1px solid var(--color-border-subtle);
}

.picker-column-calc {
    position: relative;
    height: var(--picker-height-desktop);
    overflow: hidden;
    background: var(--color-overlay-dark);
    border-radius: var(--radius-medium);
    border: 1px solid var(--color-border-subtle);
    backdrop-filter: blur(5px);
    touch-action: pan-y;
    isolation: isolate;
}

.picker-scroll-calc {
    position: absolute;
    width: 100%;
    transition: transform var(--transition-picker);
    padding: var(--picker-item-height-desktop) 0;
    z-index: 10;
}

.picker-item-calc {
    height: var(--picker-item-height-desktop);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--color-text-dimmed);
    transition: all var(--transition-fast);
    user-select: none;
    cursor: pointer;
    font-weight: 500;
    position: relative;
}

.picker-item-calc.selected {
    color: var(--color-text-secondary);
    font-size: 24px;
    font-weight: 700;
    text-shadow: var(--text-shadow-strong);
    background: var(--color-overlay-medium);
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-overlay-medium);
    color: var(--color-text-muted);
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--color-border-medium);
    margin-top: 15px;
}

.info-badge i {
    font-size: 1rem;
}

/* ==================== FIXED LOGO ==================== */
.fixed-logo {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: block;
    text-decoration: none;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.fixed-logo img {
    max-width: 140px;
    height: auto;
    opacity: 0.85;
    filter: drop-shadow(var(--shadow-soft));
    transition: opacity var(--transition-fast), filter var(--transition-fast);
}

.fixed-logo:hover {
    transform: translateX(-50%) scale(1.05);
}

.fixed-logo:hover img {
    opacity: 1;
    filter: drop-shadow(var(--shadow-medium));
}

.fixed-logo:active {
    transform: translateX(-50%) scale(0.98);
}

/* ==================== NAVIGATION BUTTON ==================== */
.nav-button {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--color-overlay-medium);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-medium);
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.nav-button:hover {
    background: var(--color-overlay-light);
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.nav-button:active {
    transform: translateY(0);
}

.nav-button i {
    font-size: 1rem;
}

/* ==================== RESPONSIVE ==================== */

/* Мобильные стили для конвертера */
@media (max-width: 576px) {
    .picker-wrapper,
    .extra-pickers-row {
        max-width: 100%;
        gap: var(--spacing-gap-mobile);
    }

    .picker-column-converter {
        height: var(--picker-height-mobile);
    }

    .picker-item-converter {
        font-size: var(--picker-font-size-mobile);
        height: var(--picker-item-height-mobile);
    }

    .picker-item-converter.selected {
        font-size: var(--picker-font-size-selected-mobile);
    }

    .picker-highlight {
        height: var(--picker-item-height-mobile);
    }

    .picker-scroll {
        padding: var(--picker-padding-vertical-mobile) 0;
    }

    .picker-fade-top,
    .picker-fade-bottom {
        height: var(--picker-fade-height-mobile);
    }

    .picker-column-title {
        font-size: var(--picker-column-title-mobile);
    }

    .extra-picker-col {
        padding: 0.5rem 0.3rem;
    }

    .extra-label {
        font-size: var(--extra-label-size-mobile);
    }

    .extra-value {
        font-size: var(--extra-value-size-mobile);
    }

    .section-title {
        font-size: var(--section-title-size-mobile);
    }
}

/* Мобильные стили для калькулятора */
@media (max-width: 768px) {
    .section-title {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }

    .result-container {
        margin-bottom: 20px;
    }

    .result-value-container {
        min-height: 100px;
        gap: 8px;
    }

    .result-value {
        font-size: var(--result-size-tablet);
    }

    .result-unit {
        font-size: var(--unit-size-tablet);
        padding-bottom: 6px;
    }

    .picker-container {
        padding: 15px 10px;
    }

    .picker-wrapper-calc {
        gap: 10px;
    }

    .picker-column-wrapper {
        max-width: 140px;
    }

    .picker-column-calc {
        height: var(--picker-height-mobile-calc);
    }

    .picker-column-title-calc {
        font-size: 11px;
        padding: 6px 8px;
        margin-bottom: 12px;
    }

    .picker-item-calc {
        font-size: 16px;
        height: var(--picker-item-height-mobile);
    }

    .picker-item-calc.selected {
        font-size: 20px;
    }

    .picker-scroll-calc {
        padding: var(--picker-item-height-mobile) 0;
    }

    .picker-fade-top,
    .picker-fade-bottom {
        height: var(--picker-item-height-mobile);
    }

    .picker-highlight {
        height: var(--picker-item-height-mobile);
    }

    .info-badge {
        font-size: 0.7rem;
        padding: 8px 16px;
        margin-top: 10px;
    }

    .fixed-logo {
        bottom: 15px;
    }
    
    .fixed-logo img {
        max-width: 100px;
    }

    .nav-button {
        top: 15px;
        right: 15px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

@media (max-width: 390px) {
    .section-title {
        font-size: 1.1rem;
    }

    .result-value {
        font-size: var(--result-size-mobile);
    }

    .result-unit {
        font-size: var(--unit-size-mobile);
        padding-bottom: 4px;
    }

    .result-value-container {
        min-height: 80px;
        gap: 6px;
    }

    .picker-wrapper-calc {
        gap: 8px;
    }

    .picker-column-wrapper {
        max-width: 120px;
    }

    .fixed-logo {
        bottom: 12px;
    }
    
    .fixed-logo img {
        max-width: 80px;
    }

    .nav-button {
        top: 12px;
        right: 12px;
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* ==================== DISABLE HOVER ON TOUCH ==================== */
@media (hover: none) and (pointer: coarse) {
    .picker-item-calc:hover,
    .picker-item-converter:hover {
        color: var(--color-text-dimmed);
        background: transparent;
    }

    .fixed-logo:hover {
        transform: translateX(-50%);
    }
    
    .fixed-logo:active {
        transform: translateX(-50%) scale(0.95);
    }

    .nav-button:hover {
        background: var(--color-overlay-medium);
        border-color: var(--color-border-medium);
        color: var(--color-text-secondary);
        transform: none;
        box-shadow: none;
    }

    .nav-button:active {
        transform: scale(0.95);
    }
}

.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.mode-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.45);
    padding: 8px 22px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.4);
    color: #fff;
    font-weight: 500;
}

.mode-btn:hover:not(.active) {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.65);
}
