/* Prefer installed fonts; optional webfont never swaps into already visible text. */
@font-face {
  font-family: 'JL Times New Roman';
  src: url('/assets/fonts/times.ttf?v=2.0.5') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: optional;
}

/* Public-only palette. The two editable colors are initialized by D1 migration. */
:root {
  /* Primary Colors */
  --primary: #0658FA;
  --primary-hover: #0B49C4;
  --primary-light: #4385FF;
  --primary-soft: #EBF3FE;
  --accent: #009CFF;

  /* Background Colors */
  --background: #FEFEFE;
  --sidebar: #FFFFFF;
  --surface: #F6F6F8;
  --surface-hover: #F1F3F5;
  --surface-blue: #EBF3FE;

  /* Dark Colors */
  --navy: #03132A;
  --navy-deep: #020E1E;
  --navy-light: #14263E;

  /* Border Colors */
  --border: #E5E7EB;
  --border-strong: #CBD5E1;
  --border-dark: #24354B;

  /* Text Colors */
  --text-primary: #0C1018;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --text-light: #FFFFFF;

  /* Semantic Colors */
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #0658FA;
  --purple: #6347F9;

  /* Gradients */
  --blue-gradient: linear-gradient(120deg, #009CFF 0%, #0658FA 55%, #0B49C4 100%);
  --navy-gradient: linear-gradient(135deg, #03132A 0%, #020E1E 100%);
  --soft-gradient: linear-gradient(120deg, #EBF3FE 0%, #F6F6F8 100%);

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(3, 19, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(3, 19, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(3, 19, 42, 0.12);

  --sans: Tahoma, 'JL Tahoma', 'Segoe UI', Arial, sans-serif;
  --serif: 'Times New Roman', 'JL Times New Roman', Georgia, serif;
  --radius: 12px;
}

/* Foundations */
*, *::before, *::after {
  box-sizing: border-box;
}
html {
  scroll-padding-top: 20px;
}
body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font: 17px/1.65 var(--serif);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* Keep the footer at the bottom on short public pages. */
.public {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.public > main {
  flex: 1 0 auto;
}
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
a {
  color: var(--primary);
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}
h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}
h1, h2, h3, h4, h5, h6 {
  color: var(--navy);
  line-height: 1.23;
}
h1 {
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -.025em;
}
h2 {
  font-size: 25px;
}
h3 {
  font-size: 21px;
}
small, .muted {
  color: var(--text-secondary);
}
img {
  max-width: 100%;
}
.wrap {
  width: min(1180px, calc(100% - 64px));
  margin-inline: auto;
}
.sr, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: absolute;
  inset: 10px auto auto 16px;
  z-index: 20;
  padding: 10px 16px;
  background: var(--primary);
  color: var(--text-light);
  border-radius: 6px;
}

/* Header and primary navigation */
.mast {
  background: var(--sidebar);
  border-top: 3px solid var(--primary);
  border-bottom: 1px solid var(--border);
}
.mast-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-height: 88px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--navy);
}
.brand:hover {
  color: var(--navy);
  text-decoration: none;
}
.brand img {
  width: 45px;
  height: 45px;
  flex-shrink: 0;
  object-fit: contain;
}
.brand span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.brand b {
  display: block;
  font-size: clamp(25px, 3vw, 32px);
  line-height: 1.15;
  letter-spacing: -.025em;
}
.mast nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mast nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--navy);
  text-decoration: none;
}
.mast nav a:hover {
  background-color: var(--surface);
  color: var(--primary-hover);
  text-decoration: none;
}
.mast nav a[aria-current] {
  background-color: var(--primary-soft);
  color: var(--primary);
}
.mast nav a[aria-current]:hover {
  background-color: var(--surface-blue);
  color: var(--primary-hover);
}

