/**
 * assets/handbook.css
 * Front-end structural styles — BEM throughout.
 * Front-end dev updates CSS custom properties to match ClubsNSW design system.
 */

:root {
    --handbook-sidebar-width: 280rem;
    --handbook-sidebar-bg: var(--teal-10);
    --handbook-sidebar-border: #d0ebe9;
    --handbook-content-max: 780rem;
    --handbook-content-padding: 48rem;
    --handbook-toc-indent: 12rem;
    --handbook-link-color: #0076AD;
    --handbook-link-hover: #0076AD;
    --handbook-active-bg: #0066cc;
    --handbook-active-color: #ffffff;
    --handbook-title-color: #1a1a1a;
    --handbook-body-color: #333333;
    --handbook-meta-color: #666666;
    --handbook-border-color: #e0e0e0;
    --handbook-font-body: "Inter", sans-serif;
    --handbook-font-ui: "Inter", sans-serif;
    --handbook-transition: 0.2s ease;
}

/* Layout */
.handbook-layout {
    display: flex;
    align-items: flex-start;
    min-height: 80vh;
}

.handbook-layout__sidebar {
    width: var(--handbook-sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    /* height: 100vh; */
    overflow-y: auto;
    border-right: 1rem solid var(--handbook-sidebar-border);
    background: var(--white);
}

/* Scrollbar styling */
.handbook-layout__sidebar::-webkit-scrollbar {
    width: 8rem;
}

.handbook-layout__sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.handbook-layout__sidebar::-webkit-scrollbar-thumb {
    background: var(--grey-dark);
    border-radius: 0;
    min-height: 40px;
}

.handbook-layout__sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--teal);
}

.handbook-layout__content {
    flex: 1;
    min-width: 0;
    max-width: calc(var(--handbook-content-max) + var(--handbook-content-padding) * 2);
}

