/*-----------------------------------------------------------------------------
 * Project : Mentor - Interactive Courses for Schools
 * File    : public/css/base.css
 * Stylesheet : reset, typography, focus, skip link, native form controls, reduced motion
 * Author  : Johann Sievering
 * AI Support : Claude Code
 * Date    : 2026-10-25 The first slice: frontend shell
 * Rev     : forked from ergane v0.69.1 public/css/base.css (the buttons, fields and banners moved to components.css)
 * Rev     : 2026-10-25 0.3.0: the hidden attribute always wins (an empty conflict box showed as a wide orange line)
 * Version : 0.3.0
 *-----------------------------------------------------------------------------
 * Brief chapter 16: what every element needs before any component — box
 * model, body, headings, links, one visible focus style, the skip link,
 * visually-hidden text, the native controls at 44 px and never under 16 px
 * (a phone would zoom in on a smaller field), and reduced motion.
 *---------------------------------------------------------------------------*/

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

/* The hidden attribute always hides: a component's own display (grid, flex) must never bring back an element the
   script hid. Without this rule the empty conflict box of the workspace showed as a wide orange line (owner's note 1). */
[hidden] { display: none !important; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: var(--line-height);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: 1.25; color: var(--text); font-weight: 700; }
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); font-weight: 600; }
h3 { font-size: var(--font-size-lg); font-weight: 600; }
p  { margin: 0 0 var(--space-3); }
a  { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.95em; }
/* Long words and long lines of code never widen the page (brief chapter 16: no horizontal page scroll). */
p, li, dd, h1, h2, h3 { overflow-wrap: anywhere; word-break: break-word; }

/* One visible focus style for every interactive element (WCAG 2.4.7). */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
/* The zones receive the focus by script (skip link, phone bar): no ring on a whole zone. */
[tabindex="-1"]:focus { outline: none; }

/* Skip link: the first focusable element of every page (WCAG 2.4.1). */
.skip-link {
    position: absolute; left: var(--space-3); top: -4rem;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-card); color: var(--primary-dark);
    border: 2px solid var(--primary); border-radius: var(--radius);
    z-index: calc(var(--z-menu) + 1);
}
.skip-link:focus { top: var(--space-3); }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
/* A hidden table must be a block, or its columns widen the phone's viewport. */
table.visually-hidden { display: block; max-width: 1px; }

/* ── Native form controls: 44 px high, 16 px text at least ── */
input[type="text"], input[type="password"], input[type="search"], input[type="email"],
input[type="number"], input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    min-height: var(--target);
    padding: var(--space-2) var(--space-3);
    font: inherit; color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
}
/* The fields never go under 16 px, whatever the text size chosen: iPhone Safari zooms in on a smaller field. */
input, select, textarea { font-size: max(16px, 1em); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); }
/* A locked field stays in sight, light grey, its text muted. */
input:disabled, select:disabled, textarea:disabled { background: var(--gray-50); color: var(--text-light); cursor: not-allowed; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
textarea { min-height: 6rem; resize: vertical; }
/* Every dropdown list: a blue rule and bold text (Ergane's look). */
select { font-weight: 600; border: 1.5px solid var(--primary); border-radius: var(--radius-sm); padding-right: var(--space-5); }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
