/*
 * kanso share viewer.
 * Colours follow Obsidian Atom (light), spacing follows the Kanso vault snippet custom.css.
 * The shell uses local Onest; Markdown uses system fonts. No external resources.
 * The shell CSP forbids inline styles, so every
 * visual rule lives here, including table alignment classes produced by the Markdown renderer.
 */

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/onest-400.woff2") format("woff2");
}

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/onest-500.woff2") format("woff2");
}

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/onest-600.woff2") format("woff2");
}

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/onest-700.woff2") format("woff2");
}

:root {
  --text-normal: #383a42;
  --text-muted: #8e8e90;
  --text-strong: #111111;
  --text-accent: #1592ff;
  --text-accent-hover: #097add;
  --text-error: #a8281b;
  --background: #ffffff;
  --background-code: #fafafa;
  --border-soft: #eaeaeb;
  --border: #dbdbdc;
  --interactive-hover: #f4f4f5;
  --blockquote-border: #c8c8cc;
  --selection: rgba(0, 122, 255, 0.15);
  --focus-ring: #1592ff;

  --font-text: Onest, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --list-gap: 8px;
  --header-padding-inline: 20px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text-normal);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Header ===== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 56px;
  padding: 10px var(--header-padding-inline);
  background: var(--background);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-strong);
  text-decoration: none;
  border-radius: 6px;
}

.brand-logo {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

.brand-arrow {
  margin-left: -3px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
}

.brand:hover .brand-arrow {
  color: var(--text-strong);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  gap: 6px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--text-normal);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.action:hover {
  background: var(--interactive-hover);
  color: var(--text-strong);
}

.action[aria-busy="true"] {
  cursor: progress;
  color: var(--text-muted);
}

.action-icon-only {
  width: 32px;
  padding: 0;
}

.action-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: none;
}

.reading-size[hidden] { display: none; }

.reading-size select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.reading-size:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== Status ===== */

.status {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 20;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--text-normal);
  border-radius: 8px;
  background: var(--text-normal);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.status:empty {
  display: none;
}

.status[data-tone="error"] {
  border-color: #e75545;
  background: var(--background);
  color: var(--text-error);
}

.clipboard-buffer {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ===== Markdown document ===== */
/* Reading-view values: Kanso/.obsidian/appearance.json (14px), Atom/theme.css,
 * snippets/custom.css, and the installed Obsidian app.css for inherited defaults.
 * Keep these scoped to the document; the branded shell has separate typography. */

.document {
  padding: 24px 24px 80px;
}

.markdown-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  font-weight: 450;
  line-height: 1.41;
  max-width: 760px;
  margin: 0 auto;
  overflow-wrap: break-word;
}

.markdown-body[data-reading-size="16"] { font-size: 16px; }
.markdown-body[data-reading-size="18"] { font-size: 18px; }
.markdown-body[data-reading-size="20"] { font-size: 20px; }

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: inherit;
  font-weight: 600;
  scroll-margin-top: 72px;
}

.markdown-body h1 {
  letter-spacing: -0.015em;
  margin: 2rem 0 0.75rem;
  font-size: 1.618em;
  font-weight: 700;
  line-height: 1.2;
}

.markdown-body h2 {
  letter-spacing: -0.011em;
  margin: 1.75rem 0 0.5rem;
  font-size: 1.462em;
  line-height: 1.2;
}

.markdown-body h3 {
  letter-spacing: -0.008em;
  margin: 1.5rem 0 0.4rem;
  font-size: 1.318em;
  line-height: 1.3;
}

.markdown-body h4 {
  letter-spacing: -0.005em;
  margin: 1.25rem 0 0.35rem;
  font-size: 1.188em;
  line-height: 1.4;
}

.markdown-body h5 {
  letter-spacing: -0.002em;
  margin: 1.25rem 0 0.35rem;
  font-size: 1.076em;
  line-height: 1.5;
}

.markdown-body h6 {
  letter-spacing: 0;
  margin: 1.25rem 0 0.35rem;
  font-size: 1em;
  line-height: 1.5;
}

@supports (font-variation-settings: normal) {
  .markdown-body h2 { font-weight: 680; }
  .markdown-body h3 { font-weight: 660; }
  .markdown-body h4 { font-weight: 640; }
  .markdown-body h5 { font-weight: 620; }
}

.markdown-body p {
  margin: 1rem 0 0.75rem;
}

.markdown-body a {
  color: var(--text-accent);
  text-decoration: none;
  text-underline-offset: 2px;
}

.markdown-body a:hover {
  color: var(--text-accent-hover);
  text-decoration: underline;
}

