/* Shared styles for the Inkhaven 2026 site */
:root {
  --bg: #f6f1e8;
  --text: #1c1916;
  --muted: #5e574e;
  --link: #1a4d73;
  --link-hover: #0e2f47;
  --rule: #d8d0c4;
  --surface: #fffdf8;
  --solid-bg: #000;
  --solid-fg: #fff;
  --shadow: rgba(0, 0, 0, 0.06);
  --card-shadow: rgba(0, 0, 0, 0.14);
  color-scheme: light;
}
/* Dark mode: follows the system unless the toggle forces a theme */
:root[data-theme="dark"] {
  --bg: #15130f;
  --text: #e8e1d5;
  --muted: #a69d90;
  --link: #8dbbe2;
  --link-hover: #bcd8f0;
  --rule: #3a342c;
  --surface: #1f1b16;
  --solid-bg: #e8e1d5;
  --solid-fg: #15130f;
  --shadow: rgba(0, 0, 0, 0.35);
  --card-shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f;
    --text: #e8e1d5;
    --muted: #a69d90;
    --link: #8dbbe2;
    --link-hover: #bcd8f0;
    --rule: #3a342c;
    --surface: #1f1b16;
    --solid-bg: #e8e1d5;
    --solid-fg: #15130f;
    --shadow: rgba(0, 0, 0, 0.35);
    --card-shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  line-height: 1.65;
  max-width: 100%;
  overflow-x: hidden;
}
.wrap, main {
  max-width: 38rem;
  width: 100%;
  margin: 0 auto;
  overflow-x: clip;
}
.wrap {
  padding: 2.5rem 1.25rem 4rem;
}
article,
article p,
article a {
  overflow-wrap: anywhere;
  word-break: break-word;
}
article img,
article video,
article iframe,
article pre,
article code,
article blockquote,
.tweet-embed,
.tweet-embed iframe,
blockquote.twitter-tweet {
  max-width: 100%;
}
article img,
article video,
article iframe {
  height: auto;
}
article pre,
article code {
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.tweet-embed {
  display: flex;
  justify-content: center;
  margin: 1.5rem auto;
  width: 100%;
  overflow-x: auto;
}
.tweet-embed blockquote.twitter-tweet,
.tweet-embed iframe.twitter-tweet-rendered {
  margin-left: auto;
  margin-right: auto;
}
header.site {
  margin-bottom: 2.25rem;
}
.masthead {
  margin: 0 0 1.15rem;
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--muted);
}
.masthead a {
  color: inherit;
  text-decoration: none;
}
.masthead a:hover,
.masthead a:focus-visible {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.masthead a:focus { outline: none; }
.masthead a:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
.site-title {
  font-size: 1.55rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: 0.005em;
  margin: 0 0 0.2rem;
}
.site-title { margin-bottom: 0.8rem; }
.site-subtitle {
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
  text-decoration-skip-ink: auto;
}
@media (min-width: 700px) {
  .site-subtitle {
    display: block;
    width: fit-content;
  }
}
.site-title a { color: inherit; text-decoration: none; }
.site-title a:hover { text-decoration: underline; }
.intro, .muted, time, .meta {
  color: var(--muted);
}
.intro { margin: 0 0 1.75rem; }
nav.site-nav, .site-links {
  margin-top: 0.75rem;
  font-size: 0.95rem;
}
a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { color: var(--link-hover); }
h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  font-weight: 650;
  margin: 0 0 0.4rem;
}
.post-date { display: block; margin-bottom: 1.5rem; font-size: 0.95rem; }
article p { margin: 0 0 1.1rem; }
article p:last-child { margin-bottom: 0; }
.x-callout {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: -0.4rem 0 1.6rem;
  padding: 0.5rem 0.6rem 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.x-callout:hover { border-color: var(--text); box-shadow: 0 2px 10px var(--shadow); color: var(--text); }
.x-callout-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--solid-bg);
  color: var(--solid-fg);
}
.x-callout-icon svg { display: block; }
.x-callout-text { flex: 1; min-width: 0; font-size: 0.85rem; color: var(--muted); }
.x-callout-text strong { color: var(--text); font-weight: 600; margin-right: 0.35rem; }
.x-callout-cta {
  flex: none;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  background: var(--solid-bg);
  color: var(--solid-fg);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 520px) {
  .x-callout-text span { display: none; }
}
.back { margin: 0 0 1.5rem; font-size: 0.95rem; }
.post-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2.5rem;
}
.post-list li {
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
}
.post-list li:last-child { border-bottom: 1px solid var(--rule); }
.post-list a.title { font-weight: 600; }
.post-list .meta { display: block; font-size: 0.9rem; margin-top: 0.15rem; }
footer.site {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}
@media (max-width: 40rem) {
  html { font-size: 17px; }
  .wrap { padding: 1.75rem 1rem 3rem; }
  h1 { font-size: 1.45rem; }
}

