/* Shared styles for the accessible pages of the Digital Accessibility Failure
   Demos & Resources site: the landing page and the image/text resource pages.

   NOT loaded by the demo pages — those are self-contained and carry their own
   CSS so their deliberate failures stay isolated.

   Plain CSS, no build step. Mobile-first: base rules target small screens, and
   `min-width` media queries layer on enhancements for larger viewports. Keep it
   accessible: readable contrast, visible focus, generous tap targets, and
   respect for reduced-motion. */

:root {
  --color-bg: #ffffff;
  --color-surface: #f4f6f8;
  --color-border: #d0d7de;
  --color-text: #1b1f23;
  --color-text-muted: #4a5159;
  --color-link: #6d28d9;
  --color-link-hover: #5b21b6;
  --color-focus: #b8860b;
  --color-on-accent: #ffffff;

  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  --max-width: 60rem;
  --measure: 65ch; /* comfortable line length for reading */
  --radius: 8px;
  --tap-target: 44px; /* minimum comfortable touch target */

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

/* Dark palette. Applied when the system prefers dark AND the viewer hasn't
   forced light, or whenever the viewer has explicitly chosen dark via the
   theme switcher (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0d1117;
    --color-surface: #161b22;
    --color-border: #30363d;
    --color-text: #e6edf3;
    --color-text-muted: #9ba7b4;
    --color-link: #c4b5fd;
    --color-link-hover: #ddd4fe;
    --color-focus: #f2cc60;
    --color-on-accent: #04101f;
  }
}

:root[data-theme="dark"] {
  --color-bg: #0d1117;
  --color-surface: #161b22;
  --color-border: #30363d;
  --color-text: #e6edf3;
  --color-text-muted: #9ba7b4;
  --color-link: #c4b5fd;
  --color-link-hover: #ddd4fe;
  --color-focus: #f2cc60;
  --color-on-accent: #04101f;
}

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

html {
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 1.0625rem;
}

/* Readable column with a comfortable mobile gutter (>=16px). Wider breathing
   room is layered on at larger widths. */
.page {
  max-width: var(--max-width);
  margin-inline: auto;
  padding: var(--space-md) var(--space-md) var(--space-xl);
}

@media (min-width: 40rem) {
  .page {
    padding-top: var(--space-lg);
  }
}

/* Skip link: hidden until focused, then clearly visible. */
.skip-link {
  position: absolute;
  left: var(--space-md);
  top: -4rem;
  z-index: 10;
  padding: var(--space-xs) var(--space-md);
  background-color: var(--color-bg);
  color: var(--color-link);
  border: 2px solid var(--color-link);
  border-radius: var(--radius);
  transition: top 0.15s ease-in-out;
}

.skip-link:focus {
  top: var(--space-md);
}

/* Row holding the theme switcher, above the header. */
.top-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-md);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--tap-target);
  padding: var(--space-xs) var(--space-md);
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--color-link);
}

.theme-toggle-icon {
  display: inline-flex;
}

header.site-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-lg);
}

h1 {
  font-size: clamp(1.6rem, 6vw, 2.5rem);
  line-height: 1.2;
  margin: 0 0 var(--space-xs);
  color: var(--color-link);
}

.tagline {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 1.0625rem;
}

@media (min-width: 40rem) {
  .tagline {
    font-size: 1.125rem;
  }
}

/* Suggested-prompt line on the resource pages: a bold label plus one or more
   quoted example prompts. The bold label and the quotation marks set the
   prompts apart — no italics (harder to read, poorer for accessibility). */
.suggested-prompt {
  margin: var(--space-md) 0 0;
  color: var(--color-text);
}

.suggested-prompt-label {
  font-weight: 600;
}

/* Callout for the participation / intentional-failures note. */
.notice {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-link);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
}

.notice :first-child {
  margin-top: 0;
}

.notice :last-child {
  margin-bottom: 0;
}

