/* ---------------------------
 AK//Journal Theme Base
 Optimized Version
 --------------------------- */

/* ========================================
   1) CSS TOKENS
   ======================================== */

:root {
  --maxw: 780px;

  /* Fonts */
  --font-display: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Light theme colors (default) */
  --bg: #FFFFFF;
  --title: #111111;
  --text: #2A2A2A;
  --muted: #666666;
  --divider: #0000002E;
  --accent: #8655E0;

  /* Spacing scale */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;

  /* Color scheme preference */
  color-scheme: light dark;

  /* SVG icon masks */
  --ak-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor' %3E%3Cpath fill-rule='evenodd' d='M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z' clip-rule='evenodd' /%3E%3C/svg%3E");
  --ak-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='currentColor' viewBox='0 0 24 24' %3E%3Cpath d='M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z' /%3E%3C/svg%3E");
  --ak-external-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2.5' stroke='gray'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M4.5 19.5l15-15m0 0H8.25m11.25 0v11.25' /%3E%3C/svg%3E");

  /* Code block colors */
  --code-header-bg: #e8e8ec;
  --code-body-bg: rgba(127, 127, 127, 0.08);
  --code-highlight-bg: #DDDDDD;
}

/* Dark theme overrides */
:root[data-theme="dark"] {
  --bg: #100F0F;
  --title: #CECDC3;
  --text: #CECDC3;
  --muted: #878580;
  --divider: #CECDC340;
  --accent: #BB9AF7;
  --code-header-bg: #151515;
  --code-body-bg: #1A1A1A;
  --code-highlight-bg: #333333;
}


/* ========================================
   2) BASE STYLES
   ======================================== */

html,
body {
  background: var(--bg);
}

