/* ============================================================
   Document styles for pandoc HTML export and Obsidian preview
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap");

/* ── CSS custom properties (Obsidian-compatible variable names) ── */
:root {
  --font-text:
    "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-monospace:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  --background-primary: #ffffff;
  --background-secondary: #f6f7f8;
  --background-code: #f0f1f2;

  --text-normal: #2e3338;
  --text-muted: #6c757d;
  --text-faint: #adb5bd;

  --color-accent-hsl: 231, 48%, 50%;
  --color-accent: hsl(var(--color-accent-hsl));
  --color-accent-hover: hsl(231, 48%, 42%);

  --divider-color: #e0e1e4;
  --interactive-accent: var(--color-accent);

  --heading-color: #1a1d20;
  --link-color: hsl(231, 55%, 52%);
  --link-color-hover: hsl(231, 55%, 40%);

  --code-size: 0.875em;

  --content-width: 780px;
  --toc-width: 220px;
  --line-height: 1.7;
}

/* ── Reset & base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: var(--line-height);
  color: var(--text-normal);
  background-color: var(--background-primary);
  margin: 0;
  padding: 0;
}

/* ── Layout ── */
body > nav#TOC,
body > .content,
body > header,
body > footer,
body > h1,
body > h2,
body > h3,
body > h4,
body > h5,
body > h6,
body > p,
body > ul,
body > ol,
body > blockquote,
body > hr,
body > pre,
body > table,
body > div {
  max-width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
}

/* When TOC and body coexist at full page, give content left padding on wide screens */
@media (min-width: 1100px) {
  body {
    display: grid;
    grid-template-columns: var(--toc-width) 1fr;
    grid-template-rows: auto;
    column-gap: 2.5rem;
    align-items: start;
    max-width: calc(var(--content-width) + var(--toc-width) + 3rem);
    margin: 0 auto;
    padding: 2rem 1.5rem;
  }

  nav#TOC {
    grid-column: 1;
    grid-row: 1 / 999;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    max-width: var(--toc-width);
    margin: 0;
  }

  body > *:not(nav#TOC) {
    grid-column: 2;
    max-width: var(--content-width);
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 1099px) {
  body {
    padding: 1.5rem 1rem;
  }
}

/* ── Table of Contents ── */
nav#TOC {
  font-size: 0.83rem;
  line-height: 1.5;
  background-color: var(--background-secondary);
  border: 1px solid var(--divider-color);
  border-radius: 6px;
  padding: 1rem 1rem 1rem 1rem;
  margin-bottom: 2rem;
}

nav#TOC::before {
  content: "Innehåll";
  display: block;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

nav#TOC ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav#TOC ul ul {
  padding-left: 1rem;
}

nav#TOC li {
  margin: 0.15rem 0;
}

nav#TOC a {
  color: var(--text-normal);
  text-decoration: none;
  display: block;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  transition:
    background 0.1s,
    color 0.1s;
}

nav#TOC a:hover {
  background-color: var(--color-accent);
  color: #fff;
}

/* ── Typography ── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-text);
  color: var(--heading-color);
  line-height: 1.3;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
  font-weight: 700;
}

h1 {
  font-size: 2rem;
  border-bottom: 2px solid var(--divider-color);
  padding-bottom: 0.3em;
}
h2 {
  font-size: 1.45rem;
  border-bottom: 1px solid var(--divider-color);
  padding-bottom: 0.2em;
}
h3 {
  font-size: 1.2rem;
}
h4 {
  font-size: 1.05rem;
}
h5 {
  font-size: 0.95rem;
  color: var(--text-muted);
}
h6 {
  font-size: 0.85rem;
  color: var(--text-muted);
}

p {
  margin: 0 0 1em 0;
}

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition:
    text-decoration-color 0.15s,
    color 0.15s;
}

a:hover {
  color: var(--link-color-hover);
  text-decoration-color: var(--link-color-hover);
}

strong {
  font-weight: 600;
}
em {
  font-style: italic;
}
del {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ── Lists ── */
ul,
ol {
  margin: 0 0 1em 0;
  padding-left: 1.8em;
}

li {
  margin-bottom: 0.25em;
}

li > ul,
li > ol {
  margin-bottom: 0;
}

