/*
  The app's own look, shared by every host: colours, type, the page, its header, buttons and the other shared parts.
  Each host links this file and its own {App}.styles.css, which holds the components' scoped styles. The board has its
  own colours (GameBoard.razor.css).
  The colours are design/tokens.css (US-044). Like the board, they follow the system's light or dark setting, or
  data-theme="light" or "dark" on <html>, which ThemeService sets from the player's choice.
*/

/* Inter for the text and Space Grotesk for titles, both under the SIL Open Font License (fonts/*-OFL.txt). They are
   part of the app, so the phone apps work offline. Each file covers the letters in its unicode-range, so a page in
   English loads only the Latin one. Space Grotesk has no Cyrillic, so Ukrainian titles take those letters from Inter. */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
        U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/space-grotesk-latin-ext-700-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
        U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Colours, light. Every text pair passes WCAG AA (4.5:1), and borders of controls 3:1 where they carry meaning. */
:root {
    color-scheme: light;
    --renju-app-bg: #f4f5f7;
    --renju-app-fg: #14161b;
    --renju-app-muted: #5b6170;
    --renju-app-panel: #ffffff;
    --renju-app-panel-2: #eef0f3;
    --renju-app-border: #e4e6eb;
    --renju-app-border-strong: #cbd0d8;
    --renju-app-hover: #fafafb;
    --renju-app-accent: #0f766e;
    --renju-app-accent-fg: #ffffff;
    --renju-app-accent-tint: #e2efee;
    --renju-app-accent-icon: #0f766e;
    --renju-app-gold: #a16207;
    --renju-app-gold-tint: #fdf3e1;
    --renju-app-logo-bg: #14161b;
    --renju-app-danger: #b42318;
    --renju-app-focus: #0b57d0;
    --renju-app-shadow: rgb(20 22 27 / 0.08);

    --renju-app-radius-card: 16px;
    --renju-app-radius-control: 10px;
    --renju-app-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --renju-app-font-display: "Space Grotesk", var(--renju-app-font);

    /* The width of a screen's content, and of its header, unless the screen is wider (the menu and the game). */
    --renju-page-width: 40rem;
    --renju-wide-width: 70rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --renju-app-bg: #0f1115;
        --renju-app-fg: #eceef2;
        --renju-app-muted: #a0a6b2;
        --renju-app-panel: #171a20;
        --renju-app-panel-2: #20242c;
        --renju-app-border: #262a33;
        --renju-app-border-strong: #3a3f4b;
        --renju-app-hover: #1c2027;
        --renju-app-accent: #5fb8ad;
        --renju-app-accent-fg: #0f1115;
        --renju-app-accent-tint: #173a39;
        --renju-app-accent-icon: #7bc4ba;
        --renju-app-gold: #e8b04b;
        --renju-app-gold-tint: #2a2214;
        --renju-app-logo-bg: #262a33;
        --renju-app-danger: #ffb4ab;
        --renju-app-focus: #a8c7fa;
        --renju-app-shadow: rgb(0 0 0 / 0.4);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --renju-app-bg: #0f1115;
    --renju-app-fg: #eceef2;
    --renju-app-muted: #a0a6b2;
    --renju-app-panel: #171a20;
    --renju-app-panel-2: #20242c;
    --renju-app-border: #262a33;
    --renju-app-border-strong: #3a3f4b;
    --renju-app-hover: #1c2027;
    --renju-app-accent: #5fb8ad;
    --renju-app-accent-fg: #0f1115;
    --renju-app-accent-tint: #173a39;
    --renju-app-accent-icon: #7bc4ba;
    --renju-app-gold: #e8b04b;
    --renju-app-gold-tint: #2a2214;
    --renju-app-logo-bg: #262a33;
    --renju-app-danger: #ffb4ab;
    --renju-app-focus: #a8c7fa;
    --renju-app-shadow: rgb(0 0 0 / 0.4);
}

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

html, body {
    margin: 0;
    background: var(--renju-app-bg);
    color: var(--renju-app-fg);
    font: 16px/1.45 var(--renju-app-font);
    -webkit-text-size-adjust: 100%;
}

body {
    font-size: 15px;
}

h1, h2, h3 {
    line-height: 1.2;
}

.renju-loading {
    padding: 24px 16px;
    color: var(--renju-app-muted);
}

.renju-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;
}