body {
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

p {
  margin: 0 0 var(--space-3);
  color: var(--text);
}

/* Base list styling */
ul,
ol {
  margin: 0 0 var(--space-3);
  color: var(--text);
}

li {
  margin-bottom: var(--space-2);
}

td {
    color: var(--text);
}

blockquote, blockquote p {
  color: var(--title) !important;
}

cite {
  color: var(--muted) !important;
}
/* ========================================
   3) CONTENT LISTS (CONSOLIDATED)
   ======================================== */

:is(.entry-content, .elementor-widget-text-editor, .elementor-widget-theme-post-content, 
    .elementor-widget-post-content, .wp-block-post-content) {
  
  ul {
    padding-inline-start: 18px;
  }

  ol {
    padding-inline-start: 24px;
  }

  li {
    margin-bottom: 0.35em;
    color: var(--text);
  }

  li:last-child {
    margin-bottom: 0;
  }

  /* Nested lists */
  li > :is(ul, ol) {
    margin-top: 0.35em;
    margin-bottom: 0;
  }

  /* Paragraphs inside list items */
  li p {
    margin-bottom: 0.5em;
  }

  li p:last-child {
    margin-bottom: 0;
  }
}

/* Mobile adjustments */
@media (max-width: 767px) {
  :is(.entry-content, .elementor-widget-text-editor, .elementor-widget-theme-post-content, 
      .elementor-widget-post-content, .wp-block-post-content) {
    
    ul {
      padding-inline-start: 14px;
    }

    ol {
      padding-inline-start: 18px;
    }

    li {
      margin-bottom: 0.3em;
    }
  }
}

/* Remove unwanted button hover effects */
:is([type=button], [type=submit], button):is(:focus, :hover) {
  background-color: unset;
}

/* ========================================
   4) LAYOUT
   ======================================== */

.ak-container,
.elementor-section.elementor-section-boxed > .elementor-container,
.elementor-container {
  max-width: var(--maxw);
}

/* Ensure left alignment */
.elementor-widget,
.elementor-widget-container,
.elementor-heading-title,
.elementor-text-editor {
  text-align: left;
}

/* ========================================
   5) TYPOGRAPHY
   ======================================== */

:is(h1, h2, h3, h4) {
  color: var(--title);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

:is(h2, h3, h4) {
  margin-block-end: 1rem;
  margin-block-start: 3rem;
}

.elementor-heading-title {
  color: var(--title) !important;
}

/* ========================================
   6) LINKS
   ======================================== */

/* Nav/Footer: no underline */
:is(header, footer, nav) a {
  color: var(--muted);
  text-decoration: none;
}

:is(header, footer, nav) a:hover {
  color: var(--accent);
}

/* Active nav item */
a.elementor-item.elementor-item-active {
  color: var(--title);
}

/* Content links: fill-from-bottom animation */
:is(.elementor-widget-text-editor, .elementor-widget-theme-post-content,
    .elementor-widget-post-content, .wp-block-post-content, .entry-content, .ak-tax-item) a {
  color: var(--title);
  background-image: linear-gradient(var(--accent), var(--accent)) !important;
  background-repeat: no-repeat !important;
  background-position: 0% 100% !important;
  background-size: 100% 1px !important;
  text-decoration: none !important;
  transition: background-size 0.425s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.425s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 2px;
  margin: 0 -2px;
  border-radius: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

:is(.elementor-widget-text-editor, .elementor-widget-theme-post-content, 
    .elementor-widget-post-content, .wp-block-post-content, .entry-content, .ak-tax-item) a:hover {
  background-size: 100% 100% !important;
  color: var(--bg) !important;
}

/* WP default loop: post list title */
.page-content .post .entry-title a {
  color: var(--accent);
  text-decoration: none;
}

.page-content .post .entry-title a:hover {
  opacity: 0.9;
}

/* Utility muted class */
.muted,
.muted * {
  color: var(--muted) !important;
}

/* ========================================
   7) DIVIDERS
   ======================================== */

:is(hr, .ak-divider, span.elementor-divider-separator) {
  border: 0;
  border-top: 1px solid var(--divider);
  margin: var(--space-5) 0;
}

/* ========================================
   8) CODE INLINE
   ======================================== */

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* ========================================
   9) NOTES LIST UTILITY
   ======================================== */

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

.ak-list-item a {
  display: block;
  padding: 10px 0;
  text-decoration: none;
}

.ak-list-date {
  color: var(--muted);
  display: inline-block;
  min-width: 140px;
}

.ak-list-title {
  color: var(--title);
}

.ak-list-item a:hover .ak-list-title {
  color: var(--accent);
}

.ak-list-item a:hover .ak-list-date {
  color: var(--muted);
}

/* ========================================
   10) DARK/LIGHT THEME TOGGLE
   ======================================== */

.ak-theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.ak-theme-toggle__track {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  box-sizing: border-box;
  border: 1px solid var(--divider);
  background: rgba(127, 127, 127, 0.14);
  transition: background-color 160ms ease, border-color 160ms ease;
}

.ak-theme-toggle__thumb {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  position: relative;
  background: var(--muted);
  transform: translateX(0);
  transition: transform 160ms ease, background-color 160ms ease;
}

:root[data-theme="dark"] .ak-theme-toggle__thumb {
  transform: translateX(18px);
}

.ak-theme-toggle__thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px;
  height: 12px;
  background-color: var(--bg);
  -webkit-mask: var(--ak-sun) no-repeat center / contain;
  mask: var(--ak-sun) no-repeat center / contain;
}

:root[data-theme="dark"] .ak-theme-toggle__thumb::before {
  -webkit-mask: var(--ak-moon) no-repeat center / contain;
  mask: var(--ak-moon) no-repeat center / contain;
}

.ak-theme-toggle:focus-visible .ak-theme-toggle__track {
  outline: 2px solid rgba(56, 150, 198, 0.45);
  outline-offset: 3px;
}

/* ========================================
   11) LOOP TITLE (WIDGET)
   ======================================== */

.ak-title-link {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.35;
  color: var(--title);
  text-decoration: none;
}

.ak-title-link:hover {
  color: var(--accent);
}

/* Latest note title override */
#latest-post .ak-title-link {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* Underline option for loop title */
.ak-title-link--underline {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* ========================================
   12) TAXONOMY LIST (DOMAINS/TOPICS)
   ======================================== */

.ak-tax-excerpt {
  color: var(--muted);
}

.ak-tax-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.ak-tax-item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.ak-tax-link {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.ak-domain-topic a {
  color: var(--muted);
}

.ak-tax-list .ak-tax-link {
  color: var(--text);
}

.ak-tax-count {
  font-size: 12px;
  opacity: 0.7;
}

/* ========================================
   13) CODE BLOCKS
   ======================================== */

/* Wrapper */
.ak-code-wrap {
  position: relative;
  margin: var(--space-4) 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--divider);
}

/* Header bar */
.ak-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--code-header-bg);
  border-bottom: 1px solid var(--divider);
  min-height: 38px;
}