/* Sidebar */
.handbook-sidebar__inner {
    padding: 36rem 0;
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.handbook-sidebar__header {
    padding: 0 20rem 16rem 0;
    border-bottom: 1rem solid var(--handbook-sidebar-border);
    margin-bottom: 8rem;
}

.handbook-sidebar__header a {
    color: var(--black);
}

.handbook-sidebar__handbook-title {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: 0.05em;
    color: var(--black);
    text-decoration: none;
}

.handbook-sidebar__handbook-title:hover {
    color: var(--teal);
}

.handbook-sidebar__toc-link {
    display: block;
    font-family: "Inter", sans-serif;
    color: var(--black);
    text-decoration: none;
    border-left: 3rem solid transparent;
    margin-top: 28rem;
    padding-left: 8rem;
}

.handbook-sidebar__mobile-toggle {
    display: none;
}

/* TOC */
.handbook-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.handbook-toc__link {
    display: block;
    font-family: var(--handbook-font-ui);
    line-height: 1.4;
    color: var(--handbook-body-color);
    text-decoration: none;
    transition: all var(--handbook-transition);
    border-left: 3rem solid transparent;
    padding: 7rem 40rem 7rem 8rem;
}

.handbook-toc__link:hover {
    /* color: var(--handbook-link-color); */
    background: var(--teal-10);
}

.handbook-toc__item .accordion-wrap {
    position: relative;
}

.handbook-toc__item .accordion-wrap .accordion-toggle {
    height: 36rem;
    width: 50rem;
    position: absolute;
    top: 0rem;
    right: 0rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.handbook-toc__item .accordion-wrap .accordion-toggle::before {
    content: "";
    width: 15rem;
    height: 9rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='9' viewBox='0 0 15 9' fill='none'%3E%3Cpath d='M6.375 0.40625C6.78125 0 7.40625 0 7.8125 0.40625L13.8125 6.40625C14.1875 6.78125 14.1875 7.4375 13.8125 7.8125C13.4062 8.21875 12.7812 8.21875 12.375 7.8125L7.09375 2.53125L1.8125 7.8125C1.40625 8.21875 0.78125 8.21875 0.375 7.8125C0 7.4375 0 6.78125 0.375 6.40625L6.375 0.40625Z' fill='%23000000'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 15rem 9rem;
    transform: rotate(180deg);
    transition: transform var(--handbook-transition), background-image var(--handbook-transition);
}

.handbook-toc__item .accordion-wrap.inactive .accordion-toggle::before {
    transform: rotate(0deg);
}

.handbook-toc__item .accordion-wrap .handbook-toc__link.is-active + .accordion-toggle::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='9' viewBox='0 0 15 9' fill='none'%3E%3Cpath d='M6.375 0.40625C6.78125 0 7.40625 0 7.8125 0.40625L13.8125 6.40625C14.1875 6.78125 14.1875 7.4375 13.8125 7.8125C13.4062 8.21875 12.7812 8.21875 12.375 7.8125L7.09375 2.53125L1.8125 7.8125C1.40625 8.21875 0.78125 8.21875 0.375 7.8125C0 7.4375 0 6.78125 0.375 6.40625L6.375 0.40625Z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.handbook-toc__item.is-active>.handbook-toc__link {
    background: var(--teal);
    color: var(--white);
}

/* Prevent mobile tap highlight and active outline on the accordion toggle */
.handbook-toc__item .accordion-wrap .accordion-toggle,
.handbook-toc__item .accordion-wrap .accordion-toggle * {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.handbook-toc__item .accordion-wrap .accordion-toggle:active,
.handbook-toc__item .accordion-wrap .accordion-toggle:focus {
    outline: none;
    box-shadow: none;
}

/* Depth 0 — Parts */
.handbook-toc__list--depth-0>.handbook-toc__item>.handbook-toc__link {
    font-weight: 400;
    font-size: 14rem;
    padding: 7rem 10rem 7rem 8rem;
}

/* Depth 1 — Sections */
.handbook-toc__list--depth-1>.handbook-toc__item>.handbook-toc__link {
    font-size: 14rem;
    padding: 5rem 20rem 5rem calc(10rem + var(--handbook-toc-indent));
}

/* Depth 2 — Sub-sections */
.handbook-toc__list--depth-2>.handbook-toc__item>.handbook-toc__link {
    font-size: 14rem;
    padding: 4rem 20rem 4rem calc(10rem + var(--handbook-toc-indent) * 2);
}

/* Search */
.handbook-sidebar__search {
    padding: 8rem 0rem 12rem;
}

.handbook-search-form__inner {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1rem solid var(--handbook-sidebar-border);
    border-radius: 6rem;
    overflow: hidden;
    transition: border-color var(--handbook-transition);
    border-radius: 30rem;
    margin-right: 10rem;
}

.handbook-search-form__inner:focus-within {
    border-color: var(--handbook-link-color);
    box-shadow: 0 0 0 2rem rgba(0, 102, 204, 0.15);
}

.handbook-search-form__input {
    flex: 1;
    border: none;
    padding: 8rem 12rem;
    font-family: var(--handbook-font-ui);
    font-size: 16rem;
    background: transparent;
    outline: none;
}

.handbook-search-form__btn {
    background: none;
    border: none;
    padding: 8rem 20rem 8rem 0rem;
    cursor: pointer;
    color: var(--handbook-meta-color);
    display: flex;
    align-items: center;
}

.handbook-search-form__btn:hover {
    color: var(--handbook-link-color);
}

/* Chapter content */
/* .handbook-chapter__inner {
    max-width: var(--handbook-content-max);
} */

/* .handbook-chapter__header {
    margin-bottom: 32rem;
    padding-bottom: 24rem;
} */

.handbook-chapter__title {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    color: var(--handbook-title-color);
    line-height: 1.2;
    margin: 0 0 12rem;
}

.handbook-chapter__meta {
    display: flex;
    align-items: center;
    gap: 12rem;
    flex-wrap: wrap;
}

.handbook-chapter__reviewed {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    color: var(--handbook-meta-color);
}

.handbook-chapter__intro {
    background: #f8f9fa;
    border-left: 4rem solid var(--handbook-active-bg);
    padding: 16rem 20rem;
    margin-bottom: 32rem;
    border-radius: 0 4rem 4rem 0;
}

.handbook-chapter__intro p {
    margin: 0;
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    line-height: 1.6;
}

.handbook-chapter__section-index {
    background: #fff;
    border: 1rem solid var(--handbook-border-color);
    border-radius: 6rem;
    padding: 24rem;
    margin-bottom: 32rem;
}

.handbook-chapter__section-index-title {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--handbook-meta-color);
    margin: 0 0 16rem;
}

.handbook-chapter__section-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12rem;
}

