/*
 * lw.io/o stylesheet
 * Adapted from the lw.io Obsidian Publish site:
 *   - Minimal theme by Steph Ango (@kepano), MIT License
 *   - Catppuccin color palette (Latte / Frappe), MIT License
 * Rebuilt as a self-contained sheet with light & dark theme support.
 */

/* ------------------------------------------------------------------ *
 * Theme palettes (Catppuccin: Latte for light, Frappe for dark)
 * ------------------------------------------------------------------ */

:root {
  /* Typography scale (from Minimal) */
  --font-text-size: 16px;
  --font-small: 13px;
  --font-smaller: 11px;

  --normal-weight: 400;
  --bold-weight: 600;

  --page-title-size: 2.1em;
  --page-title-weight: 500;
  --page-title-line-height: 1.1;

  --h1-size: 1.25em;
  --h2-size: 1.1em;
  --h3-size: 1.05em;
  --h4-size: 1em;

  --h1-weight: 600;
  --h2-weight: 600;
  --h3-weight: 600;
  --h4-weight: 500;

  --line-height: 1.5;
  --line-height-tight: 1.3;

  --image-radius: 8px;
  --radius-s: 4px;
  --radius-m: 8px;
  --border-width: 1px;

  --content-max-width: 42rem;

  --font-text:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, system-ui, Roboto,
    "Helvetica", "Arial", "Segoe UI", "Inter", "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  --font-monospace:
    ui-monospace, SFMono-Regular, "Cascadia Mono", "Roboto Mono",
    "DejaVu Sans Mono", Menlo, Monaco, "Consolas", "Source Code Pro", monospace;
}

/* Light theme -- Catppuccin Latte */
.theme-light {
  --bg1: #F0F1F5; /* background primary */
  --bg2: #DCE0E8; /* background secondary */
  --bg3: hsla(228, 11%, 65%, 0.25);

  --ui1: #CCD0DA;
  --ui2: #BCC0CC;
  --ui3: #ACB0BE;

  --tx1: #4D4F69; /* text normal */
  --tx2: #5D5F77; /* text muted */
  --tx3: #8D8FA2; /* text faint */
  --tx4: #5D5F77; /* code text */

  --link-color: hsl(11, 59%, 67%);
  --hl-bg: rgba(255, 225, 0, 0.5);

  --color-red: #E64553;
  --color-blue: #2166F6;
  --color-green: #40A02B;
}

/* Dark theme -- Catppuccin Frappe */
.theme-dark {
  --bg1: #303446;
  --bg2: #242634;
  --bg3: hsla(229, 13%, 52%, 0.25);

  --ui1: #41455A;
  --ui2: #51576D;
  --ui3: #626880;

  --tx1: #C6D0F5;
  --tx2: #A6ADCE;
  --tx3: #848BA7;
  --tx4: #A6ADCE;

  --link-color: hsl(10, 57%, 88%);
  --hl-bg: rgba(255, 177, 80, 0.3);

  --color-red: #EB999C;
  --color-blue: #8CAAEE;
  --color-green: #A6D18A;
}