/* Task lists */
ul.task-list {
  list-style: none;
  padding-left: 0.5em;
}

ul.task-list li input[type="checkbox"] {
  margin-right: 0.5em;
  accent-color: var(--color-accent);
}

/* ── Blockquote ── */
blockquote {
  border-left: 4px solid var(--color-accent);
  margin: 1.2em 0;
  padding: 0.5em 1em;
  color: var(--text-muted);
  background-color: var(--background-secondary);
  border-radius: 0 4px 4px 0;
}

blockquote > p:last-child {
  margin-bottom: 0;
}

/* ── Code ── */
code {
  font-family: var(--font-monospace);
  font-size: var(--code-size);
  background-color: var(--background-code);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: #c7254e;
}

pre {
  background-color: var(--background-code);
  border: 1px solid var(--divider-color);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1em;
  line-height: 1.45;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: var(--code-size);
}

/* ── Tables ── */
table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.5em;
  font-size: 0.93rem;
}

th,
td {
  border: 1px solid var(--divider-color);
  padding: 0.5em 0.85em;
  text-align: left;
  vertical-align: top;
}

thead tr {
  background-color: var(--background-secondary);
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background-color: #fafbfc;
}

/* ── Horizontal rule ── */
hr {
  border: none;
  border-top: 1px solid var(--divider-color);
  margin: 2em 0;
}

/* ── Images ── */
img {
  max-width: 100%;
  height: auto;
}

/* ── Buttons ── */
button,
.input-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.45em 1.1em;
  font-family: var(--font-text);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  color: #fff;
  background-color: var(--color-accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s,
    box-shadow 0.15s,
    transform 0.1s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  -webkit-appearance: none;
  appearance: none;
}

button:hover,
.input-actions button:hover {
  background-color: var(--color-accent-hover);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

button:active,
.input-actions button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

button:focus-visible,
.input-actions button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

@media print {
  button,
  .input-actions {
    display: none !important;
  }
}

/* ── Print ── */
@media print {
  nav#TOC {
    display: none;
  }
  body {
    display: block;
    padding: 0;
  }
  body > * {
    max-width: 100%;
  }
  a {
    text-decoration: underline;
  }
  pre,
  blockquote {
    page-break-inside: avoid;
  }
  h2,
  h3 {
    page-break-after: avoid;
  }
}

/* Flow list used on the settings page */
.flow-list {
  contain: inline-size;
  gap: 0.2em;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  width: -webkit-fill-available;
  background-color: var(--background-secondary);
  border: 1px solid var(--divider-color);
  border-radius: 5px;
  padding: 6px;
}

.flow-item {
  display: flex;
  flex-direction: row;
  border-radius: 100px;
  border: 1px solid var(--divider-color);
  font-size: 0.9em;
  height: min-content;
  width: max-content;
  padding: 3px 8px 3px 8px;
  margin: 0.1em 0em 0.1em 0em;
  background-color: var(--background-primary);
  align-items: center;
}

.flow-item:has(input:checked) {
  background-color: hsla(var(--color-accent-hsl), 0.3);
}

.flow-item input[type="checkbox"] {
  padding: 0;
  margin: 0.1em;
  margin-right: 0.5em;
}

.webpage-html-settings .setting-item.is-disabled {
  opacity: 0.5;
}

/* Progressbar used in the render progress */

.html-progress-bar {
  width: 300px;
  height: 15px;
  background-color: transparent;
  color: var(--interactive-accent);
}

.html-progress-bar::-webkit-progress-bar {
  background-color: var(--background-secondary);
  border-radius: 500px;
}

.html-progress-bar::-webkit-progress-value {
  background-color: currentColor;
  border-radius: 500px;
}

button.html-progress-cancel {
  background-color: var(--color-red);
  color: white;
  border: none;
  padding: 0.5em 1em;
  border-radius: 5px;
  margin-top: 1em;
}

.file-list-wrapper {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: -webkit-fill-available;
  margin-left: 1em;
}

.file-list {
  display: flex;
  flex-direction: column;
  overflow: auto;
  height: 100%;
  width: 100%;
  font-size: 12px;
  line-height: 1.6em;
  border-right: 1px solid var(--divider-color);
  padding-bottom: 4em;
}

.file-list-title {
  font-size: 20px;
  padding: 0.2em 0 0.5em 0;
  margin-right: 2em;
  text-align: center;
  width: 100%;
}