.handbook-chapter__section-list li a {
    font-family: var(--handbook-font-ui);
    font-weight: 600;
    color: var(--handbook-link-color);
    text-decoration: none;
    font-size: 12rem;
}

.handbook-chapter__section-excerpt {
    margin: 2rem 0 0;
    font-size: 12rem;
    color: var(--handbook-meta-color);
    font-family: var(--handbook-font-ui);
}

.handbook-chapter__body {
    font-family: var(--handbook-font-body);
    font-size: 12rem;
    line-height: 1.7;
    color: var(--handbook-body-color);
}

.handbook-chapter__body p {
    margin: 0 0 1.25em;
    font-family: "Inter", sans-serif;
}

.handbook-chapter__body ul, .handbook-chapter__body ol {
	margin: 0;
	padding-left: 1.5em;
}

#md_body .handbook-nav .button::before, #md_body .handbook-nav .button::after {
	top: 3rem;
	position: relative;
}

.handbook-chapter__body li {
    margin-bottom: 0.4em;
}

.handbook-chapter__body a {
    color: var(--handbook-link-color);
}

.handbook-chapter__body strong {
    font-weight: 700;
    color: var(--handbook-title-color);
}

.handbook-chapter__status {
    display: inline-block;
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    padding: 3rem 10rem;
    border-radius: 100rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status--current {
    background: #e6f4ea;
    color: #1e7e34;
}

.status--review {
    background: #fff3cd;
    color: #856404;
}

.status--draft {
    background: #f8f9fa;
    color: #6c757d;
}

.handbook-breadcrumb {
    margin-bottom: 22rem;
}

.handbook-breadcrumb__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4rem;
    align-items: center;
}

.handbook-breadcrumb__item {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    color: var(--handbook-meta-color);
    display: flex;
    align-items: center;
    gap: 4rem;
    font-size: 14rem;
}

.handbook-breadcrumb__item:not(:last-child)::after {
    content: '›';
    color: var(--handbook-border-color);
    margin-left: 4rem;
}

.handbook-breadcrumb__item a {
    color: var(--grey-dark);
    text-decoration: none;
}

.handbook-breadcrumb__item a:hover {
    color: var(--teal);
}

.handbook-breadcrumb__item--current {
    color: var(--handbook-body-color);
    font-weight: 500;
}

.handbook-chapter__related {
    margin-top: 48rem;
    padding-top: 32rem;
    border-top: 1rem solid var(--handbook-border-color);
}

.handbook-chapter__related-title {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--handbook-meta-color);
    margin: 0 0 16rem;
}

.handbook-chapter__related-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200rem, 1fr));
    gap: 12rem;
}

.handbook-chapter__related-item {
    background: #f8f9fa;
    border: 1rem solid var(--handbook-border-color);
    border-radius: 6rem;
    padding: 14rem 16rem;
}

.handbook-chapter__related-item a {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 600;
    color: var(--handbook-link-color);
    text-decoration: none;
    display: block;
    margin-bottom: 4rem;
}

.handbook-chapter__related-item p {
    margin: 0;
    font-size: 12rem;
    color: var(--handbook-meta-color);
    line-height: 1.4;
}

.handbook-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16rem;
    margin-top: 32rem;

    @media (min-width: 1024px) {
        margin-left: 30rem;
    }
}

.handbook-nav__prev {
    flex: 1;
}

.handbook-nav__prev,
.handbook-nav__next {
    display: flex;
}

.handbook-nav .button {
    display: inline-flex;
    align-items: center;
    gap: 10rem;
    color: var(--black);
    border-color: var(--black);
}

.handbook-nav__prev .button span,
.handbook-nav__next .button span {
    color: var(--black);
}

.handbook-nav .button:hover,
.handbook-nav .button:focus-visible {
    color: var(--white);
    background-color: var(--black);
    border-color: var(--black);
}

.handbook-nav .button::before,
.handbook-nav .button::after {
    content: '';
    display: inline-block;
    width: 16rem;
    height: 16rem;
    background-color: currentColor;
    -webkit-mask-image: url('../images/icon-arrow.svg');
    mask-image: url('../images/icon-arrow.svg');
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    flex-shrink: 0;
}

.handbook-nav__prev .button::before {
	/* transform: rotate(180deg); */
	transform: scaleX(-1);
}

.handbook-nav__prev .button::after {
    content: none;
}

