/*
 * Basic styling for the Text Complexity Calculator.
 *
 * A light and airy aesthetic is achieved through generous whitespace,
 * soft backgrounds and subtle colour accents. The design adapts to
 * varying screen sizes thanks to percentage based widths and margins.
 */

/* Import the HSE Sans font family. Each face is defined separately with appropriate
 * weight and style values. These font files are stored in the `static/fonts` folder
 * and are distributed as part of the project (see `/home/oai/share/HSE_Sans.zip`).
 */
@font-face {
    font-family: 'HSE Sans';
    src: url('../fonts/HSESans-Thin.otf') format('opentype');
    font-weight: 100;
    font-style: normal;
}
@font-face {
    font-family: 'HSE Sans';
    src: url('../fonts/HSESans-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'HSE Sans';
    src: url('../fonts/HSESans-Italic.otf') format('opentype');
    font-weight: 400;
    font-style: italic;
}
@font-face {
    font-family: 'HSE Sans';
    src: url('../fonts/HSESans-SemiBold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
}
@font-face {
    font-family: 'HSE Sans';
    src: url('../fonts/HSESans-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}
@font-face {
    font-family: 'HSE Sans';
    src: url('../fonts/HSESans-Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
}

html, body {
    margin: 0;
    padding: 0;
    /* Use the HSE Sans family first; fall back to system fonts if it fails */
    font-family: 'HSE Sans', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    /* Adopt a light neutral background drawn from the HSE palette */
    background-color: #E6E7E8;
}

main {
    max-width: 800px;
    margin: 1rem auto 1rem;
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
}

.form-group {
    margin-bottom: 1.2rem;
}

.page-title {
    margin: 0 0 1.5rem;
    font-size: 1.8rem;
    line-height: 1.2;
    font-weight: 700;
    text-align: center;
    color: #0F2D69;
}

.form-group .hint {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: #555;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #555;
}

textarea,
select,
input[type="file"] {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #cbd2d9;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: 'HSE Sans';
}

button {
    display: inline-block;
    padding: 0.7rem 1.4rem;
    /* Use the lighter blue from the HSE palette for the primary button */
    background-color: #374B9B;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    font-family: 'HSE Sans';
}

button:hover {
    /* Darken the button on hover */
    background-color: #0F2D69;
}

.landing-shell {
    width: 100%;
}

.landing-card {
    width: 100%;
}

.theme-landing {
    background-color: #F4F5F7;
    color: #1F2933;
}

body.theme-landing {
    background-color: #F4F5F7;
}

.theme-landing main {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: #F4F5F7;
    box-shadow: none;
}

.theme-landing .landing-shell {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    min-height: 100%;
}

.theme-landing .landing-card {
    max-width: 560px;
    width: 100%;
    border-radius: 32px;
    background-color: #fff;
    padding: 2.75rem;
    border: 1px solid #E4E7EC;
    box-shadow: 0 35px 70px rgba(20, 35, 110, 0.15);
    position: relative;
}

.theme-landing #analyze-form {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.theme-landing .form-group {
    margin-bottom: 0;
}

.theme-landing label {
    color: #0F172A;
    font-size: 1rem;
    font-weight: 600;
}

.theme-landing textarea,
.theme-landing select,
.theme-landing input[type="file"] {
    background-color: #F9FAFB;
    border: 1px solid #D0D5DD;
    border-radius: 10px;
    padding: 0.85rem;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    box-shadow: inset 0 0 0 transparent;
}

.theme-landing textarea:focus,
.theme-landing select:focus,
.theme-landing input[type="file"]:focus {
    border-color: #7B8EF1;
    outline: none;
    box-shadow: 0 0 0 3px rgba(123, 142, 241, 0.2);
}

.theme-landing textarea {
    min-height: 180px;
}

.theme-landing .form-group .hint {
    color: #6B7280;
}

.theme-landing button {
    border-radius: 16px;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 0.95rem 1.75rem;
    background: linear-gradient(135deg, #2743AD, #1A2D7C);
    box-shadow: 0 14px 30px rgba(32, 51, 122, 0.25);
}

.theme-landing button:hover {
    background: linear-gradient(135deg, #1E3A8A, #162665);
}

.theme-landing #loading-overlay {
    border-radius: 16px;
    border-color: #E0E7FF;
    box-shadow: 0 18px 35px rgba(33, 63, 154, 0.2);
    top: 2.25rem;
}

.theme-landing .result-block {
    background-color: #fff;
    border-radius: 18px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 12px 35px rgba(15, 45, 105, 0.08);
}

.theme-landing #results h2 {
    text-align: center;
    margin-bottom: 1.8rem;
    color: #0F172A;
}

.theme-landing .bar-container,
.theme-landing .metric-bar .inner-bar {
    background: #E4E7EC;
}

.theme-landing .bar {
    background: #1A8FE3;
}

.theme-landing .metric-bar .inner-bar span {
    background: #21409A;
}

.theme-landing .metric-bar .value,
.theme-landing .bar-value {
    color: #1F2933;
}

.theme-landing .info-tooltip {
    background-color: #1E3A8A;
}

.theme-landing .info-tooltip:focus {
    outline-color: #1A8FE3;
}

.hidden {
    display: none;
}

.result-block {
    margin-top: 2rem;
}

.section-header,
.metric-bar-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.section-header {
    margin-bottom: 0.6rem;
}

#metrics-section table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

#metrics-section table td {
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid #e4e9f0;
    vertical-align: top;
}

#metrics-section table td:first-child {
    width: 50%;
    font-weight: 600;
    color: #444;
}

.bar-container {
    /* Use a light grey from the HSE palette for the bar background */
    background: #C7C8CA;
    height: 22px;
    border-radius: 11px;
    overflow: hidden;
}

.bar {
    /* Accent colour for readability score bars (bright blue from departmental palette) */
    background: #0FA0D7;
    height: 100%;
    width: 0;
    transition: width 0.6s ease;
}

.bar-value {
    margin-top: 0.3rem;
    font-weight: 600;
    font-size: 1rem;
    text-align: right;
}

.metric-bar {
    margin-bottom: 1.5rem;
}

.metric-bar-header {
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #555;
}

.metric-label {
    flex: 1;
}

.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background-color: #374B9B;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: help;
    line-height: 1;
    position: relative;
}

.info-tooltip:focus {
    outline: 2px solid #0FA0D7;
    outline-offset: 2px;
}

.info-tooltip[data-tooltip]::after,
.info-tooltip[data-tooltip]::before {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.info-tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
    bottom: 150%;
    left: 50%;
    transform: translate(-50%, 6px);
    background-color: #323232;
    color: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 0.45rem;
    font-size: 0.75rem;
    line-height: 1.2;
    max-width: 18rem;
    white-space: normal;
    text-align: center;
    z-index: 20;
}

.info-tooltip[data-tooltip]::before {
    content: "";
    bottom: 140%;
    left: 50%;
    transform: translate(-50%, 6px);
    border-width: 6px;
    border-style: solid;
    border-color: #323232 transparent transparent transparent;
    z-index: 19;
}

.info-tooltip[data-tooltip]:hover::after,
.info-tooltip[data-tooltip]:hover::before,
.info-tooltip[data-tooltip]:focus::after,
.info-tooltip[data-tooltip]:focus::before {
    opacity: 1;
    transform: translate(-50%, 0);
}

.metric-bar .inner-bar {
    /* Use the same light grey as other bar backgrounds */
    background: #C7C8CA;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.metric-bar .inner-bar span {
    display: block;
    height: 100%;
    /* Use the primary blue for metric bar fills */
    background: #374B9B;
    width: 0;
    transition: width 0.6s ease;
}

.metric-bar .value {
    margin-top: 0.3rem;
    font-size: 0.9rem;
    color: #555;
    text-align: right;
    font-weight: 600;
}

#additional-section p {
    margin: 0.3rem 0;
    font-size: 0.95rem;
    color: #555;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 1.4rem;
    }
    main {
        padding: 1.5rem;
    }
}

/* === Loading overlay — компактная карточка внутри main === */
#loading-overlay {
    position: absolute;
    left: 50%;
    top: 1rem;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.75rem;

    background: #ffffff;
    border: 1px solid #e6e7e8;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    box-shadow: 0 6px 18px rgba(15, 45, 105, 0.12);
    z-index: 10; /* поверх содержимого, но не на весь экран */
}

#loading-overlay.hidden { display: none; }

.loading-text {
    margin: 0;
    font-weight: 600;
    color: #0F2D69;
    white-space: nowrap;
}

/* Компактный спиннер — 3 кольца с разной задержкой */
.loader {
    position: relative;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

.loader-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: #374B9B;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-ring:nth-child(2) {
    inset: 5px;
    border-top-color: #0FA0D7;
    animation-duration: 1.15s;
}

.loader-ring:nth-child(3) {
    inset: 10px;
    border-top-color: #C7C8CA;
    animation-duration: 1.3s;
}

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

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .loader-ring { animation: none; border-top-color: #374B9B; }
}
