/*
Theme Name: Halcyon
Description: A calm, daylight-bright theme for long-form knowledge sites: editorial serif headings, a precise slate line system, one warm amber accent, and a right-hand sidebar driven entirely by templates.
*/

/* ---------------------------------------------------------------- tokens */

:root {
  --bg: #f7f5ef;
  --surface: #ede8dc;
  --surface-2: #f2eee5;
  --fg: #33404a;
  --muted: #68757f;
  --border: #c3cbd2;
  --accent: #c8862a;
  --accent-soft: #f0e2c8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(51, 64, 74, 0.06), 0 8px 24px rgba(51, 64, 74, 0.07);
  --max: 1140px;
  --gap: clamp(1.25rem, 3vw, 2.5rem);
  --media-ratio: 3 / 2;
  --font-body: "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-head: Georgia, "Times New Roman", serif;
  --step-0: clamp(1rem, 0.96rem + 0.18vw, 1.125rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.45vw, 1.5rem);
  --step-2: clamp(1.45rem, 1.3rem + 0.7vw, 2rem);
  --step-3: clamp(1.8rem, 1.55rem + 1.1vw, 2.6rem);
  --step-4: clamp(2.2rem, 1.8rem + 1.8vw, 3.4rem);
}

/* ---------------------------------------------------------------- reset */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.7;
  overflow-wrap: break-word;
}

img, svg, video { max-width: 100%; height: auto; }

a {
  color: var(--fg);
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

a:hover { color: var(--accent); text-decoration-color: var(--accent); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.25;
  color: var(--fg);
  margin: 0 0 0.6em;
}

p { margin: 0 0 1.1em; }

ul, ol { margin: 0 0 1.1em; padding-left: 1.4em; }

figure { margin: 0; }

figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.screen-reader-text {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- layout */

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

.layout {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--gap);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--gap);
  align-items: start;
}

.site-main { min-width: 0; }

.site-aside {
  position: sticky;
  top: var(--gap);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .site-aside { position: static; }
}

/* ---------------------------------------------------------------- header */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.site-header .site-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
  flex-wrap: wrap;
}

.site-title {
  font-family: var(--font-head);
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

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

.site-title a:hover { color: var(--accent); }

/* nav */

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.25rem 1.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--fg);
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav .current-menu-item > a,
.site-nav .current_page_item > a,
.site-nav .current-menu-ancestor > a {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.site-nav li { position: relative; }

.site-nav .sub-menu,
.site-nav .children {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.5rem 0;
  display: none;
  z-index: 50;
}

.site-nav li:hover > .sub-menu,
.site-nav li:focus-within > .sub-menu,
.site-nav li:hover > .children,
.site-nav li:focus-within > .children,
.site-nav li.sub-open > .sub-menu,
.site-nav li.sub-open > .children { display: block; }

.site-nav .sub-menu li,
.site-nav .children li { display: block; }

.site-nav .sub-menu a,
.site-nav .children a {
  display: block;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  border-bottom: 0;
  white-space: nowrap;
}

.site-nav .sub-menu a:hover,
.site-nav .children a:hover { background: var(--surface-2); color: var(--accent); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.8rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
}

.sub-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 0.2rem 0.4rem;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .site-nav { display: none; width: 100%; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; align-items: stretch; gap: 0; }
  .site-nav li { border-top: 1px solid var(--border); }
  .site-nav a { display: inline-block; padding: 0.7rem 0; }
  .sub-toggle { display: inline-block; float: right; margin-top: 0.55rem; }
  .site-nav .sub-menu,
  .site-nav .children {
    position: static;
    display: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0 0 0.5rem 1rem;
    background: transparent;
  }
  /* On mobile only the .sub-open class (click toggle) controls visibility —
     hover/focus-within would keep the sub-menu visible after tap and make it
     impossible to collapse. */
  .site-nav li:hover > .sub-menu,
  .site-nav li:focus-within > .sub-menu,
  .site-nav li:hover > .children,
  .site-nav li:focus-within > .children { display: none; }
  .site-nav li.sub-open > .sub-menu,
  .site-nav li.sub-open > .children { display: block; }
  .site-nav .sub-menu a,
  .site-nav .children a { white-space: normal; padding: 0.4rem 0; }
}

