/* =========================================================================
   Oparo Help Centre — accessibility-first design system (WCAG 2.2 AA)
   - High-contrast tokens, visible focus, reduced-motion + forced-colors aware
   - No hover-only interactions; all states keyboard reachable
   ========================================================================= */

:root {
  --o-bg:        #ffffff;
  --o-surface:   #f6f8fb;
  --o-surface-2: #eef2f7;
  --o-border:    #c9d2de;       /* >=3:1 against surface for UI components */
  --o-text:      #11202e;       /* ~15:1 on white */
  --o-muted:     #46566a;       /* ~7:1 on white */
  --o-primary:   #0b5cab;       /* AA on white for text & large */
  --o-primary-d: #084480;
  --o-primary-bg:#e7f0fb;
  --o-focus:     #0a4fff;
  --o-ok:        #1c7a47;
  --o-ok-bg:     #e3f5ea;
  --o-warn:      #8a5a00;
  --o-warn-bg:   #fdf3e0;
  --o-crit:      #b21f2d;
  --o-crit-bg:   #fdeced;
  --o-radius:    14px;
  --o-radius-sm: 9px;
  --o-shadow:    0 1px 2px rgba(16,32,46,.06), 0 6px 24px rgba(16,32,46,.07);
  --o-maxw:      1120px;
  --o-font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --o-bg:#0e1620; --o-surface:#16202c; --o-surface-2:#1d2937; --o-border:#33445a;
    --o-text:#eef3f9; --o-muted:#aebccd; --o-primary:#6db1f; --o-primary-d:#9ccbff;
    --o-primary-bg:#15263a; --o-focus:#8ab4ff; --o-ok:#5fce93; --o-ok-bg:#122a1d;
    --o-warn:#f0c067; --o-warn-bg:#2e2410; --o-crit:#ff8b95; --o-crit-bg:#2e1417;
    --o-shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--o-font); color: var(--o-text); background: var(--o-bg);
  line-height: 1.55; font-size: 1.0625rem;
}
h1,h2,h3,h4 { line-height: 1.2; color: var(--o-text); }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); margin: 0 0 .4em; }
h2 { font-size: 1.5rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1.2rem; margin: 1.2em 0 .4em; }
p { margin: 0 0 1em; }
a { color: var(--o-primary); text-underline-offset: 2px; }
a:hover { color: var(--o-primary-d); }
img { max-width: 100%; height: auto; }

/* ---- Focus: always visible, never removed ---- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--o-focus);
  outline-offset: 2px;
  border-radius: 4px;
}
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--o-focus);
  outline-offset: 2px;
}

/* ---- Skip links ---- */
.skip-links a {
  position: absolute; left: 8px; top: -60px; z-index: 1000;
  background: var(--o-text); color: var(--o-bg); padding: 10px 16px;
  border-radius: var(--o-radius-sm); font-weight: 600; transition: top .15s ease;
}
.skip-links a:focus { top: 8px; }

