/*
 * Ahura Motion 1.0.2 · loaded after the Ahura Developer theme (style.css, custom.css) and only adds to it.
 * Rules of the house: animate transform, opacity and clip-path only; everything is readable without JavaScript;
 * prefers-reduced-motion switches every movement off; colours come from tokens so light and dark share one rule set.
 */

/* ---------- Tokens: light (theme default) and dark ---------- */
:root {
  color-scheme: light;
  --am-header-glass: rgba(246, 243, 238, 0.82);
  --am-glow: rgba(123, 91, 70, 0.07);
  --am-sheen: rgba(255, 255, 255, 0.45);
  --am-link-line: rgba(123, 91, 70, 0.3);
  --am-link-line-hover: rgba(24, 21, 18, 0.4);
  --am-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --am-mono: var(--wp--preset--font-family--ibm-plex-mono, ui-monospace, "SF Mono", Menlo, monospace);
  --am-serif: var(--wp--preset--font-family--newsreader, Georgia, serif);
  --am-sans: var(--wp--preset--font-family--manrope, -apple-system, "Helvetica Neue", sans-serif);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #121110;
  --page-bg-soft: #191715;
  --page-surface: rgba(255, 255, 255, 0.04);
  --page-surface-strong: rgba(255, 255, 255, 0.07);
  --page-surface-muted: rgba(255, 255, 255, 0.04);
  --ink: #f3eee7;
  --muted: #a69d92;
  --faint: #7d756c;
  --rule: rgba(243, 238, 231, 0.13);
  --rule-strong: rgba(243, 238, 231, 0.22);
  --accent: #d2a98b;
  --accent-soft: #5a4638;
  --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 40px 90px rgba(0, 0, 0, 0.45);
  --wp--preset--color--bg-primary: #121110;
  --wp--preset--color--bg-secondary: #191715;
  --wp--preset--color--bg-elevated: #211f1c;
  --wp--preset--color--accent-primary: #d2a98b;
  --wp--preset--color--accent-soft: #5a4638;
  --wp--preset--color--text-primary: #f3eee7;
  --wp--preset--color--text-secondary: #a69d92;
  --wp--preset--color--rule: rgba(243, 238, 231, 0.13);
  --am-header-glass: rgba(18, 17, 16, 0.78);
  --am-glow: rgba(210, 169, 139, 0.09);
  --am-sheen: rgba(255, 255, 255, 0);
  --am-link-line: rgba(210, 169, 139, 0.38);
  --am-link-line-hover: rgba(243, 238, 231, 0.45);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --page-bg: #121110;
    --page-bg-soft: #191715;
    --page-surface: rgba(255, 255, 255, 0.04);
    --page-surface-strong: rgba(255, 255, 255, 0.07);
    --page-surface-muted: rgba(255, 255, 255, 0.04);
    --ink: #f3eee7;
    --muted: #a69d92;
    --faint: #7d756c;
    --rule: rgba(243, 238, 231, 0.13);
    --rule-strong: rgba(243, 238, 231, 0.22);
    --accent: #d2a98b;
    --accent-soft: #5a4638;
    --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 40px 90px rgba(0, 0, 0, 0.45);
    --wp--preset--color--bg-primary: #121110;
    --wp--preset--color--bg-secondary: #191715;
    --wp--preset--color--bg-elevated: #211f1c;
    --wp--preset--color--accent-primary: #d2a98b;
    --wp--preset--color--accent-soft: #5a4638;
    --wp--preset--color--text-primary: #f3eee7;
    --wp--preset--color--text-secondary: #a69d92;
    --wp--preset--color--rule: rgba(243, 238, 231, 0.13);
    --am-header-glass: rgba(18, 17, 16, 0.78);
    --am-glow: rgba(210, 169, 139, 0.09);
    --am-sheen: rgba(255, 255, 255, 0);
    --am-link-line: rgba(210, 169, 139, 0.38);
    --am-link-line-hover: rgba(243, 238, 231, 0.45);
  }
}

/* The theme hard-codes a few light colours; they follow the tokens now. */
body::before {
  background:
    radial-gradient(circle at top center, var(--am-glow), transparent 32%),
    linear-gradient(180deg, var(--am-sheen), transparent);
}
.site-header.scrolled { background: var(--am-header-glass); }
.ahura-post-content a, .ahura-page-content a { text-decoration-color: var(--am-link-line); }
.ahura-post-content a:hover, .ahura-page-content a:hover { text-decoration-color: var(--am-link-line-hover); }
:focus-visible { outline-color: var(--accent); }
.ahura-progress-bar { background: var(--accent); }

/* One left edge: WordPress centres narrower blocks inside these wide sections (post and page headers, About's
   "How I work" and contact), while the theme means them flush with the logo. */
.ahura-single-hero .ahura-single-hero__inner > *,
.ahura-about-page .ahura-about-page__principles > :not(.alignwide):not(.alignfull),
.ahura-page-hero .is-layout-constrained > .wp-block-post-title { margin-left: 0 !important; }