/* Main layout and sections */
.editorial-main {
  padding-block: 36px 56px;
}
.editorial-heading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.editorial-content > .editorial-heading {
  margin-bottom: 0;
}
.editorial-heading p {
  max-width: 72ch;
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 18px;
  overflow-wrap: anywhere;
}
.editorial-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(255px, 310px);
  align-items: start;
  gap: 32px;
}
.editorial-content, .editorial-sidebar {
  display: grid;
  gap: 26px;
  min-width: 0;
}
.editorial-sidebar {
  gap: 18px;
}
.editorial-section {
  min-width: 0;
  scroll-margin-top: 20px;
}
.editorial-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-strong);
}
.editorial-section-head h2 {
  font-size: 24px;
  overflow-wrap: anywhere;
}
.editorial-section-head > a, .editorial-section-head > span {
  font-size: 15px;
}
.editorial-panel, .post-card, .side-widget {
  min-width: 0;
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

/* Articles: comfortable editorial rhythm without excessive decoration. */
.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.post-grid > .post-card:only-child {
  grid-column: 1 / -1;
}
.post-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 24px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.post-card:hover, .post-card:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.post-card h3 {
  font-size: clamp(22px, 2.3vw, 27px);
  letter-spacing: -.015em;
}
.post-card p {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
}
.post-meta {
  font-size: 14px;
  color: var(--text-secondary);
}
.text-link {
  display: inline-block;
  font-weight: 700;
  font-size: 15px;
}
.post-card > .text-link {
  margin-top: auto;
  padding-top: 5px;
}

/* Sidebar */
.side-widget {
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.side-widget h2, .side-widget-empty h2 {
  font-size: 21px;
  padding-bottom: 11px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.search {
  display: flex;
  gap: 7px;
}
.search input {
  flex: 1;
  width: 0;
  min-width: 0;
  min-height: 43px;
  padding: 8px 10px;
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}
.search input:hover {
  border-color: var(--border-strong);
}
.search input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
@media (forced-colors: active) {
  .search input:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}
.search button, .primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 43px;
  padding: 9px 15px;
  background: var(--primary);
  color: var(--text-light);
  border: 1px solid var(--primary);
  border-radius: 7px;
  font-weight: 700;
  font-size: 16px;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}
.search button {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
}
.search button:hover, .primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--text-light);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.blogroll-list, .recent-list, .resources {
  margin: 0;
  padding: 0;
  list-style: none;
}
.blogroll-list, .recent-list {
  margin-bottom: 12px;
}
.blogroll-list li, .recent-list li {
  border-bottom: 1px solid var(--border);
}
.blogroll-list a, .recent-list a {
  display: block;
  padding: 10px 10px;
  border-radius: 8px;
  line-height: 1.45;
  font-size: 16px;
  font-weight: 700;
}
.blogroll-list a:hover, .recent-list a:hover {
  background-color: var(--surface);
  color: var(--primary-hover);
  text-decoration: none;
}
.recent-list a {
  padding-bottom: 3px;
}
.recent-list small {
  display: block;
  padding: 0 10px 10px;
  font-size: 13px;
}
.category a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--navy);
  text-decoration: none;
}
.category a + a {
  margin-top: 4px;
}
.category a:hover {
  background-color: var(--surface);
  color: var(--primary-hover);
  text-decoration: none;
}
.category a.selected {
  background-color: var(--primary-soft);
  color: var(--primary);
}
.category a.selected:hover {
  background-color: var(--surface-blue);
  color: var(--primary-hover);
}

