/* The StaffDiary guide (docs.html). The app's own palettes (app/.../ui/theme/Color.kt): SbDark by
   default, and SbLight, Expense Tracker's Mint Mist, for a light system setting or Light picked with
   the theme button in the top bar (js/theme.js). */
:root {
  --bg: #121619;
  --surface: #1b2126;
  --surface-2: #242c32;
  --divider: #2c353c;
  --accent: #2ec4a6;
  --accent-strong: #1fa88e;
  --on-accent: #04211b;
  --amber: #f2a93b;
  --green: #3dd68c;
  --red: #f0624d;
  --blue: #5aa9f0;
  --text: #e8edf0;
  --text-2: #8d99a3;
  --text-3: #65717b;
  --top: #182025;
  --link-hover: #5fe0c6;
  --shade: rgba(0, 0, 0, .45);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f7f6;
    --surface: #ffffff;
    --surface-2: #eef4f2;
    --divider: #e2eae7;
    --accent: #0b7a66;
    --accent-strong: #0b7a66;
    --on-accent: #ffffff;
    --amber: #a0521a;
    --green: #1b7a47;
    --red: #b4372b;
    --blue: #2a5bb8;
    --text: #10231f;
    --text-2: #5b6b67;
    --text-3: #8a9894;
    --top: #ffffff;
    --link-hover: #075e4f;
    --shade: rgba(16, 35, 31, .12);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --divider: #e2eae7;
  --accent: #0b7a66;
  --accent-strong: #0b7a66;
  --on-accent: #ffffff;
  --amber: #a0521a;
  --green: #1b7a47;
  --red: #b4372b;
  --blue: #2a5bb8;
  --text: #10231f;
  --text-2: #5b6b67;
  --text-3: #8a9894;
  --top: #ffffff;
  --link-hover: #075e4f;
  --shade: rgba(16, 35, 31, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, kbd {
  font: 14px ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 0 4px;
}

/* Top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 12px 16px;
  background: var(--top);
  border-bottom: 1px solid var(--divider);
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
.brand span { color: var(--text-2); font-weight: 400; }
.top nav { display: flex; gap: 16px; margin-left: auto; font-size: 14px; }
.top nav a { text-decoration: none; white-space: nowrap; }
.top nav .short { display: none; }
.theme-toggle {
  flex-shrink: 0;
  min-width: 36px;
  min-height: 32px;
  padding: 4px 8px;
  font: 16px/1 system-ui, sans-serif;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 8px;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--text-3); }

/* A phone: the bar stays one line. "Web reports" is shortened and the gaps tightened; on a very
   narrow screen the title gives way, cut short with an ellipsis, before the links do. */
@media (max-width: 420px) {
  .top { flex-wrap: nowrap; gap: 12px; padding: 12px 14px; }
  .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top nav { flex-shrink: 0; gap: 12px; }
  .top nav .long { display: none; }
  .top nav .short { display: inline; }
}

/* Layout: contents against the left edge, the guide beside them filling the rest of the window's
   width, so a wide screen has no bare strip down its right side; one column on a phone. */
.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 40px;
  padding: 32px 24px 64px;
}
.toc {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  font-size: 14px;
}
/* The drawer's head, its backdrop and the button that opens it are for a phone only (see the
   media query). */
.toc-head, .toc-backdrop, .to-contents { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc > ol > li { margin-bottom: 14px; }
.toc .group {
  display: block;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  margin-bottom: 4px;
}
.toc ol ol a {
  display: block;
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--divider);
  color: var(--text);
  text-decoration: none;
}
.toc ol ol a:hover { border-left-color: var(--accent); color: var(--accent); }

main { min-width: 0; }

/* Intro */
.intro h1 { font-size: 32px; line-height: 1.2; margin: 0 0 12px; }
.intro p { color: var(--text-2); margin: 0 0 12px; }
.quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}
.quick a {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}
.quick a:hover { border-color: var(--accent-strong); color: var(--text); }
.quick strong { display: block; color: var(--accent); margin-bottom: 2px; }
.quick span { color: var(--text-2); font-size: 14px; }

