/* Nicecoder site styles. Direction and reasons are in DESIGN.md. */

:root {
  --navy: #14284b;
  --navy-deep: #0e1d38;
  --ink: #182033;
  --muted: #4b5568;
  --rule: #d5dbe5;
  --control: #7b8599;
  --wash: #f3f5f9;
  --signal: #2e63d1;
  --on-navy: #ffffff;
  --on-navy-muted: #c9d3e6;
  --focus-on-navy: #8fb0ee;

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;

  --page: 72rem;
  --measure: 40rem;
  --gutter: clamp(1rem, 4vw, 2rem);

  --space-xs: 0.5rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2.5rem;
  --space-xl: clamp(3rem, 7vw, 5rem);
  --space-2xl: clamp(4rem, 10vw, 7rem);
}

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

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

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 40rem) {
  body {
    font-size: 1.0625rem;
  }
}

img,
svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  color: var(--navy);
  margin: 0;
  text-wrap: balance;
}

h1,
h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.125rem, 1.4rem + 3vw, 3.25rem);
  line-height: 1.15;
}

h2 {
  font-size: clamp(1.625rem, 1.3rem + 1.4vw, 2.125rem);
  line-height: 1.2;
}

h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.35;
}

p,
ul,
ol,
dl,
table {
  margin: 0;
}

a {
  color: var(--navy);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
  border-radius: 2px;
}

.on-navy :focus-visible {
  outline-color: var(--focus-on-navy);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--navy);
  color: var(--on-navy);
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

main {
  padding-bottom: var(--space-2xl);
}

/* A page that ends on a full-width band meets the footer directly */
main:has(> :last-child.band) {
  padding-bottom: 0;
}

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

/* Long-form text: product pages, policies, about */
.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 1em;
}

.prose h2 {
  margin-top: var(--space-l);
}

.prose h3 {
  margin-top: var(--space-m);
}

.prose ul,
.prose ol {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: 0.4em;
}

.prose li::marker {
  color: var(--muted);
}

.prose strong {
  font-weight: 600;
}

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.875em;
  padding: 0.1em 0.3em;
  background: var(--wash);
  border-radius: 3px;
}

.lead {
  font-size: clamp(1.1875rem, 1.1rem + 0.4vw, 1.3125rem);
  line-height: 1.55;
  color: var(--ink);
}

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

/* The backslash from the logo, used as the mark before section headings (see DESIGN.md) */
.section-title,
.prose h2 {
  display: flex;
  align-items: baseline;
  gap: 0.45em;
}

.section-title::before,
.prose h2::before {
  content: '';
  flex: none;
  width: 0.42em;
  height: 0.78em;
  background: currentColor;
  clip-path: polygon(0 0, 33% 0, 100% 100%, 67% 100%);
  transform: translateY(0.06em);
}

/* Buttons are links in this site; each one goes somewhere real */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.75rem;
  padding: 0.55rem 1.15rem;
  border: 1px solid var(--navy);
  border-radius: 4px;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  text-decoration: none;
  text-align: center;
}

.button-primary {
  background: var(--navy);
  color: var(--on-navy);
}

.button-primary:hover {
  background: var(--navy-deep);
  border-color: var(--navy-deep);
}

.button-secondary {
  background: #ffffff;
  color: var(--navy);
}

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

.on-navy .button-primary {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--navy);
}

.on-navy .button-primary:hover {
  background: var(--wash);
}

.on-navy .button-secondary {
  background: transparent;
  border-color: var(--on-navy-muted);
  color: var(--on-navy);
}

.on-navy .button-secondary:hover {
  background: var(--navy-deep);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* External links say so in text for screen readers and with a glyph for everyone */
.external::after,
.prose a[href^='http']:not(.external)::after {
  content: '\2197';
  font-weight: 400;
  margin-left: 0.15em;
}

/* Release state of a product: text first, the border only frames it */
.status {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--control);
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
  white-space: nowrap;
}

.on-navy .status {
  border-color: var(--on-navy-muted);
  color: var(--on-navy);
}

