/* ==========================================================================
   Tokens
   A quiet, editorial look: white page, one serif face, near-black text, a
   muted grey for secondary text, hairline rules, and a single rust-red
   accent for links and the brand. Everything below reads from these.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --fg: #1f1d1a;
  --muted: #6f6b64;
  --rule: #e6e2da;
  --accent: #8a3222;
  --card: #f7f5f0;
  --mark: #f5e2a0;

  --page: 60rem;
  --gap: 1.5rem;

  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;

  color-scheme: light;
}

/* Dark theme: the same roles, re-tuned for a warm near-black page. The
   accent is lifted to a lighter rust so links and the logo (masked in
   var(--accent), see .brand-logo) keep their contrast. data-theme is always
   set explicitly by _includes/theme.html -- from the visitor's saved choice,
   or else their OS preference -- so no prefers-color-scheme block is needed
   here. */
:root[data-theme="dark"] {
  --bg: #1b1917;
  --fg: #e7e2d9;
  --muted: #a19b91;
  --rule: #35312c;
  --accent: #e08a72;
  --card: #25221f;
  --mark: #6b5220;

  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
}
img {
  max-width: 100%;
  height: auto;
}
a {
  color: var(--accent);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}
a:hover {
  text-decoration-thickness: 2px;
}
h1, h2, h3 {
  line-height: 1.25;
}
.clear {
  clear: both;
}

.wrap {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ==========================================================================
   Site header: brand left, section links right, hairline underneath
   ========================================================================== */

header.site {
  border-bottom: 1px solid var(--rule);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem var(--gap);
  flex-wrap: wrap;
  padding-top: 1.15rem;
  padding-bottom: 1.15rem;
}
.brand {
  display: block;
  max-width: 100%;
  text-decoration: none;
}
/* The site's original lettering (img/logo.png: hutsul.png cropped to its
   opaque area) is gold, drawn for the old dark-red header bar and unreadable
   on white. Used as a mask, only its shape is kept and it's painted in the
   accent colour instead -- same letterforms, recoloured by CSS. */
.brand-logo {
  display: block;
  width: 326px;
  max-width: 100%;
  aspect-ratio: 545/47;
  background-color: var(--accent);
  -webkit-mask: url(/img/logo.png) no-repeat center / contain;
  mask: url(/img/logo.png) no-repeat center / contain;
}
header.site nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.4rem;
}
header.site nav a {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}
header.site nav a:hover {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}
header.site nav a.current {
  color: var(--accent);
  font-weight: 600;
}
header.site nav {
  align-items: center;
}

/* Light/dark switch: shows a moon in the light theme (click for dark) and
   a sun in the dark theme (click for light). */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle[hidden] {
  display: none;
}
.theme-toggle:hover {
  color: var(--fg);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Icon-only nav links (search), sized and aligned like the theme switch. */
header.site nav a.icon-link {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem;
}
header.site nav svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun,
:root[data-theme="dark"] .icon-moon {
  display: none;
}
:root[data-theme="dark"] .icon-sun {
  display: block;
}

/* ==========================================================================
   Page body
   ========================================================================== */

main {
  padding-top: 2.5rem;
  padding-bottom: 1rem;
}

main h1 {
  margin: 0 0 0.5rem;
  font-size: 2.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
/* Item count after a listing title, e.g. "Статті 15". */
h1 .n {
  color: var(--muted);
  font-size: 0.42em;
  font-weight: 400;
  vertical-align: super;
  margin-left: 0.15em;
}
/* Small grey line above or below a title: a date, a parent section link. */
.when, .kicker {
  margin: -0.2rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.kicker {
  margin: 0 0 0.3rem;
}
.when a, .kicker a {
  color: var(--muted);
}
.lede {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.7;
}

/* ==========================================================================
   Listings (/articles/, /gallery/, the home page teaser)
   A bold, small group heading (a date, or a label), then entries: a bold
   underlined title link, an optional grey meta line, a plain summary.
   ========================================================================== */

.day {
  margin: 0 0 2.2rem;
}
.dayh {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  font-weight: 700;
}
.item + .item {
  margin-top: 1.3rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
}
.item h3 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
  font-weight: 700;
}
.where {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.sum {
  margin: 0;
}
.more {
  margin: 0;
  font-size: 0.95rem;
}

/* ==========================================================================
   Search (/search/, js/search.js)
   ========================================================================== */

.search-form {
  margin: 0 0 1rem;
}
.search-row {
  display: flex;
  gap: 0.5rem;
}
.search-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.search-option input {
  accent-color: var(--accent);
}
.search-option span {
  color: var(--muted);
}
.search-row input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1.05rem;
}
.search-row input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}
.search-form button {
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
#search-status {
  margin-bottom: 1.5rem;
}
/* Matched words: in search results, and on an article opened from one. No
   horizontal padding: a partial match ("Прут" in "Прутом") must sit flush
   against the rest of its word. */
mark {
  border-radius: 2px;
  background: var(--mark);
  color: inherit;
}

/* ==========================================================================
   Article / page prose
   ========================================================================== */

.prose p {
  margin: 1rem 0;
}
.prose h2 {
  margin: 2.2rem 0 0.6rem;
  font-size: 1.35rem;
}
.prose h3 {
  margin: 1.8rem 0 0.5rem;
  font-size: 1.15rem;
}
.prose strong, .prose b {
  font-weight: 600;
}
.prose ul, .prose ol {
  padding-left: 1.4rem;
}
.prose blockquote {
  margin: 1.5rem 0;
  padding: 0 0 0 1.2rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}
.prose hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}
.prose img {
  border-radius: 3px;
}
/* Legacy tables can be wider than the column; let them scroll instead of
   stretching the page. */
