
@font-face {
  font-family: "Switzer";
  src: url("/assets/fonts/Switzer-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
}
@font-face {
  font-family: "Switzer";
  src: url("/assets/fonts/Switzer-VariableItalic.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: italic;
}

/* Theme variables */
:root {
    --bg: #fafafa;
    --text: #444;
    --border: #ddd;
    --surface: #f8f8f8;
    --surface-hover: #e0e0e0;
    --input-bg: #ffffff;
    --link: #0066cc;
    --highlight: yellow;
    --highlight-current: orange;
    --code-bg: #f4f4f4;
    --secondary-text: #666;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    --floaty-start: #F5F5F5;
    --floaty-end: #FFFFFF;
    --floaty-highlight: #fff;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --text: #aaa;
        --head: #fff;
        --border: #444;
        --surface: #2d2d2d;
        --surface-hover: #3d3d3d;
        --input-bg: #1a1a1a;
        --link: #4da6ff;
        --highlight: #665500;
        --highlight-current: #cc6600;
        --code-bg: #2d2d2d;
        --secondary-text: #999;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-strong: rgba(0, 0, 0, 0.4);
        --floaty-start: #333;
        --floaty-end: #2d2d2d;
        --floaty-highlight: #444;
    }
}

/* Manual override with data attribute */
[data-theme="light"] {
    --bg: #fafafa;
    --text: #444;
    --head: #222;
    --border: #ddd;
    --surface: #f8f8f8;
    --surface-hover: #e0e0e0;
    --input-bg: #ffffff;
    --link: #0066cc;
    --highlight: yellow;
    --highlight-current: orange;
    --code-bg: #f4f4f4;
    --secondary-text: #666;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    --floaty-start: #F5F5F5;
    --floaty-end: #FFFFFF;
    --floaty-highlight: #fff;
}

[data-theme="dark"] {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --border: #444;
    --surface: #2d2d2d;
    --surface-hover: #3d3d3d;
    --input-bg: #1a1a1a;
    --link: #4da6ff;
    --highlight: #665500;
    --highlight-current: #cc6600;
    --code-bg: #2d2d2d;
    --secondary-text: #999;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.4);
    --floaty-start: #222;
    --floaty-end: #2b2b2b;
    --floaty-highlight: #2d2d2d;
}
* {
  box-sizing: border-box;
}

/* Base styles */
html {
    background: var(--bg);
}

body {
    margin: 0;
    padding: 0;
    font-family: "Switzer", system-ui;
    line-height: 1.6;
    font-size: 137.5%;
    font-weight: 250;
    color: var(--text);
    background: var(--bg);
}

img { max-width: 100%; }

code {
    background: var(--code-bg);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 3px;
}

pre {
    background: var(--code-bg);
    border-color: var(--border);
}

pre code {
    display: block;
    padding: 12px;
}

body {
    margin: 0;
    display: flex;
}

a {
    color: var(--link);
}

/* Outline */
#outline {
    width: 250px;
    height: 100vh;
    position: fixed;
    left: -250px;
    top: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    transition: left 0.3s;
    z-index: 999;
}

#outline.active {
    left: 0;
}

#outline-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    z-index: 1000;
    color: var(--text);
}

#outline h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--secondary-text);
}

#outline a {
    display: block;
    padding: 4px 0;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
}

#outline a:hover {
    color: var(--link);
}

#outline .h2 { padding-left: 12px; }
#outline .h3 { padding-left: 24px; }
#outline .h4 { padding-left: 36px; }
#outline .h5 { padding-left: 48px; }
#outline .h6 { padding-left: 60px; }

/* Content */
#content {
    position: relative;
    max-width: 800px;
    margin: 8vw auto 12vw;
    padding: 0 20px;
    flex: 1;
    color: var(--text);
}

/* Search */
#custom-search {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 12px var(--shadow);
    display: none;
    z-index: 1000;
    color: var(--text);
}

#custom-search.active {
    display: flex;
    gap: 8px;
    align-items: center;
}

#search-input {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    outline: none;
}

#search-input:focus {
    border-color: var(--link);
}

.search-count {
    color: var(--secondary-text);
    font-size: 14px;
}

mark.highlight {
    background-color: var(--highlight);
    padding: 0;
}

mark.current-highlight {
    background-color: var(--highlight-current);
}

/* Buttons */
button {
    border: none;
    background: var(--surface);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background: var(--surface-hover);
}

/* Heading anchors */
.heading-anchor {
    color: var(--secondary-text);
}

.heading-anchor:hover {
    color: var(--link);
}

/* Dark mode toggle */
#dark-mode-toggle {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

