/*
Theme Name: ICW Journal
Theme URI: https://integralcalculatorworld.com/blog/
Author: Integral Calculator World
Author URI: https://integralcalculatorworld.com/
Description: A lightweight editorial theme matching the Integral Calculator World interface.
Version: 1.0.3
Requires at least: 6.6
Requires PHP: 8.2
Text Domain: icw-journal
*/

:root {
  --bg: #f0ebe0;
  --bg-grid: #e8e2d5;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --teal: #1a5276;
  --teal-dark: #154360;
  --teal-light: #2e86c1;
  --orange: #c0392b;
  --orange-hover: #a93226;
  --border: #cdd9dd;
  --border-strong: #b8c4c8;
  --text: #2c3e50;
  --text-soft: #5d6d7e;
  --text-muted: #7b8b94;
  --preview-bg: #fdfcf8;
  --tab-active: #dde8f0;
  --serif: 'Merriweather', Georgia, serif;
  --sans: 'Source Sans 3', 'Segoe UI', sans-serif;
  --mono: 'Fira Code', Consolas, monospace;
  --shadow: 0 2px 12px rgba(22, 54, 70, 0.08);
  --shadow-lifted: 0 16px 38px rgba(22, 54, 70, 0.13);
  --radius: 8px;
  --shell: 1120px;
}

html.icw-dark-preload,
body.dark-mode {
  --bg: #0d1117;
  --bg-grid: #161b22;
  --surface: #161b22;
  --surface-soft: #1c2128;
  --teal: #58a6ff;
  --teal-dark: #388bfd;
  --teal-light: #79c0ff;
  --orange: #f85149;
  --orange-hover: #da3633;
  --border: #30363d;
  --border-strong: #3d444d;
  --text: #c9d1d9;
  --text-soft: #8b949e;
  --text-muted: #7d8590;
  --preview-bg: #0d1117;
  --tab-active: #1f2937;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
  --shadow-lifted: 0 16px 38px rgba(0, 0, 0, 0.34);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(184, 196, 200, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(184, 196, 200, 0.12) 1px, transparent 1px);
  background-size: 32px 32px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.dark-mode {
  color-scheme: dark;
}

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

a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--teal-light);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--teal-light);
  outline-offset: 3px;
  border-radius: 3px;
}

::selection {
  color: #fff;
  background: var(--teal);
}

.site-shell {
  width: min(calc(100% - 36px), var(--shell));
  margin-inline: auto;
}

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

.skip-link:focus {
  position: fixed;
  z-index: 10000;
  top: 12px;
  left: 12px;
  width: auto;
  height: auto;
  padding: 10px 14px;
  clip: auto;
  color: #fff;
  background: var(--teal-dark);
}

