/*
 * cubesite.css — the shared stylesheet for cubicecho project sites.
 *
 * Source of truth: github.com/cubicecho/cubesite → theme/cubesite.css.
 * This file is VENDORED into each project site (site/src/css/cubesite.css), so
 * edit it there only to find out what you want changed here, then change it
 * here and re-sync with `node scripts/scaffold.mjs <repo> --theme`.
 *
 * It expects the markup in cubesite's template/src/_includes/base.njk. Project
 * rules go in a second stylesheet (site.css) loaded after this one, never in
 * here — a project-shaped rule in the shared file is how the shared file stops
 * being shareable.
 */

/*
 * The palette is cubeui's — tokens/palette.mjs there is the source, and these
 * are its default light and dark values under its names, as dist/tokens.web.css
 * emits them. A token is named for what the colour means, and nothing is a
 * quieter copy of another: muted text is `foreground` at 60%, a border is
 * `foreground` at 10%, written as a color-mix() where cubeui writes
 * `text-foreground/60`. Change a value there first, then here.
 *
 * Dark follows the system. cubeui's web build keys it off `.dark` on <html>
 * because an app has a toggle; a static page has nothing to set the class.
 */

:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --secondary: oklch(0.985 0 0);
  --neutral: oklch(0.205 0 0);
  --neutral-foreground: oklch(0.985 0 0);
  --hover: oklch(0.922 0.025 218);
  --active: oklch(0.5 0.07 218);
  --active-foreground: oklch(1 0 0);
  --positive: oklch(0.5273 0.1371 150.069);
  --positive-foreground: oklch(1 0 0);
  --warning: oklch(0.5553 0.1455 48.998);
  --warning-foreground: oklch(1 0 0);
  --info: oklch(0.5 0.1193 242.749);
  --info-foreground: oklch(1 0 0);
  --negative: oklch(0.577 0.245 27.325);
  --negative-foreground: oklch(1 0 0);
  --maxw: 64rem;
  --pad: clamp(1rem, 4vw, 2rem);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas,
    monospace;

  /* The names this file used before it took cubeui's. Kept so a project's own
     site.css still resolves after a `--theme` re-sync; nothing in here uses
     them, and new rules should not either. */
  --bg: var(--background);
  --fg: var(--foreground);
  --card: var(--secondary);
  --muted: color-mix(in oklab, var(--foreground) 60%, transparent);
  --line: color-mix(in oklab, var(--foreground) 10%, transparent);
  --accent: var(--info);
  --accent-fg: var(--info-foreground);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: oklch(0.145 0 0);
    --foreground: oklch(0.985 0 0);
    --secondary: oklch(0.269 0 0);
    --neutral: oklch(0.922 0 0);
    --neutral-foreground: oklch(0.205 0 0);
    --hover: oklch(0.371 0.035 218);
    --active: oklch(0.68 0.065 218);
    --active-foreground: oklch(0.145 0 0);
    --positive: oklch(0.7227 0.192 149.579);
    --positive-foreground: oklch(0.145 0 0);
    --warning: oklch(0.7686 0.1647 70.08);
    --warning-foreground: oklch(0.145 0 0);
    --info: oklch(0.6847 0.1479 237.323);
    --info-foreground: oklch(0.145 0 0);
    --negative: oklch(0.704 0.191 22.216);
    --negative-foreground: oklch(0.145 0 0);
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--info);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--active);
  outline-offset: 2px;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* header */

.site-header {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--foreground);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.wordmark:hover {
  text-decoration: none;
}
/* A project site's wordmark is the project name, so it is set in mono to match
   the card titles and project headings across the org. */
.wordmark .name {
  font-family: var(--font-mono);
}
.mark {
  width: 40px;
  height: 40px;
  display: inline-block;
  color: var(--foreground);
  flex-shrink: 0;
}

.site-header nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
  flex-wrap: wrap;
}
.site-header nav a {
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
}
.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--foreground);
  text-decoration: none;
}

/* footer */

.site-footer {
  width: 100%;
  max-width: var(--maxw);
  margin: 4rem auto 0;
  padding: 2rem var(--pad);
  border-top: 1px solid color-mix(in oklab, var(--foreground) 10%, transparent);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
}
.site-footer a {
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
}
.site-footer a:hover {
  color: var(--foreground);
}
.footer-links {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* hero */

.hero {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid color-mix(in oklab, var(--foreground) 10%, transparent);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
/* On a project site the H1 *is* the package name, so it reads as one. */
.hero.project-hero h1 {
  font-family: var(--font-mono);
}
.hero p {
  margin: 0;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  font-size: 1.125rem;
}
.hero .meta {
  margin: 1rem 0 0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.cta {
  margin: 1.5rem 0 0;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  background: var(--neutral);
  color: var(--neutral-foreground);
  font-size: 0.95rem;
  font-weight: 500;
}
.button:hover {
  text-decoration: none;
  background: color-mix(in oklab, var(--neutral) 90%, transparent);
}
.button.secondary {
  background: var(--background);
  color: var(--foreground);
  border-color: color-mix(in oklab, var(--foreground) 15%, transparent);
}
.button.secondary:hover {
  background: var(--hover);
}

/* sections */

.section-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  margin: 2.5rem 0 1rem;
}

.section {
  padding: 2.5rem 0 0;
}
.section > h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.section > .section-intro {
  margin: 0 0 1.25rem;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  max-width: 42rem;
}

/* card grid — features on a project site, projects on an index */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}
.card-grid > li {
  display: flex;
}

.card {
  position: relative;
  flex: 1;
  background: var(--secondary);
  border: 1px solid color-mix(in oklab, var(--foreground) 10%, transparent);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover {
  border-color: var(--foreground);
  transform: translateY(-1px);
}
.card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}
.card h3 .card-link {
  color: var(--foreground);
}
.card h3 .card-link:hover {
  text-decoration: none;
}
/* The title link is stretched over the whole card so the card is clickable;
   anything that must stay independently clickable is lifted above it. */
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}
.card p {
  margin: 0;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  font-size: 0.95rem;
  flex: 1;
}
.card .card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  margin-top: 0.5rem;
}
.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}
.card-site {
  position: relative;
  z-index: 1;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
}
.card-site:hover {
  color: var(--info);
}

/* prose */

.prose {
  max-width: 42rem;
}
.prose h2 {
  margin-top: 2rem;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.prose h3 {
  margin-top: 1.5rem;
  font-size: 1.05rem;
}
.prose p,
.prose ul,
.prose ol {
  margin: 1rem 0;
}
.prose code {
  font-family: var(--font-mono);
  background: color-mix(in oklab, var(--foreground) 10%, transparent);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}
.prose pre,
pre.code {
  background: color-mix(in oklab, var(--foreground) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--foreground) 10%, transparent);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.prose pre code,
pre.code code {
  padding: 0;
  background: transparent;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid color-mix(in oklab, var(--foreground) 10%, transparent);
  vertical-align: top;
}
.prose th {
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  font-weight: 500;
}

/* the pointer every project site ends on */

.readme-link {
  margin: 2rem 0 0;
  padding: 1rem 1.25rem;
  border: 1px dashed color-mix(in oklab, var(--foreground) 10%, transparent);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
  max-width: 42rem;
}
