/* KloudKIT — landing page. Palette and fonts come from tokens.css. */

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

html {
  scrollbar-color: var(--surface1) var(--base);
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: clamp(300px, 27vw, 400px) minmax(0, 1fr);

  background-color: var(--base);
  color: var(--text);
  font-family: var(--font-brand);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background-color: color-mix(in srgb, var(--red) 35%, transparent);
  color: var(--brand-white);
}

p,
dl,
dd,
pre {
  margin: 0;
}

/* Read by screen readers, not shown. */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* An outbound link: a drawn arrow after the label, in the link's own colour. */
.ext::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.35em;
  vertical-align: -0.05em;
  background-color: currentColor;
  mask: url("/ext.svg")
    center / contain no-repeat;
}

/* Flat ground with a still dot grid. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--base);
  background-image: radial-gradient(
    circle,
    color-mix(in srgb, var(--text) 7%, transparent) 1px,
    transparent 1.5px
  );
  background-size: 28px 28px;
}

/* ── Org column ───────────────────────────────────────────────────────── */

.org {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(clamp(2.5rem, 7vh, 4.5rem) + env(safe-area-inset-top)) clamp(1.75rem, 3vw, 3.25rem)
    calc(1.5rem + env(safe-area-inset-bottom)) calc(clamp(1.75rem, 3vw, 3.25rem) + env(safe-area-inset-left));
  overflow-y: auto;
  scrollbar-width: thin;
  border-right: 1px solid var(--surface0);
  background-color: var(--crust);
}

/* KloudKIT's own two colours, from its logo, as each tool card wears its own. */
.org::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--red) 50%, var(--brand-mint) 50%);
}

.mark {
  width: 112px;
  height: auto;
  margin-bottom: 1.75rem;
  border-radius: 50%;
  border: 1px solid var(--surface1);
}

.wordmark {
  margin: 0;
  font-size: clamp(2.6rem, 4vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--brand-white);
}

/* As in the logo: a heavy "Kloud", a light red "KIT". */
.wordmark span {
  font-weight: 300;
  letter-spacing: 0.005em;
  color: var(--red);
}

.tagline {
  margin-top: 0.6rem;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--subtext1);
}

.org__about {
  margin-top: 1.5rem;
  max-width: 34ch;
  text-wrap: pretty;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--subtext0);
}

.org__about + .org__about {
  margin-top: 1em;
}

/* The tool index: each tool's lead colour as a segment beside its name. */
.family {
  display: grid;
  gap: 0.15rem;
  max-width: 34ch;
  margin-top: 1.75rem;
}

.family a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-block: 0.45rem;
  border-radius: 6px;
  font-size: 0.98rem;
  color: var(--subtext1);
  text-decoration: none;
  transition: color 0.15s ease;
}

.family a::before {
  content: "";
  flex: none;
  width: 1.75rem;
  height: 5px;
  border-radius: 3px;
  background-color: var(--c);
  transition: width 0.15s ease;
}

.family a:nth-child(1) {
  --c: var(--blue);
}

.family a:nth-child(2) {
  --c: var(--green);
}

.family a:nth-child(3) {
  --c: var(--lavender);
}

.family a:nth-child(4) {
  --c: var(--teal);
}

.family a:hover,
.family a:focus-visible {
  color: var(--c);
}

.family a:hover::before,
.family a:focus-visible::before {
  width: 2.5rem;
}

.family a:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}

/* main.js marks the tool in view. */
.family a[aria-current] {
  color: var(--c);
}

.family a[aria-current]::before {
  width: 2.5rem;
}

.org__link {
  align-self: flex-start;
  margin-top: auto;
  padding-block: 0.75rem;
  border-radius: 6px;
  font-size: 1.05rem;
  color: var(--red);
  text-decoration: none;
}

.footer {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--overlay2);
}

/* ── Tool stream ──────────────────────────────────────────────────────── */

.stream {
  padding: calc(clamp(2.5rem, 7vh, 4.5rem) + env(safe-area-inset-top))
    calc(clamp(1.5rem, 4vw, 3.5rem) + env(safe-area-inset-right))
    calc(clamp(2rem, 6vh, 4rem) + env(safe-area-inset-bottom)) clamp(1.5rem, 4vw, 3.5rem);
}

/* Each tool takes two accents from its own logo. */
.tool--workspace {
  --a: var(--blue);
  --b: var(--brand-mint);
}

.tool--testshed {
  --a: var(--green);
  --b: var(--mauve);
}

.tool--looking-glass {
  --a: var(--lavender);
  --b: var(--yellow);
}

.tool--portico {
  --a: var(--teal);
  --b: var(--peach);
}

/* Kloud Workspace first and largest; the smaller tools follow. */
.tools {
  display: grid;
  gap: 1.25rem;
  max-width: 1180px;
  container: tools / inline-size;
}

