/* Appoint — baut auf /assets/css/tokens.css, components.css und site.css von flxlhr.com auf.
   Hier steht nur, was das Werkzeug zusätzlich braucht: Formularteile, Wochenraster, Leisten. */

/* Graustufen der Heatmap: unterscheiden sich in der Helligkeit, Dunkel spiegelt Hell */
:root {
  --heat-0: var(--surface);
  --heat-1: #dadada;
  --heat-2: #bdbdbd;
  --heat-3: #8c8c8c;
  --heat-4: #595959;
  --heat-max: var(--ink);
  --savebar-height: 72px;
}
:root[data-theme="dark"] {
  --heat-1: #2a2a2a;
  --heat-2: #474747;
  --heat-3: #747474;
  --heat-4: #a6a6a6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --heat-1: #2a2a2a;
    --heat-2: #474747;
    --heat-3: #747474;
    --heat-4: #a6a6a6;
  }
}

.view { display: block; }
strong, b { font-weight: 500; }
.nowrap { white-space: nowrap; }

/* ---------- Formulare ---------- */
.form { display: grid; gap: var(--space-6); max-width: 560px; }
.form--narrow { max-width: 440px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5); }

select.pf-field__control {
  padding-right: var(--space-7);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 17px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select.pf-field__control:hover { background-color: var(--surface-sunken); }
select.pf-field__control option { background: var(--surface); color: var(--ink); }

fieldset.pf-field { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.pf-field legend { padding: 0; margin-bottom: var(--space-2); }

.visually-hidden,
.daypicker__day input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.daypicker__days { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.daypicker__day { position: relative; }
.daypicker__day span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: var(--stroke-hair) solid var(--line);
  cursor: pointer;
}
.daypicker__day span:hover { background: var(--surface-sunken); }
.daypicker__day input:checked + span { background: var(--surface-inverse); color: var(--ink-inverse); }
.daypicker__day input:focus-visible + span { outline: var(--stroke-strong) solid var(--focus); outline-offset: 3px; }
.daypicker__presets { display: flex; flex-wrap: wrap; gap: 0 var(--space-5); }

.copyfield { display: flex; gap: var(--space-2); }
.copyfield .pf-field__control { flex: 1; min-width: 0; }

/* ---------- Board-Kopf ---------- */
.board-head {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-10) var(--page-margin) 0;
}
.board-head__title { max-width: 18ch; overflow-wrap: anywhere; text-wrap: balance; }
.board-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-2); }
.board-head__meta .pf-button--text { min-height: 32px; margin-left: var(--space-2); }
.board-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- Teilen ---------- */
.share {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-7);
  align-items: start;
}
.share__links { display: grid; gap: var(--space-6); max-width: 560px; }
.share__qr { display: grid; gap: var(--space-2); justify-items: start; }
.qr { padding: var(--space-4); background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] .qr { background: var(--surface-inverse); color: var(--ink-inverse); }
.qr svg { display: block; width: 160px; height: 160px; }

/* ---------- Beste Termine (WorkIndex als Knöpfe) ---------- */
.best .pf-index__row {
  width: 100%;
  border: 0;
  border-bottom: var(--stroke-hair) solid var(--line);
  padding-inline: var(--space-3);
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  grid-template-columns: 3rem minmax(0, 1.5fr) minmax(0, 1fr) auto;
}

/* ---------- Wochenplan ---------- */
.week__aside { display: flex; flex-direction: column; gap: var(--space-6); }
.week__sticky {
  position: sticky;
  top: var(--space-4);
  display: grid;
  gap: var(--space-6);
}
.week__body { gap: var(--space-5); }
.week.is-editing .week__sticky { display: none; }

.legend { display: grid; gap: var(--space-2); }
.legend__scale { display: flex; align-items: center; gap: var(--space-1); }
.legend__scale li { display: flex; align-items: center; gap: var(--space-2); }
.legend__scale li:first-child { margin-right: var(--space-1); flex-direction: row-reverse; }
.legend__scale li:last-child { margin-left: var(--space-1); }
.legend__swatch {
  width: 20px;
  height: 14px;
  border: var(--stroke-hair) solid var(--line-subtle);
}

.inspector {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: var(--stroke-hair) solid var(--line);
  max-width: 320px;
}
.inspector__content { display: grid; gap: var(--space-2); }
.inspector__names { margin: var(--space-2) 0 0; display: grid; gap: var(--space-1); }
.inspector__names dd { margin: 0 0 var(--space-3); overflow-wrap: anywhere; }
.inspector__close { display: none; }

.tabs { display: flex; gap: var(--space-5); }
.tabs__tab {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  cursor: pointer;
}
.tabs__tab:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: var(--stroke-hair); text-underline-offset: 0.3em; }
.tabs__tab[aria-selected="true"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: var(--stroke-strong); text-underline-offset: 0.3em; }

.quickbar { display: grid; gap: var(--space-4); }
.quickbar__day { max-width: 280px; }
.quickbar__buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.quickbar__buttons .pf-button { min-height: 40px; padding: 0 var(--space-4); }

