/* integrations.css — owned by new-ux lane 07; see docs/APP.md "The split stylesheets". */
/*
 * The #/integrations screen (spec 07, Behaviour Screen 2; mockup
 * 522-567).  Colours, type sizes, radii and shadows resolve a custom
 * property from style.css's token block — no hex literals, no fetched
 * assets, no stacking order, no raw type sizes.  Spacing carries the
 * mockup's pixel values where the 4/8 scale has no step (the fidelity
 * audit, 2026-09-11: 26/14/18x20 px at dc.html :522/:527/:529).  Class
 * selectors carry the lane's `ig-` prefix; the state hooks the
 * controller writes (`data-integration-status`, `aria-pressed`,
 * `data-integrations-notice`, `data-working-set*`) are styled as
 * attribute selectors, because the hooks — not the classes — are the
 * contract (CONTRACTS.md §7.3).
 */

.ig-page {
    display: flex;
    flex-direction: column;
    gap: 26px;
}

/* Entrance motion (mockup :30 `rise`, :33 `ease`).  The section's own
 * 10px rise is the shell's `main.fade-in` (style.css `screen-rise`), so
 * .ig-page does not animate — a second rise here would stack to 20px.
 * Each card eases in staggered 60 ms by its grid index, which the
 * controller writes as `--ig-i`; `ig-rise` stays for the panels below. */
@keyframes ig-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

@keyframes ig-ease {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.ig-head {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    max-width: 680px;
}

.ig-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: var(--fs-hero);
    line-height: 1.1;
    color: var(--c-ink);
}

.ig-intro {
    margin: 0;
    font-family: var(--font-text);
    font-size: var(--fs-lede);
    line-height: 1.5;
    color: var(--c-ink-soft);
}

/* The one-shot OAuth-callback notice (the legacy hook; the kept
 * painter overwrites the class list, so the hook is the selector). */
[data-integrations-notice] {
    margin: 0;
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--c-sand-rule);
    border-radius: var(--radius-sm);
    background: var(--c-sand-card);
    font-size: var(--fs-ui);
    color: var(--c-ink-soft);
}

[data-integrations-notice][data-integration-outcome="ok"] {
    border-color: var(--c-status-complete);
}

[data-integrations-notice][data-integration-outcome="denied"],
[data-integrations-notice][data-integration-outcome="error"] {
    border-color: var(--c-status-failed);
}

/* The cards grid (mockup 527): count-agnostic, so the provider set
 * can grow without a stylesheet change. */
.ig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

/* One provider card (mockup 529): the 2 px top spine reads the status
 * hook — connected wears the success token, needs_attention the
 * failed token, everything else the hairline rule. */
.ig-card {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: 18px 20px;
    background: var(--c-sand-card);
    border: 1px solid var(--c-sand-rule);
    border-top: 2px solid var(--c-sand-rule);
    border-radius: var(--radius);
    animation: ig-ease .5s cubic-bezier(.2, .7, .2, 1) both;
    animation-delay: calc(var(--ig-i, 0) * 60ms);
    transition: box-shadow var(--t-base), transform var(--t-base);
}

.ig-card:hover {
    box-shadow: var(--sh-lift);
    transform: translateY(-2px);
}

.ig-card[data-integration-status="connected"] {
    border-top-color: var(--c-status-complete);
}

.ig-card[data-integration-status="needs_attention"] {
    border-top-color: var(--c-status-failed);
}

.ig-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.ig-identity {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* The 30x30 mark tile (mockup 531): the foundation's .fs-mark chip
 * (surfaces.css — gold ground, cream glyph by data-mark) grown from
 * 26 to 30 px with the mockup's 7 px radius; the ground and glyph
 * colours stay the chip's own. */
.ig-identity .fs-mark {
    width: 30px;
    height: 30px;
    border-radius: var(--r-7);
}

/* The card name (mockup 531: Adobe Caslon 19 px — the --fs-19 rung). */
.ig-name {
    margin: 0;
    font-family: var(--font-text);
    font-weight: 400;
    font-size: var(--fs-19);
    color: var(--c-ink);
}

/* The status word with its 7 px dot (mockup 532): the text carries
 * the state; the dot's color rides the same status hook. */
.ig-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-meta);
    font-weight: 500;
    color: var(--c-ink-muted);
    white-space: nowrap;
}

.ig-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: var(--radius-pill);
    background: var(--c-ink-faint);
    display: inline-block;
}

