/* OptiSense — shared styles from the OptiSense design system (tokens.json): tokens, navbar, language switch
   and the components used on several pages. Page styles: work.css, learn.css, guide.css. */
/* fluid base size: 16 px up to 1440 px width, then growing to 22 px (Full HD ≈ 18 px, 2560 px ≈ 21 px) */
html { font-size: clamp(16px, calc(16px + (100vw - 1440px) * 0.0045), 22px); }
:root {
  --surface-page: #fff2e6;
  --surface-panel: #ccecff;
  --surface-group: #b0e2ff;
  --surface-content: #ffffff;
  --surface-guide: #f8f8f8;
  --ink: #1d1f21;
  --ink-button: #000000;
  --ink-muted: rgba(29, 31, 33, 0.75);
  --border: #dee2e6;
  --hairline: rgba(40, 70, 94, 0.12);
  --primary: #00629b;
  --plot-objective-optimized: #0000ff;
  --plot-optimum: #cc0000;
  --plot-objective-dummy: #1f7a1f;
  --radius-control: 3px;
  --radius-card: 8px;
  --radius-modal: 0.5rem;
  --space-card: 1rem;
  --touch-target: 2.75rem;
  --sidebar-width: clamp(17.75rem, 24vw, 26rem);
  --results-width: clamp(20rem, 30vw, 38rem);

  --bs-primary: #00629b;
  --bs-primary-rgb: 0, 98, 155;
  --bs-link-color: #00629b;
  --bs-link-color-rgb: 0, 98, 155;
  --bs-link-hover-color: #004a75;
  --bs-body-color: #1d1f21;
  --bs-focus-ring-color: rgba(0, 98, 155, 0.35);
}

body { background: var(--surface-page); color: var(--ink); }

/* ---------------------------------------------------------------- navbar */
.navbar { background: var(--surface-group) !important; border-bottom: 1px solid var(--hairline); padding-top: 0; padding-bottom: 0; min-height: 3.5rem; }
.navbar .os-brand { font-size: 1.25rem; color: var(--ink); }
.navbar .nav-link { color: var(--ink-muted) !important; padding: 1rem 0.25rem !important; margin: 0 0.75rem; min-height: var(--touch-target); }
.navbar .nav-link.active { color: var(--ink) !important; font-weight: 600; box-shadow: inset 0 -3px 0 var(--primary); }
.navbar .nav-link:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }

/* language: one compact native select, scales to any number of languages */
.os-lang { padding: 0.5rem 0; }
.os-lang .shiny-input-container { margin: 0; width: auto !important; }
.os-lang .control-label { display: none; }
.os-lang select.form-select {
  min-height: 2.5rem; min-width: 8.25rem; padding: 0.375rem 2.125rem 0.375rem 0.75rem; font-size: 0.9375rem; font-weight: 500;
  background-color: var(--surface-content); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-control); cursor: pointer;
}
.os-lang select.form-select:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; box-shadow: none; }

/* ---------------------------------------------------------------- cards and small components */
.os-card {
  background: var(--surface-panel); border: 1px solid var(--hairline); border-radius: var(--radius-card); box-shadow: none;
}
.os-header-action { margin-left: auto; font-weight: 500; }
.btn.btn-link.os-header-action { margin-left: auto; padding: 0.25rem 0.375rem; min-height: 2.25rem; font-size: 0.875rem; font-weight: 500; color: var(--primary); text-decoration: none; }
.btn.btn-link.os-header-action:hover { text-decoration: underline; }
.btn.btn-link.os-header-action:disabled { color: var(--ink-muted); opacity: .7; }
.os-sidebar-btn { flex: none; width: 2rem; height: 2rem; margin-left: -4px; border-radius: var(--radius-control); border: 1px solid var(--border);
  background: var(--surface-content); color: var(--ink); font-size: 1.25rem; line-height: 1; padding: 0 0 2px; font-weight: 400; }
.os-sidebar-btn:hover { border-color: var(--primary); color: var(--primary); }
.os-sidebar-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.os-num { flex: none; width: 2rem; height: 2rem; border-radius: 1rem; display: grid; place-items: center; font-size: 1rem; font-weight: 700;
  background: var(--surface-content); border: 1px solid var(--border); }
.os-help { flex: none; margin-left: auto; width: 2rem; height: 2rem; border-radius: 1rem; border: 1px solid var(--border); background: var(--surface-content);
  color: var(--primary); font-size: 1rem; font-weight: 700; line-height: 1; padding: 0; }
.os-help:hover { border-color: var(--primary); }
.os-help:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.os-var { width: 1.375rem; font-weight: 700; }
.os-swatch { flex: none; width: 0.875rem; height: 0.875rem; border-radius: 3px; }
.os-swatch.is-dashed { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 8px) !important; height: 0.25rem; }