/* Switching themes: every colour eases over at once, then the transitions are removed again. */
html.am-theme-switching,
html.am-theme-switching *,
html.am-theme-switching *::before,
html.am-theme-switching *::after {
  transition: background-color 0.45s, color 0.45s, border-color 0.45s, fill 0.45s, text-decoration-color 0.45s !important;
}

/* ---------- Reveals: no blur (filter on large blocks costs frames on phones), first screen visible at once ---------- */
.reveal {
  filter: none !important;
  will-change: auto;
  transition:
    opacity 0.9s var(--am-ease) var(--reveal-delay, 0ms),
    transform 0.9s var(--am-ease) var(--reveal-delay, 0ms);
}
html:not(.am-js) .reveal { opacity: 1; transform: none; }
/* The hero used to wait for the script before it could appear; now it is painted with the page. */
.ahura-home-hero .reveal,
.ahura-page-hero .reveal,
.ahura-single-hero .reveal,
.ahura-journal-page__header.reveal,
.ahura-search-page__header.reveal { opacity: 1; transform: none; transition: none; }
@keyframes am-rise { from { opacity: 0; transform: translateY(16px); } }
.am-motion .ahura-home-hero .reveal,
.am-motion .ahura-journal-page__header.reveal,
.am-motion .ahura-single-hero__inner > :not(.wp-block-post-title) { animation: am-rise 0.9s var(--am-ease) both; }
.am-motion .ahura-home-hero-support.reveal { animation-delay: 0.12s; }
/* The post title is left still: it may be arriving from the journal list as a page transition. */
.am-motion .ahura-single-hero__inner > :nth-child(n+4):not(.wp-block-post-title) { animation-delay: 0.12s; }
/* Media inside articles rise in as they scroll into view (motion.js marks them). */
.am-motion [data-am-reveal] { transition: opacity 0.8s var(--am-ease), transform 0.9s var(--am-ease); }
.am-motion [data-am-reveal]:not(.is-in) { opacity: 0; transform: translateY(18px); }

/* ---------- Header toggle ---------- */
.am-theme-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.25rem; margin: 0 0 0 1.5rem; padding: 0.35rem 0.75rem;
  border: 1px solid var(--rule); border-radius: 999px; background: transparent; color: var(--muted);
  font: 500 0.68rem/1 var(--am-mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.am-theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); }
.am-theme-toggle__icon {
  width: 0.8rem; height: 0.8rem; border: 1.5px solid currentColor; border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%); transition: transform 0.45s var(--am-ease);
}
.am-theme-toggle__label::before { content: "Dark"; }
html[data-theme="dark"] .am-theme-toggle__icon { transform: rotate(180deg); }
html[data-theme="dark"] .am-theme-toggle__label::before { content: "Light"; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .am-theme-toggle__icon { transform: rotate(180deg); }
  html:not([data-theme="light"]) .am-theme-toggle__label::before { content: "Light"; }
}
@media (max-width: 782px) {
  .ahura-header-shell { position: relative; }
  .am-theme-toggle { position: absolute; top: 0; right: 0; margin: 0; }
}

/* ---------- Journal rows: the whole row is the link, an arrow slides in ---------- */
.ahura-journal-row .wp-block-post-title a::after { content: ""; position: absolute; inset: 0; }
.ahura-journal-row .ahura-journal-row__kind a,
.ahura-journal-row .wp-block-read-more,
.ahura-journal-row__more a { position: relative; z-index: 1; }
.ahura-journal-row:hover .wp-block-post-title a { color: var(--accent); }
.ahura-journal-row .wp-block-read-more::after,
.ahura-journal-row__more a::after {
  content: "\2192"; display: inline-block; margin-left: 0.45rem; opacity: 0; transform: translateX(-6px);
  transition: opacity 0.18s, transform 0.25s var(--am-ease);
}
.ahura-journal-row:hover .wp-block-read-more::after,
.ahura-journal-row:hover .ahura-journal-row__more a::after { opacity: 1; transform: none; }

/* ---------- Home ticker: drifts sideways while you scroll past ---------- */
.am-ticker { overflow: hidden; contain: paint; padding: 1.1rem 0 1.25rem; border-bottom: 1px solid var(--rule); }
.am-ticker__track {
  display: flex; align-items: center; gap: 1.4rem; width: max-content; white-space: nowrap;
  font: 400 clamp(2.4rem, 6vw, 5.25rem)/1.08 var(--am-serif); letter-spacing: -0.035em; color: var(--ink);
}
.am-ticker__item.is-alt { font-style: italic; color: var(--muted); }
.am-ticker__sep { font: 500 0.8rem/1 var(--am-mono); letter-spacing: 0.08em; color: var(--accent); }
@keyframes am-drift { from { transform: translateX(0); } to { transform: translateX(-22%); } }
.am-motion .am-ticker__track { transform: translateX(calc(var(--am-drift, 0) * -22%)); will-change: transform; }
@supports (animation-timeline: view()) {
  .am-motion .am-ticker { view-timeline: --am-ticker block; }
  .am-motion .am-ticker__track { animation: am-drift linear both; animation-timeline: --am-ticker; animation-range: cover; }
}