/* ---- Layout ---- */
.container { max-width: var(--o-maxw); margin: 0 auto; padding: 0 20px; }
.site-header {
  border-bottom: 1px solid var(--o-border); background: var(--o-bg); position: sticky; top: 0; z-index: 50;
}
.site-header__row { display: flex; align-items: center; gap: 18px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--o-text); text-decoration: none; font-size: 1.1rem; }
.brand__mark { width: 30px; height: 30px; border-radius: 8px; background: var(--o-primary); color: #fff; display: grid; place-items: center; font-weight: 800; }
.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav a { display: inline-block; padding: 8px 12px; border-radius: var(--o-radius-sm); color: var(--o-muted); text-decoration: none; font-weight: 600; font-size: .95rem; }
.site-nav a[aria-current="page"] { color: var(--o-primary-d); background: var(--o-primary-bg); }
.site-nav a:hover { background: var(--o-surface-2); color: var(--o-text); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  padding: 11px 18px; border-radius: var(--o-radius-sm); border: 1px solid transparent;
  background: var(--o-surface-2); color: var(--o-text); min-height: 44px; /* touch target */
}
.btn:hover { background: var(--o-border); }
.btn--primary { background: var(--o-primary); color: #fff; border-color: var(--o-primary); }
.btn--primary:hover { background: var(--o-primary-d); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--o-border); color: var(--o-text); }
.btn--sm { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn[aria-pressed="true"] { background: var(--o-primary); color: #fff; border-color: var(--o-primary); }

/* ---- Hero + search ---- */
.hero { background: linear-gradient(180deg, var(--o-primary-bg), var(--o-bg)); padding: 56px 0 40px; text-align: center; }
.hero p.lead { font-size: 1.15rem; color: var(--o-muted); max-width: 40ch; margin: 0 auto 1.4em; }
.search { max-width: 680px; margin: 0 auto; position: relative; }
.search__field { display: flex; align-items: center; gap: 8px; background: var(--o-bg); border: 2px solid var(--o-border); border-radius: 999px; padding: 6px 8px 6px 18px; box-shadow: var(--o-shadow); }
.search__field:focus-within { border-color: var(--o-primary); }
.search__field svg { flex: none; color: var(--o-muted); }
.search input[type="search"] { flex: 1; border: 0; background: transparent; font: inherit; font-size: 1.05rem; padding: 12px 4px; color: var(--o-text); min-width: 0; }
.search input[type="search"]:focus { outline: none; }
.search .btn { border-radius: 999px; }
.search__listbox {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--o-bg);
  border: 1px solid var(--o-border); border-radius: var(--o-radius); box-shadow: var(--o-shadow);
  list-style: none; margin: 0; padding: 6px; text-align: left; z-index: 60; max-height: 60vh; overflow: auto;
}
.search__listbox[hidden] { display: none; }
.search__option { padding: 10px 12px; border-radius: var(--o-radius-sm); cursor: pointer; display: block; color: var(--o-text); text-decoration: none; }
.search__option[aria-selected="true"], .search__option:hover { background: var(--o-primary-bg); }
.search__option small { display: block; color: var(--o-muted); }

/* ---- Quick links ---- */
.quicklinks { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.quicklinks a { background: var(--o-bg); border: 1px solid var(--o-border); border-radius: 999px; padding: 9px 16px; font-weight: 600; text-decoration: none; color: var(--o-text); }
.quicklinks a:hover { border-color: var(--o-primary); color: var(--o-primary-d); }

/* ---- Cards / grids ---- */
.section { padding: 40px 0; }
.section__head { margin-bottom: 18px; }
.section__head p { color: var(--o-muted); margin: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: block; background: var(--o-bg); border: 1px solid var(--o-border); border-radius: var(--o-radius);
  padding: 18px; text-decoration: none; color: var(--o-text); height: 100%;
}
.card:hover { border-color: var(--o-primary); box-shadow: var(--o-shadow); }
.card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.card p { margin: 0; color: var(--o-muted); font-size: .96rem; }
.card__icon { width: 40px; height: 40px; border-radius: 10px; background: var(--o-primary-bg); color: var(--o-primary-d); display: grid; place-items: center; margin-bottom: 12px; }
.card__meta { margin-top: 10px; font-size: .85rem; color: var(--o-muted); }

.list-reset { list-style: none; margin: 0; padding: 0; }
.article-list li { border-bottom: 1px solid var(--o-border); }
.article-list a { display: flex; gap: 12px; align-items: baseline; padding: 14px 4px; text-decoration: none; color: var(--o-text); }
.article-list a:hover { color: var(--o-primary-d); }
.article-list .tag { margin-left: auto; }

.tag { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--o-muted); background: var(--o-surface-2); border-radius: 999px; padding: 3px 9px; }

/* ---- Two-column content (article) ---- */
.layout-2col { display: grid; grid-template-columns: 1fr; gap: 32px; padding: 28px 0 56px; }
@media (min-width: 900px) { .layout-2col { grid-template-columns: minmax(0,1fr) 280px; } }
.toc { position: sticky; top: 84px; align-self: start; }
.toc h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--o-muted); margin: 0 0 8px; }
.toc a { display: block; padding: 6px 0; color: var(--o-muted); text-decoration: none; }
.toc a:hover { color: var(--o-primary-d); }

