/*
 * yuuuID — the app's own layer.
 *
 * The look of the suite comes from yuuu-ui's base stylesheet
 * (yuuues/yuuu-ui, linked with `yuuu_ui_stylesheet()`), and this file is
 * linked AFTER it (templates/base.html.twig). Only what is specific to
 * yuuuID lives here: the company's brand on the card, the portal, and the
 * brand button's states. Our own classes carry the `yid-` prefix, so they
 * never collide with a future version of the base.
 *
 * NO COLOURS OF OUR OWN: every colour is a `var(--yuuu-*)` token of the
 * base, whose pairs are tested in yuuu-ui, or the brand's ornament token.
 * The pairs this layer paints are checked against the base's real values,
 * in light and dark mode, by tests/Unit/Styles/StylesheetContrastTest.php,
 * which also fails on a colour literal here.
 *
 * The personality is provided by each company with its two colours,
 * which arrive in a <style nonce> linked after both stylesheets
 * (templates/_brand.html.twig, App\Branding\Brand). D-081: where text sits
 * on them (`--yuuu-color-primary[-text]`, `--yuuu-color-accent[-text]`)
 * they arrive as a shade that reads at 7:1, computed on the server
 * (App\Branding\ColorContrast); the accent as the company chose it
 * arrives as `--yid-brand-accent`, for the ornaments.
 *
 * CSP (§9): no inline styles and no external resources.
 */

/* ---------------------------------------------------------------------
 * 1. The brand button keeps its colours on hover and press.
 *
 *    yuuu-ui dims `.btn` with `filter: brightness()`, text included,
 *    which takes the company's pair from 7:1 down towards 5:1 (still
 *    above the 4.5:1 those states need). Here the colours never change,
 *    so the pair `ColorContrast` picked is the pair painted in every
 *    state, at 7:1, and the feedback is an underline (hover) and a ring
 *    in the text colour (pressed), which contrasts with the background
 *    exactly as much as the text does.
 * ------------------------------------------------------------------- */

.btn--primary:hover,
.btn--primary:active {
    filter: none;
}

.btn--primary:not(:disabled, [aria-disabled="true"]):hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.btn--primary:not(:disabled, [aria-disabled="true"]):active {
    box-shadow: inset 0 0 0 3px var(--yuuu-color-primary-text);
}

/* ---------------------------------------------------------------------
 * 2. The brand on the card (login, activation, verification, OAuth).
 *    The logo is sized by the base's `.card__header img`.
 * ------------------------------------------------------------------- */

/* The stripe on top of the card is an ornament: it keeps the company's
   accent as the company chose it (D-081), not the shade its accent takes
   under text. Without a company, the base's accent. */
.card {
    border-top-color: var(--yid-brand-accent, var(--yuuu-color-accent));
}

.yid-brand-name {
    margin: 0;
    font-weight: 650;
    font-size: 1.05rem;
}

.yid-brand-welcome {
    margin: var(--yuuu-space-2) 0 0;
    font-size: 0.95rem;
}

/* yuuu's wordmark, when there is no company. */
.yid-brand-yuuu {
    width: 6rem;
    height: auto;
}

/* On the error and page-expired screens the title sits in the header,
   right under the brand: without this it touched the welcome line. */
.card__header > h1:not(:first-child) {
    margin-top: var(--yuuu-space-4);
}

/* ---------------------------------------------------------------------
 * 3. The user's portal: three tabs (launcher, profile, security) under a
 *    `.nav`, each a narrow `.page` of sections.
 * ------------------------------------------------------------------- */

/* The portal is narrower than yuuu-ui's default content width, and the nav
   must line up with it (owner's design, 2026-10-15). The width is a
   literal and not a redeclared `--yuuu-content-width`: the layer declares
   no tokens (`StylesheetContrastTest`). `PortalStylesheetTest` pins both
   52rem together. */
.yid-portal {
    max-width: 52rem;
}

/* yuuu-ui lines the nav up with the OUTER edge of `.page`, whose content is
   inset by its own padding (space-4, border-box). Adding that padding here
   puts the wordmark and the sign-out button exactly over the content's
   edges; on a narrow screen both collapse to space-4. */
.yid-portal-nav {
    padding-inline: max(var(--yuuu-space-4), calc((100% - 52rem) / 2 + var(--yuuu-space-4)));
}

.yid-portal > h1 {
    margin-bottom: var(--yuuu-space-2);
}

.yid-portal .page-header p.yid-company {
    margin-top: var(--yuuu-space-2);
}

/* The company the person belongs to, under the title, with the brand's
   accent as an ornament (no text is painted on it). */
.yid-company {
    display: flex;
    align-items: center;
    gap: var(--yuuu-space-3);
    padding-bottom: var(--yuuu-space-4);
    border-bottom: 3px solid var(--yid-brand-accent, var(--yuuu-color-accent));
    color: var(--yuuu-color-text-muted);
}

/* The logo carries `height=` in the template; with a very wide logotype,
   without a width cap or `object-fit`, it came out squashed. */
.yid-company img {
    max-width: 12rem;
    object-fit: contain;
}

/* The company picker (D-070 §6.3): one full-width button per company,
   its logo before the name. */
.yid-picker li > form,
.yid-picker__choice {
    width: 100%;
}

.yid-picker__choice {
    display: flex;
    align-items: center;
    gap: var(--yuuu-space-3);
}

.yid-picker__choice img {
    max-width: 8rem;
    object-fit: contain;
}

/* A block of the portal or of an identity in the panel. */
.yid-section {
    margin: var(--yuuu-space-5) 0;
    padding: var(--yuuu-space-5);
    background: var(--yuuu-color-surface);
    border: 1px solid var(--yuuu-color-border);
    border-radius: var(--yuuu-radius-2);
}

