:root {
  --font-family:
    system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  --font-family-monospace:
    ui-monospace, 'Cascadia Code', Consolas, Menlo, 'Liberation Mono', monospace;

  --accent: #4a6fa5;
  --accent-dark: #3a5a8c;
}
*,
::before,
::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  color: #222;
  background-color: #fafafe;
  font-size: 16px;
  line-height: 1.4em;
  font-family: var(--font-family);
  display: flex;
  height: 100%;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

.monospaced,
code,
[data-label='Address'],
[data-label='Prefix'] {
  font-family: var(--font-family-monospace);
  &:not(input, h2) {
    font-size: 14px;
  }
}

[data-label]::before {
  font-family: var(--font-family);
  font-size: 16px;
  text-align: start;
}

.hidden {
  visibility: hidden;
}

.d-none {
  display: none;
}

.container {
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  padding-left: 1em;
  padding-right: 1em;

  @media screen and (min-width: 576px) {
    max-width: 540px;
  }

  @media screen and (min-width: 768px) {
    max-width: 720px;
  }

  @media screen and (min-width: 992px) {
    max-width: 970px;
  }

  @media screen and (min-width: 1200px) {
    max-width: 1170px;
  }

  @media screen and (min-width: 1400px) {
    max-width: 1370px;
  }
}

.spread-items {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

a:has(i[class^='bi-']),
a#copyright {
  color: #222;
  text-decoration: none;
  &:hover {
    color: #222;
    text-decoration: none;
  }
  &:visited {
    color: #222;
    text-decoration: none;
  }
}

nav {
  display: flex;
  background-color: #efefef;
  line-height: 3em;
  height: 3em;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  .heading {
    padding-left: 0.5em;
    font-size: 100%;

    @media screen and (max-width: 650px) {
      h1 {
        font-size: 1em;
        line-height: 1em;
      }
    }
  }
  .nav-links {
    display: flex;
    flex-direction: row;
    width: fit-content;
  }
  a {
    display: flex;
    text-decoration: none;
    padding: 0 1em;
    color: #222;

    &:visited {
      color: #222;
    }
    &:hover {
      background-color: var(--accent);
      color: #fff;
    }
  }
}

main {
  flex-shrink: 0;
  margin-bottom: 1em;
}

footer {
  margin-top: auto;
  padding: 0.5em 0.5em;
  background-color: #efefef;
}

@media screen and (min-width: 650px) {
  table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #222;
  }

  td,
  th {
    padding: 0.5em 1em;
    margin: 0;
  }

  thead,
  tbody,
  tfoot,
  tr,
  td,
  th {
    border: none;
  }

  thead tr:last-child {
    border-bottom: 2px solid #222;
  }

  tbody tr:nth-child(odd) {
    background-color: #efefef;
  }

  tbody tr {
    border-bottom: 1px solid #ccc;
  }

  tbody tr td {
    border-right: 1px solid #ccc;
  }

  tbody tr:last-child {
    border-bottom: none;
  }
  tbody td:last-child {
    border-right: none;
  }

  tbody tr:hover td {
    background-color: #909090;
    color: #eee;
  }
  th:nth-child(3),
  th:nth-child(4),
  th:nth-child(5),
  td:nth-child(3),
  td:nth-child(4),
  td:nth-child(5) {
    width: 1px;
    white-space: nowrap;
  }
}

#loading > span {
  font-size: 1.25em;
  font-weight: bold;
}

#loading-bar {
  height: 0.25em;
  background-color: #efefef;
  overflow: hidden;
  margin-top: 0.5em;
}

#loading-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background-color: var(--accent);
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

@media only screen and (max-width: 650px) {
  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    border: none;
  }

  tr {
    border: 1px solid #222;
    margin-bottom: 0.75em;
    padding: 0.5em;
  }

  td {
    border: none;
    border-bottom: 1px solid #ccc;
    padding: 0.5em;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    font-weight: bold;
    flex-shrink: 0;
    margin-right: 1em;
    color: #555;
  }

  tbody tr:hover td {
    background-color: inherit;
    color: inherit;
  }

  td > div.spread-items {
    flex-direction: row-reverse;
  }
}

#form {
  border: 1px solid #222;
  padding: 0.75em;
  margin-bottom: 1em;
  border-radius: 2px;
}

#form > label {
  padding-left: 0.25em;
}

.inputs {
  display: flex;
  flex-direction: row;
  gap: 0.5em;
  align-items: center;
}

