/* ANOPEDIA 1.7.1 – contrast and fixed-dark-surface repair
   Light = beige -> ivory; dark = charcoal -> deep green.
   Prevents pale text on pale callouts, pale form options, and dark logo on dark seal. */

:root{
  --surface:var(--card);
  --surface-secondary:var(--paper2);
  --control-bg:#fffefa;
  --control-ink:#1b211c;
  --control-placeholder:#666f65;
  --notice-bg:#eee8db;
  --notice-ink:#242820;
}
html[data-theme="dark"]{
  --surface:#19271e;
  --surface-secondary:#1e3025;
  --control-bg:#18281e;
  --control-ink:#f6f3eb;
  --control-placeholder:#b6c2b5;
  --notice-bg:#233428;
  --notice-ink:#f4f0e7;
}

/* Version-history notices appeared cream-white with inherited cream text. */
.ch-warning,
.ch-page .ch-warning,
.academy-page .ch-warning{
  background:var(--notice-bg);
  color:var(--notice-ink);
  border-left-color:var(--gold);
}
.ch-warning :is(p,strong,span),.academy-page .ch-warning :is(p,strong,span){color:inherit}
.ch-warning a{color:inherit;text-underline-offset:3px;text-decoration-thickness:1px}
.ch-warning a:hover,.ch-warning a:focus-visible{color:var(--accent)}
html[data-theme="dark"] .ch-warning a{color:#e5c49a}
html[data-theme="dark"] .ch-warning a:hover,
html[data-theme="dark"] .ch-warning a:focus-visible{color:#fff4d9}

/* Inputs must never use a fixed white fallback with inherited white text. */
.ch-page :is(input:not([type="checkbox"]),select,textarea),
.academy-page :is(input:not([type="checkbox"]),select,textarea){
  background-color:var(--control-bg);
  color:var(--control-ink);
  border:1px solid var(--line2);
  color-scheme:light;
}
html[data-theme="dark"] .ch-page :is(input:not([type="checkbox"]),select,textarea),
html[data-theme="dark"] .academy-page :is(input:not([type="checkbox"]),select,textarea){
  color-scheme:dark;
}
.ch-page :is(input,textarea)::placeholder,
.academy-page :is(input,textarea)::placeholder{color:var(--control-placeholder);opacity:1}
.ch-page select option,.academy-page select option{
  background:var(--control-bg);
  color:var(--control-ink);
}
.ch-page :is(input,select,textarea):focus-visible,
.academy-page :is(input,select,textarea):focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Consistent borders, card surfaces and readable secondary text in dark mode. */
html[data-theme="dark"] :is(.ch-panel,.ch-faculty,.ch-annex,.ch-hero,.ch-comparison,.ch-form,.ch-feature){border-color:var(--line)}
html[data-theme="dark"] .ch-panel{color:var(--ink)}
html[data-theme="dark"] :is(.ch-count,.ch-annex summary small,.ch-crumb){color:var(--muted);opacity:1}
html[data-theme="dark"] .ch-badge.historical{color:#b5d5b9}
html[data-theme="dark"] .ch-badge.editorial{color:#e3bf91}
html[data-theme="dark"] .ch-msg{color:#e3bf91}

/* The rector's portrait is ALWAYS on a dark green panel, even in light mode. */
.academy-rector-portrait img,
html[data-theme="dark"] .academy-rector-portrait img{
  filter:drop-shadow(0 5px 16px rgba(236,230,206,.12));
  opacity:1;
}
.aliopisto-top img,
html[data-theme="dark"] .aliopisto-top img{
  filter:drop-shadow(0 0 16px rgba(237,232,207,.15));
}

/* Keep the rest of the illustrated seals consistent with their card surface. */
html[data-theme="dark"] .academy-rector-aside img{filter:invert(1) brightness(1.07)}

/* Improve responsive long pages without hiding contents under the sticky header. */
.ch-page,.academy-page{min-width:0}
.ch-page :where(.ch-tools,.ch-form,.ch-warning,.ch-panel,.ch-comparison){min-width:0;max-width:100%}
.ch-page :is(input,textarea,select){min-width:0;max-width:100%}
@media(max-width:640px){
  .ch-warning{padding:18px 18px;overflow-wrap:anywhere}
  .ch-tools label{min-width:0;flex-basis:100%}
}
