/* operator.css — design system "operator note"
   ivory / ink / blood red — serif headlines, monospace data, hairlines instead of cards.
   Stack 100% system-fonts (no Google Fonts, no extra requests). */

:root {
  --ink: #0d1117;
  --ink-soft: #2a2620;
  --ivory: #f5f1e8;
  --paper: #fafaf5;
  --rule: #c9c2b3;
  --rule-strong: #8a8170;
  --accent: #b91c1c;
  --accent-soft: #9a2222;
  --muted: #5c5644;
  --good: #3a5a2e;
  --warn: #8b6914;
  --danger: #991b1b;
  --code-bg: #14110d;
  --code-text: #e8e3d4;
  --code-dim: #807a68;
  --code-accent: #d4a574;

  /* legacy aliases for unrefactored inline styles still in pages */
  --primary: var(--ink);
  --primary-dark: var(--ink-soft);
  --secondary: var(--muted);
  --success: var(--good);
  --warning: var(--warn);
  --bg: var(--ivory);

  --serif: ui-serif, "Iowan Old Style", "Apple Garamond", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--ivory); }

body {
  font-family: var(--sans);
  background: var(--ivory);
  color: var(--ink);
  line-height: 1.55;
  font-size: 17px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* subtle horizontal lines top + bottom of page, like a notebook page */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--ink);
  z-index: 100;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

/* === HEADER / HERO === */

.op-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 36px;
}
.op-meta .op-lang {
  margin-left: auto;
  display: flex;
  gap: 14px;
}
.op-meta .op-lang a {
  color: var(--muted);
  text-decoration: none;
}
.op-meta .op-lang a.current {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.op-hero {
  padding: 24px 0 48px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 48px;
}
.op-hero .op-kicker {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.op-hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.3rem, 5vw, 3.4rem);
  line-height: 1.04;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin-bottom: 18px;
  max-width: 18ch;
}
.op-hero .op-lede {
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 56ch;
  margin-bottom: 28px;
}
.op-hero .op-byline {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 28px;
}
.op-hero .op-byline strong {
  color: var(--ink);
  font-weight: 600;
}

.op-hero .op-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-family: var(--mono);
  font-size: 14px;
}
.op-hero .op-actions a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1.5px solid var(--accent);
  padding-bottom: 2px;
  transition: background 120ms;
}
.op-hero .op-actions a::before {
  content: "› ";
  color: var(--accent);
  font-weight: 700;
}
.op-hero .op-actions a:hover {
  background: rgba(185, 28, 28, 0.08);
}

/* === SECTIONS (replace .card) === */

.op-section {
  padding: 36px 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.op-section:last-of-type { border-bottom: none; }

.op-section-num {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 8px;
}
.op-section h2 {
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: -0.005em;
}
.op-section h3 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin: 22px 0 10px;
}
.op-section p {
  margin-bottom: 14px;
  max-width: 64ch;
}
.op-section a:not(.op-button):not(.op-mode):not(.op-os) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.op-section a:not(.op-button):not(.op-mode):not(.op-os):hover {
  color: var(--accent-soft);
  text-decoration-thickness: 2px;
}

/* === MODE / OS SELECTORS (preserve original .mode-option / .os-tab classes for JS) === */

.mode-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0;
  margin: 24px 0;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}
.mode-option {
  padding: 22px 22px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  background: var(--paper);
  transition: background 120ms;
  position: relative;
}
.mode-option:hover { background: var(--ivory); }
.mode-option.active {
  background: var(--ink);
  color: var(--ivory);
}
.mode-option.active::before {
  content: "▸ ACTIVE";
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.mode-option h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: inherit;
}
.mode-option p {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0;
}
.mode-option.active p { color: rgba(245, 241, 232, 0.7); }

/* === BUTTONS === */

.btn, .op-button {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 26px;
  background: var(--ink);
  color: var(--ivory);
  border: none;
  border-radius: 0;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms, transform 80ms;
  width: 100%;
  text-align: center;
}
.btn:hover, .op-button:hover { background: var(--accent); }
.btn:active, .op-button:active { transform: translateY(1px); }
.btn:disabled { background: var(--muted); cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
}
.btn-secondary:hover { background: var(--ink); color: var(--ivory); }

/* === INPUTS === */

.input-group { margin: 22px 0; }
.input-group label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.input-group input,
.input-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
}
.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--ivory);
}

/* === STATUS / RESULTS === */

.status-alert {
  padding: 16px 18px;
  border-radius: 0;
  margin: 20px 0;
  border-left: 4px solid;
  background: var(--paper);
  font-size: 0.95rem;
}
.status-alert.warning { border-color: var(--warn); }
.status-alert.success { border-color: var(--good); }
.status-alert.error { border-color: var(--danger); }
.status-alert.info { border-color: var(--accent); }

