/* design tokens */
:root {
  color-scheme: light;

  --c-bg: #ffffff;
  --c-text: #111111;
  --c-muted: #666666;
  --c-faint: #a8a8a8;
  --c-border: #e8e8e8;
  --c-subtle: #f5f5f5;
  --c-status: #2f9e5b;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-sm: 13px;
  --fs-ui: 14px;
  --fs-base: 15px;
  --fs-md: 16px;
  --fs-lg: 28px;

  /* spacing scale, 4px step */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  --w-page: 800px;
  --w-wide: 1600px;
  --gutter: 24px;
  --bar-h: 56px;
  --radius: 8px;
}

@media (max-width: 600px) {
  :root {
    --gutter: 16px;
  }
}

/* reset: element rules stay minimal, chart scripts render their own markup */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
}

.icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--c-faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease;
}

.link:hover {
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--c-text);
  outline-offset: 2px;
  border-radius: 4px;
}

/* layout */
.container {
  width: 100%;
  max-width: calc(var(--w-page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.container--wide {
  max-width: calc(var(--w-wide) + 2 * var(--gutter));
}

/* sticky top bar on inner pages */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--bar-h);
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--c-border);
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.topbar nav {
  min-width: 0;
}

.crumbs {
  display: flex;
  min-width: 0;
  list-style: none;
  font-size: var(--fs-ui);
  color: var(--c-muted);
}

.crumbs li {
  white-space: nowrap;
}

.crumbs li + li::before {
  content: "/";
  margin: 0 var(--s-2);
  color: var(--c-faint);
}

.crumbs a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.crumbs a:hover {
  color: var(--c-text);
}

.crumbs [aria-current] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--c-text);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  flex-shrink: 0;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-ui);
  color: var(--c-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.topbar-link:hover {
  color: var(--c-text);
}

/* tab strip under the top bar in the full screen view */
.tabs {
  background-color: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}

.tabs-inner {
  display: flex;
  gap: var(--s-5);
  overflow-x: auto;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}

.tabs-inner::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 10px 0;
  border-bottom: 2px solid transparent;
  font-size: var(--fs-ui);
  line-height: 20px;
  color: var(--c-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--c-text);
}

.tab[aria-current] {
  color: var(--c-text);
  font-weight: 500;
  border-bottom-color: var(--c-text);
}

@media (max-width: 600px) {
  /* keep the last two crumbs only */
  .crumbs li:not(:nth-last-child(-n + 2)) {
    display: none;
  }

  .crumbs li:nth-last-child(2)::before {
    content: none;
  }

  /* contact link stays, secondary links make room for it */
  .topbar-link--desktop {
    display: none;
  }
}

/* index hero */
.hero {
  padding: var(--s-8) 0 var(--s-7);
}

.hero-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero-role {
  margin-top: var(--s-1);
  font-size: var(--fs-md);
  color: var(--c-muted);
}

.hero-bio {
  margin-top: var(--s-4);
  max-width: 60ch;
}

.hero-meta,
.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  list-style: none;
  font-size: var(--fs-ui);
}

.hero-meta {
  margin-top: var(--s-5);
  color: var(--c-muted);
}

.hero-links {
  margin-top: var(--s-2);
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.hero-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--c-status);
}

/* sections */
.section + .section {
  margin-top: var(--s-7);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-4);
  margin-bottom: var(--s-2);
}

