/* Rulebend site styles.
   System fonts only; the site loads nothing from other domains.
   Palette from brand/README.md and brand/source: ink #1b1030, violet #4902bd,
   gold #ffd935, orange #ff7a2e / #b2380f.
   Checked in both colour schemes: text 4.5:1 or better, control borders and
   focus rings 3:1 or better against what they sit on. */

:root {
  color-scheme: light dark;
  --bg: #f7f3ff;
  --bg-glow: #e4d8ff;
  --surface: #ffffff;
  --surface-2: #f1ebff;
  --text: #1b1030;
  --heading: #1b1030;
  --wordmark: #1b1030;
  --muted: #4f4568;
  --accent: #a3330d;
  --link: #4902bd;
  --link-hover: #33018a;
  --border: #dcd1f5;
  --field-border: #75689a;
  --field-bg: #ffffff;
  --pill-bg: #4902bd;
  --pill-text: #ffffff;
  --pill-border: #4902bd;
  --btn-bg: #ffd935;
  --btn-bg-hover: #ffe36a;
  --btn-text: #1b1030;
  --btn-sub: #5c3b00;
  --btn-edge: #1b1030;
  --btn-depth: #b2380f;
  --focus: #4902bd;
  --error: #b42318;
  --callout-edge: #4902bd;
  --avatar-ring: #1b1030;
  --glow: rgb(73 2 189 / 0.28);
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #140c27;
    --bg-glow: #2c1766;
    --surface: #20163d;
    --surface-2: #1a1133;
    --text: #f6f1ff;
    --heading: #f6f1ff;
    --wordmark: #ffd935;
    --muted: #cbc1e8;
    --accent: #ffa66b;
    --link: #c9b2ff;
    --link-hover: #e6dcff;
    --border: #3a2b66;
    --field-border: #8c7cc0;
    --field-bg: #1a1133;
    --pill-border: #7444ea;
    --btn-depth: #ff7a2e;
    --focus: #ffd935;
    --error: #ff8f8f;
    --callout-edge: #ffd935;
    --glow: rgb(116 68 234 / 0.45);
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(130% 460px at 50% -80px, var(--bg-glow), transparent 72%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 400 1rem/1.6 var(--font-body);
  overflow-wrap: break-word;
}

img {
  max-width: 100%;
  height: auto;
}

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

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

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

code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: var(--surface-2);
  font: 0.875em/1.45 var(--font-mono);
  overflow-wrap: anywhere;
}

strong {
  font-weight: 700;
}

.url {
  overflow-wrap: anywhere;
}

/* Keeps a scope name such as yt-analytics.readonly on one line (the <wbr>
   before it is the preferred break). */
