/* Shared palette and type roles with app/assets/css/main.css.
 * Tier 3 is a typography-and-spacing skin, not a layout reset.
 * Keep legacy table, td and font display properties untouched.
 */
@import url('/assets/archive-fonts.css');

:root {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-bg-subtle: #fafafa;
  --color-text: #0a0a0a;
  --color-muted: #5c5c5c;
  --color-border: #e5e5e5;
  --color-link: #0000ff;
  --color-link-hover: #0077c2;
  --color-accent: #00a4ef;
  --font-main: 'Onest', ui-sans-serif, system-ui, sans-serif;
  --font-heading: 'Playfair Display', ui-serif, Georgia, serif;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --measure: 68ch;
  --space: clamp(1rem, 2.5vw, 1.75rem);
}

:root.h4a-archive-dark {
  color-scheme: dark;
  --color-bg: #0a0a0a;
  --color-bg-subtle: #141414;
  --color-text: #f2f2f2;
  --color-muted: #a3a3a3;
  --color-border: #262626;
  --color-link: #00a4ef;
  --color-link-hover: #4db8f5;
  --color-accent: #7cc7fa;
}

/* Tier 3: typeset text, without changing the historical markup. */
html, body {
  background: var(--color-bg);
  color: var(--color-text);
}

body {
  font: var(--text-base) / 1.7 var(--font-main);
  max-inline-size: var(--measure);
  margin: 0 auto;
  padding: var(--space) var(--space) calc(2 * var(--space));
  overflow-wrap: anywhere;
}

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

a:any-link:is(:hover, :focus-visible) {
  color: var(--color-link-hover);
  text-decoration-thickness: 2px;
}

a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 5px var(--color-link-hover);
}

@media (forced-colors: active) {
  a:focus-visible { outline-color: Highlight; }
}

pre {
  font-size: 0.92em;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  padding: 1em 1.2em;
  border-radius: 8px;
}

code { font-size: 0.92em; }

blockquote {
  border-inline-start: 3px solid var(--color-link);
  padding-inline-start: 1em;
  color: var(--color-muted);
  margin-inline: 0;
}

img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--color-border); }

h1, h2 {
  color: var(--color-text);
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.15;
}

h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.625rem, 3vw, 2.125rem); }

h3 {
  color: var(--color-text);
  font: 600 1.375rem / 1.25 var(--font-main);
}

/* The injected banner (scripts/lib/inject.ts). */
.h4a-archive-banner {
  background: var(--color-bg-subtle);
  color: var(--color-text);
  border-inline-start: 3px solid var(--color-link);
  font: 400 var(--text-sm) / 1.7 var(--font-main);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.75rem;
}

.h4a-archive-banner a:any-link {
  display: inline-flex;
  align-items: center;
  /* Leave clearance above the 44px target under mobile page scaling. */
  min-block-size: 46px;
  min-inline-size: 44px;
  vertical-align: middle;
  font-weight: 600;
}

/* Tier 3: the preserved Mailman list-info tables use light bgcolor cells. */
:root.h4a-archive-dark body:has(form[action*="/mailman/roster/"]) td[bgcolor] {
  color: #0a0a0a;
}

/* Keep words intact in the label column and leave room beside native fields. */
body:has(form[action*="/mailman/roster/"]) td[bgcolor="#dddddd" i] {
  overflow-wrap: normal;
}

@media (max-width: 36rem) {
  body:has(form[action*="/mailman/roster/"]) input:is([type="text" i], [type="password" i]) {
    box-sizing: border-box;
    max-inline-size: 70vw;
  }

  body:has(form[action*="/mailman/roster/"]) table table:has(input[name="fullname"]) {
    inline-size: 100%;
  }

  /* A percentage of the cell alone does not cap its intrinsic table width. */
  body:has(form[action*="/mailman/roster/"]) table table:has(input[name="fullname"]) input:is([type="text" i], [type="password" i]) {
    max-inline-size: 40vw;
  }
}

/* Tier 2: MonoBook hooks are scoped to the legacy wiki wrapper. */
body:has(> #globalWrapper), body:has(> .mw-body) {
  max-inline-size: 72rem;
}

#globalWrapper {
  font-size: var(--text-base);
  margin: 0;
}

#globalWrapper #column-content {
  float: none;
  width: auto;
  margin: 0;
}

#globalWrapper #column-one {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: var(--space);
  margin-block: var(--space);
  padding: 0;
}

#globalWrapper #content,
.mw-body {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  margin: 0;
  padding: var(--space);
}

#globalWrapper #bodyContent {
  max-inline-size: var(--measure);
}

#globalWrapper .firstHeading,
.mw-body :is(h1, h2, h3) {
  border-bottom: 1px solid var(--color-border);
  padding-block-end: 0.35em;
}

#globalWrapper .firstHeading {
  color: var(--color-text);
  font-family: var(--font-heading);
}

/* Recolor headings on themed surfaces, not the skin's orange H6 caps
 * or the light content inside MonoBook portlets. */
:root.h4a-archive-dark :is(#globalWrapper #content, .mw-body) :is(h4, h5, h6):not(.portlet *),
:root.h4a-archive-dark #globalWrapper .portlet > :is(h4, h5) {
  color: var(--color-text);
}

#globalWrapper .toc,
#globalWrapper .portlet,
#globalWrapper #footer {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
  font-size: var(--text-sm);
}

#globalWrapper .portlet {
  position: static;
  float: none;
  width: auto;
  margin: 0;
}

#globalWrapper #p-cactions ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#globalWrapper #footer li {
  white-space: normal;
}
