/* Mikko Koivunalho Oy -- element defaults.
 *
 * Bare elements only, no class names, so nothing here can collide with an
 * application's own stylesheet and any of it is overridden by a single class.
 * Separate from mkoy-tokens.css because tokens are facts about the brand and
 * this file is opinions about HTML -- a static marketing site and a data-entry
 * application want the same tokens and not necessarily the same opinions.
 *
 *     <link rel="stylesheet" href="/css/mkoy-tokens.css">   <!-- always -->
 *     <link rel="stylesheet" href="/css/mkoy-base.css">     <!-- usually -->
 *     <link rel="stylesheet" href="/css/mkoy-ui.css">       <!-- app chrome -->
 *
 * This reproduces how Polmai already renders, with two exceptions, both
 * measured accessibility fixes rather than restyling: form controls are bounded
 * by --mkoy-border instead of --mkoy-hairline (1.47 contrast fails WCAG
 * 1.4.11's 3:1 for anything clickable), and there is a visible focus ring.
 */

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

body {
  margin: 0;
  background: var(--mkoy-bg);
  color: var(--mkoy-ink);
  font-family: var(--mkoy-font-sans);
  font-size: var(--mkoy-text-base);
  font-weight: var(--mkoy-weight-body);
  line-height: var(--mkoy-leading-body);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--mkoy-weight-heading);
  line-height: var(--mkoy-leading-tight);
  margin: 0 0 var(--mkoy-space-3);
}

h1 { font-size: var(--mkoy-text-3xl); }
h2 { font-size: var(--mkoy-text-2xl); }
h3 { font-size: var(--mkoy-text-xl); }
h4, h5, h6 { font-size: var(--mkoy-text-lg); }

p, ul, ol, table, pre { margin: 0 0 var(--mkoy-space-4); }

strong, b { font-weight: var(--mkoy-weight-emphasis); }
small { font-size: var(--mkoy-text-sm); color: var(--mkoy-muted); }

a { color: var(--mkoy-accent); text-underline-offset: 0.15em; }
a:hover, a:focus-visible { text-decoration-thickness: 2px; }

/* Links stay underlined. Colour alone is not an accessible way to mark a link
 * (WCAG 1.4.1), and the accent against body ink is nowhere near the 3:1 that
 * would be needed to carry the meaning on its own. Removing this underline is a
 * decision, not a tidy-up. */

/* ONE focus style, on :focus-visible so a mouse click draws nothing and a
 * keyboard tab draws a ring. Never `outline: none` anywhere: a keyboard user
 * who cannot see what is focused cannot use the page at all, and this is the
 * single most commonly deleted accessibility feature on the web. */
:focus-visible {
  outline: 2px solid var(--mkoy-focus);
  outline-offset: 2px;
  border-radius: var(--mkoy-radius);
}

hr {
  border: 0;
  border-top: 1px solid var(--mkoy-hairline);
  margin: var(--mkoy-space-6) 0;
}

/* Form controls take --mkoy-border, NOT --mkoy-hairline. That distinction is
 * the reason both tokens exist: hairline is decoration at 1.47 and the boundary
 * of a control somebody has to find and click needs 3:1 (WCAG 1.4.11). An input
 * bounded by hairline is edgeless for a good many readers -- which is what
 * Polmai ships today. */
input, select, textarea, button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--mkoy-border);
  border-radius: var(--mkoy-radius);
  padding: var(--mkoy-space-2) var(--mkoy-space-3);
  background: var(--mkoy-field);
}

button { cursor: pointer; background: var(--mkoy-panel); }

table { border-collapse: collapse; width: 100%; }
th, td {
  text-align: left;
  padding: var(--mkoy-space-2) var(--mkoy-space-3);
  border-bottom: 1px solid var(--mkoy-hairline);
}
th { font-weight: var(--mkoy-weight-emphasis); }

code, pre, samp, kbd { font-family: var(--mkoy-font-mono); font-size: 0.9em; }
pre {
  background: var(--mkoy-panel);
  border: 1px solid var(--mkoy-hairline);
  border-radius: var(--mkoy-radius);
  padding: var(--mkoy-space-3);
  overflow-x: auto;   /* code scrolls inside its box, never scrolls the page */
}

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

/* Honour a reader who has asked for less movement. Cheap to respect, and the
 * people who need it often need it badly -- vestibular disorders, migraine. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
