/*
Theme Name: kestrel
Description: A warm, practical classic theme for content-rich publications, with a right sidebar, card grids, a horizontal dropdown menu and a multi-column footer.
Author: Roof to Meter
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: kestrel
*/

/* ---------- Tokens ---------- */
:root {
  --bg: #faf4ea;
  --fg: #2d241c;
  --muted: #7a6e60;
  --border: #e7dcc9;
  --radius: 10px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  --accent: #be4b28;
  --accent-dark: #9c3a1e;
  --ochre: #d9a24a;
  --sage: #7c8b6f;
  --paper: #fffdf8;
  --sidebar-w: 320px;
  --gap: 28px;
  --media-ratio: 16 / 9;
  --thumb-ratio: 16 / 9;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.75;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { color: var(--accent-dark); text-decoration: underline; }
h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 0.6em;
  color: var(--fg);
  overflow-wrap: break-word;
}
h1 { font-size: 2.1rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1.15em; }
ul, ol { margin: 0 0 1.15em; padding-left: 1.4em; }
blockquote {
  margin: 0 0 1.4em;
  padding: 0.2em 0 0.2em 1.1em;
  border-left: 4px solid var(--ochre);
  color: var(--muted);
  font-style: italic;
}
table { width: 100%; border-collapse: collapse; margin-bottom: 1.4em; }
th, td { padding: 0.55em 0.7em; border: 1px solid var(--border); text-align: left; }
th { background: var(--paper); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* ---------- Utility classes ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.fx-between { display: flex; align-items: center; justify-content: space-between; }
.fx-center { display: flex; align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.gap-sm { gap: 10px; }
.gap-md { gap: 18px; }
.grid { display: grid; gap: var(--gap); }
.grid-cards { grid-template-columns: repeat(2, 1fr); }
.grid-related { grid-template-columns: repeat(4, 1fr); }
.mb-0 { margin-bottom: 0; }
.mt-md { margin-top: 24px; }
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--paper); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Header ---------- */
.site-header { background: var(--paper); border-bottom: 1px solid var(--border); }
.site-header .fx-between { min-height: 72px; }
.brand { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.brand a { color: var(--fg); }
.brand a:hover { color: var(--accent); text-decoration: none; }
.brand img { max-height: 48px; width: auto; }

.menu { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.menu li { position: relative; margin: 0; }
.menu a {
  display: block;
  padding: 0.55em 0.9em;
  color: var(--fg);
  font-weight: 500;
  border-radius: 8px;
}
.menu a:hover, .menu a:focus-visible { background: var(--bg); color: var(--accent); text-decoration: none; }
.menu .current-menu-item > a, .menu .current_page_item > a { color: var(--accent); }
.menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 60;
  min-width: 250px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
}
.menu li:hover > .sub-menu,
.menu li:focus-within > .sub-menu { display: block; }
.menu .sub-menu a { padding: 0.5em 0.85em; white-space: nowrap; }
.menu-toggle { display: none; }
.submenu-toggle {
  display: none;
  margin-left: 4px;
  width: 34px; height: 34px;
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: 8px;
}

/* ---------- Header search ---------- */
.search-panel { display: none; border-top: 1px solid var(--border); background: var(--bg); }
.search-panel.open { display: block; }
.search-panel .wrap { padding-top: 16px; padding-bottom: 16px; }

/* ---------- Search form ---------- */
.search-form { display: flex; gap: 10px; width: 100%; }
.search-field {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.6em 1em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--fg);
  font-size: 1rem;
  font-family: inherit;
}
.search-field:focus { outline: 2px solid var(--ochre); outline-offset: 1px; }
.search-submit {
  padding: 0.6em 1.3em;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.search-submit:hover, .search-submit:focus-visible { background: var(--accent-dark); }

/* ---------- Hero (text-only, centered) ---------- */
.hero {
  position: relative;
  text-align: center;
  padding: 72px 0 56px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.45 0 0 0 0 0.35 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23g)'/%3E%3C/svg%3E"),
    var(--bg);
}
.hero .ridge { display: block; margin: 0 auto 22px; color: var(--accent); }
.hero h1 { font-size: 2.6rem; max-width: 20ch; margin-left: auto; margin-right: auto; }
.hero .lead { max-width: 62ch; margin: 0 auto; color: var(--muted); font-size: 1.08rem; }

/* ---------- Layout ---------- */
.layout { display: flex; gap: var(--gap); align-items: flex-start; padding-top: 40px; padding-bottom: 56px; }
.content { flex: 1 1 auto; min-width: 0; }
.sidebar { flex: 0 0 var(--sidebar-w); width: var(--sidebar-w); }

/* ---------- Breadcrumb ---------- */
.breadcrumb { font-size: 0.85rem; color: var(--muted); padding-top: 24px; }
.breadcrumb .trail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumb .crumb { color: var(--muted); }
.breadcrumb .crumb:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .here { color: var(--fg); }

/* ---------- Post cards ---------- */
.card-post { overflow: hidden; display: flex; flex-direction: column; transition: box-shadow 0.15s ease; }
.card-post:hover { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.09); }
.card-post .thumb { display: block; aspect-ratio: var(--media-ratio); overflow: hidden; background: var(--border); }
.card-post .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-post .pad { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-post .meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.82rem; color: var(--muted); }
.card-post .meta .cat { color: var(--sage); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.76rem; }
.card-post h2, .card-post h3 { margin: 0; font-size: 1.18rem; }
.card-post h2 a, .card-post h3 a { color: var(--fg); }
.card-post h2 a:hover, .card-post h3 a:hover { color: var(--accent); text-decoration: none; }
.card-post .excerpt { color: var(--muted); font-size: 0.95rem; margin: 0; }
.card-post .more { margin-top: auto; font-weight: 600; font-size: 0.9rem; }

