/* =========================================================
   Berufsbildung IDS – gemeinsames Design (Version 2)
   Angelehnt an stadt.sg.ch: weisse Kopfzeile, Logo «//st.gallen»,
   Arial, Rot #E00025, Beige #D8D5C5, ruhige Flächen.

   Aufbau:
     1. Variablen (Farben, Abstände, Schrift) + Dunkelmodus
     2. Grundlagen
     3. Kopfzeile, Fusszeile
     4. Seitenkopf, Begrüssung, Kacheln (Startseite)
     5. Bausteine: Knöpfe, Formulare, Karten, Tabellen,
        Meldungen, Marken, Reiter, Kennzahlen, Dialoge, Leerzustand
   Farben nur über die Variablen ändern. Regeln: keine roten
   Deko-Striche/Balken, «//» nur im Logo.
   ========================================================= */

/* ---------- 1. Variablen ---------- */
:root {
  --sg-red: #E00025;
  --sg-red-dark: #B8001E;
  --sg-beige: #D8D5C5;

  --bg: #FFFFFF;            /* Seite */
  --bg-raised: #FFFFFF;     /* Karten, Dialoge */
  --surface: #F4F3EF;       /* ruhige Fläche (leicht beige) */
  --surface-2: #EAE8E1;     /* Hover auf Fläche, Fortschrittsbalken */
  --text: #1A1A1A;
  --text-muted: #595959;
  --text-subtle: #737373;
  --border: #DEDBD0;        /* Linien, Kartenrand */
  --border-strong: #8A877C; /* Eingabefelder (Kontrast mind. 3:1) */
  --accent: var(--sg-red);
  --accent-hover: var(--sg-red-dark);
  --accent-text: #C4001F;   /* rote Schrift auf hellem Grund (AA) */
  --accent-soft: #FCEBED;
  --on-accent: #FFFFFF;
  --success: #17713A;
  --success-soft: #E5F2EA;
  --warning: #855A00;
  --warning-soft: #FBF1DA;
  --danger: #B3001B;
  --danger-soft: #FCEBED;
  --header-bg: #FFFFFF;
  --logo-filter: none;
  --focus: #1A1A1A;
  --ring: 0 0 0 3px rgba(224, 0, 37, .18);
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, .06);
  --shadow-md: 0 2px 4px rgba(26, 26, 26, .04), 0 8px 24px rgba(26, 26, 26, .08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .22);

  --font: Arial, Helvetica, sans-serif;
  --mono: Consolas, "SFMono-Regular", Menlo, monospace;
  --radius: 4px;
  --radius-lg: 6px;
  --container: 1200px;
  --gutter: 24px;
  --control-h: 44px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  color-scheme: light;
}

/* Dunkelmodus: per Knopf (data-theme="dark") oder Systemeinstellung.
   Die beiden Blöcke müssen gleich bleiben. */