/* Follow the OS preference when no explicit theme class is set */
@media (prefers-color-scheme: dark) {
  body:not(.theme-light):not(.theme-dark) {
    --bg1: #303446; --bg2: #242634; --bg3: hsla(229,13%,52%,0.25);
    --ui1: #41455A; --ui2: #51576D; --ui3: #626880;
    --tx1: #C6D0F5; --tx2: #A6ADCE; --tx3: #848BA7; --tx4: #A6ADCE;
    --link-color: hsl(10, 57%, 88%);
    --hl-bg: rgba(255, 177, 80, 0.3);
    --color-red: #EB999C; --color-blue: #8CAAEE; --color-green: #A6D18A;
  }
}
@media (prefers-color-scheme: light) {
  body:not(.theme-light):not(.theme-dark) {
    --bg1: #F0F1F5; --bg2: #DCE0E8; --bg3: hsla(228,11%,65%,0.25);
    --ui1: #CCD0DA; --ui2: #BCC0CC; --ui3: #ACB0BE;
    --tx1: #4D4F69; --tx2: #5D5F77; --tx3: #8D8FA2; --tx4: #5D5F77;
    --link-color: hsl(11, 59%, 67%);
    --hl-bg: rgba(255, 225, 0, 0.5);
    --color-red: #E64553; --color-blue: #2166F6; --color-green: #40A02B;
  }
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */

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

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

body {
  margin: 0 auto;
  max-width: var(--content-max-width);
  padding: 3rem 1.5rem 6rem;
  font-family: var(--font-text);
  font-size: var(--font-text-size);
  font-weight: var(--normal-weight);
  line-height: var(--line-height);
  color: var(--tx1);
  background: var(--bg1);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ------------------------------------------------------------------ *
 * Headings
 * ------------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: var(--line-height-tight);
  color: var(--tx1);
}
h1 { font-size: var(--h1-size); font-weight: var(--h1-weight); }
h2 { font-size: var(--h2-size); font-weight: var(--h2-weight); }
h3 { font-size: var(--h3-size); font-weight: var(--h3-weight); }
h4 { font-size: var(--h4-size); font-weight: var(--h4-weight); }
h5 { font-size: 0.85em; font-weight: 500; font-variant: small-caps; }
h6 { font-size: 0.85em; font-weight: 400; font-variant: small-caps; color: var(--tx2); }

.page-title {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: var(--page-title-size);
  font-weight: var(--page-title-weight);
  line-height: var(--page-title-line-height);
  letter-spacing: -0.015em;
}

/* ------------------------------------------------------------------ *
 * Text elements
 * ------------------------------------------------------------------ */

p { margin: 0 0 1em; }

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

.broken-link { color: var(--tx3); }

strong, b { font-weight: var(--bold-weight); color: var(--tx1); }

mark { background: var(--hl-bg); color: inherit; border-radius: 2px; }

ul, ol { margin: 0 0 1em; padding-left: 2em; }
li { margin: 0.075em 0; }
ul > li::marker, ol > li::marker { color: var(--tx3); }

hr {
  border: none;
  border-top: var(--border-width) solid var(--ui1);
  margin: 2em 0;
}

blockquote {
  border-left: 3px solid var(--ui1);
  margin: 1em 0;
  padding: 0.5em 0 0.5em 1em;
  color: var(--tx2);
}
blockquote p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ *
 * Code
 * ------------------------------------------------------------------ */

pre, code { font-family: var(--font-monospace); font-size: 0.85em; }

code {
  color: var(--tx4);
  background: var(--bg2);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--bg2);
  padding: 1rem;
  overflow-x: auto;
  border-radius: var(--radius-m);
  line-height: 1.45;
}
pre code { background: none; padding: 0; color: inherit; }

/* ------------------------------------------------------------------ *
 * Media & tables
 * ------------------------------------------------------------------ */

img, iframe {
  max-width: 100%;
  height: auto;
  border-radius: var(--image-radius);
}

table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
}
th, td {
  padding: 4px 10px;
  border: var(--border-width) solid var(--ui1);
  text-align: left;
}
th { font-weight: var(--bold-weight); }

/* ------------------------------------------------------------------ *
 * Site header
 * ------------------------------------------------------------------ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: var(--border-width) solid var(--ui1);
}
.site-name {
  font-weight: var(--bold-weight);
  font-size: 1.05rem;
  color: var(--tx1);
  text-decoration: none;
}
.site-name:hover { text-decoration: none; }
.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.site-nav a {
  color: var(--tx2);
  text-decoration: none;
  font-size: 0.95rem;
}
.site-nav a:hover { color: var(--tx1); text-decoration: none; }

/* ------------------------------------------------------------------ *
 * Theme toggle
 * ------------------------------------------------------------------ */

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
.theme-dark .theme-toggle .icon-sun { display: inline; }
.theme-dark .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  body:not(.theme-light):not(.theme-dark) .theme-toggle .icon-sun { display: inline; }
  body:not(.theme-light):not(.theme-dark) .theme-toggle .icon-moon { display: none; }
}

/* ------------------------------------------------------------------ *
 * Backlinks
 * ------------------------------------------------------------------ */

.backlinks {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: var(--border-width) solid var(--ui1);
}
.backlinks-title {
  font-size: var(--font-smaller);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tx3);
  margin-bottom: 0.5rem;
}
.backlinks-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.backlinks-list a { text-decoration: none; }
.backlinks-list a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ *
 * Private page notice
 * ------------------------------------------------------------------ */

.private-notice { text-align: center; padding: 3rem 1rem; }
.private-notice h1 { color: var(--tx2); }
.private-notice p { color: var(--tx2); }

.vote-button {
  margin-top: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--link-color);
  color: var(--bg1);
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 1rem;
  font-weight: var(--bold-weight);
}
.vote-button:hover { filter: brightness(0.95); }
