/*-----------------------------------------------------------------------------
 * Project : Ergane - Athena AI Hub
 * File    : public/css/base.css
 * Stylesheet : reset, typography, focus, forms, buttons, banners
 * Author  : Johann Sievering
 * AI Support : Claude AI
 * Date    : 2026-09-30 Start of the implementation
 * Rev     : patterns of prompt-atelier v2.4.6 public/css/base.css; WCAG 2.1 AA
 *           rules of spec chapter 14 §14.9 (visible focus, 44 px targets)
 * Rev     : 2026-09-30 Owner's review: Matériel AV's button family (primary,
 *           light secondary, ghost, danger) and dark headings
 * Rev     : 2026-10-01 Owner's batch: a faint outline on every button, ghost included
 * Rev     : 2026-10-02 The dropdown lists in the look of Prompt Atelier's select (owner's request); 2026-10-05 Phone and iPhone pass (owner's request): tabs wrap, inputs 16 px on phones, hidden table as a block, inline video, no microphone on narrow inputs; 2026-10-06 disabled fields light grey (owner's request)
 * Rev     : 2026-10-07 The saved state of a save button (D-61)
 * Rev     : 2026-11-11 [hidden] always hides (D-81)
 * Version : 0.41.0
 *-----------------------------------------------------------------------------
 * Everything a page needs before any component: box model, body, headings,
 * links, the skip link, visually-hidden text, form controls, buttons and
 * the inline banners of chapter 4 §4.0 (never an alert box).
 *---------------------------------------------------------------------------*/

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

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 { font-family: var(--font-mono); font-size: 0.95em; }

/* 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; }

/* Skip link: first focusable element of every page (chapter 14 §14.9). */
.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-header) + 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 (the radar's text alternative) must be a block, or its columns widen the phone's viewport. */
table.visually-hidden { display: block; max-width: 1px; }

/* ── Forms ── */
.field { margin-bottom: var(--space-4); }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: var(--space-1); font-size: var(--font-size-sm); }
.field .hint { font-size: var(--font-size-xs); color: var(--text-light); margin: var(--space-1) 0 0; }
.field .field-error { font-size: var(--font-size-sm); color: var(--error); margin: var(--space-1) 0 0; font-weight: 600; }
.field .field-error:empty { display: none; }

input[type="text"], input[type="password"], input[type="search"], input[type="email"],
input[type="number"], input[type="date"], input[type="time"], input[type="file"], select, textarea {
    width: 100%;
    min-height: 2.75rem;                       /* 44 px target (WCAG 2.5.5) */
    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);
}
input[type="color"] { width: 3.5rem; height: 2.75rem; padding: 0.15rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); }
/* A locked field stays in sight, light grey, its text muted (the owner's rule of 5 October: visible but disabled). */
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"] { border-color: var(--error); }
textarea { min-height: 6rem; resize: vertical; }
/* Every dropdown list: a blue rule and bold text (the owner's reference of 2 October, Prompt Atelier's provider select). */
select { font-weight: 600; border: 1.5px solid var(--primary); border-radius: var(--radius-sm); padding-right: var(--space-5); }

.checkbox, .field label.checkbox { display: flex; align-items: center; gap: var(--space-2); min-height: 2.75rem; font-size: var(--font-size-sm); font-weight: 500; }
.checkbox input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--primary); }

.input-group { display: flex; gap: var(--space-2); align-items: stretch; }
.input-group input, .input-group select { flex: 1; }

/* ── Buttons (Matériel AV's family, re-tokenised) ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 2.75rem; padding: var(--space-2) var(--space-4);
    font: inherit; font-weight: 600; font-size: var(--font-size-sm); line-height: 1.2;
    color: var(--text); background: var(--gray-50);
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
/* A save button whose data is saved (D-61): light grey, its label says so. */
.btn.is-saved:disabled { opacity: 1; background: var(--gray-50); color: var(--text-light); border-color: var(--border); cursor: default; }
.btn--primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn--accent { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn--accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn--secondary { color: var(--text); background: var(--gray-50); border-color: var(--border); }
.btn--secondary:hover { background: var(--border); }
.btn--ghost { background: var(--bg-card); border-color: var(--border); color: var(--primary); }
.btn--ghost:hover { background: var(--gray-50); }
.btn--danger { color: var(--error); background: var(--error-soft); border-color: transparent; }
.btn--danger:hover { background: #F5D0D0; }
.btn--sm { min-height: 2.25rem; padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); }
.btn .spinner { display: none; }
.btn.is-busy .spinner { display: inline-block; }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-4); }

/* ── Inline banners (chapter 4 §4.0: never an alert box) ── */
.form-banner {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--gray-50); margin-bottom: var(--space-4);
}
.form-banner:empty, .form-banner[hidden] { display: none; }
/* The hidden attribute always wins: a component rule such as .btn { display: inline-flex } would otherwise show a hidden control (D-81). */
[hidden] { display: none !important; }
.form-banner--error   { background: var(--error-soft);   border-color: var(--error);   color: var(--error); }
.form-banner--success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.form-banner--warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.form-banner--info    { background: var(--primary-soft);  border-color: var(--primary); color: var(--primary-dark); }

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

/* Phones: a field under 16 px makes iPhone Safari zoom in on focus; the smallest text sizes of the chooser (D-52) would, so the fields never go below. */
@media (max-width: 47.9rem) {
    input, select, textarea { font-size: max(16px, 1em); }
}