.handbook-nav__next .button::before {
    content: none;
}

.handbook-nav__prev .button:hover span,
.handbook-nav__next .button:hover span {
    color: var(--white);
}

.handbook-nav__next {
    text-align: right;
}

.handbook-nav__link {
    display: inline-flex;
    flex-direction: column;
    gap: 4rem;
    text-decoration: none;
    padding: 14rem 18rem;
    border: 1rem solid var(--handbook-border-color);
    border-radius: 6rem;
    transition: all var(--handbook-transition);
    max-width: 280rem;
}

.handbook-nav__link:hover {
    border-color: var(--handbook-link-color);
    background: rgba(0, 102, 204, 0.04);
}

.handbook-nav__label {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.handbook-nav__title {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 600;
    color: var(--handbook-link-color);
    line-height: 1.3;
}

.handbook-archive {
    max-width: var(--handbook-content-max);
}

.handbook-archive__header {
    margin-bottom: 40rem;
    padding-bottom: 32rem;
    border-bottom: 2rem solid var(--handbook-border-color);

    @media (min-width: 1024px) {
        margin-left: 30rem;
    }

}

.handbook-archive__title {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    font-weight: 700;
    color: var(--handbook-title-color);
    margin: 0 0 12rem;
}

.handbook-archive__intro {
    font-family: var(--handbook-font-body);
    font-size: 16rem;
    line-height: 1.6;
    color: var(--handbook-body-color);
    margin: 0;
}

.handbook-toc-index {
    @media (min-width: 1024px) {
        margin-left: 30rem;
        margin-bottom: 60rem;
    }
}

.handbook-toc-index__heading {
    font-family: var(--handbook-font-ui);
    font-size: 16rem;
    font-weight: 700;
    margin: 0 0 24rem;
}



.handbook-toc-index__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8rem;
}

.handbook-toc-index__item {
    padding: 16rem 20rem;
    border: 1rem solid var(--handbook-border-color);
    border-radius: 8rem;
    transition: border-color var(--handbook-transition);
}

.handbook-toc-index__item:hover {
    border-color: var(--handbook-link-color);
}

.handbook-toc-index__link {
    font-family: var(--handbook-font-ui);
    font-size: 16rem;
    font-weight: 700;
    color: var(--handbook-link-color);
    text-decoration: none;
    display: block;
    margin-bottom: 8rem;
}

.handbook-toc-index__sublist {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.handbook-toc-index__subitem a {
    font-family: var(--handbook-font-ui);
    font-size: 16rem;
    color: var(--handbook-body-color);
    text-decoration: none;
}

.handbook-toc-index__subitem a:hover {
    color: var(--handbook-link-color);
}

/* Mobile */
@media (max-width: 900px) {
    .handbook-layout {
        flex-direction: column;
    }

    .handbook-layout__sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1rem solid var(--teal);
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .handbook-layout__sidebar.is-open {
        max-height: 80vh;
        overflow-y: auto;
    }

    .handbook-sidebar__mobile-toggle {
        display: flex;
        align-items: center;
        gap: 8rem;
        background: var(--handbook-sidebar-bg);
        border: none;
        padding: 16rem 20rem;
        font-family: var(--handbook-font-ui);
        font-size: 16rem;
        font-weight: 600;
        cursor: pointer;
        width: 100%;
        border-bottom: 1rem solid var(--handbook-sidebar-border);
    }

    .handbook-layout__content {
        padding: 24rem 20rem;
    }

    .handbook-chapter__title {
        font-size: 12rem;
    }

    .handbook-nav__next {
        text-align: left;
    }
}

/* Contact footer */
.handbook-chapter__contact {
    margin-top: 32rem;
    padding: 16rem 20rem;
    background: #f8f9fa;
    border-radius: 6rem;
    border-left: 4rem solid var(--handbook-border-color);
}

.handbook-chapter__contact p {
    margin: 0;
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    color: var(--handbook-meta-color);
}

.handbook-chapter__contact a {
    color: var(--handbook-link-color);
}

.handbook-sidebar__version {
    display: block;
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    color: var(--handbook-meta-color);
    margin-top: 4rem;
}

.handbook-archive__meta {
    font-family: var(--handbook-font-ui);
    font-size: 12rem;
    color: var(--handbook-meta-color);
    margin: 0 0 12rem;
}