/* ---------------------------------------------------------------- hero (blog home) */

.hero {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.hero .site-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: var(--gap);
  align-items: center;
  padding-top: clamp(2rem, 5vw, 4rem);
  padding-bottom: clamp(2rem, 5vw, 4rem);
}

@media (max-width: 900px) {
  .hero .site-wrap { grid-template-columns: minmax(0, 1fr); }
}

.hero-title { font-size: var(--step-4); margin-bottom: 0.4em; }

.hero-lead {
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 34em;
  margin-bottom: 1.4em;
}

.hero-art { justify-self: end; max-width: 420px; width: 100%; }

@media (max-width: 900px) { .hero-art { justify-self: start; } }

/* ---------------------------------------------------------------- breadcrumb */

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.9rem 0 0;
}

.breadcrumb .crumb { color: var(--muted); text-decoration: none; }

.breadcrumb .crumb:hover { color: var(--accent); }

.breadcrumb .sep { margin: 0 0.45rem; color: var(--border); }

.breadcrumb .trail-current { color: var(--fg); }

/* ---------------------------------------------------------------- cards / grids */

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

@media (max-width: 560px) { .card-grid { grid-template-columns: minmax(0, 1fr); } }

.post-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.post-card .card-media {
  display: block;
  aspect-ratio: var(--media-ratio);
  background: var(--surface);
  overflow: hidden;
}

.post-card .card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-card .card-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }

.post-card .card-title {
  font-size: var(--step-1);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card .card-title a { text-decoration: none; }

.post-card .card-title a:hover { color: var(--accent); }

.post-card .card-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.post-card .card-excerpt {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card .card-cat {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.post-card .card-cat a { color: var(--accent); text-decoration: none; }

/* ---------------------------------------------------------------- archive headers */

.archive-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.2rem;
  margin-bottom: var(--gap);
}

.archive-title { font-size: var(--step-3); margin-bottom: 0.2em; }

.archive-description { color: var(--muted); max-width: 46em; margin: 0; }

.archive-count { font-size: 0.85rem; color: var(--muted); }

/* ---------------------------------------------------------------- pagination */

.pagination { margin-top: var(--gap); }

.pagination .nav-links { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.pagination a,
.pagination span {
  display: inline-block;
  min-width: 2.4rem;
  text-align: center;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.95rem;
  background: #fff;
}

.pagination .current { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.pagination a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- single article */

.single-article {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 3.5vw, 2.8rem);
}

.entry-title { font-size: var(--step-3); margin-bottom: 0.4em; }

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  font-size: 0.88rem;
  color: var(--muted);
  padding-bottom: 1.1rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
}

.entry-meta a { color: var(--muted); text-decoration: none; }

.entry-meta a:hover { color: var(--accent); }

.featured-media { margin: 0 0 1.6rem; }

.featured-media img {
  display: block;
  width: 100%;
  aspect-ratio: var(--media-ratio);
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.article-note {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.2rem;
  margin: 1.6rem 0 0;
  font-size: 0.95rem;
}

.article-note p:last-child { margin-bottom: 0; }

/* entry content */

.entry-content { max-width: 44em; margin-inline: auto; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.2em;
}

.table-scroll table { margin-bottom: 0; }

.entry-content h2 { font-size: var(--step-2); margin-top: 1.8em; }

.entry-content h3 { font-size: var(--step-1); margin-top: 1.6em; }

.entry-content h4 { font-size: 1.1rem; margin-top: 1.4em; }

.entry-content blockquote {
  margin: 1.4em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.entry-content code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

.entry-content pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 0 0 1.1em;
}

.entry-content pre code { background: none; border: 0; padding: 0; }

.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-size: 0.95rem;
}

.entry-content th,
.entry-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  text-align: left;
}

.entry-content th { background: var(--surface-2); font-weight: 600; }

.entry-content img { border-radius: var(--radius-sm); }

/* tags */

.entry-tags { margin-top: 1.8rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }

.entry-tags .tag-label {
  font-size: 0.82rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.6rem;
}

.entry-tags a {
  display: inline-block;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.8rem;
  margin: 0.15rem 0.2rem 0.15rem 0;
  text-decoration: none;
  color: var(--muted);
}

.entry-tags a:hover { border-color: var(--accent); color: var(--accent); }

/* author bio */

.author-bio {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 1.1rem;
  margin-top: 1.8rem;
  padding: 1.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.author-bio .avatar { border-radius: 50%; display: block; }

.author-bio .bio-name { font-size: 1.05rem; margin: 0 0 0.3rem; }

.author-bio .bio-text { margin: 0; font-size: 0.95rem; color: var(--muted); }

.author-bio .bio-link { font-size: 0.9rem; }

/* related */

.related-posts { margin-top: 2.2rem; }

.related-title { font-size: var(--step-2); margin-bottom: 1.1rem; }

/* comments */

.comments-area { margin-top: 2.2rem; padding-top: 1.6rem; border-top: 1px solid var(--border); }

.comments-title { font-size: var(--step-1); }

.comment-list {
  list-style: none;
  margin: 0 0 1.6rem;
  padding: 0;
}

.comment-list .children { list-style: none; padding-left: 1.4rem; margin: 0; border-left: 1px solid var(--border); }

.comment {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.comment .comment-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }

.comment .comment-author { font-weight: 600; color: var(--fg); font-style: normal; }

.comment .comment-content p { margin-bottom: 0.6em; }

.comment .reply { font-size: 0.85rem; }

.comment-form label { display: block; font-size: 0.9rem; margin-bottom: 0.3rem; }

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  max-width: 34rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--fg);
  margin-bottom: 1rem;
}

