/* The shared base styles for every page (copied to apps/worker/public/assets/base.css by
 * tools/copy-ui.mjs; edit only here). Transplanted from intalg-site public/assets/site.css: the
 * control edges and the focus ring, the type, .visually-hidden, the buttons and the theme choice
 * (chunk O4), with the course-specific parts left behind. A skip link is new. */

* {
  box-sizing: border-box;
}
html {
  background: var(--bg);
  /* iOS enlarges text on its own on a phone held sideways: the layout's sizes are meant as they are. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font);
  overflow-wrap: break-word;
}
a {
  color: var(--accent);
}
/* The focus ring: a 3px accent outline set 2px off the edge, on everything focusable. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* <main> takes the focus from the skip link; it needs no ring of its own. */
main[tabindex="-1"]:focus {
  outline: none;
}
/* Every text box, search box, text area and select draws its edge in --control-border. */
input:is(
  :not([type]),
  [type="text"],
  [type="search"],
  [type="password"],
  [type="email"],
  [type="number"],
  [type="url"],
  [type="tel"]
),
textarea,
select {
  border-color: var(--control-border);
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
h1 {
  margin: 0 0 12px;
  font-size: 2.1rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  line-height: 1.3;
}
/* On a phone (T1) a title a size smaller. */
@media (max-width: 30em) {
  h1 {
    font-size: 1.625rem;
    line-height: 1.2;
  }
}
p {
  text-wrap: pretty;
}
.muted {
  color: var(--muted);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* Out of sight until it has the keyboard's focus; then at the top left, above everything. */
.skip-link {
  position: absolute;
  left: 8px;
  top: -100px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 600;
}
.skip-link:focus {
  top: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--hit);
  padding: 0 18px;
  border-radius: var(--radius-control);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.button.soft {
  border-color: var(--control-border);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* The theme choice (lib/html.tsx ThemeChoice, public/assets/theme.js): three 44px icon buttons in a
   fully rounded track, the chosen one on a pill that slides along it. The pill's place and the chosen
   glyph's colour follow <html data-theme>, so they are right from the first paint. The chosen state
   never rests on colour alone: the pill's edge is 3:1 and more against the track in both themes. */
.theme-choice {
  --theme-button: var(--hit);
  --theme-pad: 3px;
  --theme-gap: 2px;
  position: relative;
  display: inline-flex;
  flex: none;
  gap: var(--theme-gap);
  padding: var(--theme-pad);
  border-radius: 999px;
  background: var(--track);
}
.theme-pill {
  position: absolute;
  top: var(--theme-pad);
  left: var(--theme-pad);
  width: var(--theme-button);
  height: var(--theme-button);
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: var(--theme-pill);
  box-shadow: var(--theme-pill-shadow);
  pointer-events: none;
  /* System, the middle one: also before a theme is set (no script). */
  transform: translateX(calc(100% + var(--theme-gap)));
  transition: transform 0.18s ease-out;
}
:root[data-theme="light"] .theme-pill {
  transform: none;
}
:root[data-theme="dark"] .theme-pill {
  transform: translateX(calc(200% + 2 * var(--theme-gap)));
}
.theme-choice button {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--theme-button);
  height: var(--theme-button);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.theme-choice button:hover {
  color: var(--accent-ink);
}
.theme-choice button:focus-visible {
  z-index: 1;
}
:root:not([data-theme]) .theme-choice [data-value="system"],
:root[data-theme="system"] .theme-choice [data-value="system"],
:root[data-theme="light"] .theme-choice [data-value="light"],
:root[data-theme="dark"] .theme-choice [data-value="dark"] {
  color: var(--accent-ink);
}
@media (prefers-reduced-motion: reduce) {
  .theme-pill {
    transition: none;
  }
}
/* Forced colours (Windows' contrast themes) drop the fills: the pill's edge is the system's highlight. */
@media (forced-colors: active) {
  .theme-pill {
    border: 2px solid Highlight;
  }
}
