/* Recurring components from the approved boards. Needs tokens.css and base.css. */

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

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

.btn--xs { height: 26px; padding: 0 10px; font-size: 12px; }
.btn--sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn--md { height: 32px; padding: 0 14px; font-size: 13px; }
.btn--lg { height: 40px; padding: 0 16px; }
.btn--xl { height: 48px; padding: 0 28px; font-size: 16px; font-weight: 700; }
.btn--block { width: 100%; }

.btn--gold {
    border: 0;
    background: var(--gold-fill);
    color: var(--on-gold);
}

.btn--gold:hover:not(:disabled) {
    filter: brightness(1.06);
}

.btn--outline {
    border-color: var(--gold-outline);
    background: var(--gold-tint);
    color: var(--gold);
}

.btn--watch {
    height: 32px;
    padding: 0 16px;
    border-color: var(--red);
    color: var(--red-text);
    font-size: 13px;
}

.btn--quiet {
    border-color: var(--line-strong);
    color: var(--text-2);
    font-weight: 500;
}

.btn--quiet:hover:not(:disabled) {
    color: var(--text);
}

/* A toggled quiet button (e.g. a filter that is on). */
.btn--quiet[aria-pressed="true"] {
    border-color: var(--gold-outline);
    background: var(--gold-selected);
    color: var(--gold-selected-text);
    font-weight: 600;
}

.btn--danger {
    height: 32px;
    padding: 0 14px;
    border: 0;
    background: var(--danger);
    color: var(--on-danger);
    font-size: 13px;
}

.btn--hero {
    height: 52px;
    padding: 0 32px 0 28px;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
}

.btn:disabled,
.btn-text:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Text-only buttons used in confirmations and secondary actions. */
.btn-text {
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.btn-text:hover:not(:disabled) { color: var(--text); }
.btn-text--gold { color: var(--gold); font-weight: 600; }
.btn-text--red { color: var(--red-text); font-weight: 600; }
.btn-text--gold:hover:not(:disabled) { color: var(--gold); text-decoration: underline; }
.btn-text--red:hover:not(:disabled) { color: var(--red-text); text-decoration: underline; }

/* A bare inline action that reads like a link ("Delete account", "Report"). */
.btn-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    line-height: 20px;
    text-align: left;
}

.btn-link:hover:not(:disabled) { text-decoration: underline; }
.btn-link--red { color: var(--red-text); }

.btn-link--underline {
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
    text-underline-offset: 4px;
}

.btn-link--underline:hover:not(:disabled) { text-decoration-color: currentColor; }

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    margin: 2px 0;
    padding: 0 14px 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--elevated);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.g-logo {
    flex: none;
}

@media (max-width: 768px) {
    .btn,
    .btn--xs,
    .btn--sm,
    .btn--md,
    .btn--lg,
    .btn--watch,
    .btn--danger,
    .btn-text,
    .btn-google {
        height: 44px;
    }

    .btn-link {
        min-height: 44px;
    }

    .btn--xl,
    .btn--hero {
        height: 48px;
    }
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
}

.card--item {
    padding: 12px 14px;
    background: var(--elevated);
    border-radius: var(--radius);
}

.card--rule,
.card--turn,
.card--live {
    border-left: 2px solid var(--gold-rule);
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Your turn in a daily debate. */
.card--turn { border-left-color: var(--gold); }

/* A live debate in progress. */
.card--live { border-left: 3px solid var(--red); }

/* A list card that is a button or link. */
button.card,
a.card {
    display: block;
    width: 100%;
    color: var(--text);
    /* start, not left: a right-to-left topic inside starts from the right (PG-9). */
    text-align: start;
    text-decoration: none;
}

button.card:hover,
a.card:hover {
    background: var(--hover);
}

.card__title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.card__meta {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-2);
}

/* ── Labels and headings ──────────────────────────────────────────────── */

.label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-2);
}

.section-title {
    font-family: var(--serif);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.section-title--md { font-size: 18px; }
.section-title--lg { font-size: 20px; }

.meta {
    font-size: 13px;
    color: var(--text-2);
}

.badge-pro {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold);
}

/* ── Inputs ───────────────────────────────────────────────────────────── */