.comment-form input:focus,
.comment-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.comment-form .submit,
.search-submit {
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.3rem;
  font: inherit;
  cursor: pointer;
}

.comment-form .submit:hover,
.search-submit:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.comments-closed { font-size: 0.9rem; color: var(--muted); }

/* ---------------------------------------------------------------- sidebar */

.widget {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem;
  margin-bottom: var(--gap);
}

.widget-title {
  font-size: 1.05rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.widget ul { list-style: none; margin: 0; padding: 0; }

.widget li { padding: 0.3rem 0; font-size: 0.95rem; }

.widget li a { text-decoration: none; }

.widget li a:hover { color: var(--accent); }

/* search form */

.search-form { display: flex; gap: 0.5rem; }

.search-field {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--fg);
}

.search-field:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.search-submit { flex-shrink: 0; }

/* ---------------------------------------------------------------- page */

.page-article {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 3.5vw, 2.8rem);
}

/* ---------------------------------------------------------------- search / 404 */

.notice-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.6rem, 4vw, 3rem);
  max-width: 44rem;
}

.notice-panel .big-code {
  font-family: var(--font-head);
  font-size: var(--step-4);
  color: var(--border);
  margin: 0 0 0.2em;
  line-height: 1;
}

.notice-panel .search-form { margin-top: 1.4rem; }

.search-results-list { list-style: none; padding: 0; margin: 0 0 var(--gap); }

.search-results-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.search-results-list .sr-title { font-size: var(--step-1); margin-bottom: 0.25em; }

.search-results-list .sr-title a { text-decoration: none; }

.search-results-list .sr-meta { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  margin-top: calc(var(--gap) * 1.5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: calc(var(--gap) * 1.2) 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: calc(var(--gap) * 1.2) var(--gap);
  align-items: start;
}

@media (max-width: 700px) { .footer-grid { grid-template-columns: minmax(0, 1fr); } }

.footer-group h3 {
  font-family: var(--font-body);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0 0 0.8rem;
}

.footer-group ul { list-style: none; margin: 0; padding: 0; }

.footer-group li { margin-bottom: 0.45rem; }

.footer-group a { text-decoration: none; font-size: 0.92rem; color: var(--muted); }

.footer-group a:hover { color: var(--accent); }

.footer-bottom {
  margin-top: calc(var(--gap) * 1.4);
  padding-top: calc(var(--gap) * 0.9);
  border-top: 1px solid var(--border);
}

.footer-bottom .copyright { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.35rem; }

.footer-bottom .footer-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
}

@media (max-width: 900px) { .footer-bottom .footer-note { white-space: normal; } }