.file-list-item {
  display: flex;
  align-items: center;
}

.file-list-item-icon {
  margin-right: 0.5em;
  width: 1.1em !important;
  height: 1.1em !important;
}

.html-progress-wrapper {
  position: absolute;
  height: 100%;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--background-primary);
  z-index: 1000;
}

.workspace-tab-container:has(.html-progress-wrapper) {
  position: relative;
}

.html-progress-content {
  display: flex;
  height: 100%;
}

.html-progress-inner {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.html-progress-sub {
  margin-block-start: 2em;
}

.html-progress-log {
  display: none;
  flex-direction: column;
  border-left: 1px solid var(--divider-color);
  overflow-y: auto;
  width: 300px;
  max-width: 300px;
  min-width: 300px;
}

.html-progress-log > h1 {
  color: var(--color-yellow);
  padding: 0.3em;
  background-color: rgba(100, 70, 20, 0.1);
  margin: 0;
}

/* File picker */

.file-picker .tree-icon {
  border: 1px solid transparent;
  margin: 0px 4px 0px 0px;
  display: flex;
  align-self: center;
}

.file-picker .tree-icon :is(svg, img) {
  width: 16px !important;
  height: 16px !important;
}

.file-picker .tree-icon *:has(svg, img) {
  display: contents !important;
}

.file-picker a.tree-item-self.is-clickable {
  text-decoration: none !important;
  text-decoration-line: none !important;
  outline: none !important;
  border: none !important;
}

.file-picker .tree-item-inner > p {
  display: contents !important;
}

.feature-title {
  margin: 0 0 1em 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.select-all {
  border-bottom: 1px solid var(--divider-color);
  margin-bottom: 0.5em;
}

.file-picker *:before {
  display: none !important;
}

.file-picker .tree-item > .tree-item-self,
.file-picker .tree-item .tree-item-self:has(> .tree-item-icon) {
  padding-left: 5px !important;
  display: flex !important;
  align-items: center !important;
}

.file-picker .tree-item-self > *:not(.nav-file-tag, .file-checkbox) {
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
  translate: none !important;
}

.file-picker .tree-item-self > .file-checkbox {
  margin-right: 1em;
}

.file-picker .tree-item-self > .tree-item-inner {
  padding: 0 0.3em !important;
}

.file-picker .tree-item-children > * {
  margin: 0 !important;
  padding: 0 !important;
}

.file-picker .collapse-icon,
.file-picker .collapse-icon * {
  display: block !important;
}

/* Input fields */
.input-field {
  margin: 0;
  padding: 0;
}

.input-row {
  margin: 0 0 0.75rem 0;
}

.input-row label {
  display: inline-block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.input-row input,
.input-row textarea {
  display: block;
  width: 100%;
  max-width: 480px;
  padding: 4px 8px;
  border: 1px solid #bbb;
  border-radius: 4px;
  font: inherit !important;
  box-sizing: border-box;
  margin-top: 2px;
  -webkit-appearance: none;
  appearance: none;
}

.input-row textarea {
  resize: vertical;
  min-height: 80px;
}

/* Force tel to look exactly like other fields */
.input-row input[type="tel"],
.input-row input.input-phone {
  font-family: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  line-height: inherit !important;
  letter-spacing: inherit !important;
  color: inherit !important;

  background: inherit !important;
  border: 1px solid #bbb !important;
  border-radius: 4px !important;
  padding: 4px 8px !important;
  box-sizing: border-box !important;

  -webkit-appearance: none !important;
  appearance: none !important;
  -webkit-text-size-adjust: 100%;
}

/* Placeholder often differs on tel fields */
.input-row input[type="tel"]::placeholder,
.input-row input.input-phone::placeholder {
  font-family: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  color: #9aa0a6;
  opacity: 1;
}

/* Settings sections */
details.settings-section {
  padding-left: 2em;
  border-left: 1px solid var(--interactive-accent);
}

details.settings-section > summary {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-left: -1em;
}

details.settings-section > summary > svg {
  min-width: 18px;
  min-height: 18px;
  rotate: 0deg;
  transition: rotate 0.2s;
}

details.settings-section[open] > summary > svg {
  rotate: 90deg;
}