/* Key and value pairs: company details, product facts */
.facts {
  display: grid;
  grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr);
  border-top: 1px solid var(--rule);
}

.facts dt,
.facts dd {
  margin: 0;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}

.facts dt {
  padding-right: 1.5rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

@media (max-width: 30rem) {
  .facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .facts dt {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .facts dd {
    padding-top: 0.1rem;
  }
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.65rem 1rem 0.65rem 0;
  border-bottom: 1px solid var(--rule);
}

.data-table thead th {
  color: var(--muted);
  font-weight: 500;
  border-bottom-color: var(--control);
}

.data-table tbody th {
  font-weight: 600;
  color: var(--ink);
}

.note {
  padding: var(--space-s) var(--space-m);
  background: var(--wash);
  border-radius: 4px;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
}

.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
}

.home-link {
  color: var(--navy);
  text-decoration: none;
  padding-block: 0.25rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.logo svg {
  flex: none;
}

.wordmark {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.3125rem;
  letter-spacing: -0.01em;
  line-height: 1;
}

.main-nav ul {
  display: flex;
  gap: clamp(0.25rem, 2vw, 1.75rem);
  list-style: none;
  padding: 0;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: 0.5rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
}

.main-nav a:hover {
  color: var(--navy);
  text-decoration: underline;
}

.main-nav a[aria-current='page'] {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

@media (max-width: 26rem) {
  .home-link .wordmark {
    font-size: 1.125rem;
  }

  .home-link svg {
    width: 32px;
    height: 32px;
  }

  .main-nav a {
    padding-inline: 0.4rem;
    font-size: 0.9375rem;
  }
}

/* Below about 360px the wordmark and the links don't fit; the mark stays, and the link keeps its label */
@media (max-width: 22.4rem) {
  .home-link .wordmark {
    display: none;
  }

  .site-header .bar {
    gap: 0.5rem;
  }
}

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

.site-footer {
  background: var(--navy);
  color: var(--on-navy-muted);
  font-size: 1rem;
}

.site-footer a {
  color: var(--on-navy);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-l);
  padding-block: var(--space-xl) var(--space-l);
}

.legal-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--on-navy);
  margin-bottom: 0.5rem;
}

.footer-identity p + p {
  margin-top: 0.25rem;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-m);
}

.footer-list-title {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--on-navy);
  margin-bottom: 0.5rem;
}

.footer-links ul {
  list-style: none;
  padding: 0;
}

.footer-links li a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.footer-base {
  padding-block: var(--space-m);
  border-top: 1px solid rgb(255 255 255 / 0.18);
}

@media (max-width: 44rem) {
  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Product list (home, products, blog sidebar) ---------- */

.product-icon {
  flex: none;
  border-radius: 22%;
}

.product-list {
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.product-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: var(--space-xs) var(--space-m);
  align-items: start;
  padding-block: var(--space-m);
  border-bottom: 1px solid var(--rule);
}

.product-row .name {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
}

.product-row .name a {
  text-decoration: none;
}

.product-row .name a:hover {
  text-decoration: underline;
}

.product-row .summary {
  margin-top: 0.35rem;
  max-width: 44rem;
}

.product-row .meta {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.product-row .state {
  padding-top: 0.3rem;
}

@media (max-width: 44rem) {
  .product-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .product-row .product-icon {
    width: 48px;
    height: 48px;
  }

  .product-row .state {
    grid-column: 2;
    padding-top: 0;
  }
}

/* ---------- Pages ---------- */

.page {
  padding-top: var(--space-xl);
}

.page-intro {
  margin-top: var(--space-s);
  max-width: 36rem;
}

.back {
  font-size: 1rem;
}

.back a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
}

/* Home */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: var(--space-l) var(--space-xl);
  align-items: center;
  padding-block: var(--space-xl);
}

.kicker {
  display: flex;
  align-items: baseline;
  gap: 0.45em;
  margin-bottom: var(--space-m);
  font-weight: 600;
  font-size: 1rem;
  color: var(--navy);
}