/* ---------- Posts: contents tree beside the article ---------- */
.ahura-post-content { position: relative; }
.ahura-post-content .wp-block-post-content :is(h2, h3)[id] { position: relative; scroll-margin-top: 7rem; }
.am-toc { display: none; }
@media (min-width: 1240px) {
  .ahura-post-content > .am-toc {
    display: block; position: absolute; top: 0; bottom: 0; right: calc(100% + 3rem);
    width: min(13rem, calc((100vw - 760px) / 2 - 5rem)); max-width: none; margin: 0;
  }
}
.am-toc__inner { position: sticky; top: 7rem; }
body.admin-bar .am-toc__inner { top: 9rem; }
.am-toc__title { margin: 0 0 0.9rem; color: var(--muted); font: 500 0.7rem/1.4 var(--am-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.am-toc__list { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--rule); }
.am-toc__item { margin: 0; }
.am-toc__item a {
  display: block; margin-left: -1px; padding: 0.32rem 0 0.32rem 0.9rem; border-left: 1px solid transparent;
  color: var(--muted); font: 400 0.82rem/1.35 var(--am-sans); text-decoration: none;
  transition: color 0.15s, border-color 0.15s, transform 0.25s var(--am-ease);
}
.am-toc__item--h3 a { padding-left: 1.5rem; font-size: 0.78rem; }
.am-toc__item--h3 a::before { content: "\2514\00a0"; color: var(--faint); font-family: var(--am-mono); }
.am-toc__item a:hover { color: var(--ink); transform: translateX(2px); }
.am-toc__item.is-active a { color: var(--ink); border-left-color: var(--accent); }
.am-toc__progress { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.4rem; color: var(--muted); font: 500 0.68rem/1 var(--am-mono); letter-spacing: 0.06em; }
.am-toc__bar { position: relative; flex: 1; height: 4px; overflow: hidden; border-radius: 2px; background: var(--rule); }
.am-toc__bar > span { position: absolute; inset: 0; background: var(--accent); transform-origin: left center; transform: scaleX(var(--am-read, 0)); }
.am-toc__percent { min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
.am-toc__hint { margin: 0.9rem 0 0; color: var(--faint); font: 500 0.64rem/1.4 var(--am-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.am-toc__hint kbd { padding: 0.05rem 0.3rem; border: 1px solid var(--rule-strong); border-radius: 3px; font: inherit; }
@media (hover: none) { .am-toc__hint { display: none; } }
.am-toc__share {
  margin-top: 1rem; padding: 0; border: 0; border-bottom: 1px solid var(--rule-strong); background: none; color: var(--muted);
  font: 500 0.68rem/1.6 var(--am-mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.am-toc__share:hover { color: var(--ink); border-color: currentColor; }

/* Section links: a quiet # left of each heading. */
.am-anchor {
  position: absolute; top: 50%; left: -1.6em; width: 1.3em; padding: 0; border: 0; background: none;
  color: var(--faint); font: 500 0.6em/1 var(--am-mono); cursor: pointer; opacity: 0; transform: translateY(-50%);
  transition: opacity 0.15s, color 0.15s;
}
.ahura-post-content :is(h2, h3):hover .am-anchor, .am-anchor:focus-visible { opacity: 1; }
.am-anchor:hover { color: var(--accent); }
@media (max-width: 900px), (hover: none) { .am-anchor { display: none; } }

/* Code blocks: a copy button in the corner. */
.am-code { position: relative; }
.am-code > pre { margin: 0 !important; }
.am-code__copy {
  position: absolute; top: 0.6rem; right: 0.6rem; padding: 0.32rem 0.55rem; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--page-bg-soft); color: var(--muted); font: 500 0.64rem/1 var(--am-mono); letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer; opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.am-code:hover .am-code__copy, .am-code__copy:focus-visible { opacity: 1; }
.am-code__copy:hover { color: var(--ink); }
@media (hover: none) { .am-code__copy { opacity: 1; } }

/* Toast for "copied". */
.am-toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 1300; padding: 0.6rem 0.95rem; border-radius: 6px;
  background: var(--ink); color: var(--page-bg); font: 500 0.7rem/1 var(--am-mono); letter-spacing: 0.06em; text-transform: uppercase;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity 0.25s, transform 0.25s var(--am-ease);
}
.am-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Page to page: cross-fade, the header stays, a journal title grows into the headline ---------- */
@keyframes am-page-out { to { opacity: 0; } }
@keyframes am-page-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: am-header; }
  ::view-transition-old(root) { animation: am-page-out 0.18s ease both; }
  ::view-transition-new(root) { animation: am-page-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
  ::view-transition-group(am-title) { animation-duration: 0.55s; animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1); }
}

/* ---------- Reduced motion and print ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal, .ahura-home-hero .reveal, .ahura-single-hero__inner > * { opacity: 1 !important; transform: none !important; animation: none !important; transition: none !important; }
  .am-ticker__track { animation: none !important; transform: none !important; }
}
@media print {
  .am-toc, .am-ticker, .am-theme-toggle, .am-anchor, .am-code__copy, .am-toast { display: none !important; }
  .reveal, [data-am-reveal] { opacity: 1 !important; transform: none !important; }
}