/* Justified body text (Blocksatz) with hyphenation to avoid wide gaps */
article p,
article .footnotes li {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
}

/* Inline references: short bracketed labels instead of bare URLs */
a.ref {
  white-space: nowrap;
  font-size: 0.85em;
  text-decoration: none;
}
a.ref:hover {
  text-decoration: underline;
}

/* Link preview cards */
.pv-card {
  position: absolute;
  z-index: 50;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 8px 28px var(--card-shadow);
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}
.pv-card.on { opacity: 1; visibility: visible; transform: none; }
.pv-img { display: block; width: 100%; max-height: 180px; object-fit: cover; margin: 0; }
.pv-body { padding: 0.7rem 0.85rem 0.8rem; }
.pv-meta { color: var(--muted); margin-bottom: 0.3rem; }
.pv-meta strong { color: var(--text); }
.pv-title { font-weight: 600; margin-bottom: 0.3rem; }
.pv-text { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.pv-quote { margin-top: 0.5rem; padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: 8px; color: var(--muted); }
.pv-open { display: inline-block; margin-top: 0.55rem; font-weight: 600; }

/* Full-screen image viewer */
img.zoomable { cursor: zoom-in; -webkit-tap-highlight-color: transparent; }
img.zoomable:focus { outline: none; }
img.zoomable:focus-visible { outline: 2px solid var(--muted); outline-offset: 4px; border-radius: 2px; }
.lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(20, 17, 14, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s;
  overscroll-behavior: contain;
  touch-action: none;
  cursor: zoom-out;
}
.lb.on { opacity: 1; visibility: visible; }
.lb-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0;
  cursor: default;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.lb-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 30px;
  line-height: 44px;
  text-align: center;
  padding: 0;
  cursor: pointer;
}
.lb-close:focus { outline: none; }
.lb-close:hover, .lb-close:focus-visible { background: rgba(255, 255, 255, 0.28); }

/* X embeds: widgets.js renders the card at most 550px wide inside its iframe,
   so embed-fit.js scales it up to the text column width */
.tweet-embed { display: block; }
.tweet-embed.fit { overflow: hidden; }
.tweet-embed.fit .twitter-tweet-rendered {
  width: 550px !important;
  max-width: none !important;
  margin: 0 !important;
  transform-origin: 0 0;
}

/* Pill navigation, matching the X callout */
.back a,
.site-links a,
footer.site a,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.4;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.back a:hover,
.site-links a:hover,
footer.site a:hover,
.theme-toggle:hover {
  border-color: var(--text);
  box-shadow: 0 2px 10px var(--shadow);
  color: var(--text);
}
.site-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
footer.site {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding-top: 1.5rem;
}