/* ---- Breadcrumb ---- */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 18px 0 6px; font-size: .9rem; color: var(--o-muted); }
.breadcrumb li::after { content: "›"; margin-left: 6px; color: var(--o-border); }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb a { color: var(--o-muted); }

/* ---- Quick answer callout ---- */
.callout { border-left: 4px solid var(--o-primary); background: var(--o-primary-bg); border-radius: 0 var(--o-radius-sm) var(--o-radius-sm) 0; padding: 16px 18px; margin: 0 0 24px; }
.callout h2 { margin: 0 0 .3em; font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--o-primary-d); }
.callout p { margin: 0; font-size: 1.1rem; }

/* ---- Steps ---- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 24px; }
.steps li { position: relative; padding: 4px 0 18px 52px; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--o-primary); color: #fff; display: grid; place-items: center; font-weight: 700;
}
.steps li::after { content: ""; position: absolute; left: 16px; top: 36px; bottom: 4px; width: 2px; background: var(--o-border); }
.steps li:last-child::after { display: none; }
.steps h3 { margin: 4px 0; font-size: 1.05rem; }
.step-figure { margin: 10px 0 0; border: 1px solid var(--o-border); border-radius: var(--o-radius-sm); overflow: hidden; }
.step-figure figcaption { font-size: .85rem; color: var(--o-muted); padding: 6px 10px; background: var(--o-surface); }

/* ---- Common problems (accordion via details) ---- */
.problem { border: 1px solid var(--o-border); border-radius: var(--o-radius-sm); margin-bottom: 10px; background: var(--o-bg); }
.problem > summary { cursor: pointer; padding: 14px 16px; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 10px; }
.problem > summary::-webkit-details-marker { display: none; }
.problem > summary::before { content: "+"; font-weight: 800; color: var(--o-primary); width: 1em; }
.problem[open] > summary::before { content: "–"; }
.problem__body { padding: 0 16px 16px; }
.problem__body h4 { margin: 8px 0 4px; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--o-muted); }

/* ---- Feedback widget ---- */
.feedback { margin: 32px 0; padding: 20px; border: 1px solid var(--o-border); border-radius: var(--o-radius); background: var(--o-surface); }
.feedback__buttons { display: flex; gap: 10px; margin-top: 8px; }

/* ---- Escalation CTA ---- */
.escalation { background: var(--o-surface); border-top: 1px solid var(--o-border); padding: 40px 0; }
.escalation .grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---- Status ---- */
.status-banner { padding: 10px 0; font-weight: 600; }
.status-banner__inner { display: flex; align-items: center; gap: 10px; }
.status--none, .status--operational { background: var(--o-ok-bg); color: var(--o-ok); }
.status--warning { background: var(--o-warn-bg); color: var(--o-warn); }
.status--critical { background: var(--o-crit-bg); color: var(--o-crit); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; flex: none; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: .85rem; padding: 5px 11px; border-radius: 999px; border: 1px solid currentColor; text-decoration: none; }
.status-list { list-style: none; padding: 0; margin: 16px 0; }
.status-list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--o-border); }
.status-list .state { margin-left: auto; font-weight: 600; }