input#lookup {
  flex-grow: 1;
  line-height: 2em;
  padding: 0.5em;
  border-radius: 5px;
  border: 1px solid #222;
  margin-top: 0.25em;
}

input#lookup:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type='submit'] {
  line-height: 2em;
  padding: 0.5em 1em;
  border-radius: 5px;
  border: 1px solid #222;
  background-color: var(--accent);
  border-color: var(--accent);
  font-family: inherit;
  color: #fff;
  &:hover {
    background-color: var(--accent-dark);
    border-color: var(--accent-dark);
  }
  &:active {
    background-color: var(--accent-dark);
  }
}

a,
a:visited {
  color: var(--accent);
}

#error-container {
  padding: 1em;
  background-color: #ff9999;
  border: 0.25em solid #cd5c5c;
  border-radius: 2px;
  color: #8b0000;
  &::first-line {
    font-weight: bold;
  }
}

.error-stack {
  padding: 0.5em 0.5em 0;
  border-radius: 2px;

  summary {
    margin: -0.5em -0.5em 0;
    padding: 0.5em;
  }

  .error-stack-details {
    margin: 0;
  }
}

.error-stack[open] {
  width: fit-content;
  border: 1px solid #cd5c5c;
  padding: 0.5em;

  summary {
    margin-bottom: 0.5em;
    border-bottom: 1px solid #cd5c5c;
  }
}

#not-found,
.info-alert {
  padding: 1em;
  background-color: #cff4fc;
  border: 0.25em solid #0dcaf0;
  color: #052c65;
  font-style: italic;
  code {
    font-style: normal;
    font-weight: bold;
  }
  &::before {
    font-family: 'bootstrap-icons';
    font-style: normal;
    content: '\F431  ';
  }
}

#table-heading {
  margin: 0;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  padding: 0.25em;
}

.copy-button {
  margin-left: auto;
  margin-right: 0.25em;
  cursor: pointer;
  border: none;
  background-color: transparent;
  font-size: 1em;
  color: inherit;

  @media (hover: hover) {
    &:hover {
      border-radius: 2px;
      background-color: #222222;
      &.copy-success {
        background-color: transparent;
      }
      &.copy-failure {
        background-color: transparent;
      }
    }
  }
  &:active {
    background-color: transparent;
  }
}

.copy-success {
  color: #00cc00;
}

.copy-failure {
  color: red;
}

.hide-mobile {
  @media screen and (max-width: 650px) { 
    display: none;
  }
}

.map-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.75em;
  border-bottom: 2px solid #222;
}

.tab-btn {
  padding: 0.4em 1.2em;
  border: 1px solid #222;
  border-bottom: none;
  background: #f5f5f5;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95em;
  margin-bottom: -2px;

  &:hover {
    background: #e0e0e0;
  }
}

.tab-active {
  background: #fff;
  border-bottom: 2px solid #fff;
  font-weight: bold;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 0.5em;
  font-size: 0.9em;
  min-height: 1.4em;
}

.breadcrumb-item {
  color: #444;
}

.breadcrumb-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;

  &:hover {
    color: var(--accent-dark);
  }
}

.breadcrumb-sep {
  color: #999;
  margin: 0 0.1em;
}

.map-hint {
  font-size: 0.85em;
  color: #555;
  margin: 0 0 0.75em;
  font-style: italic;
}

.drill-frame {
  width: fit-content;
  max-width: 100%;
  margin-bottom: 1.25em;
}

.drill-map {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
  image-rendering: pixelated;
}

.legend {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5em 1.25em;
  margin-top: 0.5em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.85em;
}

.legend-swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 2px;
  flex-shrink: 0;
}

.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(20, 20, 30, 0.92);
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.4em 0.6em;
  font-size: 0.82em;
  line-height: 1.5;
  z-index: 100;
  max-width: 18em;
}

.tooltip-prefix {
  font-weight: bold;
}

.tooltip-services {
  color: #ccc;
}

.tooltip-region {
  color: #999;
  font-size: 0.9em;
}

.tooltip-usage {
  color: #999;
  font-size: 0.9em;
}

@media print {
  body {
    width: 100%;
    padding: 0;
    margin: 0;
  }
  table {
    border-collapse: collapse;
    width: 100%;
  }

  thead,
  tbody,
  tfoot,
  tr,
  td,
  th {
    border: 1px solid black;
  }

  tbody td {
    padding-left: 0.25em;
  }

  #form {
    display: none;
  }
  nav {
    display: none;
  }
  .instructions {
    display: none;
  }
  .copy-button {
    display: none;
  }
  footer {
    display: none;
  }
}
