/*
 * EasyMeet — site stylesheet: design tokens, base elements, header, buttons, dialogs.
 * Light theme only. Page-specific styles live in assets/css/<area>/.
 *
 * Contrast (WCAG 2.2 AA: text >= 4.5:1; control boundaries and focus >= 3:1) was computed
 * for every pair the pages use; the values are noted next to the tokens. Disabled controls
 * are exempt (WCAG 1.4.3).
 */

:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-text: #1b1f24;           /* 16.6:1 on surface, 15.3:1 on bg, 15.0:1 on danger-soft */
    --color-text-muted: #59616c;     /* 6.3:1 on surface, 5.8:1 on bg */
    --color-border: #dde1e6;         /* decorative card borders only */
    --color-border-strong: #868e98;  /* inputs and buttons: 3.3:1 on surface, 3.1:1 on bg */

    --color-primary: #b3154f;        /* 6.7:1 with white, 6.2:1 on bg */
    --color-primary-hover: #941142;  /* 8.7:1 with white */
    --color-primary-soft: #fbeef3;

    --color-focus: #1d4ed8;          /* 6.7:1 on surface, 6.2:1 on bg, 6.1:1 on danger-soft */

    --color-danger: #a1121b;         /* 8.0:1 on surface, 7.3:1 on danger-soft */
    --color-danger-soft: #fdf1f1;
    --color-danger-border: #f0c6c8;

    --color-success: #146c2e;        /* 6.0:1 on success-soft */
    --color-success-soft: #edf7f0;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-card-hover: 0 2px 4px rgba(16, 24, 40, 0.08), 0 4px 12px rgba(16, 24, 40, 0.10);
    --shadow-dialog: 0 12px 32px rgba(16, 24, 40, 0.18);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --page-gutter: 16px;
    --header-height: 56px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
}

h1,
h2,
h3 {
    margin: 0 0 var(--space-3);
    line-height: 1.25;
}

p {
    margin: 0 0 var(--space-3);
}

a {
    color: var(--color-primary);
}

a:hover {
    color: var(--color-primary-hover);
}

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

/* ---------- Form controls ---------- */

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    min-height: 44px;
    padding: 0 var(--space-4);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
}

button:hover:not(:disabled) {
    background: var(--color-bg);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

input[type="email"],
input[type="text"],
input[type="password"] {
    width: 100%;
    min-height: 44px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}

input:disabled {
    background: var(--color-bg);
}

label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: 600;
}

/* ---------- Buttons ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-weight: 600;
    text-decoration: none;
}

.button--primary {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #ffffff;
}

.button--primary:hover:not(:disabled) {
    border-color: var(--color-primary-hover);
    background: var(--color-primary-hover);
}

.button--secondary {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
}

.button--danger {
    border-color: var(--color-danger-border);
    background: var(--color-surface);
    color: var(--color-danger);
}

.button--danger:hover:not(:disabled) {
    background: var(--color-danger-soft);
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    max-width: 1120px;
    min-height: var(--header-height);
    margin: 0 auto;
    padding: var(--space-2) var(--page-gutter);
}

.site-header__brand {
    color: var(--color-primary);
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
}

.site-header__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
}

/* The live logout message stays rendered (so it is announced) but outside the row,
   so an empty one takes no space; with text it shows as a note under the controls. */
.site-header__controls {
    position: relative;
}

.site-header__controls p {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    width: max-content;
    max-width: calc(100vw - 2 * var(--page-gutter));
    margin: 0;
}

.site-header__controls p:not(:empty) {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-danger-border);
    border-radius: var(--radius-sm);
    background: var(--color-danger-soft);
    color: var(--color-danger);
    font-size: 14px;
}

.site-header__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--space-2);
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
}

.site-header__link:hover {
    color: var(--color-primary);
}

/* Narrow phones: one header row. "Способы входа" leaves the header (the same dialog
   opens from Настройки → Безопасность) and the remaining controls get a little less
   horizontal padding; touch targets stay 44px high. */
@media (max-width: 559px) {
    #login-methods-open-button {
        display: none;
    }

    .site-header__inner {
        gap: var(--space-2);
    }

    .site-header__controls {
        flex-wrap: nowrap;
        gap: var(--space-1);
    }

    .site-header__controls .button {
        padding: 0 var(--space-3);
    }

    .site-header__link {
        padding: 0 var(--space-2);
    }
}

/* ---------- Generic page ---------- */

.page__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--space-5) var(--page-gutter);
}

/* ---------- Dialogs ---------- */

.site-dialog {
    width: min(440px, calc(100% - 2 * var(--page-gutter)));
    max-height: calc(100% - 2 * var(--page-gutter));
    padding: 0;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-dialog);
}

.site-dialog::backdrop {
    background: rgba(16, 24, 40, 0.45);
}

.site-dialog__body {
    position: relative;
    padding: var(--space-5);
}

.site-dialog__title {
    margin-right: var(--space-6);
    font-size: 22px;
}

.site-dialog__close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 40px;
    min-height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
}

.site-dialog form {
    display: grid;
    gap: var(--space-3);
}

@media (min-width: 768px) {
    :root {
        --page-gutter: 24px;
    }
}