.site-header {
  position: sticky;
  z-index: 1000;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  min-height: 76px;
  align-items: center;
  gap: 28px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.site-brand:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.brand-copy {
  display: grid;
  line-height: 1.08;
}

.brand-copy strong {
  color: var(--text);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.primary-navigation {
  justify-self: center;
}

.primary-menu {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.primary-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 5px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.primary-menu a:hover,
.primary-menu .current-menu-item > a,
.primary-menu .current_page_item > a {
  color: var(--teal);
  background: var(--tab-active);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dark-mode-btn {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.dark-mode-btn:hover {
  border-color: var(--teal-light);
  background: var(--tab-active);
  transform: translateY(-1px);
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}

.menu-toggle > span:not(.screen-reader-text) {
  display: block;
  height: 2px;
  margin: 4px 0;
  border-radius: 2px;
  background: var(--text);
}

.button,
.wp-element-button,
.wp-block-button__link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1.5px solid var(--teal);
  border-radius: 5px;
  color: #fff;
  background: var(--teal);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.13);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.button:hover,
.wp-element-button:hover,
.wp-block-button__link:hover {
  color: #fff;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.button-small {
  min-height: 40px;
  padding: 8px 13px;
  font-size: 13px;
}

.button-secondary {
  color: var(--teal);
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: none;
}

.button-secondary:hover {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.text-link {
  font-weight: 700;
  text-decoration: none;
}

.site-main {
  min-height: 55vh;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  align-items: center;
  gap: 34px;
  padding-block: 64px 48px;
}

.hero-copy,
.formula-card {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #27ae60;
  box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.12);
}

.hero-copy h1,
.archive-header h1,
.article-header h1,
.not-found-card h1 {
  max-width: 760px;
  margin: 0;
  color: var(--teal);
  font-family: var(--serif);
  font-size: clamp(2.15rem, 5vw, 4.25rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.hero-copy > p {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 28px;
}

.formula-card,
.info-card,
.post-card,
.empty-state,
.article-card,
.not-found-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.formula-card {
  position: relative;
  padding: 28px;
  overflow: hidden;
}

.formula-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--orange);
  content: '';
}

.formula-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.formula {
  margin: 22px 0 16px;
  color: var(--teal);
  font-family: var(--serif);
  font-size: clamp(1.4rem, 3vw, 2.05rem);
  font-weight: 700;
  white-space: nowrap;
}

.formula-card p {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: 14px;
}

.formula-card a {
  font-weight: 700;
  text-decoration: none;
}

.topic-section {
  margin-bottom: 38px;
  padding: 18px 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.compact-heading {
  align-items: center;
  margin: 0;
}

.section-heading h2,
.info-card h2,
.empty-state h3,
.article-cta h2 {
  margin: 0;
  color: var(--teal);
  font-family: var(--serif);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.section-heading p {
  margin: 7px 0 0;
  color: var(--text-soft);
}

.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-pills a,
.category-tag,
.tag-list a {
  display: inline-flex;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--teal);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.topic-pills a:hover,
.category-tag:hover,
.tag-list a:hover {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.content-section {
  padding-bottom: 48px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.post-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.post-card:hover {
  border-color: var(--teal-light);
  box-shadow: var(--shadow-lifted);
  transform: translateY(-3px);
}

.post-card-media {
  display: grid;
  min-height: 168px;
  place-items: center;
  overflow: hidden;
  color: var(--teal);
  background:
    radial-gradient(circle at 80% 20%, rgba(46, 134, 193, 0.2), transparent 32%),
    linear-gradient(145deg, var(--preview-bg), var(--tab-active));
  text-decoration: none;
}

.post-card-media img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  transition: transform 0.3s;
}

.post-card:hover .post-card-media img {
  transform: scale(1.025);
}

.post-card-placeholder {
  font-family: var(--serif);
  font-size: 72px;
  font-weight: 700;
  opacity: 0.72;
}

.post-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 19px;
}

.post-card-meta,
.post-card-footer,
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--text-muted);
  font-size: 12px;
}

.post-card h2 {
  margin: 14px 0 9px;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.38;
  letter-spacing: -0.02em;
}

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

.post-card h2 a:hover {
  color: var(--teal);
}

.post-card-excerpt {
  color: var(--text-soft);
  font-size: 14px;
}

.post-card-excerpt p {
  margin: 0;
}

.post-card-footer {
  justify-content: space-between;
  padding-top: 17px;
  margin-top: auto;
}

.post-card-footer a {
  font-weight: 700;
  text-decoration: none;
}

.empty-state {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 26px;
}

.empty-mark,
.info-icon {
  display: inline-grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 700;
}

.empty-state p,
.info-card p {
  margin: 6px 0 0;
  color: var(--text-soft);
}

.trust-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding-bottom: 68px;
}

.info-card {
  padding: 22px;
}

.info-card .info-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 17px;
  font-size: 19px;
}

.info-card h2 {
  font-size: 17px;
}

.page-spacing {
  padding-block: 54px 70px;
}

.archive-header {
  padding: 28px 0 34px;
}

.archive-header h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.archive-header p,
.archive-description {
  max-width: 680px;
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 17px;
}

.archive-grid {
  margin-top: 26px;
}

.pagination {
  margin-top: 32px;
  text-align: center;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.page-numbers {
  display: inline-grid;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  text-decoration: none;
}

.page-numbers.current,
.page-numbers:hover {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.article-shell {
  max-width: 940px;
  padding-block: 54px 72px;
}

.article-card {
  overflow: hidden;
}

.article-header {
  padding: clamp(28px, 6vw, 62px);
  border-bottom: 1.5px solid var(--border);
  background: var(--surface-soft);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--text-muted);
  font-size: 13px;
}

.breadcrumbs a {
  text-decoration: none;
}

.article-header h1 {
  color: var(--text);
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.article-meta {
  margin-top: 20px;
}

.article-hero {
  margin: 0;
  background: var(--preview-bg);
}

.article-hero img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: cover;
}

.article-content {
  max-width: 760px;
  padding: clamp(28px, 6vw, 62px);
  margin-inline: auto;
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.9;
}

.article-content > *:first-child {
  margin-top: 0;
}

.article-content h2,
.article-content h3,
.article-content h4 {
  margin: 1.75em 0 0.65em;
  color: var(--teal);
  font-family: var(--serif);
  line-height: 1.3;
}

.article-content h2 {
  font-size: clamp(1.55rem, 3vw, 2.05rem);
}

.article-content h3 {
  font-size: 1.35rem;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content pre,
.article-content figure,
.article-content table {
  margin-block: 1.2em;
}

.article-content a {
  font-weight: 700;
}

.article-content code,
.article-content pre {
  font-family: var(--mono);
}

.article-content code {
  padding: 0.12em 0.35em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-soft);
  font-size: 0.87em;
}

.article-content pre {
  max-width: 100%;
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--preview-bg);
  font-size: 14px;
  line-height: 1.65;
}

.article-content blockquote {
  padding: 4px 0 4px 20px;
  border-left: 4px solid var(--orange);
  color: var(--text-soft);
  font-style: italic;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 15px;
}

.article-content th,
.article-content td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-content th {
  color: var(--teal);
  background: var(--surface-soft);
}

.article-footer {
  padding: 0 clamp(28px, 6vw, 62px) clamp(28px, 6vw, 62px);
}

.tag-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 28px;
  color: var(--text-muted);
  font-size: 13px;
}

.article-cta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 24px;
  border: 1.5px solid var(--border);
  border-left: 5px solid var(--orange);
  border-radius: 6px;
  background: var(--preview-bg);
}