/*
  A screen: its header, then its content, centred, inside the safe area on phones with notches and system bars.
  Settings, About, the account and online screens use PageHeader and .renju-page. The menu and the game screens are
  wider, and have their own header content.
*/
.renju-header {
    padding-top: env(safe-area-inset-top);
    background: var(--renju-app-panel);
    border-bottom: 1px solid var(--renju-app-border);
}

.renju-header__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: var(--renju-page-width);
    margin-inline: auto;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}

.renju-header--wide .renju-header__inner {
    max-width: var(--renju-wide-width);
}

/* "← Menu", or back to the screen this one came from. */
.renju-header__back {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 12px 0 8px;
    font: inherit;
    font-weight: 500;
    color: var(--renju-app-fg);
    white-space: nowrap;
    background: transparent;
    border: 0;
    border-radius: var(--renju-app-radius-control);
    cursor: pointer;
    touch-action: manipulation;
}

.renju-header__back:hover {
    background: var(--renju-app-panel-2);
}

.renju-header__title {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    font-family: var(--renju-app-font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.renju-header__title:focus {
    outline: none;
}

.renju-page {
    display: grid;
    align-content: start;
    gap: 24px;
    max-width: var(--renju-page-width);
    margin-inline: auto;
    padding: 24px max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* A section's heading, small and in capitals, above its list or cards. */
.renju-section-label {
    margin: 0;
    color: var(--renju-app-muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* A group of rows in one rounded panel, separated by lines, as for settings and links. */
.renju-list {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-card);
    overflow: hidden;
}

.renju-list > * + * {
    border-top: 1px solid var(--renju-app-border);
}

/*
  Options, as on Settings (US-024) and the bot game's setup screen (US-050): a radio button or checkbox with its label
  and a muted hint, in rows at least 52 pixels tall. A fieldset of them is one panel with its legend at the top, and a
  lone option can be a panel of its own.
*/
.renju-options {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-card);
    overflow: hidden;
}

.renju-options__legend {
    float: left;
    width: 100%;
    padding: 14px 16px 2px;
    font-weight: 600;
}

.renju-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 12px;
    min-height: 52px;
    padding: 14px 16px;
    cursor: pointer;
}

.renju-option:hover {
    background: var(--renju-app-hover);
}

.renju-option--panel {
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-card);
}

.renju-option + .renju-option:not(.renju-option--panel) {
    border-top: 1px solid var(--renju-app-border);
}

.renju-option__control {
    width: 1.3rem;
    height: 1.3rem;
    margin: 0.05rem 0 0;
    accent-color: var(--renju-app-accent);
    cursor: pointer;
}

.renju-option:has(.renju-option__control:focus-visible) {
    outline: 3px solid var(--renju-app-focus);
    outline-offset: -3px;
}

.renju-option--panel:has(.renju-option__control:focus-visible) {
    outline-offset: 2px;
}

.renju-option__text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.renju-option__label {
    font-weight: 600;
    font-size: 16px;
}

.renju-option__hint {
    color: var(--renju-app-muted);
    font-size: 14px;
}

/* A label in a pill, such as the bot's level. */
.renju-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 6px 12px;
    color: var(--renju-app-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--renju-app-panel-2);
    border-radius: 999px;
}

/* A stone, as drawn on the board, for the menu, the player cards and the colour choice. */
.renju-stone {
    display: inline-block;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.renju-stone--black {
    background: radial-gradient(circle at 35% 30%, #5a5d63, #15171b 62%);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.35);
}

.renju-stone--white {
    background: radial-gradient(circle at 35% 30%, #ffffff, #d7d9dd 70%);
    box-shadow: 0 0 0 1px var(--renju-app-border-strong), 0 1px 2px rgb(0 0 0 / 0.2);
}

/* Not yet known, as before the colour choice under the opening rule: half black, half white. */
.renju-stone--unknown {
    background: linear-gradient(135deg, #15171b 50%, #ffffff 50%);
    box-shadow: 0 0 0 1px var(--renju-app-border-strong);
}

/* Buttons. */

.renju-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px;
    font: inherit;
    font-weight: 500;
    color: var(--renju-app-fg);
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border-strong);
    border-radius: var(--renju-app-radius-control);
    cursor: pointer;
    touch-action: manipulation;
}

/* A link to another screen can look like a button. */
a.renju-button {
    text-decoration: none;
}

.renju-button:hover {
    background: var(--renju-app-hover);
    border-color: var(--renju-app-muted);
}

.renju-button:focus-visible,
.renju-icon-button:focus-visible,
.renju-header__back:focus-visible {
    outline: 3px solid var(--renju-app-focus);
    outline-offset: 2px;
}

.renju-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.renju-button:disabled:hover {
    background: var(--renju-app-panel);
    border-color: var(--renju-app-border-strong);
}

.renju-button--primary,
.renju-button--primary:hover,
.renju-button--primary:disabled:hover {
    background: var(--renju-app-accent);
    border-color: var(--renju-app-accent);
    color: var(--renju-app-accent-fg);
    font-weight: 600;
}

.renju-button--primary:hover {
    background: color-mix(in srgb, var(--renju-app-accent) 88%, var(--renju-app-fg));
}

.renju-button--quiet,
.renju-button--quiet:hover {
    background: transparent;
    border-color: transparent;
}

.renju-button--quiet:hover {
    background: var(--renju-app-panel-2);
}

/* A button for an action that can't be undone, such as deleting the account (US-026). */
.renju-button--danger,
.renju-button--danger:hover {
    background: var(--renju-app-danger);
    border-color: var(--renju-app-danger);
    color: var(--renju-app-bg);
    font-weight: 600;
}

/* A button with only an icon, such as the theme button. Its aria-label names it. */
.renju-icon-button {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--renju-app-fg);
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-control);
    cursor: pointer;
    touch-action: manipulation;
}