.markdown-body strong {
  color: inherit;
}

.markdown-body ul,
.markdown-body ol {
  margin: 1rem 0;
  padding-left: 0;
}

.markdown-body li {
  margin-left: 3ch;
  padding-block: 0.075em;
  margin-bottom: var(--list-gap);
}

.markdown-body li li {
  margin-left: 2.25em;
  margin-bottom: 2px;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin-top: 0;
  margin-bottom: 0;
}

.markdown-body li > p {
  margin: 0 0 10px;
}

.markdown-body li > p:last-child {
  margin-bottom: 0;
}

.markdown-body blockquote {
  margin: 1rem 0;
  padding: 10px 14px;
  border-left: 2px solid var(--blockquote-border);
  border-radius: 4px;
  background: #f6f6f7;
}

.markdown-body blockquote > :first-child {
  margin-top: 0;
}

.markdown-body blockquote > :last-child {
  margin-bottom: 0;
}

.markdown-body code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--background-code);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.markdown-body pre {
  margin: 0 0 0.75rem;
  padding: 12px 16px;
  overflow-x: auto;
  border-radius: 4px;
  background: var(--background-code);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  line-height: 1.5;
}

.markdown-body pre code {
  padding: 0;
  background: none;
  box-shadow: none;
  white-space: pre;
}

.markdown-body hr {
  height: 0;
  margin: 1.5rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.markdown-body .table-scroll {
  max-width: 100%;
  margin: 0 0 0.75rem;
  overflow-x: auto;
}

.markdown-body table {
  border-collapse: collapse;
  font-size: 1em;
}

.markdown-body th,
.markdown-body td {
  padding: 4px 8px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  color: inherit;
  font-weight: 700;
}

.markdown-body .align-left {
  text-align: left;
}

.markdown-body .align-center {
  text-align: center;
}

.markdown-body .align-right {
  text-align: right;
}

.markdown-body .image-placeholder,
.markdown-body .image-link {
  display: inline-block;
  padding: 2px 8px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.875em;
}

.markdown-body .image-link {
  color: var(--text-accent);
}

.markdown-body .link-blocked {
  color: var(--text-muted);
  text-decoration: underline dotted;
  cursor: help;
}

/* ===== HTML document: the frame takes the rest of the window and scrolls by itself ===== */

.viewer-html {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.viewer-html .site-header {
  position: static;
  flex: none;
}

.frame-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.document-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

/* ===== Notice pages (home, unavailable) ===== */

.notice {
  max-width: 700px;
  margin: 0 auto;
  padding: 64px 24px;
}

.notice h1 {
  margin: 0 0 0.75rem;
  color: var(--text-strong);
  font-size: 1.375em;
  line-height: 1.2;
}

.notice p {
  margin: 0;
  color: var(--text-normal);
}

/* ===== Mobile ===== */

@media (max-width: 560px) {
  :root {
    --header-padding-inline: 12px;
    --list-gap: 6px;
  }

  .site-header {
    min-height: 52px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .brand-name {
    font-size: 15px;
  }

  .brand-logo {
    width: 24px;
    height: 24px;
  }

  .brand {
    gap: 6px;
  }

  .site-header {
    column-gap: 8px;
  }

  .actions {
    gap: 4px;
  }

  .action {
    min-height: 40px;
    padding: 0 8px;
    font-size: 12px;
  }

  .action-icon-only {
    width: 40px;
    padding: 0;
  }

  .document {
    padding: 16px 16px 64px;
  }

  .markdown-body h1 {
    font-size: calc(20em / 14);
    font-weight: 650;
    margin: 24px 0 10px;
  }

  .markdown-body h2 {
    font-size: calc(17em / 14);
    font-weight: 600;
    margin: 20px 0 6px;
  }

  .markdown-body h3 {
    font-size: calc(15em / 14);
    font-weight: 600;
    margin: 18px 0 6px;
  }

  .markdown-body h4,
  .markdown-body h5,
  .markdown-body h6 {
    font-size: 1em;
    font-weight: 600;
    margin: 16px 0 6px;
  }

  .markdown-body p,
  .markdown-body ul,
  .markdown-body ol {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .markdown-body > :first-child {
    margin-top: 0;
  }

  .notice {
    padding: 40px 16px;
  }
}

/* Below ~350px the actions wrap under the brand; a two-row sticky header would eat the reading area. */
@media (max-width: 350px) {
  .site-header {
    position: static;
  }
}

@media print {
  .site-header,
  .status {
    display: none;
  }

  .document {
    padding: 0;
  }
}