.notice strong {
  color: var(--color-text);
}

h2 {
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
}

section:first-of-type h2 {
  margin-top: 0;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-link-hover);
}

/* A strong, consistent focus indicator everywhere. */
a:focus-visible,
button:focus-visible,
.card:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Card grid for the demo / resource listings. One column on phones; it fills in
   more columns as space allows. */
.card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-md);
  grid-template-columns: 1fr;
}

@media (min-width: 30rem) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  }
}

/* Two card grids in a row (images then text) stay visibly separated and the
   second always starts on its own row. */
.card-grid + .card-grid {
  margin-top: var(--space-lg);
}

/* Intro line under a section heading. Spans the full content width. */
.section-intro {
  margin: 0 0 var(--space-md);
  color: var(--color-text);
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}

.card:hover {
  border-color: var(--color-link);
}

/* Type icon sits on the same line as the card title, vertically centred. The
   icon stays outside the <h3> so it doesn't pick up the title's underline. It's
   decorative (aria-hidden) since the card name already states the type. */
.card-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
}

.card-head h3 {
  margin: 0;
}

.card-icon {
  display: inline-flex;
  color: var(--color-link);
}

.card:hover .card-icon {
  color: var(--color-link-hover);
}

.card h3 {
  margin: 0 0 var(--space-xs);
  font-size: 1.2rem;
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card:hover h3 {
  color: var(--color-link-hover);
}

.card p {
  margin: 0;
  color: var(--color-text-muted);
}

/* "Last updated" line pinned to the bottom-right of each card. Scoped as
   `.card .card-meta` so its `margin-top: auto` outranks `.card p` above (which
   would otherwise reset the top margin and stop it sticking to the bottom). */
.card .card-meta {
  margin-top: auto;
  padding-top: var(--space-md);
  text-align: right;
  font-size: 0.8rem;
}

/* Back link shown on inner pages — padded to a comfortable tap target. */
.back-link {
  display: inline-block;
  margin-bottom: var(--space-md);
  padding-block: var(--space-xs);
}

/* Button-styled control — image download link, text copy button, etc. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: var(--tap-target);
  padding: var(--space-xs) var(--space-md);
  background-color: var(--color-link);
  color: var(--color-on-accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background-color: var(--color-link-hover);
  color: var(--color-on-accent);
}

/* Full-width button on narrow screens; natural width once there's room. */
@media (max-width: 29.99rem) {
  .button {
    width: 100%;
  }
}

/* Image resource pages. */
.resource-figure {
  margin: 0 0 var(--space-md);
}

.resource-image {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-surface);
}

.resource-figure figcaption {
  margin-top: var(--space-xs);
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Text resource pages — snippet shown full width in a surfaced block, at a
   larger size (>=1.5x the base body text) so it's easy to read and work with. */
.snippet {
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1.6rem;
  line-height: 1.5;
}

.snippet > :first-child {
  margin-top: 0;
}

.snippet > :last-child {
  margin-bottom: 0;
}

/* Copy-text control row and its status message. */
.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.copy-status {
  color: var(--color-text-muted);
}

/* Inline code — technical tokens in prose (colour values, attributes, tags).
   Surface fill + border so it reads as code and keeps contrast in both themes. */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

/* Report / audit resource pages — long-form prose kept to a readable measure. */
.report {
  max-width: var(--measure);
}

.report > :first-child {
  margin-top: 0;
}

.report h2 {
  margin-top: var(--space-lg);
}

.report ul,
.report ol {
  padding-left: 1.5rem;
}

.report li + li {
  margin-top: var(--space-xs);
}

.report li > ul {
  margin-top: var(--space-xs);
}

/* The one-line verdict that opens the audit, set a touch larger. */
.report .verdict {
  font-size: 1.1rem;
}

/* Methodology / scope note, set a touch quieter. */
.report .scope {
  color: var(--color-text-muted);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