/* The calendar's colours, as the app draws them (DayColors). */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 4px 0 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 14px;
}
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}
.dot.present { background: var(--green); }
.dot.part { background: var(--amber); }
.dot.absent { background: var(--red); }
.dot.leave { background: var(--blue); }
.dot.off { background: var(--text-3); }

/* Who a step is for: the employer's phone or the staff member's. */
.tag {
  display: inline-block;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 6px;
  white-space: nowrap;
  color: var(--accent);
  border: 1px solid var(--accent-strong);
}
.tag.staff { color: var(--amber); border-color: var(--amber); }

/* Groups and features */
.group-head {
  margin: 56px 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}
.group-head h2 { font-size: 24px; margin: 0; }
.group-head p { color: var(--text-2); margin: 4px 0 0; }

.feature {
  margin: 24px 0 0;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 14px;
}
.feature h3 { font-size: 20px; margin: 0 0 6px; line-height: 1.3; }
.feature h3 a.anchor { color: var(--text-3); text-decoration: none; margin-left: 6px; font-weight: 400; }
.feature h3 a.anchor:hover { color: var(--accent); }
.feature .lead { color: var(--text-2); margin: 0 0 14px; }
.feature h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 18px 0 6px;
}
.feature p { margin: 0 0 10px; }
.feature ul, .feature ol { margin: 0 0 10px; padding-left: 22px; }
.feature li { margin: 3px 0; }
.feature li::marker { color: var(--text-3); }

/* The place in the app a step goes to, as in the app's Help. */
.path {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 0 7px;
  white-space: nowrap;
}

.note {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent-strong);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  font-size: 15px;
}
.note.warn { border-left-color: var(--amber); }

/* A worked example: the sums the app does. */
.example {
  margin: 10px 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px dashed var(--divider);
  border-radius: 10px;
  font-size: 15px;
}
.example .sum { font: 14px ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--accent); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 4px 0 10px;
}
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--divider); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }

footer {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
  color: var(--text-3);
  font-size: 14px;
}

@media (max-width: 860px) {
  html { scroll-padding-top: 64px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px 16px 48px; }
  /* The contents are a drawer from the left, over the page, opened by the floating button. */
  .toc {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    width: min(320px, 85vw);
    /* The screen's height, so the list scrolls inside it. The wide layout's align-self: start
       would otherwise shrink this grid child to the whole list's height, past the screen, with
       nothing left to scroll. */
    align-self: stretch;
    height: 100dvh;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border-right: 1px solid var(--divider);
    box-shadow: 8px 0 24px var(--shade);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .22s ease, visibility .22s;
  }
  /* Shown at once when opening, so focus can move into it; hidden only once it has slid out. */
  .toc-open .toc { transform: none; visibility: visible; transition: transform .22s ease; }
  .toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    padding: 8px 8px 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
    font-weight: 600;
    font-size: 16px;
  }
  .toc-close {
    min-width: 44px;
    min-height: 44px;
    font: inherit;
    font-size: 18px;
    color: var(--text-2);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
  }
  .toc-close:hover { color: var(--text); background: var(--surface-2); }
  .toc > ol { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
  .toc ol ol a { padding: 7px 0 7px 12px; font-size: 15px; }
  .toc-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 4;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
  }
  .toc-open .toc-backdrop { opacity: 1; pointer-events: auto; }
  /* The page stays put under the open drawer. */
  .toc-open { overflow: hidden; }
  .to-contents {
    display: block;
    font: inherit;
    border: 0;
    cursor: pointer;
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 3;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--accent-strong);
    color: var(--on-accent);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 16px var(--shade);
  }
  .to-contents:hover { color: var(--on-accent); background: var(--accent); }
  footer { padding-bottom: 56px; }
  .intro h1 { font-size: 26px; }
  .feature { padding: 18px 16px; }
  .path { white-space: normal; }
}