:root[data-theme="dark"] {
  --bg: #121212;
  --bg-raised: #1B1B1B;
  --surface: #1E1E1E;
  --surface-2: #2A2A2A;
  --text: #EDEDED;
  --text-muted: #B4B4B4;
  --text-subtle: #969696;
  --border: #303030;
  --border-strong: #6E6E6E;
  --accent: #F0283F;
  --accent-hover: #FF4D61;
  --accent-text: #FF6B7C;
  --accent-soft: #3A1219;
  --on-accent: #FFFFFF;
  --success: #6CCB8E;
  --success-soft: #16301F;
  --warning: #F0C060;
  --warning-soft: #33280F;
  --danger: #FF8A99;
  --danger-soft: #3A1219;
  --header-bg: #161616;
  --logo-filter: invert(1);
  --focus: #FFFFFF;
  --ring: 0 0 0 3px rgba(255, 77, 97, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --bg-raised: #1B1B1B;
    --surface: #1E1E1E;
    --surface-2: #2A2A2A;
    --text: #EDEDED;
    --text-muted: #B4B4B4;
    --text-subtle: #969696;
    --border: #303030;
    --border-strong: #6E6E6E;
    --accent: #F0283F;
    --accent-hover: #FF4D61;
    --accent-text: #FF6B7C;
    --accent-soft: #3A1219;
    --on-accent: #FFFFFF;
    --success: #6CCB8E;
    --success-soft: #16301F;
    --warning: #F0C060;
    --warning-soft: #33280F;
    --danger: #FF8A99;
    --danger-soft: #3A1219;
    --header-bg: #161616;
    --logo-filter: invert(1);
    --focus: #FFFFFF;
    --ring: 0 0 0 3px rgba(255, 77, 97, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ---------- 2. Grundlagen ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }

body {
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.005em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }

a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

code, kbd { font-family: var(--mono); font-size: .9em; }
small { font-size: .875rem; }
[hidden] { display: none !important; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 8px 12px;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 3. Kopfzeile (wie stadt.sg.ch, ohne Farbstreifen) ---------- */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--container);
  min-height: 72px;
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  flex: none;
}
.brand:hover { color: var(--text); }
.brand-logo {
  display: block;
  width: 128px;
  height: auto;
  filter: var(--logo-filter);
}
.brand-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-unit {
  font-size: .75rem;
  letter-spacing: .02em;
  color: var(--text-muted);
}
.app-name {
  font-size: 1.125rem;
  font-weight: bold;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .9375rem;
}
.header-actions > a,
.header-actions .text-button,
.header-actions .link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.header-actions > a:hover,
.header-actions .text-button:hover,
.header-actions .link-btn:hover {
  background: var(--surface);
  color: var(--text);
}
/* Name der angemeldeten Person (Konto-Seiten: .konto-name, Journal: .benutzer, Noten: .user) */
.header-actions .konto-name,
.header-actions .benutzer,
.header-actions .user {
  color: var(--text-muted);
  font-size: .875rem;
}
.header-actions > .konto-name,
.header-actions > .benutzer,
.header-actions > .user {
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  border-radius: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.icon-button:hover { background: var(--surface); }
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Mond im Hellmodus, Sonne im Dunkelmodus (main.js setzt .is-dark) */
.icon-sun { display: none; }
.icon-button.is-dark .icon-sun { display: block; }
.icon-button.is-dark .icon-moon { display: none; }

/* Hauptnavigation einer Anwendung (z. B. Noten) */
.main-nav {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin: -12px 0 -13px auto; /* volle Höhe der Kopfzeile, Unterstrich sitzt auf deren Linie */
  align-self: stretch;
}
.main-nav a {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px 0;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-size: .9375rem;
  border-bottom: 3px solid transparent;
}
.main-nav a:hover { color: var(--accent-text); }
.main-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: bold;
  border-bottom-color: var(--accent);
}

@media (max-width: 640px) {
  .header-inner { min-height: 60px; padding: 10px var(--gutter); gap: 12px; }
  .brand { gap: 10px; }
  .brand-logo { width: 100px; }
  .brand-divider { height: 30px; }
  .brand-unit { font-size: .6875rem; }
  .app-name { font-size: 1rem; }
  .header-actions > .konto-name,
  .header-actions > .benutzer,
  .header-actions > .user { display: none; }
  .header-actions > a,
  .header-actions .text-button,
  .header-actions .link-btn { padding: 0 8px; }
}
@media (max-width: 380px) {
  .brand-divider, .brand-unit { display: none; }
}

/* ---------- Fusszeile ---------- */
.site-footer {
  margin-top: var(--s8);
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: var(--s5) 0;
  font-size: .875rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}
.footer-inner a { color: var(--text-muted); }

/* ---------- 4. Seitenaufbau ---------- */
main { flex: 1; }

.page-head { margin: var(--s6) 0 var(--s5); }
.page-head h1 { margin: 0; }
.eyebrow {
  margin: 0 0 var(--s2);
  font-size: .75rem;
  font-weight: bold;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 62ch;
}

/* Begrüssung: Fläche über die ganze Breite, Inhalt im Raster */
.hero {
  position: relative;
  margin: 0 0 var(--s7);
  padding: var(--s7) 0 var(--s7);
  background: var(--surface);
  box-shadow: 0 0 0 100vmax var(--surface);
  clip-path: inset(0 -100vmax);
}
.hero h1 {
  margin: 0 0 var(--s3);
  font-size: 2.75rem;
  line-height: 1.1;
  letter-spacing: -.015em;
}
.hero p:last-child {
  margin: 0;
  max-width: 58ch;
  font-size: 1.125rem;
  color: var(--text-muted);
}
@media (max-width: 700px) {
  .hero { padding: var(--s6) 0; margin-bottom: var(--s6); }
  .hero h1 { font-size: 2rem; }
  .hero p:last-child { font-size: 1rem; }
}

/* ---------- Kacheln (Startseite) ---------- */
.section-title {
  margin: 0 0 var(--s4);
  font-size: 1.25rem;
}

.tiles {
  list-style: none;
  margin: 0 0 var(--s7);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s5);
}
.tiles > li { display: flex; flex-direction: column; }
@media (max-width: 960px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr; gap: var(--s4); }
}