/* Directory: text-first list, no placeholder icons or ownership badges. */
.editorial-panel.resources {
  padding-inline: 24px;
  box-shadow: var(--shadow-sm);
}
.resource {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding-block: 22px;
  border-bottom: 1px solid var(--border);
}
.resource:last-child {
  border-bottom: 0;
}
.resource-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}
.resource-title {
  display: inline-block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
}
.resource-copy p {
  margin-top: 6px;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
}
.resource-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.resource-meta span + span {
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.visit {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.visit:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  text-decoration: none;
}
/* Empty collections render a plain paragraph, never a card or list grid. */
.editorial-empty {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.side-widget-empty {
  min-width: 0;
  padding: 0 2px;
}
.side-widget-empty > .text-link {
  margin-top: 10px;
}
.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.editorial-content > .pagination {
  margin-top: 0;
}
.pagination > a, .pagination > span[aria-current] {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 14px;
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
}
.pagination a:hover {
  background: var(--primary-soft);
  border-color: var(--border-strong);
  text-decoration: none;
}
.pagination > span[aria-current] {
  background: var(--primary);
  color: var(--text-light);
  border-color: var(--primary);
}
.about {
  padding: 26px;
}
.about h3 {
  margin-top: 20px;
  font-size: 20px;
}
.about p {
  margin-top: 8px;
  max-width: 72ch;
  color: var(--text-secondary);
}

/* Single page and rich content */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 10px;
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 15px;
  overflow-wrap: anywhere;
}
.breadcrumb > * + *::before {
  content: '/';
  margin-right: 10px;
  color: var(--text-secondary);
}
.single-post {
  padding: clamp(23px, 4vw, 46px);
}
.single-post h1 {
  font-size: clamp(29px, 4vw, 44px);
  margin-bottom: 12px;
}
.detail-description {
  white-space: pre-wrap;
  margin-block: 16px;
  font-size: 18px;
}
.detail-meta {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(0, 3fr);
  margin-block: 20px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 16px;
}
.detail-meta dt, .detail-meta dd {
  padding: 11px 13px;
  margin: 0;
  overflow-wrap: anywhere;
}
.detail-meta dt {
  background: var(--primary-soft);
  color: var(--navy);
  font-weight: 700;
}
.detail-meta dt:not(:first-child), .detail-meta dd:not(:nth-child(2)) {
  border-top: 1px solid var(--border);
}
.article-body {
  margin-top: 22px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: clamp(18px, 1.6vw, 20px);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
/* Authored font choices remain stored in the editor; public reading uses one local face. */
.article-body *, .detail-description *, .resource-copy p *, .widget p * {
  font-family: var(--serif) !important;
}
.article-body p {
  margin-block: 0 1em;
}
.article-body h2, .article-body h3, .article-body h4, .article-body h5, .article-body h6 {
  margin-block: 1.35em .55em;
}
.article-body h2 {
  font-size: 28px;
}
.article-body h3 {
  font-size: 23px;
}
.article-body a, .resource-copy p a, .detail-description a, .widget p a {
  color: var(--primary);
  text-decoration: underline;
  overflow-wrap: anywhere;
}
.article-body img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
.article-body figure {
  margin: 20px 0;
}
.article-body figcaption {
  font-size: .85em;
  color: var(--text-secondary);
}
.article-body blockquote {
  margin: 20px 0;
  padding: 12px 18px;
  border-inline-start: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 6px 6px 0;
}
.article-body blockquote > :last-child {
  margin-bottom: 0;
}
.article-body ul, .article-body ol {
  padding-inline-start: 28px;
  margin-block: 14px;
}
.article-body table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-block: 22px;
  font-size: 16px;
}
.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.article-body th {
  background: var(--primary-soft);
  color: var(--navy);
}
.article-body tbody tr:nth-child(even) {
  background: var(--surface);
}
.article-body pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 14px;
  background: var(--primary-soft);
  border-radius: 7px;
}
.article-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin-block: 24px;
}
.article-neighbors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.article-neighbors a {
  display: block;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.article-neighbors a:only-of-type {
  grid-column: 1 / -1;
}
.article-neighbors a:hover {
  background: var(--primary-soft);
  border-color: var(--border-strong);
}
.article-neighbors small {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 400;
}

/* Embedded widgets, fallback pages, and footer */
.embed {
  background: var(--sidebar);
}
.widget {
  padding: 16px;
  background: var(--sidebar);
  overflow-wrap: anywhere;
}
.widget h2 {
  font-size: 23px;
  margin-bottom: 12px;
}
.widget li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.widget li:last-child {
  border-bottom: 0;
}
.widget.grid ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 12px;
}
.widget.grid li {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.widget p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 5px;
}
.detail {
  max-width: 800px;
  padding-block: 60px;
  min-height: 65vh;
  overflow-wrap: anywhere;
}
.detail p {
  margin-block: 15px 24px;
  white-space: pre-wrap;
}
/* Public footer: one shared layout on every full page. */
.footer {
  background: var(--navy);
  color: var(--border-strong);
  border-top: 3px solid var(--primary);
  font-size: 16px;
  overflow-wrap: anywhere;
}
.footer-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  padding-block: 42px 34px;
}
.footer-identity, .footer-group {
  min-width: 0;
}
.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-light);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.2;
}
.footer-brand img {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  object-fit: contain;
}
.footer-brand img {
  background-color: var(--sidebar);
  border-radius: 7px;
  padding: 4px;
}
.footer-brand:hover {
  color: var(--text-light);
  text-decoration: none;
}
.footer-identity p {
  max-width: 42ch;
  margin-top: 14px;
  line-height: 1.6;
}
.footer-group h2 {
  color: var(--text-light);
  font-size: 18px;
  margin-bottom: 12px;
}
.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}
.footer-links a, .footer-bottom a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--border-strong);
  text-decoration: none;
}
.footer-links a:hover, .footer-bottom a:hover {
  background-color: var(--navy-light);
  color: var(--text-light);
  text-decoration: none;
}
.footer a:focus-visible {
  outline-color: var(--text-light);
  outline-offset: 3px;
}
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-block: 15px 20px;
  border-top: 1px solid var(--border-dark);
  font-size: 14px;
}

/* Responsive layouts: one readable column, then compact sidebar widgets. */
@media (max-width: 940px) {
  .wrap {
    width: calc(100% - 40px);
  }
  .editorial-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .editorial-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .mast-inner {
    gap: 12px;
  }
  .mast nav a {
    padding-inline: 10px;
  }
}
@media (max-width: 640px) {
  .wrap {
    width: calc(100% - 28px);
  }
  .mast-inner {
    flex-direction: column;
    align-items: stretch;
    padding-block: 15px 8px;
    min-height: auto;
  }
  .brand {
    align-self: flex-start;
  }
  .mast nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-top: 6px;
    border-top: 1px solid var(--border);
    gap: 2px;
  }
  .mast nav a {
    padding-inline: 3px;
    font-size: 15px;
  }
  .editorial-main {
    padding-block: 24px 36px;
  }
  .editorial-heading {
    margin-bottom: 20px;
    padding-bottom: 17px;
  }
  .editorial-heading p {
    font-size: 17px;
  }
  .editorial-content {
    gap: 22px;
  }
  .editorial-sidebar, .post-grid, .article-neighbors {
    grid-template-columns: minmax(0, 1fr);
  }
  .post-card, .side-widget, .about {
    padding: 18px;
  }
  .editorial-panel.resources {
    padding-inline: 16px;
  }
  .resource {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding-block: 18px;
  }
  .resource-title {
    font-size: 22px;
  }
  .visit {
    justify-self: start;
  }
  .single-post {
    padding: 20px;
  }
  .article-body {
    padding-top: 19px;
  }
  .article-body th, .article-body td {
    padding: 6px;
    font-size: 14px;
  }
  .footer-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 16px;
    padding-block: 30px 24px;
  }
  .footer-identity {
    grid-column: 1 / -1;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
