/* Side navigation: a vertical menu on the left with grouped pages (desktop),
   collapsible to a column of icons. On phones the same markup is the
   full-screen menu of mobile-shell.js, now showing the groups. */
.nexo-sidebar-tip {
  position: fixed;
  z-index: 1300;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #0a1726;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px #0a172633;
}

@media (min-width: 961px) {
  .shell.moodle-layout {
    --nexo-sidebar-width: 256px;
    display: grid;
    grid-template-columns: var(--nexo-sidebar-width) minmax(0, 1fr);
    align-items: start;
    min-height: 100vh;
    transition: grid-template-columns 0.18s ease;
  }
  .shell.moodle-layout[data-sidebar="collapsed"] {
    --nexo-sidebar-width: 72px;
  }
  /* The help mascot sits in the bottom-right corner, over the page column:
     the end of every page can scroll above it, and keyboard focus stops
     short of it (as the phone layout does for its dock). */
  html:has(.shell.moodle-layout) {
    scroll-padding-bottom: 156px;
  }
  .moodle-layout main.content {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 160px;
  }
  .moodle-layout .moodle-header.nexo-sidebar {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    min-height: 0;
    padding: 0;
    background: #fff;
    border: 0;
    border-right: 1px solid var(--nexo-line);
    overflow: hidden;
  }

  /* Brand and the collapse button. */
  .moodle-layout .nexo-sidebar .moodle-brand {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 20px 8px 18px 20px;
  }
  .moodle-layout .nexo-sidebar .nexo-sidebar__wordmark {
    width: 124px;
  }
  .moodle-layout .nexo-sidebar .moodle-brand > span {
    font-size: 12px;
    white-space: nowrap;
  }
  .moodle-layout .nexo-sidebar .nexo-sidebar__collapse {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 0;
    margin: 18px 12px 0 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: #536985;
  }
  .moodle-layout .nexo-sidebar .nexo-sidebar__collapse:hover {
    background: #f1f4f7;
    color: var(--ink);
  }
  .moodle-layout .nexo-sidebar .nexo-sidebar__collapse svg {
    transition: transform 0.18s ease;
  }
  .moodle-layout .nexo-sidebar .moodle-menu-toggle {
    display: none;
  }

  /* Pages and groups. */
  .moodle-layout .nexo-sidebar .moodle-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    flex: none;
    gap: 2px;
    width: auto;
    min-height: 0;
    padding: 4px 12px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  .moodle-layout .nexo-sidebar .moodle-nav button,
  .moodle-layout .nexo-sidebar .moodle-user button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--nexo-muted);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    white-space: nowrap;
  }
  .moodle-layout .nexo-sidebar .moodle-nav button:hover,
  .moodle-layout .nexo-sidebar .moodle-user button:hover {
    background: #f1f4f7;
    color: var(--ink);
  }
  .moodle-layout .nexo-sidebar .moodle-nav button[aria-current="page"],
  .moodle-layout .nexo-sidebar .moodle-user button[aria-current="page"] {
    background: #fff1e6;
    color: #a43b08;
    font-weight: 600;
  }
  .moodle-layout .nexo-sidebar .moodle-nav button[aria-current="page"]::before,
  .moodle-layout
    .nexo-sidebar
    .moodle-user
    button[aria-current="page"]::before {
    content: "";
    position: absolute;
    inset: 8px auto 8px 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--nexo-accent);
  }
  .moodle-layout
    .nexo-sidebar
    :is(.moodle-nav, .moodle-user)
    button:focus-visible {
    outline: 3px solid var(--nexo-navy);
    outline-offset: -3px;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-icon {
    flex: none;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-extra {
    margin-left: auto;
    display: inline-flex;
  }
  .moodle-layout .nexo-sidebar .support-nav-badge {
    margin: 0;
    padding: 1px 7px;
    border-radius: 10px;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-group + :not(.nexo-nav-group) {
    margin-top: 6px;
  }
  .moodle-layout .nexo-sidebar .moodle-nav .nexo-nav-group__toggle {
    color: var(--ink);
    font-weight: 600;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-chevron {
    flex: none;
    width: 16px;
    height: 16px;
    margin-left: auto;
    color: #536985;
    transition: transform 0.18s ease;
  }
  .moodle-layout
    .nexo-sidebar
    .nexo-nav-group[data-open="false"]
    .nexo-nav-chevron {
    transform: rotate(180deg);
  }
  .moodle-layout .nexo-sidebar .nexo-nav-group__items {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .moodle-layout
    .nexo-sidebar
    .nexo-nav-group[data-open="false"]
    .nexo-nav-group__items {
    display: none;
  }
  /* Sub-items line up with the group's name, without their own icon, a
     little shorter than the pages so four groups fit a 900 px window. */
  .moodle-layout .nexo-sidebar .moodle-nav .nexo-nav-group__items button {
    min-height: 36px;
    padding: 6px 12px 6px 44px;
  }
  .moodle-layout .nexo-sidebar .nexo-nav-group__items .nexo-nav-icon {
    display: none;
  }

  /* "Gestão | Minha área": two halves of one control above the pages. */
  .moodle-layout .nexo-sidebar .nexo-area-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    flex-shrink: 0;
    margin: 0 0 10px;
    padding: 3px;
    border-radius: 10px;
    background: #f1f4f7;
  }
  .moodle-layout .nexo-sidebar .moodle-nav .nexo-area-switch button {
    justify-content: center;
    gap: 8px;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 14px;
  }
  .moodle-layout .nexo-sidebar .nexo-area-switch .nexo-nav-icon {
    width: 16px;
    height: 16px;
  }
  .moodle-layout
    .nexo-sidebar
    .moodle-nav
    .nexo-area-switch
    button[aria-pressed="true"] {
    background: #fff;
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 1px 2px rgb(16 32 51 / 14%);
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .nexo-area-switch {
    grid-template-columns: 1fr;
    padding: 2px;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-area-switch
    .nexo-nav-icon {
    width: 20px;
    height: 20px;
  }

  /* Contrast, account and exit at the foot of the menu. */
  .moodle-layout .nexo-sidebar .moodle-user {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 10px 12px 16px;
    border-top: 1px solid var(--nexo-line);
  }
  .moodle-layout .nexo-sidebar #toggle-contrast {
    min-width: 0;
    font-size: 15px;
  }
  .moodle-layout .nexo-sidebar #toggle-contrast[aria-pressed="true"] {
    color: var(--ink);
    font-weight: 600;
  }
  .moodle-layout .nexo-sidebar .moodle-user .avatar {
    display: grid;
    flex: none;
    width: 24px;
    height: 24px;
    margin: -2px -2px;
    font-size: 10px;
    background: #ecf1f7;
    color: var(--ink);
  }

  /* Collapsed: a column of icons; names appear as tips. */
  .moodle-layout[data-sidebar="collapsed"] .moodle-header.nexo-sidebar {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .moodle-brand {
    align-items: center;
    padding: 16px 0 6px;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .moodle-brand > span {
    display: none;
  }
  /* Only the book of the approved logo (its left part), from the same image:
     a second view of the SVG would be another 1.4 MB download. */
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-sidebar__wordmark {
    width: 42px;
    height: 30px;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: 0 50%;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-sidebar__collapse {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    margin: 0 0 6px;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-sidebar__collapse
    svg {
    transform: rotate(180deg);
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .moodle-nav {
    grid-row: 3;
    align-items: center;
    padding-inline: 0;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .moodle-user {
    grid-row: 4;
    align-items: center;
    padding-inline: 0;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    :is(.moodle-nav, .moodle-user)
    button,
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .moodle-nav
    .nexo-nav-group__items
    button {
    justify-content: center;
    width: 48px;
    min-height: 44px;
    padding: 0;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .nexo-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-nav-group__toggle {
    display: none;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .nexo-nav-group {
    align-items: center;
    width: 100%;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--nexo-line);
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-nav-group
    + :not(.nexo-nav-group) {
    margin-top: 13px;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-nav-group
    + :not(.nexo-nav-group)::after {
    content: "";
    position: absolute;
    top: -7px;
    left: -12px;
    right: -12px;
    border-top: 1px solid var(--nexo-line);
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-nav-group[data-open="false"]
    .nexo-nav-group__items {
    display: flex;
  }
  .moodle-layout[data-sidebar="collapsed"]
    .nexo-sidebar
    .nexo-nav-group__items
    .nexo-nav-icon {
    display: block;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .nexo-nav-extra {
    position: absolute;
    top: 3px;
    right: 2px;
    margin: 0;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .support-nav-badge {
    padding: 0 5px;
    font-size: 11px;
    line-height: 16px;
  }
  .moodle-layout[data-sidebar="collapsed"] .nexo-sidebar .moodle-user .avatar {
    width: 28px;
    height: 28px;
    margin: 0;
    font-size: 11px;
  }

  body.high-contrast .moodle-layout .nexo-sidebar {
    border-right-color: #000;
  }
  body.high-contrast
    .moodle-layout
    .nexo-sidebar
    :is(.moodle-nav, .moodle-user)
    button {
    color: #000;
  }
  body.high-contrast
    .moodle-layout
    .nexo-sidebar
    :is(.moodle-nav, .moodle-user)
    button[aria-current="page"] {
    background: #fff;
    outline: 2px solid #000;
    outline-offset: -2px;
  }
  body.high-contrast .nexo-sidebar-tip {
    background: #000;
  }
}

@media (min-width: 961px) and (max-height: 640px) {
  .moodle-layout .nexo-sidebar .moodle-brand {
    padding-block: 12px 10px;
  }
  .moodle-layout .nexo-sidebar .moodle-user {
    padding-block: 6px 8px;
  }
  .moodle-layout .nexo-sidebar :is(.moodle-nav, .moodle-user) button {
    min-height: 36px;
  }
}

/* Phones and small tablets: the full-screen menu shows the same groups. */
@media (max-width: 960px) {
  .moodle-layout .nexo-sidebar__collapse {
    display: none;
  }
  .moodle-layout .moodle-header[data-menu-open] .moodle-nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
  }
  .moodle-layout .nexo-area-switch {
    display: none;
  }
  .moodle-layout .moodle-header[data-menu-open] .nexo-area-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }
  .moodle-layout
    .moodle-header[data-menu-open]
    .moodle-nav
    .nexo-area-switch
    button {
    justify-content: center;
    border: 1px solid var(--nexo-line);
    border-radius: 8px;
  }
  .moodle-layout
    .moodle-header[data-menu-open]
    .moodle-nav
    .nexo-area-switch
    button[aria-pressed="true"] {
    border-color: var(--nexo-navy);
    color: var(--ink);
    font-weight: 700;
  }
  .moodle-layout .moodle-header[data-menu-open] .nexo-nav-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .moodle-layout .moodle-header[data-menu-open] .nexo-nav-group__toggle {
    background: transparent;
    color: var(--ink);
    font-weight: 700;
  }
  .moodle-layout .moodle-header[data-menu-open] .nexo-nav-chevron {
    width: 18px;
    height: 18px;
    margin-left: auto;
    transition: transform 0.18s ease;
  }
  .moodle-layout
    .moodle-header[data-menu-open]
    .nexo-nav-group[data-open="false"]
    .nexo-nav-chevron {
    transform: rotate(180deg);
  }
  .moodle-layout .moodle-header[data-menu-open] .nexo-nav-group__items {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .moodle-layout
    .moodle-header[data-menu-open]
    .nexo-nav-group[data-open="false"]
    .nexo-nav-group__items {
    display: none;
  }
  .moodle-layout
    .moodle-header[data-menu-open]
    .moodle-nav
    .nexo-nav-group__items
    button {
    padding-left: 48px;
  }
  .moodle-layout
    .moodle-header[data-menu-open]
    .nexo-nav-group__items
    .nexo-nav-icon {
    display: none;
  }
  .moodle-layout .moodle-header[data-menu-open] .nexo-nav-extra {
    margin-left: auto;
  }
  .moodle-layout .moodle-header[data-menu-open] .moodle-user button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .moodle-layout #toggle-contrast {
    font-size: 15px;
  }
  .moodle-layout #toggle-contrast::after {
    content: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell.moodle-layout,
  .moodle-layout .nexo-sidebar svg,
  .moodle-layout .nexo-nav-chevron {
    transition: none !important;
  }
}