.status-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1.5px solid;
}
.status-badge.excellent { color: var(--good); border-color: var(--good); background: rgba(58, 90, 46, 0.08); }
.status-badge.good { color: var(--warn); border-color: var(--warn); background: rgba(139, 105, 20, 0.08); }
.status-badge.poor { color: var(--danger); border-color: var(--danger); background: rgba(153, 27, 27, 0.08); }

.result-box {
  padding: 18px 20px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 0;
  margin: 20px 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-x: auto;
}

.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 20px 22px;
  border-radius: 0;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.6;
  overflow-x: auto;
  margin: 16px 0;
  border-left: 3px solid var(--code-accent);
}
.code-block .comment { color: var(--code-dim); font-style: italic; }
.code-block .highlight { color: var(--code-accent); }

/* === OS TABS === */

.os-tab {
  padding: 10px 18px;
  border: none;
  border-bottom: 2px solid var(--rule);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
}
.os-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.os-tab:hover { color: var(--ink); }

/* === CONNECTION DOT === */

.connection-status {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.connection-status.connected { background: var(--good); }
.connection-status.disconnected { background: var(--danger); }
.connection-status.connecting { background: var(--warn); animation: op-pulse 1.1s infinite; }
@keyframes op-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* === INLINE FLEX UTILITY === */

.inline-flex {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.inline-flex input { flex: 1; }
.inline-flex .btn, .inline-flex .op-button { width: auto; }

/* === SIGNATURE BLOCK === */

.op-signature {
  margin: 56px 0 24px;
  padding: 28px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-soft);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
}
.op-signature p { max-width: 50ch; margin: 0; line-height: 1.5; }
.op-signature .op-sig-author {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
  line-height: 1.5;
}
.op-signature .op-sig-author strong {
  display: block;
  font-family: var(--serif);
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.05rem;
  color: var(--ink);
  font-weight: 600;
}

/* === FOOTER === */

.op-footer {
  margin-top: 56px;
  padding-top: 36px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.7;
}
.op-footer a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--rule-strong);
}
.op-footer a:hover {
  border-bottom-style: solid;
  border-bottom-color: var(--accent);
  color: var(--accent);
}
.op-footer .op-cross {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--rule);
}

/* === LEGACY CARD FALLBACK ===
   For pages we haven't refactored yet, .card still works but flat. */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 28px;
  margin: 22px 0;
}
.card h2 {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

/* === COOKIE BANNER OVERRIDES ===
   Inline styles in HTML are imposed by templated banner on 10 pages.
   We override here with high specificity + !important — pragmatic
   choice to keep banner in one place rather than edit every page. */

#cookie-banner {
  background: var(--ivory) !important;
  color: var(--ink) !important;
  border-top: 4px solid var(--ink) !important;
  box-shadow: 0 -1px 0 var(--rule) inset !important;
  font-family: var(--sans) !important;
  font-size: 0.88rem !important;
  padding: 18px 22px !important;
  line-height: 1.5;
}
#cookie-banner p { margin: 0 0 12px 0 !important; }
#cookie-banner a { color: var(--accent) !important; text-decoration: underline !important; text-underline-offset: 2px; }
#cookie-banner label {
  font-family: var(--sans) !important;
  font-size: 0.88rem !important;
  color: var(--ink-soft) !important;
}
#cookie-banner input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px; height: 14px;
}
#cookie-banner button {
  font-family: var(--mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
  padding: 9px 18px !important;
  border-radius: 0 !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  border: 1.5px solid var(--ink) !important;
  transition: background 120ms;
}
#cookie-banner button:nth-of-type(1) {
  background: transparent !important;
  color: var(--ink) !important;
}
#cookie-banner button:nth-of-type(2) {
  background: var(--paper) !important;
  color: var(--ink) !important;
}
#cookie-banner button:nth-of-type(3) {
  background: var(--ink) !important;
  color: var(--ivory) !important;
}
#cookie-banner button:hover {
  background: var(--accent) !important;
  color: var(--ivory) !important;
  border-color: var(--accent) !important;
}

/* === RESPONSIVE === */

@media (max-width: 640px) {
  .container { padding: 24px 18px 60px; }
  .op-meta {
    font-size: 10px;
    gap: 10px 14px;
    padding-bottom: 14px;
    margin-bottom: 24px;
    flex-direction: column;
    align-items: flex-start;
  }
  .op-meta .op-lang { margin-left: 0; gap: 18px; }
  .op-hero { padding: 16px 0 32px; margin-bottom: 32px; }
  .op-hero h1 { font-size: 1.95rem; max-width: 100%; }
  .op-hero .op-lede { font-size: 1.05rem; }
  .op-hero .op-actions { flex-direction: column; gap: 14px; }
  .op-section h2 { font-size: 1.5rem; }
  .mode-selector { grid-template-columns: 1fr; border-left: 1px solid var(--rule); }
  .op-signature { grid-template-columns: 1fr; }
  .op-signature .op-sig-author { text-align: left; }
  .inline-flex { flex-direction: column; }
}
