/*
  site.css - the single stylesheet for software.sumtrol.uk.
  Purpose: colours (light and dark), layout, typography and components for the
  catalogue page, the app pages and the technical pages. Uses only the visitor's
  built-in system fonts, so there are no font licences or downloads involved.

  Theme handling:
  - Light colours are the default (:root).
  - Dark colours apply when the visitor picked "Dark" (data-theme="dark"), or
    picked "System" / nothing and their device is set to dark.
  - Every text/background pair below meets WCAG AA contrast (4.5:1 or better).
*/

/* ---------- Colour tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f6f7f8;          /* page background */
  --surface: #ffffff;     /* cards, header */
  --surface-2: #eef1f4;   /* subtle panels, code blocks */
  --text: #1b1d1f;        /* body text (16:1 on surface) */
  --muted: #4a5057;       /* secondary text (8:1 on surface) */
  --line: #d6dade;        /* borders */
  --accent: #0b5cad;      /* links and buttons (6.6:1 on surface) */
  --accent-hover: #084a8c;
  --on-accent: #ffffff;   /* text on accent buttons */
  --warn-bg: #fff4d6;     /* pre-release notice */
  --warn-text: #5c3d00;
  --warn-line: #e8c56a;
  --focus: #0b5cad;
}

/* Dark colours: written once as a mixin-style block, applied two ways. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121416;
  --surface: #1c1f23;
  --surface-2: #252a30;
  --text: #e8eaed;        /* 13:1 on surface */
  --muted: #aab1b9;       /* 7.5:1 on surface */
  --line: #353b42;
  --accent: #6cb2ff;      /* 7.4:1 on surface */
  --accent-hover: #95c8ff;
  --on-accent: #0b1420;
  --warn-bg: #3a2e10;
  --warn-text: #ffe2a3;
  --warn-line: #7a5f1f;
  --focus: #95c8ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #121416;
    --surface: #1c1f23;
    --surface-2: #252a30;
    --text: #e8eaed;
    --muted: #aab1b9;
    --line: #353b42;
    --accent: #6cb2ff;
    --accent-hover: #95c8ff;
    --on-accent: #0b1420;
    --warn-bg: #3a2e10;
    --warn-text: #ffe2a3;
    --warn-line: #7a5f1f;
    --focus: #95c8ff;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.4rem); letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; margin-top: 1.5rem; }
p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
code, pre { font-family: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.9em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; overflow-x: auto; }
pre code { background: none; padding: 0; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 0.5rem; top: 0.5rem; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 760px; }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; flex-wrap: wrap; padding-top: 0.5rem; padding-bottom: 0.5rem; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.header-right { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; margin-left: 1rem; }
.site-nav a:first-child { margin-left: 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }

/* Apps drop-down menu */
.site-nav { display: flex; align-items: center; }
.menu { position: relative; }
.menu-toggle {
  font: inherit; font-size: 0.95rem; background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 0.35rem 0.25rem; min-height: 36px;
}
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { color: var(--text); }
.menu-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 220px; max-width: calc(100vw - 2rem);
  list-style: none; margin: 0; padding: 0.35rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.menu-list[hidden] { display: none; }
.menu-list li { margin: 0; }
.site-nav .menu-list a { display: block; margin: 0; padding: 0.55rem 0.75rem; border-radius: 6px; color: var(--text); font-size: 0.95rem; }
.site-nav .menu-list a:hover, .site-nav .menu-list a:focus-visible { background: var(--surface-2); }
.site-nav .menu-list a[aria-current="page"] { font-weight: 700; }
.menu-all { border-top: 1px solid var(--line); margin-top: 0.3rem !important; padding-top: 0.3rem; }
.site-nav .menu-all a { color: var(--accent); }

/* About pop-up */
.about-dialog {
  width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem 1.5rem 1.25rem;
}
.about-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.about-dialog h1 { font-size: 1.6rem; padding-right: 2rem; }
.about-dialog .dialog-body > :last-child { margin-bottom: 0; }
.dialog-close {
  position: absolute; top: 0.6rem; right: 0.6rem; width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.5rem; line-height: 1; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer;
}
.dialog-close:hover { border-color: var(--accent); }

/* Theme switch: three-way segmented control */
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface-2); }
.theme-switch button {
  font: inherit; font-size: 0.85rem; border: 0; background: transparent; color: var(--muted);
  padding: 0.3rem 0.75rem; border-radius: 999px; cursor: pointer; min-height: 32px;
}
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