/* Theme toggle (Auto / Light / Dark) */
.back { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.theme-toggle {
  margin-left: auto;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle svg { display: block; flex: none; }
.theme-toggle:focus { outline: none; }
.theme-toggle:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
body { transition: background-color 0.2s ease, color 0.2s ease; }

/* X's embed document is light-scheme; in dark mode a scheme mismatch makes
   the browser paint an opaque white backdrop behind the iframe. Matching the
   scheme keeps the iframe transparent so only the dark card shows. */
.tweet-embed iframe { color-scheme: light; background: transparent; }

/* While an X embed loads: spinner plus a link to the post; space is reserved
   by theme.js so nothing jumps when the card appears */
.tweet-embed blockquote.twitter-tweet {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin: 10px 0;
  padding: 1.2rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}
.tweet-embed blockquote.twitter-tweet > :not(a) { display: none; }
/* Skeleton card while loading: avatar, name and handle, text lines and a
   media area, pulsing softly. The link to the post sits at the bottom. */
.tweet-embed.loading blockquote.twitter-tweet {
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  padding: 1rem 1rem 1.1rem;
}
.tweet-embed.loading blockquote.twitter-tweet::before,
.tweet-embed.loading blockquote.twitter-tweet::after {
  content: "";
  display: block;
  background-repeat: no-repeat;
  animation: tw-pulse 1.4s ease-in-out infinite;
}
.tweet-embed.loading blockquote.twitter-tweet::before {
  order: 0;
  flex: none;
  height: 44px;
  background-image:
    radial-gradient(circle at 22px 22px, var(--rule) 21.5px, transparent 22.5px),
    linear-gradient(var(--rule), var(--rule)),
    linear-gradient(var(--rule), var(--rule));
  background-size: 44px 44px, 38% 12px, 24% 10px;
  background-position: 0 0, 58px 7px, 58px 27px;
}
.tweet-embed.loading blockquote.twitter-tweet::after {
  order: 1;
  flex: 1 1 auto;
  min-height: 70px;
  background-image:
    linear-gradient(var(--rule), var(--rule)),
    linear-gradient(var(--rule), var(--rule)),
    linear-gradient(var(--rule), var(--rule)),
    linear-gradient(var(--rule), var(--rule)),
    linear-gradient(color-mix(in srgb, var(--rule) 55%, transparent), color-mix(in srgb, var(--rule) 55%, transparent));
  background-size: 100% 11px, 93% 11px, 97% 11px, 58% 11px, 100% calc(100% - 104px);
  background-position: 0 2px, 0 24px, 0 46px, 0 68px, 0 104px;
  border-radius: 4px;
  animation-delay: 0.15s;
}
.tweet-embed.loading blockquote.twitter-tweet a:last-of-type { order: 2; align-self: flex-start; }
@keyframes tw-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) {
  .tweet-embed.loading blockquote.twitter-tweet::before,
  .tweet-embed.loading blockquote.twitter-tweet::after { animation: none; }
}
.tweet-embed blockquote.twitter-tweet a { display: none; }
.tweet-embed blockquote.twitter-tweet a:last-of-type {
  display: inline-flex;
  padding: 0.32rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.tweet-embed blockquote.twitter-tweet a:last-of-type:hover { border-color: var(--text); }

/* Home: intro, filter, thumbnails and word counts */
.about { color: var(--muted); font-size: 0.98rem; margin: 0.6rem 0 0; }
.list-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem 1rem; margin: 0 0 0.9rem; }
.filter {
  flex: 1 1 140px;
  min-width: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 0.95rem 0.45rem 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999088' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
  outline: none;
  transition: border-color 0.15s ease;
}
.filter:focus { border-color: var(--text); }
.filter::placeholder { color: var(--muted); }
.list-count { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.post-list li { display: flex; gap: 1rem; align-items: flex-start; }
.post-list li[hidden] { display: none; }
.post-list .thumb {
  flex: none;
  width: 108px;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  overflow: hidden;
  background: var(--rule);
  margin-top: 0.2rem;
}
.post-list .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s ease; }
.post-list li:hover .thumb img { transform: scale(1.04); }
.post-info { flex: 1; min-width: 0; }
.post-list .meta { color: var(--muted); }
.post-list .meta .dot { margin: 0 0.4rem; }
.no-match { color: var(--muted); font-size: 0.95rem; }
@media (max-width: 520px) { .post-list .thumb { width: 84px; } }

/* Post title menu: the N/30 opens a list of all meditations */
.num-wrap { position: relative; display: inline-block; }
.num-menu {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0 0.1em;
  margin: 0 -0.1em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
  border-radius: 6px;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}
.num-menu svg { color: var(--muted); transition: transform 0.15s ease; }
.num-menu:hover { text-decoration-color: var(--muted); }
.num-wrap.open .num-menu svg { transform: rotate(180deg); }
.num-menu-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 2.5rem));
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--card-shadow, rgba(0,0,0,0.12));
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.num-wrap.open .num-menu-pop { opacity: 1; transform: none; pointer-events: auto; }
.nm-head { padding: 0.35rem 0.6rem 0.4rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.num-menu-pop a {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  column-gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  outline: none;
}
.num-menu-pop a:hover, .num-menu-pop a:focus-visible { background: var(--bg); }
.num-menu-pop a.current .nm-t::after { content: "Reading"; margin-left: 0.5rem; font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.nm-n { grid-row: span 2; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.num-menu-pop a.current .nm-n { color: var(--text); }
.nm-t { font-weight: 600; }
.nm-d { grid-column: 2; font-size: 0.8rem; color: var(--muted); }
.num-menu-pop a.nm-all { display: block; margin-top: 0.25rem; border-top: 1px solid var(--rule); border-radius: 0 0 8px 8px; font-size: 0.85rem; color: var(--link); text-align: center; }

.sort {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 2rem 0.45rem 0.9rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23999088' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  outline: none;
}
.sort:focus { border-color: var(--text); }
.list-count { flex-basis: 100%; }