.nowrap {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The display stack has no true 800 weight in some fonts (Arial Rounded MT
   Bold in Chrome on macOS), so never let the browser fake a bolder one. */
.hero h1,
.tagline,
.link-btn .platform,
.eyebrow,
.brand,
.doc h1,
.doc h2,
.btn {
  font-synthesis: none;
}

.skip-link {
  position: absolute;
  top: -200px;
  left: 16px;
  z-index: 10;
  padding: 10px 14px;
  border: 2px solid var(--focus);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

.wrap {
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 16px;
}

.wrap--doc {
  max-width: 46rem;
}

/* ---------- Home: profile ---------- */

/* Longhands only: the side padding comes from .wrap (the 16px gutter). */
.hero {
  padding-top: 44px;
  padding-bottom: 4px;
  text-align: center;
}

.avatar {
  display: block;
  width: 128px;
  height: 128px;
  margin: 4px auto 22px;
  border: 4px solid var(--avatar-ring);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--btn-bg), 0 14px 34px var(--glow);
}

.hero h1 {
  margin: 0 0 12px;
  color: var(--wordmark);
  font: 800 2.75rem/1.05 var(--font-display);
  letter-spacing: -0.01em;
}

.tagline {
  display: inline-block;
  max-width: 100%;
  margin: 0 0 16px;
  padding: 6px 14px;
  border: 1px solid var(--pill-border);
  /* Fully round on one line, and still a tidy shape if large text wraps it. */
  border-radius: 1.2em;
  background: var(--pill-bg);
  color: var(--pill-text);
  font: 700 0.8125rem/1.35 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-wrap: balance;
}

/* Narrow phones, or larger default text (em-based, so it follows the
   reader's text size): tighten the pill so the brand line stays on one line. */
@media (max-width: 24em) {
  .tagline {
    padding-right: 12px;
    padding-left: 12px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
  }
}

.lede {
  max-width: 26rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.0625rem;
  text-wrap: balance;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

/* ---------- Home: platform buttons ---------- */

.links {
  display: grid;
  gap: 16px;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
}

/* The arrow is pinned to the right edge, so only the platform name and the
   handle can wrap (the handle then sits right-aligned under the name). */
.link-btn {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  min-height: 64px;
  padding: 12px 44px 12px 20px;
  border: 2px solid var(--btn-edge);
  border-radius: 16px;
  background: var(--btn-bg);
  box-shadow: 0 5px 0 var(--btn-depth);
  color: var(--btn-text);
  text-decoration: none;
}

.link-btn:hover {
  background: var(--btn-bg-hover);
  color: var(--btn-text);
}

.link-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--btn-depth);
}

.link-btn .platform {
  font: 800 1.1875rem/1.2 var(--font-display);
}

.link-btn .handle {
  margin-left: auto;
  color: var(--btn-sub);
  font-size: 0.9375rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.link-btn .go {
  position: absolute;
  top: 50%;
  right: 18px;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-50%);
}

@media (prefers-reduced-motion: no-preference) {
  .link-btn,
  .btn {
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
  }

  .link-btn:hover,
  .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 0 var(--btn-depth);
  }

  .link-btn:active,
  .btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--btn-depth);
  }
}

/* ---------- Eyebrows, fine print and chips ---------- */

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font: 800 0.8125rem/1.3 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fine {
  color: var(--muted);
  font-size: 0.9375rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--link);
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}

.chip:hover {
  background: var(--surface-2);
}

/* ---------- Header for inner pages ---------- */

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

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 16px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  color: var(--heading);
  font: 800 1.25rem/1 var(--font-display);
  text-decoration: none;
}

.brand:hover {
  color: var(--heading);
}

.brand img {
  width: 36px;
  height: 36px;
  border: 2px solid var(--avatar-ring);
  border-radius: 50%;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding: 11px 0;
  font-weight: 600;
}

.site-nav a[aria-current="page"] {
  color: var(--heading);
  text-decoration-color: var(--btn-depth);
  text-decoration-thickness: 3px;
}

/* ---------- Document pages ---------- */

.doc {
  padding-top: 32px;
}

.doc h1 {
  margin: 0 0 6px;
  color: var(--heading);
  font: 800 2.25rem/1.15 var(--font-display);
}

.doc .meta {
  margin: 0 0 26px;
  color: var(--muted);
}

/* Rulebend Studio page: the eyebrow sits tight above the h1, and the opening
   paragraph gets a little room and size of its own. */
.doc .eyebrow {
  margin-bottom: 6px;
}

.doc .intro {
  margin-top: 14px;
  font-size: 1.0625rem;
}

.doc h2 {
  margin: 46px 0 12px;
  color: var(--heading);
  font: 800 1.5rem/1.25 var(--font-display);
}

.doc h3 {
  margin: 28px 0 8px;
  color: var(--heading);
  font: 700 1.125rem/1.35 var(--font-body);
}

.doc section,
.doc h2,
.doc h3 {
  scroll-margin-top: 16px;
}

.doc p,
.doc ul,
.doc ol,
.doc dl {
  margin: 0 0 14px;
}

.doc ul,
.doc ol {
  padding-left: 1.4em;
}

.doc li + li {
  margin-top: 6px;
}