.section-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.section-note {
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

/* clickable rows: projects on index, report tabs on project pages */
.rows {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  list-style: none;
  /* hover background bleeds into the gutter, text stays aligned */
  margin: 0 calc(-1 * var(--s-4));
}

.row {
  display: block;
  padding: var(--s-4);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

/* rows that are not links, such as pipeline write-ups, stay flat */
a.row:hover {
  background-color: var(--c-subtle);
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.row-title {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.4;
}

.row-arrow {
  color: var(--c-faint);
  transition: color 0.15s ease, transform 0.15s ease;
}

.row:hover .row-arrow {
  color: var(--c-text);
  transform: translateX(2px);
}

.row-desc {
  margin-top: var(--s-1);
  color: var(--c-muted);
}

.row-meta {
  margin-top: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

.row-meta--mono {
  font-family: var(--font-mono);
}

/* stack items are told apart by space alone */
.row-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-4);
  margin-top: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

.row-date,
.row-label {
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

/* dated sections on index: labels and dates in a left column, notes and titles share the content edge */
.section--dated {
  --w-date: 112px;
}

.section--dated .section-head,
.section--dated .row {
  display: grid;
  grid-template-columns: var(--w-date) minmax(0, 1fr);
  align-items: baseline;
  column-gap: 0;
}

.section--dated .row > * {
  grid-column: 2;
}

.section--dated .row > .row-date,
.section--dated .row > .row-label {
  grid-column: 1;
  grid-row: 1;
}

@media (max-width: 600px) {
  .row {
    border-radius: 0;
  }

  /* one column, the date sits above the title */
  .section--dated .section-head,
  .section--dated .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .section--dated .row > *,
  .section--dated .row > .row-date,
  .section--dated .row > .row-label {
    grid-column: 1;
    grid-row: auto;
  }
}

/* project intro */
.intro {
  padding: var(--s-7) 0 var(--s-6);
}

.eyebrow {
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

.page-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* project sketch: under the title on narrow screens, beside the title and lead on wide ones */
.intro-figure {
  margin: var(--s-5) 0;
}

.intro-figure img {
  display: block;
  width: 200px;
  height: auto;
}

@media (min-width: 760px) {
  .intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 200px;
    column-gap: 40px;
  }

  .intro > * {
    grid-column: 1;
  }

  /* facts keep the full width under the text and the sketch */
  .intro > .facts {
    grid-column: 1 / -1;
  }

  .intro-figure {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    margin: 0;
  }
}

.lead {
  margin-top: var(--s-3);
  max-width: 64ch;
  font-size: var(--fs-md);
}

/* label column sized by the longest label, values wrap at reading width */
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 64ch);
  gap: var(--s-2) var(--s-5);
  margin-top: var(--s-5);
}

.facts > div {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: baseline;
}

.facts dt {
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

.facts dd {
  font-size: var(--fs-ui);
}

/* facts right under a section head */
.facts--flush {
  margin-top: var(--s-3);
}

@media (max-width: 600px) {
  .facts {
    column-gap: var(--s-4);
  }
}

/* last text section before a wide block, such as the Workout Calendar tests */
.section--tail {
  margin-bottom: var(--s-6);
}

/* footer, with next-project link on inner pages */
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-8);
  padding: var(--s-5) 0 var(--s-6);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-ui);
  color: var(--c-muted);
}

.footer a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer a:hover {
  color: var(--c-text);
}

.footer-next span {
  color: var(--c-text);
}

/* overview report: charts stacked in one frame */
.dashboard {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
}

/* charts are built for desktop, narrower screens scroll sideways */
.dashboard-item {
  position: relative;
  min-width: 960px;
}

.dashboard-hint {
  display: none;
  margin-bottom: var(--s-3);
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

@media (max-width: 1009px) {
  .dashboard-hint {
    display: block;
  }
}

.dashboard-item + .dashboard-item {
  border-top: 1px solid var(--c-border);
}

.dashboard-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* full screen button, shown on chart hover or always on touch screens */
.expand-btn {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: var(--fs-sm);
  color: var(--c-text);
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.dashboard-item:hover .expand-btn,
.dashboard-item.is-hovered .expand-btn,
.expand-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.expand-btn:hover {
  border-color: var(--c-text);
}

@media (hover: none) {
  .expand-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

/* same button outside the frame, always visible */
.expand-btn--static {
  position: static;
  opacity: 1;
  pointer-events: auto;
}

/* standalone site embedded in a frame */
.embed-bar {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.embed {
  display: block;
  width: 100%;
  height: calc(100vh - var(--bar-h) - 2 * var(--gutter));
  height: calc(100dvh - var(--bar-h) - 2 * var(--gutter));
  min-height: 560px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