/* The one place the signal blue appears outside focus rings: the logo's backslash */
.kicker::before {
  content: '';
  width: 0.5em;
  height: 0.9em;
  background: var(--signal);
  clip-path: polygon(0 0, 33% 0, 100% 100%, 67% 100%);
  transform: translateY(0.1em);
}

.hero-text .lead {
  margin-top: var(--space-m);
  max-width: 36rem;
}

.hero-text .actions {
  margin-top: var(--space-l);
}

.flagship {
  background: var(--navy);
  color: var(--on-navy-muted);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 4px;
}

.flagship > * + * {
  margin-top: var(--space-s);
}

.flagship-label {
  color: var(--on-navy);
  font-weight: 600;
  font-size: 1rem;
}

.flagship-name {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}

.flagship h2 {
  color: var(--on-navy);
}

.flagship .actions {
  margin-top: var(--space-m);
}

.block {
  padding-top: var(--space-xl);
}

.block + .block {
  padding-top: var(--space-2xl);
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-l);
  margin-bottom: var(--space-m);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-l) var(--space-xl);
  align-items: start;
}

.side-note {
  margin-top: var(--space-s);
  max-width: 30rem;
}

.band {
  margin-top: var(--space-2xl);
  padding-block: var(--space-xl);
  background: var(--wash);
}

.band .facts {
  border-top-color: var(--control);
}

@media (max-width: 52rem) {
  .hero,
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Product page */

.product-head {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--space-l) var(--space-xl);
  align-items: start;
  padding-block: var(--space-m) var(--space-l);
}

.product-head .back {
  grid-column: 1 / -1;
}

.name-row {
  display: flex;
  align-items: center;
  gap: var(--space-m);
}

.store-name {
  margin-top: 0.35rem;
  font-size: 1rem;
}

.product-head .summary {
  margin-top: var(--space-m);
  max-width: 36rem;
}

.product-head .actions {
  margin-top: var(--space-m);
}

.product-body {
  padding-top: var(--space-l);
  border-top: 1px solid var(--rule);
}

.help {
  max-width: var(--measure);
  margin-top: var(--space-xl);
  padding: var(--space-m);
  background: var(--wash);
  border-radius: 4px;
}

.help ul {
  list-style: none;
  padding: 0;
  margin-top: var(--space-s);
}

.help li + li {
  margin-top: 0.6rem;
}

@media (max-width: 52rem) {
  .product-head {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 30rem) {
  .name-row .product-icon {
    width: 64px;
    height: 64px;
  }
}

/* Document pages: policies and support */

.doc .back {
  margin-bottom: var(--space-s);
}

.doc .back a {
  font-weight: 600;
}

.updated {
  margin-top: 0.5rem;
  font-size: 1rem;
}

.doc .prose {
  margin-top: var(--space-l);
}

/* Markdown blockquotes read as notes, like the worked example on the Mindset page */
.prose blockquote {
  margin: 1em 0 0;
  padding: var(--space-s) var(--space-m);
  background: var(--wash);
  border-radius: 4px;
}

.prose blockquote > * + * {
  margin-top: 0.75em;
}

/* Code blocks in guides keep their line breaks and scroll sideways inside themselves, so a long command or query
   plan never widens the page on a phone. */
.prose pre {
  overflow-x: auto;
  padding: var(--space-s) var(--space-m);
  background: var(--wash);
  border-radius: 4px;
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  background: none;
  border-radius: 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.65rem 1rem 0.65rem 0;
  border-bottom: 1px solid var(--rule);
}

.prose thead th {
  color: var(--muted);
  font-weight: 500;
  border-bottom-color: var(--control);
}

.prose img {
  height: auto;
  border-radius: 4px;
}

/* Products page filter */

.filter {
  margin: var(--space-l) 0 0;
  padding: 0;
  border: 0;
}

.filter legend {
  padding: 0;
  margin-bottom: 0.6rem;
  font-weight: 600;
  font-size: 1rem;
}

.filter .options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter label {
  position: relative;
}

.filter input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.filter span {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--control);
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  background: #ffffff;
}

.filter input:hover + span {
  background: var(--wash);
}