/* Language label */
.ak-code-lang {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  user-select: none;
  line-height: 1;
}

.ak-code-lang:empty {
  display: none;
}

.ak-code-header:has(.ak-code-lang:empty) {
  justify-content: flex-end;
}

/* Copy button */
.ak-code-copy {
  font: 12px/1 var(--font-body);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.12);
  border: 1px solid var(--divider);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.ak-code-copy:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--divider));
}

/* Pre block inside wrapper */
.ak-code-wrap pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--code-body-bg);
  padding: var(--space-3);
  font-size: 0.8em;
  overflow-x: auto;
}

/* Standalone pre (not inside ak-code-wrap) */
pre:not(.ak-code-wrap pre) {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: var(--code-body-bg);
  padding: var(--space-3);
  border-radius: 10px;
  overflow-x: auto;
  border: 1px solid var(--divider);
}

/* hljs background override */
:root[data-theme="light"] .ak-code-wrap .hljs,
:root[data-theme="dark"] .ak-code-wrap .hljs {
  background: transparent;
}

/* Highlight color override */
.hljs > mark.shcb-loc {
    background-color: var(--code-highlight-bg) !important;
}

/* Line numbers */
.ak-code-wrap .hljs .hljs-ln-numbers {
  user-select: none;
  padding-right: var(--space-3);
  color: var(--muted);
  opacity: 0.5;
}

/* Scrollbar styling */
.ak-code-wrap pre {
  padding-bottom: 0;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.ak-code-wrap pre:hover {
  scrollbar-color: color-mix(in srgb, var(--muted) 50%, transparent) transparent;
}

.ak-code-wrap pre code {
  display: block;
  padding-bottom: 16px;
}

/* Webkit scrollbar */
.ak-code-wrap pre::-webkit-scrollbar {
  height: 6px;
  background: transparent;
}

.ak-code-wrap pre::-webkit-scrollbar-track {
  background: transparent;
}

.ak-code-wrap pre::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}

.ak-code-wrap pre:hover::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 50%, transparent);
}

.ak-code-wrap pre:hover::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ========================================
   14) EXTERNAL LINKS
   ======================================== */

/* Title link wrap: flex so icon stays vertically centred beside single-line title */
.ak-title-link-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
}

/* Content external link wrap: inline so <a> stays inline-level,
   allowing box-decoration-break and per-line background underlines */
.ak-external-link-wrap {
  display: inline;
}

.ak-external-icon {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  flex: 0 0 auto;
  background-color: var(--muted);
  -webkit-mask: var(--ak-external-icon) no-repeat center / contain;
  mask: var(--ak-external-icon) no-repeat center / contain;
  vertical-align: middle;
  position: relative;
  top: -0.05em;
  pointer-events: none;
}

.ak-external-link-wrap .ak-external-icon {
  margin-left: 0.25em;
}

