@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-700-italic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* CSS Variables
---------------------------- */
:root {
  --bg: #fff;
  --text: #000;
  --link: #0000ee;
  --link-hover: #551a8b;

  --text-muted: #666;
  --text-subtle: #333;

  --border: #ddd;

  --code-bg: #f5f5f5;

  --font: "Inter", sans-serif;
  --base-font-size: 16px;
}

/* Auto dark mode
---------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #111;
    --text: #e6e6e6;
    --link: #8ab4ff;
    --link-hover: #c58cff;

    --text-muted: #aaa;
    --text-subtle: #888;

    --border: #333;

    --code-bg: #1b1b1b;
  }
}

/* Manual theme override
---------------------------- */
:root[data-theme="light"] {
  --bg: #fff;
  --text: #000;
  --link: #0000ee;
  --link-hover: #551a8b;

  --text-muted: #666;
  --text-subtle: #333;

  --border: #ddd;

  --code-bg: #f5f5f5;
}

:root[data-theme="dark"] {
  --bg: #111;
  --text: #e6e6e6;
  --link: #8ab4ff;
  --link-hover: #c58cff;

  --text-muted: #aaa;
  --text-subtle: #888;

  --border: #333;

  --code-bg: #1b1b1b;
}

/* Base & reset
---------------------------- */
html {
  font-size: var(--base-font-size);
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  max-width: 960px;
  margin: auto;
  padding: 2rem;
  line-height: 1.6;
  font-size: 1rem;

  font-variant-ligatures: common-ligatures discretionary-ligatures;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  orphans: 3;
  widows: 3;
}

nav {
  margin-bottom: 2rem;
}

/* Typography
---------------------------- */
h1 {
  font-size: 2rem;
  margin: 1.5rem 0 1rem;
}

h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  font-size: 1.5rem;
  margin: 1.5rem 0 0.75rem;
}

h3 {
  font-size: 1.25rem;
  margin: 1.25rem 0 0.5rem;
}

h4 {
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem;
}

p {
  margin: 0.75rem 0;
}

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

a:hover {
  text-decoration: underline;
}

a[href^="http"]::after {
  content: " ↗";
  font-size: 0.85em;
}

ul {
  list-style: none;
  padding-left: 0;
}

ul ul {
  margin-top: 0.25rem;
  margin-left: 1rem;
}

li {
  margin: 0.4rem 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Blockquote
---------------------------- */
blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  font-style: italic;
  quotes: "\201C" "\201D" "\2018" "\2019";
}

blockquote p::before {
  content: open-quote;
}

blockquote p::after {
  content: close-quote;
}

blockquote p {
  margin: 0.5rem 0;
}

/* Code
---------------------------- */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  background: var(--code-bg);
  padding: 0.15em 0.3em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
}

pre code {
  background: none;
  padding: 0;
}

/* Prose
---------------------------- */
.prose {
  text-align: justify;
  hyphens: auto;
}

@media (max-width: 480px) {
  .prose {
    text-align: left;
    hyphens: none;
  }
}

.prose ul {
  list-style: disc;
  padding-left: 1.5rem;
}

.prose ol {
  padding-left: 1.5rem;
}

.prose li {
  margin: 0.2rem 0;
}

/* Footnotes
---------------------------- */
.footnotes {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footnotes ol {
  padding-left: 1.5rem;
}

/* Mark
---------------------------- */
mark {
  background: #fff3a3;
  color: var(--text);
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

:root[data-theme="dark"] mark {
  background: #5a4f00;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) mark {
    background: #5a4f00;
  }
}

/* Table of contents
---------------------------- */
#toc {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  background: var(--code-bg);
  border-radius: 4px;
  font-size: 0.875rem;
}

#toc::before {
  content: "Indice";
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-subtle);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc-list,
.prose .toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin: 0.25rem 0;
}

.toc-item a {
  color: var(--text-muted);
}

.toc-item a:hover {
  color: var(--text);
}

.toc-item--sub {
  padding-left: 1rem;
}

.toc-item--sub::before {
  content: "↳";
  margin-right: 0.35rem;
  color: var(--text-muted);
}

