/* ==========================================================================
   openpolicy.no — the policy document (doc.css)
   One stylesheet for every place a policy is read: the editor's live
   preview and result (.paper .op-doc), and the hosted page /p/<id>
   (body.op-page), which loads NOTHING else — so this file brings its own
   fonts, tokens and box-sizing (openlink's lesson: a stylesheet a page
   loads on its own must carry its own base).

   Hosted pages follow the reader's system theme; the editor's paper
   follows the editor's theme (the tokens below yield to styles.css
   there, because they are declared on .op-page only).
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-var-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+1E00-1EFF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* ------------------------------------------------ the hosted page's base */

.op-page {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --text: #171717;
  --text-2: #555555;
  --text-3: #6f6f6f;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  .op-page {
    --bg: #0e0e0e;
    --surface: #171717;
    --surface-2: #0e0e0e;
    --text: #ededed;
    --text-2: #b0b0b0;
    --text-3: #9a9a9a;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    color-scheme: dark;
  }
}

.op-page *, .op-page *::before, .op-page *::after { box-sizing: border-box; }

.op-bar {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 20px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  font-size: 13.5px;
}

.op-back {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

@media (hover: hover) { .op-back:hover { text-decoration: underline; text-underline-offset: 3px; } }

.op-tabs, .op-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
}

.op-tabs a, .op-langs a {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}

.op-tabs a[aria-current], .op-langs a[aria-current] { background: var(--text); color: var(--bg); font-weight: 600; }
@media (hover: hover) { .op-tabs a:not([aria-current]):hover, .op-langs a:not([aria-current]):hover { color: var(--text); } }

.op-main {
  max-width: 820px;
  margin: 16px auto 48px;
  padding: 0 20px;
}

.op-main > .op-doc {
  background: var(--surface);
  border-radius: 24px;
  padding: clamp(24px, 5vw, 56px);
}

.op-missing .op-doc h1 { margin-bottom: 8px; }

/* ------------------------------------------------------------ the article */

.op-doc {
  color: var(--text);
  overflow-wrap: break-word;
}

.op-doc h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 4.4vw, 40px);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.op-doc h2 {
  margin: 2.2em 0 0.6em;
  font-size: 1.3em;
  font-weight: 620;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.op-doc h3 {
  margin: 1.7em 0 0.5em;
  font-size: 1.05em;
  font-weight: 620;
  line-height: 1.3;
}

.op-doc p, .op-doc ul, .op-doc dl { margin: 0 0 1em; }
.op-doc ul { padding-left: 1.2em; }
.op-doc li + li { margin-top: 0.35em; }
.op-doc strong { font-weight: 620; }

.op-doc a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

@media (hover: hover) { .op-doc a:hover { text-decoration-color: currentColor; } }

.op-doc .op-meta {
  margin: 0 0 1.8em;
  font-family: var(--font-mono);
  font-size: 0.72em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.op-doc .op-head + p { font-size: 1.06em; }

.op-doc .op-summary {
  margin: 1.4em 0 0;
  padding: 1.2em 1.4em 0.4em;
  border-radius: 16px;
  background: var(--surface-2);
}

.op-doc .op-summary h2 { margin: 0 0 0.6em; font-size: 1.05em; }
.op-doc .op-summary ul { list-style: none; padding: 0; }

.op-doc .op-dl { display: grid; gap: 0.5em; }
.op-doc .op-dl div { display: grid; grid-template-columns: minmax(8em, 11em) 1fr; gap: 0.2em 1.2em; }
.op-doc .op-dl dt { color: var(--text-3); font-size: 0.92em; }
.op-doc .op-dl dd { margin: 0; }

.op-doc .op-lines { line-height: 1.55; }

.op-doc .op-table {
  margin: 0 0 1.2em;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
}

.op-doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.4;
}

.op-doc th, .op-doc td {
  padding: 0.65em 0.9em;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.op-doc th {
  font-family: var(--font-mono);
  font-size: 0.78em;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

.op-doc tbody tr:last-child td { border-bottom: 0; }

.op-doc code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  white-space: nowrap;
}

.op-doc .op-credit {
  margin: 3em 0 0;
  font-family: var(--font-mono);
  font-size: 0.72em;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

/* A missing answer in the editor's preview */
.op-doc .op-ph {
  padding: 0 0.25em;
  border-radius: 4px;
  background: rgba(217, 45, 32, 0.1);
  color: inherit;
  box-shadow: inset 0 -1px 0 rgba(217, 45, 32, 0.45);
}

@media (max-width: 600px) {
  .op-doc .op-dl div { grid-template-columns: 1fr; gap: 0.1em; }
  .op-main { padding: 0 12px; }
  .op-main > .op-doc { border-radius: 20px; }
  .op-bar { padding: 14px 12px 0; }
}

@media print {
  .op-page { background: #fff; color: #000; }
  .op-bar { display: none; }
  .op-main { margin: 0; padding: 0; max-width: none; }
  .op-main > .op-doc { padding: 0; border-radius: 0; }
  .op-doc .op-summary { background: none; border: 1px solid #ccc; }
  .op-doc a { color: inherit; }
}