.summary {
  padding: 20px 20px 8px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--btn-bg);
  border-radius: 16px;
  background: var(--surface);
}

.doc .summary h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.toc {
  margin: 28px 0 0;
  padding: 16px 20px 6px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.doc .toc h2 {
  margin: 0 0 8px;
  font-size: 1.125rem;
}

.toc ol {
  columns: 2 15rem;
  column-gap: 28px;
}

.toc li {
  break-inside: avoid;
}

.perm dt {
  margin-top: 14px;
  font-weight: 700;
}

.perm dd {
  margin: 6px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--border);
}

/* An edge and an accent, so notices stand out from the page and, in dark
   mode, don't look like the form's text boxes. */
.callout {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--callout-edge);
  border-radius: 14px;
  background: var(--surface);
}

.callout p {
  margin: 0;
}

.callout p + p {
  margin-top: 8px;
}

/* ---------- Contact form ---------- */

.contact-form {
  margin: 24px 0 32px;
}

.field {
  margin: 0 0 22px;
}

.field label {
  display: block;
  margin: 0 0 4px;
  font-weight: 700;
}

.hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.field textarea,
.field input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--field-border);
  border-radius: 12px;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
}

.field textarea {
  min-height: 11rem;
  resize: vertical;
}

.field textarea:focus-visible,
.field input:focus-visible {
  border-color: var(--focus);
  outline-offset: 2px;
}

/* Errors: a red border and a short message under the field, shown once the
   visitor has changed the field and moved on, or tried to send. Separate rules,
   so a browser without :user-invalid still uses the aria-invalid one that
   assets/contact.js sets. */
.field-error {
  display: none;
  margin: 8px 0 0;
  color: var(--error);
  font-size: 0.9375rem;
  font-weight: 600;
}

.field textarea:user-invalid,
.field input:user-invalid {
  border-color: var(--error);
}

.field textarea[aria-invalid="true"],
.field input[aria-invalid="true"] {
  border-color: var(--error);
}

.field textarea:user-invalid + .field-error,
.field input:user-invalid + .field-error {
  display: block;
}

.field textarea[aria-invalid="true"] + .field-error,
.field input[aria-invalid="true"] + .field-error {
  display: block;
}

.form-note {
  margin: 0 0 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px 28px;
  border: 2px solid var(--btn-edge);
  border-radius: 14px;
  background: var(--btn-bg);
  box-shadow: 0 5px 0 var(--btn-depth);
  color: var(--btn-text);
  font: 800 1.0625rem/1.2 var(--font-display);
  cursor: pointer;
}

.btn:hover {
  background: var(--btn-bg-hover);
}

.btn:disabled {
  cursor: progress;
  opacity: 0.75;
}

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

.site-footer {
  margin: 56px 0 0;
  padding: 20px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: center;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 22px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.site-footer a {
  display: inline-block;
  padding: 11px 0;
}

.site-footer p {
  margin: 0;
}

/* Home page: the low-key link to the Rulebend Studio page. Muted, but still
   underlined, 4.5:1 or better, and a 44px tap target from the padding above. */
.footer-about a {
  color: var(--muted);
  font-size: 0.875rem;
}

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

/* ---------- Wider screens ---------- */

@media (min-width: 40rem) {
  .hero {
    padding-top: 64px;
  }

  .doc {
    padding-top: 44px;
  }

  .doc h1 {
    font-size: 2.625rem;
  }
}

/* ---------- Forced colours (Windows high contrast) ---------- */

@media (forced-colors: active) {
  .link-btn,
  .btn,
  .chip,
  .tagline {
    border-color: CanvasText;
  }

  .avatar {
    forced-color-adjust: none;
  }
}

/* ---------- Print ---------- */

@media print {
  body {
    background: #ffffff;
    color: #000000;
  }

  .skip-link,
  .site-nav,
  .toc {
    display: none;
  }

  a {
    color: #000000;
  }

  .summary,
  .callout {
    border: 1px solid #999999;
    background: #ffffff;
  }
}