.renju-icon-button:hover {
    background: var(--renju-app-panel-2);
}

/* The theme button shows the sun in the dark theme, to switch to light, and the moon in the light one. */
.renju-theme-toggle__sun {
    display: none;
}

:root[data-theme="dark"] .renju-theme-toggle__sun {
    display: block;
}

:root[data-theme="dark"] .renju-theme-toggle__moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .renju-theme-toggle__sun {
        display: block;
    }

    :root:not([data-theme="light"]) .renju-theme-toggle__moon {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* The menu's bottom bar on phones (MainMenu) keeps the online notices above it. */
@media (max-width: 599.98px) {
    body:has(.menu__more) .online-notices {
        bottom: calc(66px + env(safe-area-inset-bottom));
    }
}

/*
  The privacy policy and the support page (US-053): long text, so paragraphs and lists rather than the grid of cards
  the other screens have. Long addresses wrap rather than widen the page.
*/
.public-page {
    display: block;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.public-page > :first-child {
    margin-top: 0;
}

.public-page h2 {
    margin: 32px 0 8px;
    font-family: var(--renju-app-font-display);
    font-size: 19px;
}

.public-page h3 {
    margin: 24px 0 4px;
    font-size: 16px;
}

.public-page p,
.public-page ul {
    margin: 0 0 12px;
}

.public-page ul {
    padding-inline-start: 20px;
}

.public-page li + li {
    margin-top: 6px;
}

.public-page a {
    color: var(--renju-app-accent-icon);
    font-weight: 600;
    text-underline-offset: 0.2em;
}

.public-page a:focus-visible {
    outline: 3px solid var(--renju-app-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

.public-page__updated {
    color: var(--renju-app-muted);
    font-size: 14px;
}

.public-page__contact {
    font-size: 18px;
}

/*
  The account screens (US-026): sign-in, registration, the forgotten password, the account, changing the password and
  deleting the account. Their text boxes are TextField, with styles of its own.
*/
.account__form {
    display: grid;
    gap: 16px;
}

.account__submit {
    width: 100%;
}

.account__text,
.account__note,
.account__notice,
.account__error,
.account__field-error {
    margin: 0;
    overflow-wrap: anywhere;
}

.account__note {
    color: var(--renju-app-muted);
    font-size: 14px;
}

.account__notice {
    padding: 12px 16px;
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-inline-start: 4px solid var(--renju-app-accent);
    border-radius: var(--renju-app-radius-control);
}

.account__error {
    padding: 12px 16px;
    color: var(--renju-app-danger);
    font-weight: 600;
    background: var(--renju-app-panel);
    border: 2px solid var(--renju-app-danger);
    border-radius: var(--renju-app-radius-control);
}

.account__field-error {
    color: var(--renju-app-danger);
    font-size: 14px;
    font-weight: 600;
}

.account__check {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 10px;
    min-height: 44px;
    padding-block: 10px;
    cursor: pointer;
}

.account__checkbox {
    width: 1.3rem;
    height: 1.3rem;
    margin: 0.1rem 0 0;
    accent-color: var(--renju-app-accent);
    cursor: pointer;
}

.account__checkbox[aria-invalid="true"] {
    outline: 2px solid var(--renju-app-danger);
    outline-offset: 2px;
}

.account__confirm {
    display: grid;
    gap: 2px;
}

.account__links {
    display: grid;
    gap: 10px;
}

.account__link {
    color: var(--renju-app-accent-icon);
    font-weight: 600;
    text-underline-offset: 0.2em;
}

/* Links take taps 44 pixels tall: on a line of their own by their height, and in a sentence by padding, which
   doesn't move the lines. */
.account__links > .account__link {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: 44px;
}

.account__text .account__link {
    padding-block: 13px;
}

.account__link:focus-visible {
    outline: 3px solid var(--renju-app-focus);
    outline-offset: 2px;
}

.account__details {
    display: grid;
    gap: 0;
    margin: 0;
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-card);
}

.account__detail {
    display: grid;
    gap: 2px;
    padding: 12px 16px;
}

.account__detail + .account__detail {
    border-top: 1px solid var(--renju-app-border);
}

.account__detail dt {
    color: var(--renju-app-muted);
    font-size: 14px;
}

.account__detail dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.account__panel {
    display: grid;
    gap: 10px;
    padding: 16px;
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-card);
}

.account__panel--danger {
    border: 2px solid var(--renju-app-danger);
}

.account__heading {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.account__list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding-inline-start: 1.2rem;
}

/* The account's actions: rows in one panel, each with a chevron. */
.account__actions {
    display: grid;
    background: var(--renju-app-panel);
    border: 1px solid var(--renju-app-border);
    border-radius: var(--renju-app-radius-card);
    overflow: hidden;
}

.account__action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 12px 16px;
    font: inherit;
    color: var(--renju-app-fg);
    text-align: start;
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.account__action + .account__action {
    border-top: 1px solid var(--renju-app-border);
}

.account__action:hover {
    background: var(--renju-app-hover);
}

.account__action:focus-visible {
    outline: 3px solid var(--renju-app-focus);
    outline-offset: -3px;
}

.account__action:disabled {
    opacity: 0.5;
    cursor: default;
}

.account__action-text {
    display: grid;
    gap: 2px;
}

.account__action-label {
    font-weight: 600;
    font-size: 16px;
}

.account__action-hint {
    color: var(--renju-app-muted);
    font-size: 14px;
}

.account__chevron {
    color: var(--renju-app-muted);
}

.account__action--danger .account__action-label {
    color: var(--renju-app-danger);
}

/* "or", between signing in with Google and with a password (US-041). */
.account__or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: var(--renju-app-muted);
    font-size: 14px;
}

.account__or::before,
.account__or::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--renju-app-border-strong);
}

