/*
 * Two-level site navigation.
 * The existing switcher/menu rules remain the source of truth for the
 * desktop details control; these rules only add the new navigation shells.
 */

.orl-site-nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.orl-site-nav > .orl-site-root,
.orl-site-nav > .orl-switcher {
  flex: 0 1 auto;
  min-width: 0;
}

.orl-site-root {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  max-width: 100%;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--orl-text);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.orl-site-root:hover {
  border-color: var(--orl-accent);
  background: var(--orl-hover);
  color: var(--orl-text);
}

.orl-site-root[aria-current="location"] {
  border-color: var(--orl-accent);
  background: var(--orl-hover);
  color: var(--orl-accent);
  font-weight: 700;
}

.orl-site-root:focus-visible {
  border-color: var(--orl-accent);
  outline: 2px solid var(--orl-accent);
  outline-offset: 2px;
}

.orl-site-nav > .orl-switcher > summary[aria-current="location"] {
  border-color: var(--orl-accent);
  background: var(--orl-hover);
  color: var(--orl-accent);
  font-weight: 700;
}

/* Keep the customisation route discoverable without competing with current state. */
.orl-site-nav .orl-custom-option:not([aria-current="page"]),
.orl-mobile-tree .orl-custom-option:not([aria-current="page"]) {
  background: color-mix(in srgb, var(--orl-accent) 10%, var(--orl-panel));
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--orl-accent) 58%, transparent);
}

.orl-site-nav .orl-site-option[aria-current="page"],
.orl-mobile-tree .orl-mobile-child[aria-current="page"] {
  background: var(--orl-hover);
  box-shadow: inset 1px 0 0 var(--orl-accent);
  color: var(--orl-accent);
  font-weight: 700;
}

/* The new mobile tree is hidden until its site's existing mobile breakpoint. */
body[data-orl-site] .orl-mobile-sites.orl-mobile-tree {
  display: none;
  box-sizing: border-box;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  width: 100%;
  min-width: 0;
  margin: 0 0 4px;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--orl-line);
}

body[data-orl-site] .orl-mobile-sites.orl-mobile-tree > .orl-mobile-root,
body[data-orl-site] .orl-mobile-sites.orl-mobile-tree > .orl-mobile-branch {
  width: 100%;
  min-width: 0;
}

.orl-mobile-root,
.orl-mobile-branch > summary,
.orl-mobile-child {
  box-sizing: border-box;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--orl-text);
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  text-decoration: none;
  white-space: normal;
}

.orl-mobile-root,
.orl-mobile-child {
  display: flex;
  align-items: center;
}

.orl-mobile-root {
  justify-content: flex-start;
  font-weight: 650;
}

.orl-mobile-branch {
  display: block;
  min-width: 0;
}

.orl-mobile-branch > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}

.orl-mobile-branch > summary::-webkit-details-marker,
.orl-mobile-branch > summary::marker {
  display: none;
  content: "";
}

.orl-mobile-branch > summary .orl-switcher-chevron {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform .16s ease;
}

.orl-mobile-branch[open] > summary .orl-switcher-chevron {
  transform: rotate(180deg);
}

.orl-mobile-children {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  padding: 4px 0 0 12px;
}

.orl-mobile-child {
  gap: 7px;
  overflow-wrap: anywhere;
  text-align: left;
}

.orl-mobile-child .orl-site-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.orl-mobile-root:hover,
.orl-mobile-branch > summary:hover,
.orl-mobile-child:hover {
  background: var(--orl-hover);
  color: var(--orl-text);
}

.orl-mobile-root:focus-visible,
.orl-mobile-branch > summary:focus-visible,
.orl-mobile-child:focus-visible {
  border-color: var(--orl-accent);
  outline: 2px solid var(--orl-accent);
  outline-offset: -2px;
}

.orl-mobile-root[aria-current="location"],
.orl-mobile-branch > summary[aria-current="location"] {
  border-color: var(--orl-accent);
  background: var(--orl-hover);
  color: var(--orl-accent);
  font-weight: 700;
}

.orl-mobile-branch[open] > summary:not([aria-current="location"]) {
  border-color: color-mix(in srgb, var(--orl-accent) 42%, transparent);
}

/* Match the three existing site palettes without changing the old switcher. */
body[data-orl-site="official"] .orl-site-nav,
body[data-orl-site="official"] .orl-mobile-sites.orl-mobile-tree {
  --orl-panel: #171720;
  --orl-hover: #2a2935;
  --orl-text: #faf7ef;
  --orl-muted: #d0c8d0;
  --orl-accent: #ffda3e;
  --orl-line: #ffffff55;
}

body[data-orl-site="studio"] .orl-site-nav,
body[data-orl-site="studio"] .orl-mobile-sites.orl-mobile-tree {
  --orl-panel: var(--surface);
  --orl-hover: var(--surface-2);
  --orl-text: var(--text);
  --orl-muted: var(--muted);
  --orl-accent: var(--purple);
  --orl-line: var(--line);
}

body[data-orl-site="opendoll"] .orl-site-nav,
body[data-orl-site="opendoll"] .orl-mobile-sites.orl-mobile-tree {
  --orl-panel: #141414;
  --orl-hover: #202a34;
  --orl-text: #f5f5f7;
  --orl-muted: #b8b8bd;
  --orl-accent: #1890ff;
  --orl-line: #3b3b40;
}

@media (max-width: 600px) {
  body[data-orl-site="official"] .orl-site-nav {
    display: none;
  }

  body[data-orl-site="official"] .orl-mobile-sites.orl-mobile-tree {
    display: grid;
  }
}

@media (max-width: 1240px) {
  body[data-orl-site="studio"] .orl-site-nav {
    display: none;
  }

  body[data-orl-site="studio"] .orl-mobile-sites.orl-mobile-tree {
    display: grid;
  }
}

@media (max-width: 1000px) {
  body[data-orl-site="opendoll"] .orl-site-nav {
    display: none;
  }

  body[data-orl-site="opendoll"] .orl-mobile-sites.orl-mobile-tree {
    display: grid;
  }
}


/* Give the Studio section links their own row on desktop. */
@media (min-width: 1241px) {
  :root[data-design="editorial"] body[data-orl-site="studio"] .site-header {
    height: auto;
    flex-wrap: wrap;
    column-gap: 16px;
    row-gap: 0;
  }

  body[data-orl-site="studio"] .site-header > .orl-studio-brand-group,
  body[data-orl-site="studio"] .site-header > .header-actions {
    min-height: 64px;
  }

  body[data-orl-site="studio"] .site-header > .main-nav {
    order: 4;
    flex: 1 0 100%;
    height: 52px;
    gap: 4px;
    justify-content: space-between;
    border-top: 1px solid var(--line);
  }

  :root[data-design="editorial"] body[data-orl-site="studio"] .site-header > .main-nav > a {
    flex: 1 1 0;
    justify-content: center;
    height: 48px;
    padding-inline: 8px;
    font-size: 14px;
  }

  :root[data-design="editorial"] body[data-orl-site="studio"] .site-header > .main-nav > a:hover {
    background: var(--surface-2);
  }

  :root[data-design="editorial"] body[data-orl-site="studio"] .site-header > .main-nav > a:focus-visible {
    outline: 2px solid var(--purple);
    outline-offset: -2px;
  }

  :root[data-design="editorial"] body[data-orl-site="studio"] .site-header > .main-nav > a.active {
    color: var(--purple);
    font-weight: 650;
  }

  :root[data-design="editorial"] body[data-orl-site="studio"] .site-header > .main-nav > a.active::after {
    inset-inline: calc(50% - 12px);
    height: 2px;
  }
}