#dark-mode-toggle span {
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    transition: background 0.3s, color 0.3s;
}

[data-theme="light"] #dark-mode-toggle .light,
:root:not([data-theme]) #dark-mode-toggle .light {
    background: var(--surface-hover);
}

[data-theme="dark"] #dark-mode-toggle .dark {
    background: var(--surface-hover);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) #dark-mode-toggle .dark {
        background: var(--surface-hover);
    }
    :root:not([data-theme]) #dark-mode-toggle .light {
        background: transparent;
    }
}

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--link);
    z-index: 9999;
    transition: width 0.1s ease;
}

/* Reading Time Estimate */
#reading-time {
    position: fixed;
    top: 80px;
    left: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--secondary-text);
    z-index: 998;
}

/* Notes – bottom action bar */
#notes-actions {
    display: none;
    position: fixed;
    bottom: 5vw;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    gap: 8px;
    padding: 8px 24px;
    align-items: center;
}

#notes-actions.visible {
    display: flex;
}

/* Margin note icon */
.margin-note-icon {
    position: absolute;
    left: -32px;
    top: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--link);
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
}

.margin-note-icon:hover {
    background: var(--surface-hover);
}

/* Expanded margin note */
.margin-note {
    position: absolute;
    left: -280px;
    top: 0;
    width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 2px 8px var(--shadow);
    z-index: 50;
    padding: 8px;
}

.margin-note textarea {
    width: 100%;
    min-height: 60px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    font-family: system-ui;
    font-size: 13px;
    line-height: 1.4;
    background: var(--input-bg);
    color: var(--text);
    outline: none;
}

.margin-note textarea:focus {
    border-color: var(--link);
}

.margin-note-thread {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.margin-note-entry {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.margin-note-entry:first-child {
    padding-top: 0;
}

.margin-note-entry-text {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
    white-space: pre-wrap;
}

.margin-note-entry-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 11px;
    color: var(--secondary-text);
}

.margin-note-entry-delete {
    font-size: 11px;
    padding: 0 4px;
    line-height: 1.6;
    opacity: 0.6;
}

.margin-note-entry-delete:hover {
    opacity: 1;
}

.margin-note-add {
    width: 100%;
    margin-top: 4px;
    font-size: 12px;
    padding: 4px 8px;
}

/* Wrapper so note icon/textarea (position: absolute) have something to
   anchor to — <img> is a void element and can't host child nodes visually */
.annotatable-img-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

/* Annotatable elements */
.annotatable {
    position: relative;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: border-color 0.15s;
}

.annotatable:hover {
    border-left-color: var(--border);
}

.annotatable.has-note {
    border-left-color: var(--link);
}

.annotatable.note-active {
    border-left-color: var(--link);
    background: color-mix(in srgb, var(--link) 8%, transparent);
}

/* Print note blocks (injected before printing) */
.print-note {
    display: none;
}

@media print {
    /* Hide all UI chrome */
    #dark-mode-toggle,
    #outline-toggle,
    #outline,
    #custom-search,
    #reading-progress,
    #reading-time,
    #notes-actions,
    .margin-note-icon,
    .margin-note,
    header {
        display: none !important;
    }

    /* Show injected notes */
    .print-note {
        display: block;
        background: #f0f4ff;
        border-left: 3px solid #0066cc;
        padding: 6px 10px;
        margin: 4px 0 12px 0;
        font-size: 13px;
        color: #333;
        white-space: pre-wrap;
    }

    /* Remove annotatable hover styles */
    .annotatable {
        border-left-color: transparent !important;
        cursor: default;
    }
    .annotatable::before {
        display: none !important;
    }
    .annotatable.has-note {
        border-left-color: #0066cc !important;
    }
}

/* Utilities */
.u-floaty {
    box-sizing: border-box;
    background: linear-gradient(180deg, var(--floaty-start) 0%, var(--floaty-end) 50%);
    box-shadow: 0px 2px 2px var(--shadow), 0px 3px 12px var(--shadow), 0 1px 0 rgba(0, 0, 0, 0.05);
    border-radius: 40px;
    border: 1.5px solid var(--floaty-highlight);
    min-height: 40px;
    display: flex;
    align-items: center;
}
.u-floaty--medium {
  min-height: 70px;
}

.avatar {
  border-radius: 28px;
  width: 28px;
  height: 28px;
  display: inline-block;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.author {
  display: flex;
  align-items: center;
  margin: 0 .6em 0 .25em;
  gap: .25em;
}

img {
  max-width: 100%;
}


h1, h2, h3, h4, h5, h6 {
  color: var(--head);
}