/* ---------- Archive headers ---------- */
.archive-head { margin-bottom: 28px; }
.archive-head h1 { margin-bottom: 0.25em; }
.archive-head .desc { color: var(--muted); max-width: 70ch; }

/* ---------- Single ---------- */
.article-head h1 { font-size: 2.15rem; margin-bottom: 0.35em; }
.post-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 0.88rem; margin-bottom: 24px; }
.post-meta .author { font-weight: 600; color: var(--fg); }
.post-meta .author a { color: var(--fg); }
.post-meta .author a:hover { color: var(--accent); }
.feat { margin: 0 0 28px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.feat img { width: 100%; }
.entry { overflow-wrap: break-word; }
.entry > *:last-child { margin-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; }
.table-wrap table { margin-bottom: 0; }
.note {
  margin: 32px 0;
  padding: 18px 22px;
  background: #f6ecd9;
  border: 1px solid var(--ochre);
  border-left-width: 4px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.note > *:last-child { margin-bottom: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0; }
.tags a {
  display: inline-block;
  padding: 0.3em 0.95em;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
}
.tags a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.bio { display: flex; gap: 18px; padding: 22px; margin: 32px 0; align-items: flex-start; }
.bio .avatar { flex-shrink: 0; }
.bio .avatar img { border-radius: 50%; width: 64px; height: 64px; }
.bio h3 { margin-bottom: 4px; font-size: 1.05rem; }
.bio p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.related { margin-top: 44px; }
.related h2 { font-size: 1.4rem; margin-bottom: 20px; }
.card-mini { overflow: hidden; display: flex; flex-direction: column; }
.card-mini .thumb { display: block; aspect-ratio: var(--thumb-ratio); overflow: hidden; background: var(--border); }
.card-mini .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-mini .pad { padding: 14px 16px 16px; }
.card-mini h3 { margin: 0; font-size: 0.98rem; line-height: 1.4; }
.card-mini h3 a { color: var(--fg); }
.card-mini h3 a:hover { color: var(--accent); text-decoration: none; }
.card-mini .date { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }

/* ---------- Comments ---------- */
.comments { margin-top: 48px; padding-top: 8px; }
.comments h2 { font-size: 1.4rem; }
.comment-list { list-style: none; padding: 0; margin: 0 0 32px; }
.comment-list .children { list-style: none; margin-left: 24px; }
.comment-body {
  padding: 18px 20px;
  margin-bottom: 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.comment-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.comment-meta .fn { font-weight: 600; color: var(--fg); }
.comment-content p:last-child { margin-bottom: 0; }
.reply { font-size: 0.85rem; margin-top: 8px; }
.comment-form label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  padding: 0.6em 0.9em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
}
.comment-form input:focus, .comment-form textarea:focus { outline: 2px solid var(--ochre); outline-offset: 1px; }
.comment-form .form-submit .submit {
  padding: 0.65em 1.6em;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
.comment-form .form-submit .submit:hover { background: var(--accent-dark); }

/* ---------- Sidebar ---------- */
.side-box { padding: 22px; margin-bottom: var(--gap); }
.side-box h2, .side-box h3 { font-size: 1.05rem; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--ochre); }
.side-box ul { list-style: none; margin: 0; padding: 0; }
.side-box li { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.side-box li:last-child { border-bottom: 0; }
.side-box li a { color: var(--fg); }
.side-box li a:hover { color: var(--accent); }
.side-box .count { color: var(--muted); font-size: 0.82rem; }
.side-box .recent .date { display: block; font-size: 0.78rem; color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { margin-top: 40px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pagination .page-numbers {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 12px;
  background: var(--paper); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); font-weight: 600; font-size: 0.92rem;
}
.pagination .page-numbers.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination a.page-numbers:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 0;
  background: #f2e9d8;
  border-top: 3px solid var(--ochre);
  padding: 48px 0 28px;
}
.foot-grid { display: flex; flex-wrap: wrap; gap: 24px; }
.foot-brand { flex: 1 1 180px; min-width: 0; }
.foot-name { font-size: 1.2rem; font-weight: 700; color: var(--fg); letter-spacing: -0.01em; }
.foot-name:hover { color: var(--accent); text-decoration: none; }
.foot-group { flex: 1 1 200px; min-width: 0; }
.foot-group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 20px;
}
.foot-group ul { list-style: none; margin: 0; padding: 0; }
.foot-group li { margin-bottom: 14px; }
.foot-group a { color: var(--fg); font-size: 0.94rem; line-height: 1.45; }
.foot-group a:hover { color: var(--accent); }
.foot-group li span { color: var(--muted); font-size: 0.94rem; line-height: 1.45; }
.foot-base {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}
.foot-note { margin: 0; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 64px 0; }
.notfound h1 { font-size: 2.4rem; }
.notfound p { color: var(--muted); max-width: 52ch; margin-left: auto; margin-right: auto; }
.notfound .search-form { max-width: 460px; margin: 24px auto 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .grid-related { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; }
  .foot-grid { flex-direction: column; }
  .foot-brand, .foot-group { flex-basis: auto; }
  .menu-toggle { display: inline-flex; }
  .nav-wrap { display: none; width: 100%; order: 3; }
  .nav-wrap.open { display: block; }
  .site-header .fx-between { flex-wrap: wrap; padding: 10px 0; min-height: 0; }
  .menu { flex-direction: column; align-items: stretch; gap: 2px; padding-bottom: 12px; }
  .menu li { display: flex; flex-wrap: wrap; align-items: center; }
  .menu li > a { flex: 1; }
  .menu .sub-menu {
    position: static; display: none; width: 100%; min-width: 0;
    border: 0; box-shadow: none; background: var(--bg); padding: 4px 0 4px 14px;
  }
  .menu li.open > .sub-menu { display: block; }
  .menu li:hover > .sub-menu, .menu li:focus-within > .sub-menu { display: none; }
  .menu li.open:hover > .sub-menu, .menu li.open:focus-within > .sub-menu { display: block; }
  .submenu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .hero { padding: 52px 0 42px; }
  .hero h1 { font-size: 2rem; }
}
@media (max-width: 640px) {
  .grid-cards { grid-template-columns: 1fr; }
  .grid-related { grid-template-columns: 1fr; }
  h1 { font-size: 1.8rem; }
  .hero h1 { font-size: 1.7rem; }
  .article-head h1 { font-size: 1.7rem; }
  .bio { flex-direction: column; }
}
