/* Reset, type, links, focus, page shell, site header and footer. Needs tokens.css. */

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: normal;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, figure {
    margin: 0;
}

ul, ol {
    padding: 0;
}

img, svg {
    display: block;
}

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

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

a {
    color: var(--gold);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--gold);
    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;
}

.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 30;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: var(--elevated);
    color: var(--text);
    font-size: 14px;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

html.has-overlay {
    overflow: hidden;
}

/* ── Type ─────────────────────────────────────────────────────────────── */

.page-title {
    font-family: var(--serif);
    font-size: 28px;
    font-weight: 600;
    line-height: 1.25;
}

.serif {
    font-family: var(--serif);
    font-weight: 600;
}

/* ── Page shell ───────────────────────────────────────────────────────── */

.page-main {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ── Site header ──────────────────────────────────────────────────────── */

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    padding: 12px 24px;
    background: var(--surface);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--logo);
}

.brand:hover {
    text-decoration: none;
}

.brand__name {
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.nav__link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
}

.nav__link:hover {
    color: var(--text);
    text-decoration: none;
}

.nav__link[aria-current="page"] {
    color: var(--gold);
    background: var(--gold-tint);
}

.site-header--live .nav__link[aria-current="page"] {
    color: var(--text-2);
    background: none;
}

.ext-arrow {
    width: 11px;
    height: 11px;
}

/* A tab that is not ready yet (Discord, until there is an invite): a label,
   not a link, with a small "soon" beside it. */
.nav__link--soon,
.site-menu__link--soon {
    cursor: default;
}

.nav__link--soon:hover,
.site-menu__link--soon:hover {
    color: var(--text-2);
}

.nav__soon {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.75;
}

/* The Play tab while a live debate is running. */
.match {
    position: relative;
    display: flex;
}

.match .nav__link {
    gap: 7px;
    color: var(--gold);
    background: var(--gold-tint);
}

.match__sep {
    opacity: 0.5;
}

/* A long opponent name is cut short rather than pushing the header onto two rows. */
.match__opp {
    max-width: 10em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.match__dot {
    width: 6px;
    height: 6px;
    margin-left: -2px;
    border-radius: 50%;
    background: var(--online);
}

.match__clock {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.match__progress {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 0;
    display: flex;
    gap: 2px;
    list-style: none;
}

.match__progress li {
    flex: 1;
    height: 2px;
    background: var(--progress-todo);
}

.match__progress li.is-done {
    background: var(--progress-done);
}

.match__progress li.is-now {
    background: var(--gold-fill);
}

.header-end {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
}

.icon-btn:hover {
    color: var(--text);
}

.header-stats {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.stat__num {
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
}

.stat__num--rating { color: var(--gold); }
.stat__num--wins { color: var(--green); }
.stat__num--losses { color: var(--red); }
.stat__num--empty { color: var(--text-2); }

.stat__label {
    font-size: 12px;
    color: var(--text-2);
}

.header-divider {
    width: 1px;
    height: 20px;
    background: var(--line);
}

.header-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.header-logout {
    padding: 6px 12px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
}

.header-logout:hover {
    color: var(--text);
}

/* Above phone widths the header keeps to one row: a long name is cut short
   with an ellipsis rather than pushing Sign out onto a second row. */
@media (min-width: 769px) {
    .site-header {
        flex-wrap: nowrap;
    }

    .site-header > .brand,
    .site-header > .nav,
    .header-end > * {
        flex: none;
    }

    .site-header > .header-end,
    .header-end > .header-name {
        flex: 0 1 auto;
        min-width: 0;
    }

    .header-name bdi {
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .header-logout {
        white-space: nowrap;
    }
}

.header-phone {
    display: none;
    flex: none;
    align-items: center;
    gap: 8px;
}

.menu-btn {
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: transparent;
}

.menu-btn span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: var(--text);
}

.match-chip {
    position: relative;
    display: flex;
}

.match-chip a {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 8px;
    border-radius: var(--radius);
    background: var(--gold-tint);
    color: var(--gold);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.match-chip a:hover {
    text-decoration: none;
}

.match-chip .match__clock {
    font-size: 14px;
}

.match-chip .match__progress {
    left: 8px;
    right: 8px;
}

.site-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-menu__link,
.site-menu__btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
}

.site-menu__btn {
    font-weight: 400;
}

.site-menu__link:hover {
    text-decoration: none;
    color: var(--text);
}

.site-menu__link[aria-current="page"] {
    color: var(--gold);
    background: var(--gold-tint);
}

.site-header--live .site-menu__link[aria-current="page"] {
    color: var(--text);
    background: none;
}

.site-menu__user {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

.site-menu__name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* A long name gives way so the stats stay on the screen. */
.site-menu__user > .stat {
    flex: none;
}

.site-menu__rule {
    border-top: 1px solid var(--line);
}

.site-menu__google {
    gap: 10px;
    color: var(--text);
    font-weight: 600;
}

/* Between the phone layout and full width the stats would push the header
   onto two rows: they drop out (the profile still shows them). */
@media (min-width: 769px) and (max-width: 1100px) {
    .header-stats,
    .header-stats + .header-divider {
        display: none;
    }

    .nav__link {
        padding: 6px 10px;
    }
}

/* A tablet held upright keeps the logo mark and gives the wordmark's room to
   the name and Sign out, or to the Google button, and to the Play tab while a
   live debate is running. */
@media (min-width: 769px) and (max-width: 900px) {
    .site-header .brand__name {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .match__opp {
        max-width: 7em;
    }
}

@media (max-width: 768px) {
    .site-header {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 12px 16px;
        border-bottom: 1px solid var(--line);
    }

    .brand {
        flex: none;
        min-height: 44px;
    }

    .site-header .nav,
    .site-header .header-end {
        display: none;
    }

    .header-phone {
        display: flex;
    }
}

/* Phones: the live chip gives way rather than pushing the Menu button off
   the screen; the opponent's name is cut short first. A short name fits
   whole from 360px; a 30-letter name needs this at 390px too. */
@media (max-width: 768px) {
    .header-phone {
        flex: 0 1 auto;
        min-width: 0;
    }

    .match-chip,
    .match-chip a {
        min-width: 0;
    }

    .match-chip a > span:not([class]) {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.site-footer {
    margin-top: 48px;
    padding: 24px 16px;
    border-top: 1px solid var(--footer-line);
    text-align: center;
    font-size: 12px;
    color: var(--text-2);
}

.site-footer a {
    color: var(--text-2);
}

.site-footer a:hover {
    color: var(--text);
    text-decoration: none;
}

.site-footer__sep {
    margin: 0 8px;
    opacity: 0.4;
}

@media (max-width: 768px) {
    .site-footer {
        margin-top: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        padding: 12px 16px;
        font-size: 13px;
    }

    .site-footer a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .site-footer__sep {
        margin: 0;
    }
}
