/* Custom styles for Home Chemistry Lab website */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&family=Quicksand:wght@500;600;700&family=Fira+Code:wght@400;500&display=swap');

/* Base typography - slightly smaller, tighter */
body {
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Headings - scaled down, tighter spacing */
h1, h2, h3, h4, h5, h6,
.navbar-brand, .nav-link, .sidebar-title {
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
h5, h6 { font-size: 0.9rem; }

/* First heading on page - no top margin */
.content > h1:first-child,
#quarto-content h1:first-child {
  margin-top: 0;
}

/* Paragraphs - tighter */
p {
  margin-bottom: 0.75em;
}

/* Lists - compact */
ul, ol {
  margin-bottom: 0.75em;
  padding-left: 2em;
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

li {
  display: list-item;
  margin-bottom: 0.25em;
}

/* Code */
code, pre {
  font-family: 'Fira Code', monospace;
  font-size: 0.85em;
}

code {
  background-color: rgba(0,0,0,0.05);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

/* Navbar - compact, aligned */
.navbar {
  padding: 0.4rem 1rem;
  min-height: auto;
}

/* Fix anchor scroll position for fixed navbar */
html {
  scroll-padding-top: 60px;
  scroll-behavior: auto !important;
}

/* Scroll margin for all anchor targets */
[id] {
  scroll-margin-top: 60px;
}

h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 60px;
}

.navbar > .container-fluid {
  display: flex;
  align-items: baseline;
}

.navbar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0;
  margin: 0;
}

.navbar-nav {
  display: flex;
  align-items: baseline;
}

.nav-link {
  padding: 0 0.75rem !important;
  font-size: 1.25rem;
}

.navbar-toggler {
  padding: 0.15rem 0.4rem;
}

/* Sidebar - compact */
.sidebar {
  font-size: 0.85rem;
}

.sidebar-title {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.sidebar-item {
  padding: 0.2rem 0;
}

.sidebar-section {
  margin-bottom: 0.75rem;
}

/* Table of contents - compact */
#TOC, .toc, .sidebar-toc {
  font-size: 0.75rem;
}

#TOC a, .toc a, .sidebar-toc a {
  padding: 0.1em 0;
  line-height: 1.3;
  font-size: 0.75rem;
}

#toc-title, .toc-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tables - refined */
table {
  font-size: 0.9rem;
  margin: 1em 0;
  width: 100%;
}

th, td {
  padding: 0.4rem 0.6rem;
}

th {
  background-color: var(--bs-primary);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Alternating rows */
tbody tr:nth-child(even) {
  background-color: rgba(0,0,0,0.02);
}

/* Content width and spacing */
main {
  padding: 1.5rem 2rem;
}

/* Section dividers */
hr {
  margin: 2rem 0;
  opacity: 0.15;
}

/* Blockquotes */
blockquote {
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  border-left: 3px solid var(--bs-primary);
  background: rgba(0,0,0,0.02);
}

/* Description text (italics under chemical names) */
.content em, main em {
  font-size: 0.92em;
  color: #555;
}

/* Strong/bold - safety labels */
strong {
  font-weight: 700;
}

/* Callouts - compact */
.callout {
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.callout-title {
  font-size: 0.9rem;
}

/* Page title */
.title {
  font-size: 2rem;
  margin-bottom: 0.25em;
}

.subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  opacity: 0.8;
  margin-bottom: 1.5rem;
}

/* Links */
a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Footer */
.page-footer {
  font-size: 0.8rem;
  padding: 1rem;
  opacity: 0.7;
}

/* Print styles */
@media print {
  /* Hide navigation chrome */
  .sidebar, .navbar, #TOC, .toc, .page-footer,
  .quarto-sidebar, #quarto-sidebar, .sidebar-navigation {
    display: none !important;
  }

  /* Collapse Quarto's multi-column grid to a single block */
  .page-columns, #quarto-content, #quarto-document-content,
  .page-layout-article, .page-layout-full {
    display: block !important;
    grid-template-columns: unset !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Let the content fill the page */
  main, .content, article {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0.25cm 1cm 0.25cm 1cm !important;
    grid-column: unset !important;
  }

  body {
    font-size: 10pt;
  }

  h1 { font-size: 16pt; }
  h2 { font-size: 13pt; }
  h3 { font-size: 11pt; }
}

/* Dark mode adjustments */
[data-bs-theme="dark"] code {
  background-color: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .content em,
[data-bs-theme="dark"] main em {
  color: #aaa;
}

[data-bs-theme="dark"] tbody tr:nth-child(even) {
  background-color: rgba(255,255,255,0.03);
}

/* Molecular structure image — floats right alongside the formula block */
.mol-structure {
  float: right;
  width: 190px;
  margin: 0 0 1.25em 1.75em;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 8px;
  padding: 5px;
  text-align: center;
}

.mol-structure p { margin: 0; }

.mol-structure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

@media (max-width: 600px) {
  .mol-structure {
    float: none;
    width: 160px;
    margin: 0 auto 1em auto;
  }
}

[data-bs-theme="dark"] .mol-structure {
  background: #1e1e1e;
  border-color: rgba(255, 255, 255, 0.15);
  /* invert white backgrounds on structure PNGs in dark mode */
  filter: invert(1) hue-rotate(180deg);
}

/* Hazard classification badges */
.hazard-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.haz-safe    { background: #d4edda; color: #155724; }
.haz-caution { background: #fff3cd; color: #664d00; }
.haz-danger  { background: #f8d7da; color: #58151c; }

[data-bs-theme="dark"] .haz-safe    { background: #1a3a22; color: #75c98a; }
[data-bs-theme="dark"] .haz-caution { background: #3a2e00; color: #ffc107; }
[data-bs-theme="dark"] .haz-danger  { background: #3a0f12; color: #f5a0a7; }

/* Cross-reference experiment lists */
.experiments-list {
  background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.05) 0%, rgba(var(--bs-primary-rgb), 0.02) 100%);
  border-left: 3px solid var(--bs-primary);
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  margin: 1rem 0 1.5rem 0;
  font-size: 0.9rem;
}

.experiments-list strong {
  color: var(--bs-primary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 0.5rem;
}

.experiments-list ul {
  margin: 0;
  padding-left: 1.25rem;
}

.experiments-list li {
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.experiments-list a {
  font-weight: 500;
}

/* Dark mode experiments list */
[data-bs-theme="dark"] .experiments-list {
  background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.12) 0%, rgba(var(--bs-primary-rgb), 0.05) 100%);
}