/* A card: mark, name and tagline with its links on top, then its facts. */
.tool {
  position: relative;
  display: grid;
  grid-template-columns: var(--mark, 64px) minmax(0, 1fr) auto;
  column-gap: 1.25rem;
  row-gap: 0.15rem;
  padding: 1.6rem 1.75rem 1.5rem;
  overflow: hidden;
  scroll-margin-top: 1.5rem;
  border: 1px solid var(--surface0);
  border-radius: 16px;
  background-color: var(--mantle);
  transition:
    border-color 0.18s ease,
    transform 0.25s cubic-bezier(0.19, 1, 0.22, 1);
}

/* The tool's two colours, as a flat bar across the top. */
.tool::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--a) 50%, var(--b) 50%);
}

.tool:hover,
.tool:has(:focus-visible) {
  border-color: color-mix(in srgb, var(--a) 60%, var(--surface0));
}

/* The card an index link jumped to lifts out in its own colour. */
.tool:target {
  transform: translateY(-4px);
  border-color: var(--a);
}

.tool__icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  width: var(--mark, 64px);
  height: var(--mark, 64px);
  object-fit: contain;
}

.tool__name {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.tool__tagline {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--subtext1);
  text-wrap: balance;
}

.tool__links {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
}

.tool__links a {
  white-space: nowrap;
  margin-block: -0.75rem;
  padding-block: 0.75rem;
  border-radius: 6px;
  color: var(--a);
  text-decoration: none;
}

.tool__links a + a {
  color: var(--b);
}

.tool__links a:hover,
.org__link:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.tool__links a:focus-visible,
.org__link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* What it is, how it ships and how to try it, as labelled facts. */
.tool__spec {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--surface0);
}

/* Wide enough: what it is over how it ships, the command beside both. */
@container tools (min-width: 52rem) {
  .tool__spec {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto 1fr;
    column-gap: 2rem;
  }

  .tool__try {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
  }

  .tool__try dd {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .tool__try pre,
  .tool__try .steps {
    flex: 1;
  }

  .tool__try .steps {
    grid-auto-rows: 1fr;
  }

  .tool__try pre {
    display: flex;
    align-items: center;
  }

  /* The command scales with the card, so its longest line never wraps. */
  .tool .tool__try pre {
    font-size: clamp(0.8rem, 1.8cqi, 0.85rem);
  }

  .tool--lead .tool__try pre {
    font-size: clamp(0.8rem, 1.85cqi, 0.95rem);
  }
}

.tool__spec dt {
  margin-bottom: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--overlay2);
}

.tool__spec dd {
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--subtext0);
  text-wrap: pretty;
}

.tool__try dt {
  margin-bottom: 0.4rem;
}

pre {
  padding: 0.85rem 1rem;
  border: 1px solid var(--surface0);
  border-radius: 10px;
  background-color: var(--crust);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--a);
  white-space: pre;
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
}

/* Grid and flex items grow to fit a long command unless told otherwise; keep them inside the card. */
.tool__spec > div,
.tool__try dd,
.steps,
.steps li {
  min-width: 0;
}

/* A command in more than one step: each numbered, each copied on its own. */
.steps {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  display: flex;
  counter-increment: step;
}

.steps li > pre {
  flex: 1;
  padding-left: 1.6rem;
}

/* The step number sits on the command box's left edge, like a numbered part. */
.steps li::before {
  content: counter(step);
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid var(--a);
  border-radius: 50%;
  background-color: var(--mantle);
  font: 700 0.75rem / 1 var(--font-brand);
  color: var(--a);
  transform: translate(-50%, -50%);
}

/* main.js makes each command a copy button; without script it stays selectable text.
   The badge sits over the first line, which the two-line commands keep short. */
pre.is-copyable {
  position: relative;
  cursor: copy;
  transition: border-color 0.15s ease;
}

pre.is-copyable:hover,
pre.is-copyable:focus-visible {
  border-color: color-mix(in srgb, var(--a) 70%, var(--surface0));
}

pre.is-copyable:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--surface1);
  border-radius: 6px;
  background-color: var(--mantle);
  color: var(--subtext0);
  font: 600 0.72rem / 1.3 var(--font-brand);
  opacity: 0;
  transition: opacity 0.15s ease;
}

pre:hover .copy,
pre:focus-visible .copy,
pre[data-copied] .copy {
  opacity: 1;
}

pre[data-copied] .copy {
  border-color: var(--a);
  color: var(--a);
}

/* Without hover the badge stays visible, so it moves up beside the "Try it" label. */
@media (hover: none) {
  .copy {
    top: auto;
    right: 0;
    bottom: calc(100% + 0.3rem);
    opacity: 1;
  }
}

