/* The top bar on every page, the home page too (nav.js): the brand, the four places to go, then Search, the bell and
   your picture as plain round icons. Where the four don't fit, they go under a Menu button. Then the search itself: a
   box over the page from the bar, or filling /search. */

/* ------------------------------------------------------------ the bar */

.nav .nav-inner {
  gap: 0;
}

.nav .brand {
  margin-right: 28px;
}

/* Where to go: the same four on every page, and the page you're on underlined. */
.nav .nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
}

.nav .nav-links a {
  position: relative;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--haze);
  font: 600 15px/1.2 var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav .nav-links a:hover {
  background: rgba(246, 241, 255, 0.06);
  color: var(--moon);
}

.nav .nav-links a:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.nav .nav-links a[aria-current="page"] {
  color: var(--moon);
}

.nav .nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 1px;
  left: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--pink);
}

/* Search and Menu, then the bell and your picture (or Sign in): together at the right. */
.nav .nav-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav .nav-end {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.nav-search,
.nav-menu,
.nav .bell {
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--haze);
  cursor: pointer;
}

.nav-search:hover,
.nav-menu:hover,
.nav-menu[aria-expanded="true"],
.nav .bell:hover {
  background: rgba(246, 241, 255, 0.08);
  color: var(--moon);
}

.nav-search:focus-visible,
.nav-menu:focus-visible,
.nav .bell:focus-visible,
.nav .me-button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.nav-search svg,
.nav-menu svg,
.nav .bell svg {
  width: 20px;
  height: 20px;
}

.nav-menu {
  display: none;
}

/* How many notifications are new, on the bell. */
.nav .bell-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border: 2px solid var(--night);
  border-radius: 999px;
  background: var(--pink-press);
  color: var(--moon);
  font: 800 10.5px/15px var(--text);
  text-align: center;
}

/* Your picture opens your menu; your name is at the top of it (and in the button's label). */
.nav .me-button {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(246, 241, 255, 0.04);
  cursor: pointer;
}

.nav .me-button:hover,
.nav .me-button[aria-expanded="true"] {
  border-color: rgba(246, 241, 255, 0.6);
}

.nav .me-button img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.nav .me-button span {
  display: none;
}

.nav .nav-end .button-small {
  margin-left: 8px;
}

/* Who you're signed in as, at the top of your menu. */
.menu .menu-me {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.menu-me img {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
}

.menu-me span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.menu-me b {
  overflow: hidden;
  font: 700 15.5px/1.2 var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-me small {
  color: var(--dim);
  font: 600 13px/1.2 var(--text);
}

/* Where the four don't fit: they go under Menu. */
@media (max-width: 900px) {
  .nav .nav-links {
    display: none;
  }

  .nav-menu {
    display: inline-grid;
  }
}

.nav-panel {
  position: absolute;
  top: calc(var(--nav-h) - 6px);
  right: max(var(--gutter), (100% - var(--content)) / 2);
  z-index: 46;
  display: grid;
  min-width: 230px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #1a1140;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
}

.nav-panel[hidden] {
  display: none;
}

.nav-panel a {
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--moon);
  font: 650 16px/1.2 var(--text);
  text-decoration: none;
}

.nav-panel a:hover,
.nav-panel a:focus-visible {
  background: rgba(246, 241, 255, 0.08);
  outline: none;
}

.nav-panel a[aria-current="page"] {
  color: var(--amber);
}

/* Phones: everything a little closer. */
@media (max-width: 600px) {
  .nav .nav-tools,
  .nav .nav-end {
    gap: 2px;
  }

  .nav .me-button {
    margin-left: 4px;
  }

  .nav-panel {
    left: var(--gutter);
    min-width: 0;
  }
}

/* The smallest phones: the logo alone says RailroaderHub. */
@media (max-width: 420px) {
  .nav .brand > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* ------------------------------------------------------------ the search */

.sr-open {
  overflow: hidden;
}

.sr-dialog {
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
  margin: min(12vh, 110px) auto auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--moon);
  overflow: visible;
}

.sr-dialog::backdrop {
  background: rgba(9, 5, 24, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sr-box {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(640px, calc(100vh - min(12vh, 110px) - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: #1a1140;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.sr-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.sr-bar > svg {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--dim);
}

.sr-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--moon);
  font: 500 18px/1.2 var(--text);
  outline: none;
}

.sr-input::placeholder {
  color: var(--dim);
}

.sr-input::-webkit-search-cancel-button {
  display: none;
}

.sr-close {
  flex: none;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--haze);
  font: 650 14px/1 var(--text);
  cursor: pointer;
}

.sr-close:hover {
  color: var(--moon);
  border-color: rgba(246, 241, 255, 0.45);
}

.sr-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 8px 12px;
}

.sr-status {
  padding: 14px 12px 6px;
  color: var(--dim);
  font-size: 15px;
}

.sr-status:empty {
  display: none;
}

.sr-group + .sr-group {
  margin-top: 6px;
}

.sr-group-title {
  padding: 12px 12px 6px;
  color: var(--dim);
  font: 700 13.5px/1.2 var(--text);
}

.sr-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  color: var(--moon);
  text-decoration: none;
}

.sr-item[aria-selected="true"] {
  background: rgba(246, 241, 255, 0.09);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.sr-thumb {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(246, 241, 255, 0.07);
  color: var(--haze);
  font: 800 13px/1 var(--display);
  letter-spacing: 0.02em;
}

.sr-thumb[data-round] {
  border-radius: 50%;
}

.sr-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sr-thumb svg {
  width: 18px;
  height: 18px;
}

.sr-text {
  min-width: 0;
}

.sr-title {
  display: block;
  overflow: hidden;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-sub {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--haze);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-tag {
  padding: 4px 8px;
  border: 1px solid rgba(255, 195, 92, 0.45);
  border-radius: 6px;
  color: var(--amber);
  font: 800 12px/1 var(--display);
  letter-spacing: 0.1em;
}

.sr-more {
  grid-template-columns: 36px minmax(0, 1fr);
  color: var(--haze);
  font-size: 15px;
}

.sr-more .sr-thumb {
  background: transparent;
}

.sr-item mark {
  padding: 0 1px;
  border-radius: 3px;
  background: rgba(255, 195, 92, 0.28);
  color: inherit;
}

.sr-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 13.5px;
}

.sr-foot kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-right: 4px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--haze);
  font: 700 12px/1 var(--text);
}

.sr-foot a {
  color: var(--moon);
  font-weight: 650;
}

/* Phones: the search fills the screen. */
@media (max-width: 600px) {
  .sr-dialog {
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }

  .sr-box {
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .sr-keys {
    display: none;
  }
}

/* /search: the same search, in the page. */
.sr-page .sr-box {
  max-height: none;
  background: var(--panel, rgba(246, 241, 255, 0.03));
  box-shadow: none;
  overflow: visible;
}

.sr-page .sr-body {
  overflow: visible;
}

.sr-page .sr-bar {
  padding: 8px 12px 8px 18px;
}

@media (prefers-reduced-motion: no-preference) {
  .sr-dialog[open] .sr-box {
    animation: sr-in 0.14s ease-out;
  }
}

@keyframes sr-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