.yid-section > :last-child {
    margin-bottom: 0;
}

.yid-section form:not(.inline) {
    max-width: 24rem;
}

/* In the base's column form a button would stretch to the full width. */
.yid-section form:not(.inline) > .btn {
    align-self: flex-start;
}

/* A membership on a person's record in the panel (D-070 §6.16): one per
   company, separated like the rows of a list. The one the operator came
   for is marked by a bar —and by its `aria-current` and a badge, so the
   colour is never the only signal—. */
.yid-membership {
    padding: var(--yuuu-space-4) 0;
    border-top: 1px solid var(--yuuu-color-border);
}

.yid-membership--marked {
    padding-inline-start: var(--yuuu-space-4);
    border-inline-start: 3px solid var(--yid-brand-accent, var(--yuuu-color-accent));
}

.yid-avatar {
    display: block;
    margin: 0 0 var(--yuuu-space-3);
    border-radius: var(--yuuu-radius-2);
}

/* The portal's top bar: who is signed in, photo and name, a way to the
   profile. */
.yid-nav-user {
    display: inline-flex;
    align-items: center;
    gap: var(--yuuu-space-2);
    color: var(--yuuu-color-text-muted);
    text-decoration: none;
}

.yid-nav-user:hover span {
    text-decoration: underline;
}

.yid-nav-user__photo {
    border-radius: 50%;
    object-fit: cover;
}

/* The head of a person's panel record: photo, name, login email. */
.yid-person {
    display: flex;
    align-items: center;
    gap: var(--yuuu-space-3);
}

.yid-person h1 {
    margin: 0;
}

.yid-person__photo {
    flex: none;
    border-radius: 50%;
    object-fit: cover;
}

.yid-person__email {
    margin: 0;
    color: var(--yuuu-color-text-muted);
    overflow-wrap: anywhere;
}

/* Rows with their inline actions: requests, passkeys, apps, grants. */
.yid-list {
    padding: 0;
    list-style: none;
}

.yid-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--yuuu-space-2) var(--yuuu-space-3);
    padding: var(--yuuu-space-3) 0;
    border-bottom: 1px solid var(--yuuu-color-border);
}

/* A notice on top of the launcher (link requests): a `.flash` that holds a
   title and a list instead of one line. */
.yid-notice h2 {
    margin: 0 0 var(--yuuu-space-2);
    font-size: 1rem;
}

.yid-notice .yid-list {
    margin: 0;
}

.yid-notice .yid-list li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

/* The launcher: a grid of app cards. The whole card is the link. */
.yid-apps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: var(--yuuu-space-4);
    margin: var(--yuuu-space-5) 0;
    padding: 0;
    list-style: none;
}

.yid-app__link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: var(--yuuu-space-3);
    align-items: center;
    align-content: center;
    height: 100%;
    padding: var(--yuuu-space-4);
    background: var(--yuuu-color-surface);
    color: var(--yuuu-color-text);
    border: 1px solid var(--yuuu-color-border);
    border-radius: var(--yuuu-radius-2);
    text-decoration: none;
}

a.yid-app__link:hover {
    border-color: var(--yuuu-color-border-strong);
}

a.yid-app__link:hover .yid-app__name {
    text-decoration: underline;
}

/* The monogram: apps carry no logo of their own (D-065 put the logo on
   the company). A neutral tone, the same for every app. */
.yid-app__icon {
    grid-row: 1 / span 2;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--yuuu-radius-2);
    background: var(--yuuu-color-neutral-bg);
    color: var(--yuuu-color-neutral-text);
    font-size: 1.25rem;
    font-weight: 700;
}

.yid-app__name {
    font-weight: 650;
}

/* A long hostname is cut with an ellipsis instead of breaking mid-word:
   it is a hint of where the card goes, the name is what is read. */
.yid-app__name,
.yid-app__host {
    min-width: 0;
}

.yid-app__host {
    overflow: hidden;
    font-size: 0.875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Without an address the line is a sentence, not a hostname: it wraps. */
.yid-app__link--none .yid-app__host {
    white-space: normal;
}

/* A row of the security tab: what it is and its value, the action on the
   right (wrapping below on a phone). */
.yid-settings li {
    justify-content: space-between;
}

.yid-settings li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.yid-settings__text {
    display: flex;
    flex-direction: column;
}

/* The buttons of a form on its own page: side by side, not stretched. */
.yid-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--yuuu-space-3);
}

/* ---------------------------------------------------------------------
 * 4. Two-step verification (D-076)
 *
 *    The code field of the login, collapsed in a `<details>`; the QR code
 *    of the enrolment, an inline SVG that paints its own black-on-white
 *    (a QR code needs that pair in dark mode too, and it is markup, not a
 *    colour of this layer); and the recovery codes, in the monospace font
 *    so that `l` and `1` cannot be confused when copying them by hand.
 * ------------------------------------------------------------------- */

.yid-login-code {
    margin: var(--yuuu-space-3) 0;
}

.yid-login-code summary {
    cursor: pointer;
}

.yid-qr svg {
    display: block;
    width: 12rem;
    max-width: 100%;
    height: auto;
}

.yid-secret,
.yid-recovery-codes {
    font-family: var(--yuuu-font-mono);
    overflow-wrap: anywhere;
}

.yid-recovery-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--yuuu-space-2);
    padding: 0;
    list-style: none;
}

/* ---------------------------------------------------------------------
 * 5. Narrow screens
 * ------------------------------------------------------------------- */

@media (max-width: 30rem) {
    .yid-section {
        padding: var(--yuuu-space-4);
    }

    /* The nav keeps the tabs, the photo and the way out; the name is on
       the profile tab. */
    .yid-nav-user span {
        display: none;
    }
}
