/*
 * OpenSportTaxonomy site styles.
 *
 * The site is built on Designsystemet (https://designsystemet.no): components
 * come from ds/designsystemet.css, every colour, size and radius from the
 * theme tokens in ds/theme.css (--ds-*). This file adds only page layout and
 * the few pieces Designsystemet has no component for (the sport tree, the
 * anatomy figure, code). It uses tokens throughout, never raw colours, so a
 * re-themed `make design-system` restyles the whole site.
 *
 * Unlayered on purpose: Designsystemet lives in @layer ds, so these rules win
 * without specificity games.
 */

:root {
  --ost-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ost-page-width: 72rem;
  --ost-prose-width: 44rem;
  --ost-gutter: var(--ds-size-6);
  --ost-ink: var(--ds-color-neutral-text-default);
  --ost-muted: var(--ds-color-neutral-text-subtle);
  --ost-line: var(--ds-color-neutral-border-subtle);
}

@media (max-width: 40rem) {
  :root {
    --ost-gutter: var(--ds-size-4);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Layout rules below set `display`; `hidden` must still win. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--ds-font-family), system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
  width: 100%;
}

.ost-container {
  max-width: var(--ost-page-width);
  margin-inline: auto;
  padding-inline: var(--ost-gutter);
}

.ost-prose {
  max-width: var(--ost-prose-width);
}

/* ---- Site header --------------------------------------------------------- */

.ost-header {
  border-bottom: var(--ds-border-width-default) solid var(--ost-line);
  background: var(--ds-color-neutral-background-default);
}

.ost-header .ost-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--ds-size-8);
}

.ost-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-size-2);
  padding-block: var(--ds-size-4);
  color: var(--ost-ink);
  font-weight: var(--ds-font-weight-semibold);
  font-size: var(--ds-body-md-font-size);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.ost-brand img {
  width: var(--ds-size-7);
  height: var(--ds-size-7);
}

.ost-brand:focus-visible,
.ost-nav a:focus-visible {
  outline: var(--dsc-focus-outline);
  box-shadow: var(--dsc-focus-boxShadow);
  border-radius: var(--ds-border-radius-sm);
}

.ost-nav {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: var(--ds-size-6);
  overflow-x: auto;
  scrollbar-width: none;
  font-size: var(--ds-body-sm-font-size);
}

.ost-nav a {
  display: inline-flex;
  align-items: center;
  padding-block: var(--ds-size-4);
  color: var(--ost-muted);
  text-decoration: none;
  white-space: nowrap;
  /* The active marker sits on the header's bottom rule. */
  border-bottom: var(--ds-size-1) solid transparent;
  margin-bottom: calc(-1 * var(--ds-border-width-default));
}

.ost-nav a:hover {
  color: var(--ost-ink);
}

.ost-nav a[aria-current="page"] {
  color: var(--ost-ink);
  font-weight: var(--ds-font-weight-medium);
  border-bottom-color: var(--ds-color-accent-base-default);
}

/* External links trail the page links, pushed to the far end. */
.ost-nav .ost-ext:first-of-type {
  margin-left: auto;
}

.ost-ext::after {
  content: "↗";
  margin-left: 0.2em;
  font-size: 0.85em;
  color: var(--ost-muted);
}

@media (max-width: 52rem) {
  .ost-header .ost-container {
    gap: 0;
  }

  .ost-nav {
    flex-basis: 100%;
  }

  .ost-nav a {
    padding-block: var(--ds-size-3);
  }

  .ost-nav .ost-ext:first-of-type {
    margin-left: 0;
  }
}

/* ---- Page intro ---------------------------------------------------------- */

.ost-intro {
  padding-block: var(--ds-size-12) var(--ds-size-8);
}

.ost-intro > * + * {
  margin-top: var(--ds-size-4);
}

.ost-intro .ds-heading + * {
  margin-top: var(--ds-size-5);
}

/* The landing headline: as large as the viewport comfortably allows. */
.ost-intro .ds-heading[data-size="2xl"] {
  font-size: clamp(2.25rem, 7vw, var(--ds-heading-2xl-font-size));
  letter-spacing: -0.02em;
}

/* The landing page's calls to action. */
.ost-intro .ost-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-size-3);
  margin-top: var(--ds-size-8);
}

@media (max-width: 40rem) {
  .ost-intro {
    padding-block: var(--ds-size-8) var(--ds-size-6);
  }
}

/* ---- Sections ------------------------------------------------------------ */

.ost-section {
  padding-block: var(--ds-size-8);
}

.ost-section + .ost-section {
  border-top: var(--ds-border-width-default) solid var(--ost-line);
}

/* A simple vertical rhythm for long-form content. */
.ost-flow > * + * {
  margin-top: var(--ds-size-4);
}

.ost-flow > * + :is(h2, h3) {
  margin-top: var(--ds-size-8);
}

.ost-flow > :is(h2, h3) + * {
  margin-top: var(--ds-size-3);
}

.ost-muted {
  color: var(--ost-muted);
}

/* ---- Footer -------------------------------------------------------------- */

.ost-footer {
  margin-top: var(--ds-size-15);
  padding-block: var(--ds-size-10);
  background: var(--ds-color-neutral-background-tinted);
  border-top: var(--ds-border-width-default) solid var(--ost-line);
  color: var(--ost-muted);
}

.ost-footer .ds-paragraph {
  max-width: var(--ost-prose-width);
}

.ost-footer .ds-link {
  --dsc-link-color: var(--ost-ink);
  --dsc-link-color--hover: var(--ost-ink);
}

/* ---- Code ---------------------------------------------------------------- */

