/*
 * DreamHost theme for the Scalar API reference (Figma: API-Scalar-Doc, DEV SPEC).
 * Scalar's variables are layered, so the ones here win wherever this sheet loads. Its utility classes are not, and
 * they are injected after this sheet, so every rule that overrides a Scalar element starts with body to outrank them.
 */

@font-face {
  font-family: 'Proxima Nova';
  src: url('fonts/proximanova-regular-webfont.woff2') format('woff2'),
    url('fonts/proximanova-regular-webfont.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Proxima Nova';
  src: url('fonts/proximanova-medium-webfont.woff2') format('woff2'),
    url('fonts/proximanova-medium-webfont.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Proxima Nova';
  src: url('fonts/proximanova-semibold-webfont.woff2') format('woff2'),
    url('fonts/proximanova-semibold-webfont.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gilroy';
  src: url('fonts/gilroy-medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gilroy';
  src: url('fonts/gilroy-semibold.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gilroy';
  src: url('fonts/gilroy-bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Roboto Mono';
  src: url('fonts/roboto-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Roboto Mono';
  src: url('fonts/roboto-mono-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Roboto Mono';
  src: url('fonts/roboto-mono-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Roboto Mono';
  src: url('fonts/roboto-mono-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Shape and type, the same in both modes */
:root {
  --scalar-border-width: 1px;

  --scalar-radius: 12px;
  --scalar-radius-lg: 16px;
  --scalar-radius-xl: 16px;
  --scalar-radius-2xl: 24px;

  --scalar-font: 'Proxima Nova', 'Mulish', sans-serif;
  --scalar-font-code: 'Roboto Mono', monospace;
  --scalar-bold: 700;
  --scalar-semibold: 600;
  --scalar-mini: 12px;
  --scalar-font-size-1: 20px;
  --scalar-font-size-4: 12px;
  --scalar-heading-1: 24px;

  --scalar-text-decoration: underline;
  --scalar-text-decoration-hover: underline;
  --scalar-text-decoration-color-hover: currentColor;
}

/* :root too, so the header does not flash unstyled before Scalar sets the mode class on body */
:root,
.light-mode {
  /* Surfaces and borders */
  --scalar-background-1: #ffffff;
  --scalar-background-2: #fafafa;
  --scalar-background-3: #f7f7f7;
  --scalar-background-accent: #0073ec1f;
  --scalar-border-color: #e0e4e8;

  /* Text */
  --scalar-color-1: #000000;
  --scalar-color-2: #52525b;
  --scalar-color-3: #71717a;
  --scalar-color-accent: #0051a5;

  /* Links */
  --scalar-link-color: var(--scalar-color-2);
  --scalar-link-color-hover: var(--scalar-color-2);
  --scalar-text-decoration-color: rgba(82, 82, 91, 0.4);

  /* Buttons */
  --scalar-button-1: #0073ec;
  --scalar-button-1-hover: #0051a5;
  --scalar-button-1-color: #ffffff;
  --dh-button-outline-border: #c7c7cd;
  --dh-button-hover: #e4e4e7;

  /* Method labels and code syntax */
  --scalar-color-blue: #0051a5;
  --scalar-color-green: #006655;
  --scalar-color-orange: #7b4f00;
  --scalar-color-red: #b33432;
  --scalar-color-purple: #953dce;
  --scalar-color-yellow: #4d4100;
  --scalar-color-query: #52525b;

  /* Sidebar */
  --scalar-sidebar-background-1: #f4f6f9;
  --scalar-sidebar-color-1: #000000;
  --scalar-sidebar-color-2: #52525b;
  --scalar-sidebar-color-active: #0051a5;
  --scalar-sidebar-border-color: #e0e4e8;
  --scalar-sidebar-item-hover-background: #e0e4e8;
  --scalar-sidebar-item-hover-color: #000000;
  --scalar-sidebar-item-active-background: #e6f1fd;
  --scalar-sidebar-indent-border: #e0e4e8;
  --scalar-sidebar-indent-border-hover: #c7c7cd;
  --scalar-sidebar-indent-border-active: #0073ec;
  --scalar-sidebar-search-background: #ffffff;
  --scalar-sidebar-search-border-color: #e0e4e8;
  --scalar-sidebar-search-color: #52525b;

  /* Header bar */
  --scalar-header-background-1: #f4f6f9;
  --scalar-header-background-2: #e0e4e8;
  --scalar-header-color-1: #000000;
  --scalar-header-color-2: #52525b;
  --scalar-header-border-color: #e0e4e8;
  --scalar-header-call-to-action-color: #0073ec;
}

.dark-mode {
  /* Surfaces and borders */
  --scalar-background-1: #111111;
  --scalar-background-2: #1f1f22;
  --scalar-background-3: #27272a;
  --scalar-background-accent: #4d9df224;
  --scalar-border-color: #3f3f46;

  /* Text */
  --scalar-color-1: #ffffff;
  --scalar-color-2: #e4e4e7;
  --scalar-color-3: #a1a1aa;
  --scalar-color-accent: #80b9f5;

  /* Links */
  --scalar-link-color: var(--scalar-color-2);
  --scalar-link-color-hover: var(--scalar-color-2);
  --scalar-text-decoration-color: rgba(228, 228, 231, 0.4);

  /* Buttons */
  --scalar-button-1: #0073ec;
  --scalar-button-1-hover: #0051a5;
  --scalar-button-1-color: #ffffff;
  --dh-button-outline-border: #c7c7cd;
  --dh-button-hover: #27272a;

  /* Method labels and code syntax */
  --scalar-color-blue: #4d9df2;
  --scalar-color-green: #00caaa;
  --scalar-color-orange: #f59d00;
  --scalar-color-red: #ff4a48;
  --scalar-color-purple: #b869ea;
  --scalar-color-yellow: #ffda00;
  --scalar-color-query: #a1a1aa;

  /* Sidebar */
  --scalar-sidebar-background-1: #1f1f22;
  --scalar-sidebar-color-1: #ffffff;
  --scalar-sidebar-color-2: #a1a1aa;
  --scalar-sidebar-color-active: #80b9f5;
  --scalar-sidebar-border-color: #3f3f46;
  --scalar-sidebar-item-hover-background: #27272a;
  --scalar-sidebar-item-hover-color: #ffffff;
  --scalar-sidebar-item-active-background: #4d9df20f;
  --scalar-sidebar-indent-border: #27272a;
  --scalar-sidebar-indent-border-hover: #3f3f46;
  --scalar-sidebar-indent-border-active: #4d9df2;
  --scalar-sidebar-search-background: #111111;
  --scalar-sidebar-search-border-color: #3f3f46;
  --scalar-sidebar-search-color: #a1a1aa;

  /* Header bar */
  --scalar-header-background-1: #1f1f22;
  --scalar-header-background-2: #27272a;
  --scalar-header-color-1: #ffffff;
  --scalar-header-color-2: #a1a1aa;
  --scalar-header-border-color: #3f3f46;
  --scalar-header-call-to-action-color: #0073ec;
}

/* Things variables cannot do */

/* 5a: there is only one --scalar-font, no heading family */
body .scalar-app h1,
body .scalar-app h2,
body .scalar-app h3,
body .scalar-app h4 {
  font-family: 'Gilroy', var(--scalar-font);
}

/* 5c: DS <Button> Small Neutral Outlined, no button-border variable exists. Only Scalar's outlined variant (Copy as
 * Markdown): the ghost and solid ones are selectors, icons and the API client's controls, which the mockups keep as is */
body .scalar-app .scalar-button-outlined {
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--dh-button-outline-border);
  border-radius: 8px;
  background: transparent;
  color: var(--scalar-color-1);
  font-size: 14px;
}

body .scalar-app .scalar-button-outlined:hover {
  background: var(--dh-button-hover);
}

/* Test Request is the one Medium; Scalar renders it as .show-api-client-button, not a .scalar-button */
body .scalar-app .request-card-footer .show-api-client-button {
  height: 40px;
  padding: 0 24px;
  border: 1px solid var(--dh-button-outline-border);
  border-radius: 10px;
  background: transparent;
  color: var(--scalar-color-1);
  font-size: 14px;
}

body .scalar-app .request-card-footer .show-api-client-button:hover {
  background: var(--dh-button-hover);
}

/* 5d: the enum chip reads --scalar-radius-lg; ours is 16, which on a ~20px chip clamps to a pill */
body .scalar-app .property-enum-chip {
  border-radius: 6px;
}

/* 5e: the DS <TextField> radius, the search input reads --scalar-radius-lg otherwise */
body .scalar-app .searchInput {
  border-radius: 12px;
}

/* 5f: Scalar paints the Example popover with background-1, so in dark it vanishes into the page */
body .scalar-app .property-example-value-list {
  background: var(--scalar-background-2);
}

/* Header and footer around the Scalar app (Figma Handoff 50:91) */

:root {
  /* Scalar offsets its sticky sidebar and headings by this */
  --scalar-custom-header-height: 64px;
}

body {
  margin: 0;
  /* Scalar paints this too, but only once its bundle has run */
  background: var(--scalar-background-1);
}

/* Keeps the footer below the fold while the spec is still loading and #app is empty */
#app {
  min-height: calc(100dvh - var(--scalar-custom-header-height));
}

/* Spinner until Scalar mounts into #app; the bundle is the slow part of the load */
#app:empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app:empty::before {
  content: '';
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border: 3.27px solid var(--scalar-button-1);
  border-left-color: transparent;
  border-radius: 50%;
  animation: dh-spin 0.8s linear infinite;
}

@keyframes dh-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  #app:empty::before {
    animation-duration: 2.4s;
  }
}

.dh-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 16px;
  box-sizing: border-box;
  height: var(--scalar-custom-header-height);
  padding: 0 24px;
  border-bottom: var(--scalar-border-width) solid var(--scalar-header-border-color);
  background: var(--scalar-header-background-1);
  color: var(--scalar-header-color-1);
  font-family: var(--scalar-font);
}

.dh-header__brand {
  display: flex;
  color: inherit;
}

.dh-header__brand svg {
  width: auto;
  height: 24px;
}

.dh-header__divider {
  width: 1px;
  height: 24px;
  background: var(--scalar-header-border-color);
}

.dh-header__label {
  color: var(--scalar-header-color-2);
  font-size: 14px;
}

.dh-header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

/* DS <Button> Small Neutral Outlined, the same look as 5c */
.dh-button {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--dh-button-outline-border);
  border-radius: 8px;
  color: var(--scalar-color-1);
  font-size: 14px;
  font-weight: var(--scalar-semibold);
  text-decoration: none;
}

.dh-button:hover {
  background: var(--dh-button-hover);
}

.dh-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-sizing: border-box;
  min-height: 65px;
  padding: 0 24px;
  border-top: var(--scalar-border-width) solid var(--scalar-border-color);
  background: var(--scalar-sidebar-background-1);
  color: var(--scalar-color-2);
  font-family: var(--scalar-font);
  font-size: 14px;
}

.dh-footer__links {
  display: flex;
  gap: 20px;
}

/* DS <Link> Color=Inherit, Underline=Hover */
.dh-footer__links a {
  color: var(--scalar-link-color);
  text-decoration: none;
}

.dh-footer__links a:hover {
  text-decoration: underline;
}

/* The API client modal pins its close button to the top right corner, over Go to panel; the header sits under its
 * backdrop then anyway */
body:has(.scalar-client--open) .dh-header__actions {
  visibility: hidden;
}

/* No mobile mockup: on a phone the label goes and the header tightens so Go to panel stays on screen */
@media (max-width: 600px) {
  .dh-header {
    gap: 12px;
    padding: 0 16px;
  }

  .dh-header__brand svg {
    height: 20px;
  }

  .dh-header__divider,
  .dh-header__label {
    display: none;
  }

  .dh-header__actions {
    gap: 8px;
  }

  /* Test Request drops to Small, like the other outlined buttons */
  body .scalar-app .request-card-footer .show-api-client-button {
    height: 32px;
    padding: 0 16px;
    border-radius: 8px;
  }

  .dh-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .dh-footer__links {
    flex-wrap: wrap;
    gap: 8px 20px;
  }
}

/* Theme toggle, 40x40 IconButton; the icon shows the mode it switches to */
.dh-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--scalar-header-color-1);
  cursor: pointer;
}

.dh-theme-toggle:hover {
  background: var(--dh-button-hover);
}

.dh-theme-toggle__sun,
.dark-mode .dh-theme-toggle__moon {
  display: none;
}

.dark-mode .dh-theme-toggle__sun {
  display: block;
}

/* Scalar's own toggle, with Powered by Scalar, moves to the header; theme.js still clicks it */
body .scalar-app .darklight-reference {
  display: none;
}