.filter input:checked + span {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--on-navy);
}

.filter input:focus-visible + span {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.count {
  margin: var(--space-m) 0 var(--space-s);
  font-size: 1rem;
}

.empty > * + * {
  margin-top: 0.5rem;
}

.link-button {
  padding: 0.5rem 0;
  min-height: 2.75rem;
  border: 0;
  background: none;
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* Contact and about */

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-l) var(--space-xl);
  margin-top: var(--space-m);
  align-items: start;
}

.stack > * + * {
  margin-top: var(--space-s);
}

.stack h2 {
  margin-top: var(--space-xl);
}

.plain-list {
  padding-left: 1.25em;
}

.plain-list li + li {
  margin-top: 0.4em;
}

.details {
  max-width: var(--measure);
  margin-top: var(--space-m);
}

@media (max-width: 52rem) {
  .contact-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Blog ---------- */

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  list-style: none;
  padding: 0;
  margin-top: var(--space-m);
  font-size: 1rem;
}

.categories a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.categories a[aria-current='page'] {
  font-weight: 600;
  text-decoration-thickness: 2px;
}

.article-list {
  list-style: none;
  padding: 0;
  margin-top: var(--space-m);
  border-top: 1px solid var(--rule);
}

.article-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14rem;
  gap: var(--space-s) var(--space-l);
  padding-block: var(--space-m);
  border-bottom: 1px solid var(--rule);
}

.article-row.no-cover {
  grid-template-columns: minmax(0, 1fr);
}

.article-row h2,
.article-row h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
}

.article-row h2 a,
.article-row h3 a {
  text-decoration: none;
}

.article-row h2 a:hover,
.article-row h3 a:hover {
  text-decoration: underline;
}

.article-row .excerpt {
  margin-top: 0.4rem;
  max-width: 40rem;
}

.byline {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.article-row img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 4px;
}

@media (max-width: 44rem) {
  .article-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-row figure {
    order: -1;
  }
}

.pagination {
  display: flex;
  justify-content: space-between;
  gap: var(--space-m);
  margin-top: var(--space-l);
  font-weight: 600;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.article {
  padding-top: var(--space-xl);
}

.article-head {
  max-width: 48rem;
}

.article-head .lead {
  margin-top: var(--space-s);
}

.article-cover {
  margin: var(--space-l) 0 0;
  max-width: 56rem;
}

.article-cover img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.article .prose {
  margin-top: var(--space-l);
}

figure {
  margin: 0;
}

.article-foot {
  margin-top: var(--space-xl);
}

.empty-state {
  margin-top: var(--space-l);
  max-width: var(--measure);
}

.empty-state > * + * {
  margin-top: 0.5rem;
}

/* Shown only in the admin's preview of an article */
.preview-banner {
  padding: 0.75rem var(--gutter);
  background: #fbf0dc;
  color: #5c3a05;
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
}

.preview-banner a {
  color: inherit;
}

/* ---------- Long product pages ---------- */

/* Screenshots and tables use the full width; running text keeps a readable line length. */
.prose.product-body {
  max-width: 60rem;
}

.product-body > :is(p, ul, ol, h2, h3, h4, blockquote) {
  max-width: var(--measure);
}

.product-body > p:has(> img) {
  max-width: none;
}

.product-body img,
.article .prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

/* An emphasised line right after a screenshot is its caption: ![...](...) then *caption* on the next line. */
.product-body p:has(> img) > em,
.article .prose p:has(> img) > em {
  display: block;
  margin-top: 0.6rem;
  font-style: normal;
  font-size: 0.9375rem;
  color: var(--muted);
}

.product-body h3 {
  font-size: 1.125rem;
}

.product-body table {
  font-size: 0.9375rem;
}

.product-body th:first-child,
.product-body td:first-child {
  min-width: 9rem;
}

.product-body thead th {
  white-space: nowrap;
}

/* Full-width tables on wide screens; on phones they scroll sideways inside themselves instead of widening the page. */
@media (min-width: 44rem) {
  .product-body table {
    display: table;
  }
}