.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.5;
}
.prose th, .prose td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.prose th {
  border-bottom-color: var(--fg);
  font-weight: 700;
}
.prose iframe {
  max-width: 100%;
  height: auto;
  aspect-ratio: 680/600;
  border: 0;
  border-radius: 3px;
}
.back {
  margin: 2.5rem 0 0;
  font-size: 0.95rem;
}

/* ==========================================================================
   Home page banner slideshow
   ========================================================================== */

#banner {
  aspect-ratio: 920/330;
  margin: 0 0 2.5rem;
  position: relative;
  overflow: hidden;
  border-radius: 3px;
  background: var(--card);
}
#slideshow {
  position: relative;
  width: 100%;
  height: 100%;
}
/* The crossfade animation itself (opacity keyframes + per-image delay) is
   generated in index.html, since it depends on how many photos are in
   slider/ -- this just positions every image in the same spot, stacked. */
#slideshow img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Filled in by js/random-article.js after a fetch; reserving roughly one
   teaser's height keeps the page from jumping when it arrives. */
#randomArticle {
  min-height: 5.5rem;
}

/* ==========================================================================
   Facebook widgets
   The SDK (loaded async, see _includes/facebook-sdk.html) swaps these
   placeholders for iframes well after first paint; the min-heights reserve
   roughly their settled size so that swap doesn't shift the page. Any
   spacing lives on the .fb-widget wrapper, not the .fb-* element itself:
   Facebook measures that element and pins an inline pixel width on it, so
   padding placed there would end up outside the measured box.
   ========================================================================== */

.fb-widget {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.fb-widget.centered {
  text-align: center;
}
.fb-page {
  min-height: 70px;
}
.fb-comments {
  min-height: 60px;
}

/* ==========================================================================
   Photo album
   ========================================================================== */

.album figure {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: var(--gap);
  align-items: start;
  margin: 0;
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}
.album figure:first-child {
  border-top: 0;
  padding-top: 0.5rem;
}
.album img {
  display: block;
  width: 100%;
  border-radius: 3px;
}
.album figcaption {
  font-size: 0.95rem;
}

/* ==========================================================================
   Site footer
   ========================================================================== */

footer.site {
  margin-top: 2.5rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.foot-note {
  margin: 0;
}
.foot-note a {
  color: var(--muted);
}

/* ==========================================================================
   Narrow screens
   ========================================================================== */

@media (max-width: 640px) {
  :root {
    --gap: 1.1rem;
  }
  body {
    font-size: 16px;
  }
  main {
    padding-top: 1.75rem;
  }
  main h1 {
    font-size: 2rem;
  }
  .album figure {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}