/* Inline code is an OST sport string unless marked otherwise: the site's
   subject, in a washed accent. Platform identifiers (Strava's `Ride`, a FIT
   pair) and other foreign values take .ost-platform, in neutral, so "ours"
   and "theirs" read apart at a glance. */
code {
  font-family: var(--ost-font-mono);
  font-size: 0.875em;
  padding: 0.125em 0.4em;
  color: var(--ds-color-accent-text-subtle);
  background: var(--ds-color-accent-background-tinted);
  box-shadow: inset 0 0 0 var(--ds-border-width-default) var(--ds-color-accent-surface-tinted);
  border-radius: var(--ds-border-radius-sm);
  overflow-wrap: anywhere;
}

code.ost-platform {
  color: var(--ost-ink);
  background: var(--ds-color-neutral-background-tinted);
  box-shadow: inset 0 0 0 var(--ds-border-width-default) var(--ds-color-neutral-surface-tinted);
}

/* No equivalent: the value is a fallback, not a translation. */
code.ost-fallback {
  color: var(--ost-muted);
  background: none;
  box-shadow: inset 0 0 0 var(--ds-border-width-default) var(--ost-line);
}

pre {
  margin: 0;
  padding: var(--ds-size-4) var(--ds-size-5);
  overflow-x: auto;
  font-size: var(--ds-body-sm-font-size);
  line-height: 1.6;
  background: var(--ds-color-neutral-background-tinted);
  border: var(--ds-border-width-default) solid var(--ost-line);
  border-radius: var(--ds-border-radius-md);
}

pre code {
  padding: 0;
  font-size: inherit;
  color: inherit;
  background: none;
  box-shadow: none;
  overflow-wrap: normal;
}

mark {
  color: inherit;
  background: var(--ds-color-warning-surface-hover);
  border-radius: var(--ds-border-radius-sm);
}

/* ---- Anatomy of a sport string -------------------------------------------- */

.ost-anatomy {
  margin-inline: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--ds-size-2) 0;
  padding: var(--ds-size-6);
  background: var(--ds-color-neutral-background-default);
  border: var(--ds-border-width-default) solid var(--ost-line);
  border-radius: var(--ds-border-radius-lg);
}

.ost-anatomy > span {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ds-size-1);
}

.ost-anatomy b {
  font-family: var(--ost-font-mono);
  font-size: clamp(1.125rem, 3.5vw, 1.625rem);
  font-weight: var(--ds-font-weight-medium);
  color: var(--ost-ink);
}

.ost-anatomy .sep b {
  color: var(--ds-color-accent-text-subtle);
  font-weight: var(--ds-font-weight-semibold);
  padding-inline: 0.1em;
}

.ost-anatomy small {
  font-size: var(--ds-body-xs-font-size);
  color: var(--ost-muted);
}

/* ---- Toolbars, status ----------------------------------------------------- */

/* A row of controls above a table or tree: summary left, actions right. */
.ost-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-size-3) var(--ds-size-4);
  margin-bottom: var(--ds-size-4);
}

.ost-toolbar .ost-summary {
  margin: 0;
  color: var(--ost-muted);
  font-size: var(--ds-body-sm-font-size);
}

.ost-toolbar .ost-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-size-2);
  margin-left: auto;
}

/* An explicit basis: ds-search under-reports its intrinsic width. */
.ost-toolbar .ds-search {
  flex: 0 0 20rem;
}

@media (max-width: 40rem) {
  .ost-toolbar .ost-actions {
    width: 100%;
    margin-left: 0;
  }

  .ost-toolbar .ds-search {
    flex-basis: 100%;
  }
}

.ost-status {
  display: flex;
  align-items: center;
  gap: var(--ds-size-3);
  padding-block: var(--ds-size-6);
  color: var(--ost-muted);
}

.ost-status .ds-spinner {
  width: var(--ds-size-6);
  height: var(--ds-size-6);
}

/* Horizontal scroll for wide tables on narrow screens, not for the page. */
.ost-table-scroll {
  overflow-x: auto;
}

.ds-table td.ost-empty {
  padding-block: var(--ds-size-8);
  text-align: center;
  color: var(--ost-muted);
}

/* Tables keep codes whole and scroll sideways (in .ost-table-scroll) instead. */
.ds-table {
  --dsc-table-background--zebra: var(--ds-color-neutral-background-tinted);
}

.ds-table code {
  white-space: nowrap;
  overflow-wrap: normal;
}


/* ---- Translations popover (xlate-popover.js) ------------------------------ */

/* Sits inline after a code, in text and table cells alike, without growing the line. */
.ost-xlate-btn.ds-button {
  --dsc-button-size: var(--ds-size-8);
  display: inline-flex;
  vertical-align: middle;
  margin-block: calc(-1 * var(--ds-size-1));
  color: var(--ost-muted);
}

.ost-xlate {
  --dsc-popover-max-width: min(24rem, calc(100vw - 2 * var(--ds-size-4)));
  --dsc-popover-padding: var(--ds-size-4);
  font-size: var(--ds-body-sm-font-size);
}

.ost-xlate header {
  padding-bottom: var(--ds-size-3);
  margin-bottom: var(--ds-size-3);
  border-bottom: var(--ds-border-width-default) solid var(--ost-line);
}

.ost-xlate header strong {
  display: block;
  font-family: var(--ost-font-mono);
  font-weight: var(--ds-font-weight-semibold);
  overflow-wrap: anywhere;
}

.ost-xlate header span {
  color: var(--ost-muted);
}

.ost-xlate dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--ds-size-2) var(--ds-size-5);
  margin: 0;
}

.ost-xlate dt {
  color: var(--ost-muted);
}

.ost-xlate dd {
  margin: 0;
}

/* A closing call to action below a page's main content. */
.ost-callout {
  margin-top: var(--ds-size-10);
}
