/* Home ---------------------------------------------------------------- */

body {
    padding-top: 64px;
}

.home-header {
    max-width: 760px;
    margin-bottom: 44px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-bottom: 28px;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1;
}

.brand img {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.home-description {
    margin-bottom: 22px;
    color: var(--text-soft);
    word-break: keep-all;
    font-size: clamp(17px, 2.2vw, 19px);
    letter-spacing: -0.01em;
    line-height: 1.7;
}

.home-description a {
    margin-left: 6px;
    color: var(--text);
    text-decoration-color: var(--border-strong);
    white-space: nowrap;
}

.home-description a:hover {
    text-decoration-color: currentColor;
}

.home-notice {
    margin-bottom: 0;
}

.home-section {
    margin-top: 48px;
}

.home-section .section-title {
    margin-top: 0;
}

/* Card grid ----------------------------------------------------------- */

.subtitles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.subtitles--clients {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.myButton {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 72px;
    margin: 0;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
    text-align: left;
    text-decoration: none;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: border-color 200ms var(--ease), background-color 200ms var(--ease), box-shadow 200ms var(--ease), transform 200ms var(--ease);
}

.myButton b {
    min-width: 0;
    font-weight: 550;
    letter-spacing: -0.01em;
}

.myButton:hover,
.myButton:focus-visible {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    box-shadow: var(--shadow-md);
    color: var(--text);
    transform: translateY(-2px);
}

.myButton:active {
    border-color: var(--border-strong);
    background: var(--surface-active);
    transform: translateY(0) scale(.992);
}

.myButton:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* Open state of the rule picker / share button */
.rule-picker > .myButton[aria-expanded="true"],
#shareBtn:has(.share-popover.active) {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    box-shadow: var(--shadow-sm), var(--ring);
    transform: none;
}

/* Quiet chevron on every link card */
.subtitles > a:not(#shareBtn)::after {
    content: "";
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    margin-right: 3px;
    border-top: 1.5px solid var(--subtle);
    border-right: 1.5px solid var(--subtle);
    transform: rotate(45deg);
    transition: transform 200ms var(--ease), border-color 200ms var(--ease);
}

.subtitles > a:not(#shareBtn):hover::after {
    border-color: var(--text);
    transform: translateX(3px) rotate(45deg);
}

/* Client cards: icon on top, name below */
.client-card {
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 22px;
    min-height: 132px;
    padding: 20px;
}

.client-card > img {
    display: block;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 40px;
    height: 40px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-soft);
    object-fit: contain;
    transition: transform 200ms var(--ease);
}

.client-card > img[src*="/IMG/app-"] {
    padding: 0;
    border-radius: 9px;
    object-fit: cover;
}

.client-card:hover > img {
    transform: scale(1.05);
}

.subtitles > a.client-card::after {
    position: absolute;
    top: 22px;
    right: 20px;
}

/* Rule picker and share button use the same card; their chevron sits top-right too */
.client-card .rule-chevron {
    position: absolute;
    top: 22px;
    right: 22px;
    margin: 0;
}

.rule-picker > .myButton.client-card[aria-expanded="true"] .rule-chevron {
    top: 26px;
    margin: 0;
}

#shareBtn.client-card b {
    min-height: 0;
}

/* Rule picker --------------------------------------------------------- */

.rule-picker {
    position: relative;
    min-width: 0;
}

.rule-picker:focus-within {
    z-index: 3;
}

.rule-picker > .myButton {
    height: 100%;
}

.rule-chevron {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    margin: -4px 3px 0 0;
    overflow: hidden;
    border-right: 1.5px solid var(--subtle);
    border-bottom: 1.5px solid var(--subtle);
    color: transparent;
    font-size: 0;
    transform: rotate(45deg);
    transition: transform 200ms var(--ease), border-color 200ms var(--ease);
}

.rule-picker > .myButton:hover .rule-chevron {
    border-color: var(--text);
}

.rule-picker > .myButton[aria-expanded="true"] .rule-chevron {
    margin-top: 4px;
    border-color: var(--text);
    transform: rotate(225deg);
}

.rule-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 10;
    box-sizing: border-box;
    width: max-content;
    min-width: 100%;
    max-width: calc(100vw - 36px);
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-popover);
    animation: pop-in 160ms var(--ease);
}

.rule-options[hidden] {
    display: none;
}

.rule-options a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 450;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.rule-options a + a {
    margin-top: 2px;
}

.rule-options a:hover {
    background: var(--surface-active);
    color: var(--text);
}

.rule-options a:focus-visible {
    outline: none;
    background: var(--surface-active);
    box-shadow: inset 0 0 0 1.5px var(--focus);
    color: var(--text);
}

/* Share popover ------------------------------------------------------- */

#shareBtn {
    position: relative;
}

#shareBtn:focus-within {
    z-index: 3;
}

.share-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    z-index: 10;
    box-sizing: border-box;
    width: max-content;
    max-width: calc(100vw - 36px);
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-popover);
    cursor: default;
}

.share-popover.active {
    display: block;
    animation: pop-in 160ms var(--ease);
}

.share-flex {
    display: flex;
    align-items: center;
    gap: 6px;
}

.s-btn-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
    cursor: pointer;
    transition: border-color 140ms var(--ease), background-color 140ms var(--ease), transform 140ms var(--ease);
}

.s-btn-img:hover {
    border-color: var(--border-strong);
    background: var(--surface-active);
}

.s-btn-img:active {
    transform: scale(.96);
}

.s-btn-img img {
    display: block;
    width: 30px;
    height: 30px;
}

.arrow-down {
    position: absolute;
    top: 100%;
    left: 24px;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    transform: rotate(45deg);
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(4px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* Responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
    .subtitles--clients {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    body {
        padding-top: 36px;
    }

    .brand {
        margin-bottom: 22px;
    }

    .home-header {
        margin-bottom: 36px;
    }

    .home-section {
        margin-top: 40px;
    }

    .subtitles,
    .subtitles--clients {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .myButton {
        min-height: 64px;
        padding: 16px;
        border-radius: var(--radius);
        font-size: 14px;
    }

    .client-card {
        gap: 18px;
        min-height: 116px;
        padding: 16px;
    }

    .subtitles > a.client-card::after {
        top: 20px;
        right: 16px;
    }

    .client-card .rule-chevron {
        top: 20px;
        right: 18px;
    }

    .rule-picker > .myButton.client-card[aria-expanded="true"] .rule-chevron {
        top: 24px;
    }

    .share-popover {
        right: 0;
        left: auto;
    }

    .arrow-down {
        right: 24px;
        left: auto;
    }
}

@media (hover: none) {
    .myButton:hover {
        box-shadow: var(--shadow-sm);
        transform: none;
    }
}