/* ---------- Catalogue (home) ---------- */
.intro { padding: 2.5rem 0 1.5rem; }
.intro p { color: var(--muted); font-size: 1.15rem; max-width: 40rem; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.25rem; padding-bottom: 3rem; list-style: none; margin: 0; padding-left: 0; }
.app-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 0.75rem; margin: 0;
}
.app-card .head { display: flex; align-items: center; gap: 0.85rem; }
.app-icon { width: 56px; height: 56px; border-radius: 12px; flex-shrink: 0; }
.app-card h2 { font-size: 1.2rem; margin: 0; }
.app-card p { margin: 0; color: var(--muted); }
/* Platform chips always sit above the button, so every card lines up the same way at any width */
.app-card .foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; padding-top: 0.25rem; }
.app-card.soon { border-style: dashed; background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; padding: 0; margin: 0; }
.chips li { margin: 0; border: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; padding: 0.05rem 0.6rem; border-radius: 999px; }

.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-line); vertical-align: middle; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600;
  padding: 0.6rem 1.1rem; border-radius: 8px; min-height: 44px; border: 1px solid var(--accent);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.secondary:hover { background: var(--surface-2); color: var(--accent-hover); }

/* ---------- App page ---------- */
.crumbs { font-size: 0.9rem; color: var(--muted); padding-top: 1.25rem; }
.crumbs a { color: var(--muted); }
.app-hero { display: flex; gap: 1.25rem; align-items: center; padding: 1.25rem 0 0.5rem; }
.app-hero .app-icon { width: 80px; height: 80px; border-radius: 18px; }
.app-hero h1 { margin: 0; }
.app-hero .meta { color: var(--muted); margin: 0.2rem 0 0; }
.lead { font-size: 1rem; }
.small { font-size: 0.85rem; }

.notice { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-line); border-radius: 10px; padding: 0.9rem 1.1rem; margin: 1rem 0; }
.notice strong { color: inherit; }
.notice a { color: inherit; }

.layout { display: grid; grid-template-columns: 210px 1fr; gap: 2.5rem; padding: 1rem 0 3rem; align-items: start; }
.toc { position: sticky; top: 1rem; font-size: 0.95rem; }
.toc p { font-weight: 600; margin-bottom: 0.4rem; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.toc li { margin: 0; }
.toc a { display: block; padding: 0.3rem 0 0.3rem 0.85rem; color: var(--muted); text-decoration: none; margin-left: -2px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); border-left-color: var(--accent); }
.content { min-width: 0; }
.content > section:first-child h2 { margin-top: 0; }
section { scroll-margin-top: 1rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; margin: 1rem 0; }
.panel > :last-child { margin-bottom: 0; }

/* Screenshots sit on a fixed light frame so they stay visible in dark mode */
.shot { margin: 1rem 0 1.5rem; }
.shot img { border: 1px solid var(--line); border-radius: 10px; background: #ffffff; }
.shot.phone img { max-width: 300px; }
.shot figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 0.5rem; }

/* Download blocks */
.downloads { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.85rem; margin: 0.75rem 0 1rem; }
.dl {
  display: flex; flex-direction: column; gap: 0.15rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; min-height: 44px;
}
.dl:hover { border-color: var(--accent); color: var(--text); }
.dl .os { font-weight: 700; color: var(--accent); }
.dl .file { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.dl.recommended { border: 2px solid var(--accent); }
.dl .rec { display: none; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.dl.recommended .rec { display: block; }
.dl-group h3 { margin-top: 1.25rem; }

.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: 1rem; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}
.expect { color: var(--muted); font-size: 0.95rem; display: block; margin-top: 0.2rem; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 1rem; margin: 0.6rem 0; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 0.5rem; }

.tech-link { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.95rem; }

table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1.25rem; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.9rem; }
.site-footer .wrap { padding-top: 1.25rem; padding-bottom: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; gap: 0.5rem; }
  .toc { position: static; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 1rem; }
  .toc ol { border-left: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
  .toc a { padding: 0.2rem 0; border-left: 0; margin: 0; }
  .app-hero .app-icon { width: 64px; height: 64px; border-radius: 14px; }
  .site-nav a { margin-left: 0.75rem; }
}
@media (max-width: 420px) {
  .wrap { padding: 0 1rem; }
  .site-header .wrap { justify-content: center; }
  .header-right { justify-content: center; }
}
@media print {
  .site-header, .theme-switch, .toc, .site-footer { display: none; }
}