/* Inside a list of steps the label row belongs to the whole list, so each badge stays in its box. */
@media (hover: none) {
  .steps .copy {
    top: 0.45rem;
    right: 0.5rem;
    bottom: auto;
  }
}

/* The lead: the same card, larger, with a wash of its own colour. */
.tool--lead {
  --mark: 112px;

  margin-bottom: 1.5rem;
  column-gap: 1.75rem;
  padding: 2.5rem 2.5rem 2.25rem;
  background-image: linear-gradient(
    160deg,
    color-mix(in srgb, var(--a) 9%, var(--mantle)),
    var(--mantle) 55%
  );
}

.tool--lead .tool__name {
  font-size: clamp(2rem, 3.2vw, 3rem);
  letter-spacing: -0.02em;
}

.tool--lead .tool__tagline {
  font-size: 1.2rem;
}

.tool--lead .tool__links {
  font-size: 1.05rem;
}

.tool--lead .tool__spec {
  margin-top: 1.6rem;
  padding-top: 1.4rem;
}

.tool--lead .tool__spec dt {
  color: var(--subtext0);
}

.tool--lead .tool__spec dd {
  font-size: 1.08rem;
}

.tool--lead pre {
  padding: 1.1rem 1.25rem;
  font-size: 0.95rem;
}

/* ── Narrower screens ─────────────────────────────────────────────────── */

@media (min-width: 861px) and (max-height: 860px) {
  .org {
    padding-top: calc(2rem + env(safe-area-inset-top));
  }

  .mark {
    width: 84px;
    margin-bottom: 1.25rem;
  }

  .org__about {
    margin-top: 1.1rem;
    line-height: 1.55;
  }

  .family {
    margin-top: 1.25rem;
  }

  .family a {
    padding-block: 0.3rem;
  }
}

@media (min-width: 1280px) {
  .stream {
    padding-inline: clamp(1.5rem, 3vw, 3rem);
  }
}

/* Room after the last card, so every index link can bring its card to the top. */
@media (min-width: 861px) {
  .stream::after {
    content: "";
    display: block;
    height: max(0px, calc(100vh - 22rem));
  }
}

/* Links drop under the tagline when the header row runs out of room. */
@media (max-width: 560px) {
  .tool {
    --mark: 56px;

    column-gap: 1rem;
    padding: 1.4rem 1rem 1.25rem;
  }

  .tool--lead {
    --mark: 72px;
  }

  .tool__icon {
    grid-row: 1 / span 3;
    align-self: start;
  }

  .tool__links {
    grid-column: 2;
    grid-row: 3;
    align-self: start;
    margin-top: 0.6rem;
  }

  .tool__name,
  .tool--lead .tool__name {
    font-size: 1.35rem;
  }

  .tool--lead .tool__name {
    font-size: 1.7rem;
  }

  .tool--lead .tool__tagline {
    font-size: 1.05rem;
  }

  pre,
  .tool--lead pre {
    padding: 0.75rem 0.7rem;
    font-size: 0.78rem;
  }
}

/* The column becomes a header above the stream. */
@media (max-width: 860px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .org {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-content: start;
    column-gap: 1.25rem;
    padding: calc(2rem + env(safe-area-inset-top)) calc(1.25rem + env(safe-area-inset-right)) 1.75rem
      calc(1.25rem + env(safe-area-inset-left));
    border-right: 0;
    border-bottom: 1px solid var(--surface0);
  }

  .mark {
    grid-row: 1 / span 2;
    width: 72px;
    margin: 0;
  }

  .wordmark {
    align-self: end;
    font-size: 2.4rem;
  }

  .tagline {
    margin-top: 0.25rem;
    font-size: 1.1rem;
  }

  .org__about,
  .family,
  .org__link,
  .footer {
    grid-column: 1 / -1;
    max-width: none;
  }

  .family {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1rem;
  }

  .family a {
    min-height: 44px;
  }

  .tool--lead {
    min-height: 0;
    margin-bottom: 0.5rem;
  }

  .org__about {
    margin-top: 1rem;
    font-size: 0.95rem;
    line-height: 1.55;
  }

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

  .footer {
    display: none;
  }

  .stream {
    padding: 1.5rem calc(1rem + env(safe-area-inset-right)) calc(2.5rem + env(safe-area-inset-bottom))
      calc(1rem + env(safe-area-inset-left));
  }
}

/* ── Not found ────────────────────────────────────────────────────────── */

.lost {
  align-self: center;
  max-width: 40rem;
}

.lost h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--brand-white);
}

.lost p {
  margin-top: 1rem;
  font-size: 1.1rem;
  color: var(--subtext0);
}

.lost a {
  display: inline-block;
  margin-top: 1rem;
  padding-block: 0.75rem;
  color: var(--red);
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .tool:target {
    transform: none;
  }

  .tool,
  .copy,
  .family a,
  .family a::before {
    transition: none;
  }
}