.tile {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--s2);
  min-height: 220px;
  padding: var(--s5) var(--s5) 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tile:hover {
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.tile-number {
  font-size: .875rem;
  font-weight: bold;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
}
.tile-title {
  font-size: 1.375rem;
  font-weight: bold;
  line-height: 1.25;
}
.tile-text {
  flex: 1;
  color: var(--text-muted);
}
.tile-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--s3);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  font-weight: bold;
  color: var(--accent-text);
}
.tile-link::after {
  content: "\2192";
  font-size: 1.125rem;
  line-height: 1;
  position: relative;
  top: -1px;
  transition: transform .15s;
}
.tile:hover .tile-link::after { transform: translateX(4px); }

/* ---------- 5. Bausteine ---------- */

/* Knöpfe: .btn = neutral, .btn-primary = Rot, .btn-ghost, .btn-danger, .btn-sm */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: bold;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--danger); border-color: currentColor; background: transparent; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* Formulare */
.field { display: grid; gap: 6px; }
.field-label, .field > label { font-weight: bold; font-size: .9375rem; }
.field-hint { font-size: .875rem; color: var(--text-muted); }

input:where([type="text"], [type="email"], [type="password"], [type="search"], [type="number"], [type="date"], [type="url"], [type="tel"], :not([type])),
select,
textarea {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-height: var(--control-h);
  padding: 9px 12px;
  line-height: 1.375;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:where([type="text"], [type="email"], [type="password"], [type="search"], [type="number"], [type="date"], [type="url"], [type="tel"], :not([type])):hover,
select:hover, textarea:hover { border-color: var(--text-muted); }
input:where([type="text"], [type="email"], [type="password"], [type="search"], [type="number"], [type="date"], [type="url"], [type="tel"], :not([type])):focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}
::placeholder { color: var(--text-subtle); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }

/* Karten */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s5);
}
.card > :last-child { margin-bottom: 0; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: .8125rem;
  font-weight: bold;
  letter-spacing: .02em;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table tbody tr:hover td { background: var(--surface); }
.table tbody tr:last-child td { border-bottom: 0; }

/* Meldungen */
.alert {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }

/* Marken */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .8125rem;
  line-height: 1.5;
  white-space: nowrap;
}

/* Reiter (Unternavigation) */
.tabs {
  display: flex;
  gap: var(--s5);
  border-bottom: 1px solid var(--border);
  margin: 0 0 var(--s5);
  overflow-x: auto;
}
.tabs a {
  padding: 12px 0 10px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); font-weight: bold; border-bottom-color: var(--accent); }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }
.stat {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-label { font-size: .875rem; color: var(--text-muted); }
.stat-value { font-size: 2rem; font-weight: bold; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* Leerzustand */
.empty-state {
  text-align: center;
  padding: var(--s7) var(--s5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

/* Dialoge */
dialog {
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 10, 10, .55); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
@media print {
  .site-header, .site-footer { display: none; }
  body { background: #fff; color: #000; }
}