.ak-external-icon--title {
  width: 0.95em;
  height: 0.95em;
  margin-left: 0.25em;
}

/* Keep icon muted even when link text is hovered */
/* Loop title links only — keep icon muted (no fill animation here) */
.ak-title-link-wrap:hover .ak-external-icon {
  background-color: var(--muted);
  transition: none;
}


/* ========================================
   15) BLOCKQUOTES
   ======================================== */

/* ---- wp-block-quote: Double-slash SVG icon + vertical line ---- */
.wp-block-quote {
  position: relative !important;
  padding: 0.35rem 0 0.35rem 3rem !important;
  margin: var(--space-5) 0 !important;
  border: none !important;
  border-left: none !important;
  background: transparent !important;
  overflow: visible !important;
}

/* "//" as two parallelogram shapes — same mask method as pullquote */
.wp-block-quote::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 1.5rem;
  height: 1.25rem;
  background-color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 32'%3E%3Cpath d='M0 32L4 32L14 0L10 0Z M10 32L14 32L24 0L20 0Z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 32'%3E%3Cpath d='M0 32L4 32L14 0L10 0Z M10 32L14 32L24 0L20 0Z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* Vertical line below the icon */
.wp-block-quote::after, .wp-block-pullquote::after {
  content: "";
  position: absolute;
  left: 0.6875rem;
  top: 2.2rem;
  width: 1px;
  height: calc(100% - 2.2rem);
  background-color: var(--divider);
}

.wp-block-quote p {
  font-size: 1.5rem !important;
  font-style: normal !important;
  color: var(--text) !important;
  line-height: 1.55 !important;
  margin-bottom: 0.5rem !important;
}

.wp-block-quote p:last-of-type {
  margin-bottom: 0 !important;
}

.wp-block-quote cite,
.wp-block-quote .wp-block-quote__citation {
  display: block;
  margin-top: 0.875rem !important;
  font-size: 0.875rem !important;
  font-style: normal !important;
  color: var(--muted) !important;
}

/* ---- wp-block-pullquote: Classic style ---- */
.wp-block-pullquote {
  position: relative !important;
  text-align: left !important;
  padding: 0.35rem 0 0.35rem 3rem !important;
  margin: var(--space-6) 0 !important;
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  background: transparent !important;
}

/* Opening double-quote SVG icon */
.wp-block-pullquote::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 1.5rem;
  height: 1.25rem;
  background-color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 40'%3E%3Cpath d='M0 40V24.5Q0 13.5 5.25 7T19.5 0h2.5l-2 8q-5.5 0-7.5 4.5T10.5 24H16V40zm26 0V24.5Q26 13.5 31.25 7T45.5 0H48l-2 8q-5.5 0-7.5 4.5T36.5 24H42V40z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 40'%3E%3Cpath d='M0 40V24.5Q0 13.5 5.25 7T19.5 0h2.5l-2 8q-5.5 0-7.5 4.5T10.5 24H16V40zm26 0V24.5Q26 13.5 31.25 7T45.5 0H48l-2 8q-5.5 0-7.5 4.5T36.5 24H42V40z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* Inner blockquote reset (WP wraps text in a nested blockquote) */
.wp-block-pullquote blockquote {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

.wp-block-pullquote p {
  font-size: 1.5rem !important;
  font-style: normal !important;
  font-weight: 400 !important;
  color: var(--text) !important;
  text-align: left !important;
  line-height: 1.55 !important;
  margin-bottom: 0.5rem !important;
}

.wp-block-pullquote p:last-of-type {
  margin-bottom: 0 !important;
}

.wp-block-pullquote cite,
.wp-block-pullquote .wp-block-pullquote__citation {
  display: block;
  text-align: left !important;
  margin-top: 0.875rem !important;
  font-size: 1.4rem !important;
  font-style: normal !important;
  text-transform: none !important;
  color: var(--muted) !important;
}