.toc-item--sub a {
  font-size: 0.8rem;
}

.toc-item--subsub {
  padding-left: 2rem;
}

.toc-item--subsub::before {
  content: "↳";
  margin-right: 0.35rem;
  color: var(--text-muted);
}

.toc-item--subsub a {
  font-size: 0.75rem;
}

/* Tables
---------------------------- */
table {
  border-collapse: collapse;
  margin: 0.5em 0;
  width: 100%;
  display: block;
  overflow-x: auto;
}

table th,
table td {
  border: 1px solid var(--text);
  padding: 3px 4px;
  text-align: left;
}

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

.page-featured-image {
  margin: 1.5rem 0;
}

.page-featured-image img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 6px;
}

/* Breadcrumb
---------------------------- */
.breadcrumb {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  word-wrap: break-word;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--text);
}

/* Theme toggle button
---------------------------- */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;

  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: background 0.2s ease;
}

#theme-toggle:hover,
#theme-toggle:focus {
  background: var(--border);
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* Back to top button
---------------------------- */
#back-to-top {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;

  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: background 0.2s ease, opacity 0.2s ease;

  opacity: 0;
  pointer-events: none;
}

#back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

#back-to-top:hover,
#back-to-top:focus {
  background: var(--border);
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* Folder listing
---------------------------- */
.intro {
  margin-bottom: 2rem;
}

.item-description {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-top: 0.1rem;
}

/* Filter bar
---------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.filter-chip {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.7rem;
}

.filter-chip:hover {
  border-color: var(--link);
  color: var(--text);
}

.filter-chip.active {
  background: var(--link);
  border-color: var(--link);
  color: var(--bg);
}

.filter-separator {
  font-size: 0.75rem;
  color: var(--text-muted);
  align-self: center;
  margin-left: 0.25rem;
}

.filter-break {
  width: 100%;
}

/* Recipe card
---------------------------- */
.recipe-card {
  margin: 1rem 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.recipe-meta-item {
  color: var(--text-muted);
  white-space: nowrap;
}

.recipe-servings {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.servings-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.3rem;
}

.servings-btn:hover {
  background: var(--border);
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* Ingredient table
---------------------------- */
.recipe-page table {
  border-collapse: collapse;
  margin: 0.5em 0;
  width: 100%;
  display: table;
}

.recipe-page table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-left: none;
  border-right: none;
  border-top: none;
  vertical-align: top;
}

.recipe-page table td:last-child {
  text-align: right;
  color: var(--text-muted);
  white-space: nowrap;
}

.recipe-page table th {
  display: none;
}

/* Wake lock button
---------------------------- */
.wake-lock-row {
  margin-top: 2rem;
}

.wake-lock-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

.wake-lock-btn:hover {
  border-color: var(--link);
  color: var(--text);
}

.wake-lock-btn.active {
  border-color: var(--link);
  color: var(--link);
}

/* Footer
---------------------------- */
.site-footer {
  position: relative;
  margin-top: 1rem;
}

footer p {
  margin: 0.25rem 0;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

footer .cc-link img {
  display: inline-block;
  vertical-align: middle;
  max-width: 1em;
  max-height: 1em;
  margin: 0;
}

.site-footer a {
  text-decoration: none;
}

/* Responsive
---------------------------- */
@media (max-width: 480px) {
  body {
    padding: 1rem;
    font-size: 1rem;
    line-height: 1.5;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  table th,
  table td {
    padding: 2px 3px;
  }

  nav {
    font-size: 0.95rem;
  }

  #theme-toggle {
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.9rem;
  }
}

/* Print
---------------------------- */
@media print {
  #theme-toggle,
  .breadcrumb,
  .recipe-tags,
  .servings-btn,
  .wake-lock-btn,
  .site-footer,
  hr {
    display: none !important;
  }

  .page-featured-image {
    display: none;
  }

  body {
    max-width: 100%;
    padding: 0;
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: none;
  }

  a[href^="http"]::after {
    content: none;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  table {
    page-break-inside: avoid;
  }
}