.hint { max-width: var(--measure); }

/* Das Raster: eine Zeile pro Viertelstunde, eine Spalte pro Tag */
.timeline {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.timeline--wide { overflow-x: auto; }
.timeline--wide table { min-width: calc(3.5rem + var(--days) * 72px); }
.timeline table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.timeline th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--space-2) 0;
  background: var(--surface);
  border-bottom: var(--stroke-hair) solid var(--line);
  font-weight: 500;
  text-align: center;
}
.timeline .timeline__axis { width: 3.5rem; }
.timeline .day-short { display: none; }
.timeline__time {
  padding: 0 var(--space-2) 0 0;
  vertical-align: top;
  text-align: right;
  color: var(--ink-muted);
  line-height: 1;
}
.timeline__time span { position: relative; top: -0.45em; }
tr:first-child .timeline__time span { top: 0; }
.slot {
  height: 12px;
  padding: 0;
  border-left: var(--stroke-hair) solid var(--line-subtle);
  background: var(--heat-0);
  cursor: pointer;
}
tr.is-hour .slot { border-top: var(--stroke-hair) solid var(--line-subtle); }
tr:first-child .slot { border-top: 0; }

.heat-0 { background: var(--heat-0); }
.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); }
.heat-4 { background: var(--heat-4); }
.heat-max { background: var(--heat-max); }

.slot:hover,
.slot.is-inspected { outline: var(--stroke-strong) solid var(--focus); outline-offset: -2px; }
.slot.heat-max:hover,
.slot.heat-max.is-inspected,
.slot.heat-4:hover,
.slot.heat-4.is-inspected { outline-color: var(--ink-inverse); }

.timeline.is-editing .slot { background: var(--surface); }
.timeline.is-editing .slot:hover { background: var(--surface-sunken); outline: 0; }
.timeline.is-editing .slot.is-selected { background: var(--surface-inverse); }

/* ---------- Personen ---------- */
.people { border-top: var(--stroke-hair) solid var(--line); }
.people:empty { display: none; }
.people li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: var(--space-5);
  padding: var(--space-3) 0;
  border-bottom: var(--stroke-hair) solid var(--line);
}
.people__name { overflow-wrap: anywhere; }
.people__time { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.people li .pf-button--text { min-height: 32px; }
.admin { display: grid; gap: var(--space-4); max-width: var(--measure); padding-top: var(--space-4); }

/* ---------- Speicherleiste und Meldungen ---------- */
.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--savebar-height);
  padding: var(--space-3) var(--page-margin);
}
.savebar__info { display: grid; gap: 2px; }
.savebar__actions { display: flex; align-items: center; gap: var(--space-4); }
body.has-savebar { padding-bottom: var(--savebar-height); }
.savebar .pf-button:disabled {
  border-color: var(--ink-inverse-muted);
  background: transparent;
  color: var(--ink-inverse-muted);
  cursor: default;
}

.toasts {
  position: fixed;
  left: var(--page-margin);
  bottom: var(--space-4);
  z-index: 40;
  display: grid;
  gap: var(--space-2);
  max-width: min(440px, calc(100vw - 2 * var(--page-margin)));
}
body.has-savebar .toasts { bottom: calc(var(--savebar-height) + var(--space-3)); }
.toast {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-inverse);
  color: var(--ink-inverse);
}
.toast--error {
  background: var(--surface);
  color: var(--ink);
  border: var(--stroke-strong) solid var(--error);
}
.toast--error strong { color: var(--error); font-weight: 500; }

/* ---------- Mittlere Breite ---------- */
@media (max-width: 1023px) {
  .best .pf-index__row { grid-template-columns: 2.5rem minmax(0, 1fr) auto; }
  .best .pf-index__kind { grid-column: 2; grid-row: 2; }
  .best .pf-index__year { grid-column: 3; grid-row: 1; }
}

/* ---------- Schmal ---------- */
@media (max-width: 720px) {
  .board-head { padding-top: var(--space-8); }
  .share { grid-template-columns: minmax(0, 1fr); }
  .form__row { gap: var(--space-4); }

  .week__aside { display: contents; }
  .week__body { order: 1; }
  .timeline .timeline__axis { width: 2.75rem; }
  .timeline .day-long { display: none; }
  .timeline .day-short { display: inline; }
  .slot { height: 18px; }

  /* Details erscheinen unten, sobald eine Viertelstunde angetippt wurde */
  .week__sticky { display: contents; }
  .legend { order: 0; }
  .inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    max-width: none;
    max-height: 50vh;
    overflow-y: auto;
    padding: var(--space-4) var(--page-margin);
    background: var(--surface);
  }
  .inspector:not(.is-active) { display: none; }
  .inspector__empty { display: none; }
  .inspector__close { display: inline-flex; justify-self: start; }
  .week.is-editing .legend,
  .week.is-editing .inspector { display: none; }
}