.input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    background: var(--elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

.input::placeholder {
    color: var(--text-2);
}

.input:focus-visible {
    outline: none;
    border-color: var(--gold-rule);
}

.input[aria-invalid="true"] {
    border-color: var(--red);
}

.input--sm {
    height: 28px;
    padding: 0 10px;
    font-size: 13px;
}

/* An input with a button attached on its right (the challenge link and Copy). */
.input-group {
    display: flex;
}

.input-group .input {
    flex: 1;
    min-width: 0;
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
}

.input-group__btn {
    flex: none;
    min-width: 76px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.input-group__btn:hover:not(:disabled) { color: var(--text); }
.input-group__btn.is-ok { color: var(--green); }

/* Form layout: fields stacked 14px apart, each label 6px above its control. */
.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field > .label {
    margin-bottom: 6px;
}

.hint {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-2);
}

@media (max-width: 768px) {
    .input,
    .input-group__btn { height: 44px; }
}

/* ── Segmented control ────────────────────────────────────────────────── */

.seg {
    display: flex;
    background: var(--elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.seg button {
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.seg button + button {
    border-left: 1px solid var(--line);
}

.seg button[aria-pressed="true"] {
    background: var(--gold-selected);
    color: var(--gold-selected-text);
    font-weight: 600;
}

.seg button small {
    font-size: 11px;
}

.seg--tall button {
    height: 44px;
}

/* A compact inline control (e.g. "Per turn: 1 day · 2 days · 3 days"). */
.seg--sm {
    display: inline-flex;
}

.seg--sm button {
    flex: none;
    height: 28px;
    padding: 0 14px;
    font-size: 12px;
}

.seg:has(button:disabled) {
    opacity: 0.5;
}

.seg button:disabled {
    cursor: default;
}

@media (max-width: 768px) {
    .seg button { height: 44px; }
    .seg--tall button { height: 52px; }
}

/* ── Filter chips ─────────────────────────────────────────────────────── */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    height: 32px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.chip[aria-pressed="true"] {
    border-color: var(--gold-outline);
    background: var(--gold-selected);
    color: var(--gold-selected-text);
    font-weight: 600;
}

/* ── Status text ──────────────────────────────────────────────────────── */

.status {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-2);
}

.status--error { color: var(--red-text); }
.status--ok { color: var(--green); }

/* ── Dialog and bottom sheet ──────────────────────────────────────────── */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--scrim);
}

.dialog {
    width: 440px;
    max-width: 100%;
    max-height: 100%;
    overflow: auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}

.dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dialog__title {
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.dialog__body {
    margin-top: 20px;
}

.dialog__close {
    flex: none;
    width: 32px;
    height: 32px;
    margin-right: -8px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay--sheet {
    align-items: flex-end;
    padding: 0;
}

.sheet {
    width: 100%;
    max-height: 92vh;
    overflow: auto;
    padding: 8px 16px 16px;
    background: var(--surface);
    border-top: 1px solid var(--hairline);
    border-radius: 12px 12px 0 0;
}

.sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
}

.sheet__close {
    flex: none;
    min-width: 44px;
    height: 44px;
    padding: 0 0 0 8px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

/* ── In-place confirmation ────────────────────────────────────────────── */

.confirm__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.confirm__detail {
    margin-top: 2px;
    white-space: pre-line;
    font-size: 13px;
    line-height: 18px;
    color: var(--text-2);
}

/* An error shown in the detail line's place (confirmInPlace errorInDetail). */
.confirm__detail.status--error {
    font-size: 12px;
    color: var(--red-text);
}

.confirm__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
}

.confirm--end {
    text-align: right;
}

.confirm--end .confirm__actions {
    justify-content: flex-end;
}

/* ── Table card ───────────────────────────────────────────────────────── */

.table-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}

.table thead tr {
    background: var(--elevated);
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-2);
}

.table tbody tr {
    border-top: 1px solid var(--hairline);
}

.table td {
    padding: 14px 16px;
}

.table .muted {
    color: var(--text-2);
}

.table .num {
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 600;
    color: var(--gold);
}

/* ── Avatars ──────────────────────────────────────────────────────────── */

.avatar {
    position: relative;
    overflow: hidden;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--avatar);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.avatar--md {
    width: 36px;
    height: 36px;
    background: var(--gold-avatar);
    font-size: 14px;
    color: var(--gold);
}

.avatar--lg {
    width: 80px;
    height: 80px;
    background: var(--gold-fill);
    font-size: 30px;
    color: var(--on-gold);
}

/* A player's picture over the initial (avatar.js): see-through until it has
   loaded, then a short fade; removed if it fails, so the initial shows. */
.avatar__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 150ms ease;
}

.avatar__img.is-loaded {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .avatar__img {
        transition: none;
    }
}

/* ── Signed-out hero ──────────────────────────────────────────────────── */

.hero {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 64px 24px 40px;
}

.hero__inner {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hero__mark {
    color: var(--logo);
}

.hero__title {
    margin-top: 36px;
    font-family: var(--serif);
    font-size: 48px;
    font-weight: 600;
    line-height: 1.15;
    text-wrap: balance;
}

.hero__lead {
    max-width: 560px;
    margin-top: 16px;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-2);
    text-wrap: balance;
}

.hero .btn--hero {
    margin-top: 40px;
}

.hero__note {
    margin-top: 20px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-2);
    text-wrap: balance;
}

.hero__challenge {
    width: 100%;
    max-width: 480px;
}

/* A friend's challenge on the signed-out welcome (INC-3): a small card with a
   gold rule, above the sign-in button. */
.hero-challenge {
    margin-top: 32px;
    padding: 14px 16px;
    text-align: start;
}

.hero-challenge__line {
    margin-top: 6px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    overflow-wrap: anywhere;
}

.hero-challenge__name {
    font-weight: 600;
}

.hero-challenge__cta {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-2);
}

/* The card's room while its answer is late: the height of a two-line card,
   so the welcome does not move when it arrives. */
.hero-challenge--pending {
    min-height: 126px;
    visibility: hidden;
}

/* The line for a challenge that is gone: quiet, no box. */
.hero-challenge-gone {
    margin-top: 28px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-2);
}

.hero__challenge:not(:empty) + .btn--hero {
    margin-top: 20px;
}

@media (max-width: 768px) {
    .hero {
        padding: 40px 16px;
    }

    .hero__title {
        margin-top: 28px;
        font-size: 34px;
        line-height: 1.2;
    }

    .hero__lead {
        margin-top: 14px;
        line-height: 1.55;
    }

    .hero .btn--hero {
        width: 100%;
        height: 52px;
        margin-top: 36px;
        padding: 0 20px;
    }

    .hero__note {
        margin-top: 18px;
        line-height: 1.6;
    }

    .hero-challenge {
        margin-top: 28px;
    }

    .hero .hero__challenge:not(:empty) + .btn--hero {
        margin-top: 18px;
    }
}

@media (max-width: 360px) {
    .hero-challenge--pending {
        min-height: 150px;
    }
}