/*
  The "Sign in with Google" button that the app draws itself, in the Android app (US-041), to Google's branding
  guidelines: the standard four-colour "G" at 18 pixels, Roboto Medium at 14/20 pixels (Android's own font), 12 pixels
  of padding with 10 between the logo and the text, a pill shape, and Google's light and dark colours. It is 44 pixels
  tall rather than Google's 40, the app's smallest tap target. On the web, Google's script draws its own button.
*/
:root {
    --google-button-bg: #ffffff;
    --google-button-border: #747775;
    --google-button-fg: #1f1f1f;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --google-button-bg: #131314;
        --google-button-border: #8e918f;
        --google-button-fg: #e3e3e3;
    }
}

:root[data-theme="dark"] {
    --google-button-bg: #131314;
    --google-button-border: #8e918f;
    --google-button-fg: #e3e3e3;
}

.google-sign-in {
    display: grid;
    gap: 6px;
}

.google-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    font: 500 14px/20px Roboto, Arial, sans-serif;
    letter-spacing: 0.25px;
    color: var(--google-button-fg);
    background: var(--google-button-bg);
    border: 1px solid var(--google-button-border);
    border-radius: 22px;
    cursor: pointer;
}

.google-button:hover {
    box-shadow: 0 1px 2px rgb(60 64 67 / 0.3), 0 1px 3px 1px rgb(60 64 67 / 0.15);
}

.google-button:focus-visible {
    outline: 3px solid var(--renju-app-focus);
    outline-offset: 2px;
}

.google-button:disabled {
    opacity: 0.6;
    box-shadow: none;
    cursor: default;
}

.google-button__logo {
    flex: none;
}

/* Google's own button, on the web: its script puts a frame here, as wide as the form allows. */
.google-button-host {
    display: flex;
    justify-content: center;
    min-height: 44px;
}