.article-cta p {
  margin: 7px 0 0;
  color: var(--text-soft);
}

.post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.post-navigation a {
  display: grid;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.post-navigation div:last-child {
  text-align: right;
}

.post-navigation span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.page-card .article-content {
  max-width: 820px;
}

.not-found-card {
  max-width: 720px;
  padding: clamp(34px, 8vw, 76px);
  margin: 30px auto;
  text-align: center;
}

.error-code {
  display: block;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.not-found-card .empty-mark {
  margin: 20px auto;
}

.not-found-card h1 {
  color: var(--text);
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.not-found-card > p {
  color: var(--text-soft);
}

.centered-actions {
  justify-content: center;
}

.site-footer {
  border-top: 1.5px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, var(--bg));
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 48px;
  padding-block: 44px 34px;
}

.footer-brand > p {
  max-width: 440px;
  margin: 16px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.site-footer h2 {
  margin: 0 0 12px;
  color: var(--teal);
  font-family: var(--serif);
  font-size: 15px;
}

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

.footer-links li + li {
  margin-top: 7px;
}

.footer-links a {
  color: var(--text-soft);
  font-size: 14px;
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--teal);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-block: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.footer-bottom p {
  margin: 0;
}

@media (max-width: 980px) {
  .header-inner {
    grid-template-columns: auto auto 1fr;
  }

  .menu-toggle {
    display: block;
    justify-self: end;
    order: 2;
  }

  .header-actions {
    justify-self: end;
    order: 1;
  }

  .primary-navigation {
    position: absolute;
    top: calc(100% + 1px);
    right: 18px;
    left: 18px;
    display: none;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 0 0 8px 8px;
    background: var(--surface);
    box-shadow: var(--shadow-lifted);
  }

  .primary-navigation.is-open {
    display: block;
  }

  .primary-menu {
    display: grid;
    gap: 3px;
  }

  .primary-menu a {
    padding: 11px 12px;
  }

  .hero-section {
    grid-template-columns: 1fr;
  }

  .formula-card {
    max-width: 620px;
  }

  .post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trust-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .site-shell {
    width: min(calc(100% - 24px), var(--shell));
  }

  .site-header {
    position: relative;
  }

  .header-inner {
    min-height: 68px;
    gap: 8px;
  }

  .brand-mark {
    width: 39px;
    height: 39px;
    flex-basis: 39px;
    font-size: 24px;
  }

  .brand-copy strong {
    font-size: 13px;
  }

  .brand-copy small {
    font-size: 8px;
  }

  .header-actions .button {
    display: none;
  }

  .hero-section {
    gap: 26px;
    padding-block: 42px 32px;
  }

  .hero-copy h1 {
    font-size: clamp(2.1rem, 12vw, 3.15rem);
  }

  .hero-copy > p {
    font-size: 16px;
  }

  .hero-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .formula-card {
    padding: 22px;
  }

  .formula {
    white-space: normal;
  }

  .compact-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .post-grid,
  .trust-grid,
  .footer-grid,
  .post-navigation {
    grid-template-columns: 1fr;
  }

  .empty-state {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .article-header,
  .article-content,
  .article-footer {
    padding: 25px;
  }

  .article-content {
    font-size: 16px;
  }

  .article-cta {
    grid-template-columns: 1fr;
  }

  .post-navigation div:last-child {
    text-align: left;
  }

  .footer-grid {
    gap: 30px;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