.ig-card[data-integration-status="connected"] .ig-status {
    color: var(--c-status-complete);
}

.ig-card[data-integration-status="connected"] .ig-status::before {
    background: var(--c-status-complete);
}

.ig-card[data-integration-status="needs_attention"] .ig-status {
    color: var(--c-status-failed);
}

.ig-card[data-integration-status="needs_attention"] .ig-status::before {
    background: var(--c-status-failed);
}

.ig-account {
    margin: 0;
    font-size: var(--fs-13);
    color: var(--c-ink-muted);
    overflow-wrap: anywhere;
}

.ig-line {
    margin: 0;
    font-size: var(--fs-13-5);
    line-height: 1.45;
    color: var(--c-ink-muted);
}

/* The unavailable note sits where the action row would (mockup 535/542:
 * the foot-anchored row); its colour stays --c-ink-muted for AA
 * contrast (spec 07 Deviations 20). */
.ig-unavailable {
    margin: 0;
    margin-top: auto;
    font-size: var(--fs-13);
    color: var(--c-ink-muted);
}

/* The action row (mockup 535-543). */
.ig-actions {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    flex-wrap: wrap;
    margin-top: auto;
}

.ig-btn {
    border: 1px solid var(--c-rule-strong);
    background: transparent;
    color: var(--c-ink);
    font-family: var(--font-ui);
    font-size: var(--fs-13);
    font-weight: 500;
    padding: 7px var(--s-3);
    border-radius: var(--r-6);
    cursor: pointer;
    transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}

.ig-btn:hover {
    border-color: var(--c-accent);
    color: var(--c-accent);
}

.ig-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ig-btn-primary {
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: var(--c-sand-page);
}

.ig-btn-primary:hover {
    border-color: var(--c-accent-hover);
    background: var(--c-accent-hover);
    color: var(--c-sand-page);
}

/* Disconnect (mockup 538): a borderless text button at the row's right,
 * regular weight, the UA's slim inline padding. */
.ig-btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--c-ink-muted);
    font-weight: 400;
    padding-inline: var(--s-2);
    margin-left: auto;
}

.ig-btn-quiet:hover {
    border-color: transparent;
    color: var(--c-status-failed);
}

.ig-btn-danger {
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: var(--c-sand-page);
}

.ig-btn-danger:hover {
    border-color: var(--c-accent-hover);
    background: var(--c-accent-hover);
    color: var(--c-sand-page);
}

.ig-manage-link {
    font-size: var(--fs-13);
    color: var(--c-ink-muted);
}

.ig-manage-link:hover {
    color: var(--c-accent);
}

/* The repository working set (mockup 547-565), below the grid. */
.ig-ws {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 22px;
    animation: ig-rise .3s both;
    background: var(--c-sand-card);
    border: 1px solid var(--c-sand-rule);
    border-radius: var(--radius);
}

.ig-ws-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    flex-wrap: wrap;
}

.ig-ws-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: var(--fs-section);
    color: var(--c-ink);
}

.ig-ws-count {
    font-size: var(--fs-13);
    color: var(--c-ink-muted);
}

.ig-ws-lede {
    margin: 0;
    font-size: var(--fs-ui);
    color: var(--c-ink-muted);
}

.ig-ws-truncated {
    margin: 0;
    font-size: var(--fs-meta);
    color: var(--c-ink-muted);
}

/* The tile grid (mockup 551): whole tiles are buttons; the pressed
 * state is the aria-pressed hook the controller writes. */
.ig-ws-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--s-2);
}

.ig-ws-tile {
    text-align: left;
    display: flex;
    gap: var(--s-3);
    align-items: flex-start;
    padding: 10px var(--s-3);
    border: 1px solid var(--c-sand-rule);
    background: transparent;
    border-radius: var(--r-6);
    cursor: pointer;
    font-family: var(--font-ui);
    transition: border-color var(--t-fast), background var(--t-fast);
}

/* dc.html :553 hovers the tile's border to the mockup's hover rung,
   `--c-gold-hover`. */
.ig-ws-tile:hover {
    border-color: var(--c-gold-hover);
}

.ig-ws-tile:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ig-ws-tile[aria-pressed="true"] {
    border-color: var(--c-accent);
    background: var(--c-sand-page);
}

/* dc.html :553 puts the hover on every tile, the chosen one too, and
   gives the chosen state no hover variant of its own; the pressed rule
   above ties the plain `:hover` on specificity and wins on source
   order, so the pressed hover restates it (review r2, the `.nt-repo` /
   `.nt-branch` twin in composer.css :750, :816). */