/* ---- Troubleshooter ---- */
.ts-card { max-width: 720px; margin: 0 auto; border: 1px solid var(--o-border); border-radius: var(--o-radius); background: var(--o-bg); padding: 26px; box-shadow: var(--o-shadow); }
.ts-progress { font-size: .85rem; color: var(--o-muted); margin-bottom: 8px; }
.ts-options { display: grid; gap: 10px; margin-top: 18px; }
.ts-option { text-align: left; }
.ts-node--resolution { border-left: 4px solid var(--o-ok); padding-left: 14px; }
.ts-node--escalate { border-left: 4px solid var(--o-warn); padding-left: 14px; }
.ts-controls { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ---- Paro drawer (dialog) ---- */
.paro-trigger { position: fixed; right: 20px; bottom: 20px; z-index: 70; box-shadow: var(--o-shadow); }
dialog.paro {
  position: fixed; right: 16px; bottom: 16px; top: auto; left: auto; margin: 0;
  width: min(420px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 32px));
  border: 1px solid var(--o-border); border-radius: var(--o-radius); padding: 0; background: var(--o-bg);
  color: var(--o-text); box-shadow: var(--o-shadow); overflow: hidden;
}
dialog.paro::backdrop { background: rgba(16,32,46,.35); }
.paro__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--o-border); }
.paro__head h2 { margin: 0; font-size: 1.05rem; }
.paro__close { margin-left: auto; }
.paro__modes { display: flex; gap: 6px; padding: 10px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--o-border); }
.paro__log { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 220px; }
.paro__msg { max-width: 90%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; }
.paro__msg--user { align-self: flex-end; background: var(--o-primary); color: #fff; }
.paro__msg--assistant { align-self: flex-start; background: var(--o-surface-2); }
.paro__cite { font-size: .82rem; margin-top: 6px; }
.paro__cite a { display: inline-block; margin-right: 8px; }
.paro__form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--o-border); }
.paro__form textarea { flex: 1; resize: none; border: 1px solid var(--o-border); border-radius: var(--o-radius-sm); padding: 10px; font: inherit; background: var(--o-bg); color: var(--o-text); }
.paro__disclaimer { font-size: .78rem; color: var(--o-muted); padding: 0 16px 12px; margin: 0; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--o-border); border-radius: var(--o-radius-sm);
  font: inherit; background: var(--o-bg); color: var(--o-text);
}
.field .hint { font-size: .85rem; color: var(--o-muted); margin-top: 4px; }
.field--error input, .field--error textarea { border-color: var(--o-crit); }
.error-text { color: var(--o-crit); font-size: .88rem; margin-top: 4px; }

/* ---- Alerts ---- */
.alert { padding: 14px 16px; border-radius: var(--o-radius-sm); margin: 16px 0; border: 1px solid; }
.alert--success { background: var(--o-ok-bg); color: var(--o-ok); border-color: currentColor; }

/* ---- Tables (accessible) ---- */
table.data { width: 100%; border-collapse: collapse; margin: 12px 0; }
table.data caption { text-align: left; color: var(--o-muted); padding: 6px 0; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--o-border); }
table.data th[scope="col"] { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--o-muted); }

/* ---- Stat tiles (admin) ---- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 16px 0 28px; }
.stat { background: var(--o-bg); border: 1px solid var(--o-border); border-radius: var(--o-radius); padding: 16px; }
.stat b { display: block; font-size: 1.8rem; }
.stat span { color: var(--o-muted); font-size: .9rem; }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--o-border); background: var(--o-surface); margin-top: 40px; padding: 28px 0; color: var(--o-muted); }
.site-footer__row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer a { color: var(--o-muted); }

/* ---- Language switcher ---- */
.lang { display: inline-flex; border: 1px solid var(--o-border); border-radius: 999px; overflow: hidden; }
.lang a { padding: 7px 12px; text-decoration: none; color: var(--o-muted); font-weight: 600; font-size: .85rem; }
.lang a[aria-current="true"] { background: var(--o-primary); color: #fff; }

/* ---- Utilities ---- */
.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;
}
.muted { color: var(--o-muted); }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.flow > * + * { margin-top: 1em; }

/* ---- Motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skip-links a { transition: none; }
}

/* ---- Forced colors / Windows high contrast ---- */
@media (forced-colors: active) {
  .card, .btn, .search__field, .ts-card, dialog.paro { border: 1px solid CanvasText; }
  .status-dot { forced-color-adjust: none; }
  :focus-visible { outline: 3px solid Highlight; }
}
