/*
  Site design layer over the Beautiful Jekyll theme.
  Direction: the site reads like a well-kept engineering record. Public Sans for
  names, headings and interface; Source Serif 4 for reading; a deep forest green
  as the only accent. Colours for the theme's own rules come from _config.yml.
*/
:root {
  --ink: #1E2A28;
  --forest: #2F6B52;
  --forest-dark: #24533F;
  --slate: #5E6B67;
  --rule: #D5DEDA;
  --mist: #EEF3F0;
  --paper: #FFFFFF;
  --font-ui: 'Public Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-text: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

/* ---------- Type ---------- */

body {
  font-family: var(--font-text);
  font-size: 1.075rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

h1, h2, h3, h4, h5, h6,
.navbar-custom, .intro-header, .post-meta, .post-preview, footer,
.blog-tags, .tag-btn, .pagination, .pager, .btn, .dropdown-menu,
figcaption, .resume-button {
  font-family: var(--font-ui);
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -0.01em; }
[role="main"] h2 { font-size: 1.4rem; font-weight: 700; margin-top: 2.75rem; }
[role="main"] h3 { font-size: 1.15rem; font-weight: 600; }
[role="main"] h4 { font-size: 1.02rem; font-weight: 600; }

p { margin: 0 0 1.1rem; }

a { color: var(--forest); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover, a:focus { color: var(--forest-dark); }

hr { border-color: var(--rule); }

/* ---------- Navbar ---------- */

.navbar-custom {
  border-bottom: 1px solid var(--rule);
  box-shadow: none;
}
.navbar-custom .navbar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.navbar-custom .nav-link {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 600;
  font-size: .95rem;
}

/* Left-align the dropdown items (the theme centers them on wide screens) */
.navbar-custom .nav-item.dropdown .dropdown-menu { text-align: left; }

/*
  On wide screens the theme makes the dropdown exactly as wide as its menu button
  and breaks words anywhere, which splits longer project names mid-word. Let the
  menu grow to fit its longest item instead (never narrower than the button).
*/
@media (min-width: 1200px) {
  .navbar-custom .nav-item.dropdown .dropdown-menu {
    width: auto;
    min-width: 100%;
    word-break: normal;
    border: 1px solid var(--rule);
  }

  .navbar-custom .nav-item.dropdown .dropdown-menu .dropdown-item {
    white-space: nowrap;
    padding-left: 1rem;
    padding-right: 1.5rem;
    border: 0;
    background: var(--paper);
  }
}

/* ---------- Page and post headings ---------- */

/* Left-aligned like a document title, in the same column as the content */
.intro-header .page-heading,
.intro-header .post-heading { text-align: left; }
.intro-header { margin-top: 5.5rem; }
.intro-header hr.small { display: none; }

.intro-header .page-heading h1,
.intro-header .post-heading h1 {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0;
}

.intro-header .page-heading .page-subheading,
.intro-header .post-heading .post-subheading {
  font-family: var(--font-text);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--slate);
  margin-top: .6rem;
}

.intro-header .post-heading .post-meta { font-size: .95rem; color: var(--slate); }

@media (min-width: 768px) {
  .intro-header .page-heading h1,
  .intro-header .post-heading h1 { font-size: 2.35rem; }
  [role="main"] h2 { font-size: 1.5rem; }
}

@media (min-width: 1200px) {
  .intro-header { margin-top: 7rem; }
}

/* ---------- Blog list and posts ---------- */

.post-preview .post-title { font-size: 1.45rem; font-weight: 700; line-height: 1.25; color: var(--ink); }
.post-preview .post-subtitle { font-family: var(--font-text); font-weight: 400; color: var(--slate); }
.post-preview .post-meta { color: var(--slate); }
.blog-tags a, .tag-btn { text-transform: none; letter-spacing: 0; }

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

code { font-size: .88em; color: var(--ink); background: var(--mist); padding: .1em .3em; border-radius: 3px; }
pre code { background: none; padding: 0; }

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  font-size: .9rem;
}

/* ---------- Accessibility and polish (Web Interface Guidelines) ---------- */

/* Visible only when reached with the keyboard */
.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 2000;
  padding: .5rem 1rem;
  border-radius: 6px;
  background: var(--forest);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 600;
}
.skip-link:not(:focus) {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus { color: #fff; }

a:focus-visible,
button:focus-visible,
summary:focus-visible,
video:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* Anchored headings must not hide under the fixed navbar */
[role="main"] [id] { scroll-margin-top: 6rem; }

h1, h2, h3 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Print (every page; the home page's CV adds its own rules in resume.css) ---------- */

.print-only { display: none !important; }

@media print {
  /*
    No page margin: browsers then have no room for their own header and footer
    (date, title, URL). The margin moves to the body padding instead.
  */
  @page { margin: 0; }

  html, body { background: #fff !important; }
  body {
    padding: 14mm 15mm !important;
    font-size: 10.5pt;
    line-height: 1.45;
    color: var(--ink);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-only { display: block !important; }

  /* Site chrome that has no place on paper */
  nav.navbar, footer, .skip-link, #beautifuljekyll-search-overlay,
  .blog-pager, .pagination, .language-selector, .project-shot video,
  .avatar-container { display: none !important; }

  /* Full width, no space reserved for the fixed navbar */
  .container-md, .container-fluid { max-width: 100% !important; padding: 0 !important; }
  .row { margin: 0 !important; }
  [class*="col-"] { flex: 0 0 100% !important; max-width: 100% !important; margin-left: 0 !important; padding: 0 !important; }
  .intro-header { margin: 0 0 6mm !important; padding: 0 !important; }
  .intro-header .page-heading h1,
  .intro-header .post-heading h1 { font-size: 20pt; }
  .intro-header .page-heading .page-subheading,
  .intro-header .post-heading .post-subheading { font-size: 11.5pt; margin-top: 1.5mm; }

  [role="main"] h2 { font-size: 14pt; margin-top: 7mm; }
  [role="main"] h3 { font-size: 12pt; }
  p { margin-bottom: 2.5mm; }

  /* Keep things whole: no heading alone at the bottom, no split screenshot */
  h1, h2, h3, h4, .step-label { break-after: avoid; }
  figure, img, .project-tree, .project-flow li, table, pre, blockquote { break-inside: avoid; }
  p, li { orphans: 3; widows: 3; }

  /* On paper a link must say where it goes: external ones print their address */
  a { color: var(--ink) !important; text-decoration: none !important; }
  [role="main"] a[href^="http"]:not([href*="kellsaro.github.io"])::after {
    content: " (" attr(href) ")";
    font-size: .85em;
    color: var(--slate);
    word-break: break-all;
  }
  .project-shot a::after, .resume-page a::after { content: none !important; }

  pre { white-space: pre-wrap; border: 1px solid var(--rule); }

  .print-footer {
    margin: 8mm 0 0;
    padding-top: 2mm;
    border-top: .5pt solid var(--rule);
    font-family: var(--font-ui);
    font-size: 8.5pt;
    color: var(--slate);
  }
  /* The CV on the home page already carries the contact details */
  .resume-page ~ .print-footer { display: none !important; }
}