.ig-ws-tile[aria-pressed="true"]:hover {
    border-color: var(--c-gold-hover);
}

.ig-ws-box {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--c-rule-strong);
    background: transparent;
    color: var(--c-sand-page);
    font-size: var(--fs-micro);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    margin-top: 2px;
}

.ig-ws-tile[aria-pressed="true"] .ig-ws-box {
    border-color: var(--c-accent);
    background: var(--c-accent);
}

.ig-ws-text {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    min-width: 0;
}

.ig-ws-name {
    font-size: var(--fs-ui);
    font-weight: 500;
    color: var(--c-ink);
    overflow-wrap: anywhere;
}

.ig-ws-meta {
    font-size: var(--fs-meta);
    color: var(--c-ink-muted);
}

.ig-ws-foot {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    flex-wrap: wrap;
}

/* Footer (mockup 559-562): Save and Skip sit together at the left;
 * only the saved note takes the slack, so Skip never floats. */
.ig-ws-foot .ig-btn-primary {
    font-size: var(--fs-13-5);
    padding: var(--s-2) 13px;
}

.ig-ws-foot .ig-btn-quiet {
    font-size: var(--fs-13-5);
    margin-left: 0;
}

.ig-ws-foot .ig-btn-quiet:hover {
    color: var(--c-ink);
}

.ig-ws-note {
    margin: 0;
    margin-left: auto;
    font-size: var(--fs-13);
    color: var(--c-status-complete);
}

.ig-ws-error {
    margin: 0;
    font-size: var(--fs-ui);
    color: var(--c-status-failed);
}

/* The two AppSurface dialog bodies (§7.4 owns the surface chrome;
 * these dress only the body content this controller renders). */
.ig-dialog-lede {
    margin: 0 0 var(--s-3);
    font-size: var(--fs-ui);
    line-height: 1.5;
    color: var(--c-ink-soft);
}

.ig-dialog-label {
    display: block;
    margin-bottom: var(--s-1);
    font-size: var(--fs-meta);
    font-weight: 500;
    color: var(--c-ink);
}

.ig-dialog-input {
    width: 100%;
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--c-rule-strong);
    border-radius: var(--radius-sm);
    background: var(--c-sand-page);
    color: var(--c-ink);
    font-family: var(--font-mono);
    font-size: var(--fs-ui);
}

.ig-dialog-input:focus-visible {
    outline: none;
    border-color: var(--c-accent);
    box-shadow: var(--focus-ring);
}

.ig-dialog-error {
    margin: var(--s-2) 0 0;
    font-size: var(--fs-ui);
    color: var(--c-status-failed);
}

.ig-confirm-body {
    margin: 0 0 var(--s-3);
    font-size: var(--fs-base);
    line-height: 1.5;
    color: var(--c-ink-soft);
}

.ig-dialog-actions {
    display: flex;
    gap: var(--s-2);
    justify-content: flex-end;
    margin-top: var(--s-4);
}

/* Phone (< 720 px; §7.8): cards single-column and full-width, the
 * action row wraps with full-width touch targets, the tiles stack,
 * and the footer stacks Save above Skip. */
@media (max-width: 720px) {
    /* §7.8 (touch targets >= 44px): the quiet "Manage repository
     * access" link is inline text on the desktop; on the phone it
     * becomes an inline-flex box so min-height gives it a 44px tap
     * area without changing its look. */
    .ig-manage-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .ig-grid {
        grid-template-columns: 1fr;
        gap: var(--s-4);
    }

    .ig-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ig-actions .ig-btn {
        width: 100%;
        min-height: 44px;
    }

    .ig-btn-quiet {
        margin-left: 0;
    }

    .ig-ws-grid {
        grid-template-columns: 1fr;
    }

    .ig-ws-foot {
        flex-direction: column;
        align-items: stretch;
    }

    .ig-ws-foot .ig-btn {
        width: 100%;
        min-height: 44px;
    }

    .ig-ws-note {
        margin-left: 0;
    }
}

/* Reduced motion: the entrance motion, the card hover lift and every
 * transition go still. */
@media (prefers-reduced-motion: reduce) {
    .ig-card,
    .ig-ws {
        animation: none;
    }

    .ig-card,
    .ig-btn,
    .ig-ws-tile {
        transition: none;
    }

    .ig-card:hover {
        transform: none;
    }
}