/* switch */
.os-switch { position: relative; flex: none; width: 2.25rem; height: 1.375rem; margin: 0; cursor: pointer; }
.os-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.os-switch span { position: absolute; inset: 0; border-radius: 0.75rem; background: #a9b2bb; transition: background .15s; }
.os-switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 1rem; height: 1rem; border-radius: 0.5625rem; background: #fff; transition: transform .15s; }
.os-switch input:checked + span { background: var(--primary); }
.os-switch input:checked + span::after { transform: translateX(14px); }
.os-switch input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* buttons; is-active: the result of this button is shown */
.btn.os-btn { width: 100%; min-height: var(--touch-target); white-space: normal; padding: 0.5rem 0.875rem; font-weight: 500;
  background: var(--surface-content); color: var(--ink-button); border: 1px solid var(--border); border-radius: var(--radius-control); }
.btn.os-btn:hover { border-color: var(--primary); background: #f3f9fd; color: var(--ink-button); }
.btn.os-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.os-btn-primary:hover { background: #004a75; border-color: #004a75; color: #fff; }
.btn.os-btn:disabled, .btn.os-btn.disabled { opacity: 0.55; }
.btn.os-btn.is-active, .btn.os-btn.is-active:hover { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; box-shadow: none; }

/* ---------------------------------------------------------------- key figures, tables, tags */
.os-kpis { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0.5rem; margin-bottom: 0.875rem; }
.os-kpi { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 0.375rem 0.625rem; }
.os-kpi small { display: block; font-size: 0.78rem; color: var(--ink-muted); line-height: 1.3; }
.os-kpi b { display: block; font-size: 1.3rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.os-kpi.is-value b { color: var(--plot-optimum); }
.os-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin-bottom: 0.75rem; }
.os-table th, .os-table td { padding: 0.4375rem 0.375rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.os-table th { font-weight: 600; font-size: 0.8125rem; }
.os-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.os-table .os-swatch { display: inline-block; vertical-align: -2px; margin-right: 0.375rem; }
.os-tag { display: inline-block; font-size: 0.75rem; padding: 1px 0.5rem; border-radius: 0.625rem; border: 1px solid var(--border); white-space: nowrap; }
.os-tag.is-binding { background: var(--surface-group); border-color: var(--surface-group); }

/* ---------------------------------------------------------------- dialogs & notifications */
.modal-content { border-radius: var(--radius-modal); background: var(--surface-content); }
.modal-footer .btn.os-btn { width: auto; }
.modal-title { font-size: 1.35rem; }
.modal-body .shiny-input-container { width: 100%; }
.modal-body .form-control, .modal-body .form-select { min-height: 2.625rem; }
.modal-footer { gap: 0.5rem; }
.modal-footer .btn { min-height: var(--touch-target); min-width: 6.875rem; }
.modal-footer .btn-primary, .modal-body .btn-primary, .shiny-download-link.btn-primary { background: var(--primary); border-color: var(--primary); }
.shiny-notification { border-radius: var(--radius-modal); font-size: 0.9375rem; }
#shiny-notification-panel { width: 21.25rem; max-width: calc(100% - 2rem); }

/* ---------------------------------------------------------------- smartphones
   below 768 px Bootstrap would hide the pages behind a menu button; with three pages they stay visible:
   first row OptiSense and the language, second row the three pages */
@media (max-width: 767.98px) {
  .navbar > .container-fluid { position: relative; flex-wrap: wrap; padding: 0 1rem; }
  .navbar .navbar-brand { min-height: 3.5rem; display: flex; align-items: center; margin: 0; padding: 0; }
  .navbar .navbar-toggler { display: none; }
  .navbar .navbar-collapse { display: block !important; flex-basis: 100%; height: auto !important; }
  .navbar .navbar-nav { flex-direction: row; flex-wrap: nowrap; margin: 0 -0.25rem; }   /* one row also at 360 px */
  .navbar .navbar-nav > .nav-item { flex: 1 1 auto; min-width: 0; }
  .navbar .nav-link { display: flex; align-items: center; justify-content: center; margin: 0 0.25rem; padding: 0.5rem 0.125rem !important;
    font-size: 0.875rem; text-align: center; white-space: nowrap; }
  .navbar .bslib-nav-spacer { display: none; }
  .navbar .navbar-nav > li:has(.os-lang) { position: absolute; top: 0; right: 1rem; }
  .os-lang select.form-select { min-width: 7rem; font-size: 0.875rem; }
}
@media (max-width: 374.98px) {
  .navbar .nav-link { font-size: 0.8125rem; }
}

/* ---------------------------------------------------------------- legal notice (Impressum), see optisense.js */
.os-imprint-link { padding: 0; border: 0; font-size: inherit; line-height: inherit; vertical-align: baseline; color: var(--primary); text-decoration: underline; }
.os-imprint-link:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.os-dialog { border: 0; border-radius: var(--radius-modal); padding: 1.25rem 1.25rem 1rem; width: min(26rem, calc(100vw - 2rem)); color: var(--ink); box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.25); }
.os-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.os-dialog h2 { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.25rem; }
.os-dialog p { margin: 0 0 0.75rem; line-height: 1.5; }
.os-dialog .os-dialog-h { font-size: 0.875rem; font-weight: 600; margin: 1rem 0 0.375rem; }
.os-dialog-foot { display: flex; justify-content: flex-end; margin-top: 0.5rem; }
.os-dialog-foot .btn.os-btn { width: auto; min-width: 6.875rem; min-height: var(--touch-target); }
