/* ==========================================================================
   Custom styles for Hyperfocus — Inspired by AkitaOnRails
   ========================================================================== */

/* ---------- Daily quote bridge ---------- */
.daily-quote-body {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: #050711;
}

.daily-quote-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  color: #f8fafc;
  background: #050711;
  outline: none;
}

.daily-quote-aurora,
.daily-quote-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.daily-quote-aurora {
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, rgba(15, 23, 42, 0.15), rgba(2, 6, 23, 0.96) 72%);
}

.daily-quote-grid {
  opacity: 0.14;
  background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 4rem 4rem;
  mask-image: radial-gradient(circle at center, black, transparent 72%);
}

.daily-quote-orb {
  position: absolute;
  display: block;
  border-radius: 9999px;
  filter: blur(5rem);
  opacity: 0.48;
  animation: daily-quote-drift 4.5s ease-out 1 both;
}

.daily-quote-orb--one { width: 38rem; height: 38rem; left: -16rem; top: -13rem; background: rgba(45, 212, 191, 0.42); }
.daily-quote-orb--two { width: 34rem; height: 34rem; right: -14rem; top: 4%; background: rgba(99, 102, 241, 0.38); }
.daily-quote-orb--three { width: 27rem; height: 27rem; left: 35%; bottom: -18rem; background: rgba(251, 191, 36, 0.24); }

.daily-quote-composition {
  width: min(100%, 68rem);
  min-width: 0;
  animation: daily-quote-arrive 800ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.daily-quote-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 0 0 clamp(2rem, 6vh, 4.5rem);
  color: rgba(207, 250, 254, 0.78);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.daily-quote-brand span {
  width: 1.8rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, #67e8f9);
}

.daily-quote-card {
  position: relative;
  min-width: 0;
  padding: clamp(2.1rem, 6vw, 5.5rem) clamp(1.4rem, 7vw, 6.5rem);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: clamp(1.75rem, 4vw, 3.25rem);
  background: linear-gradient(135deg, rgba(255,255,255,0.11), rgba(255,255,255,0.035) 48%, rgba(45,212,191,0.055));
  box-shadow: 0 2.5rem 8rem rgba(0, 0, 0, 0.5), inset 0 1px rgba(255,255,255,0.12);
  backdrop-filter: blur(1.6rem);
}

.daily-quote-mark {
  position: absolute;
  inset-inline-start: clamp(1.1rem, 3vw, 2.5rem);
  top: clamp(0.8rem, 2vw, 1.5rem);
  color: rgba(103, 232, 249, 0.36);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(4.5rem, 10vw, 8rem);
  line-height: 1;
}

.daily-quote-text {
  max-width: 24ch;
  margin: 0 auto;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(2rem, 5.2vw, 4.75rem);
  font-optical-sizing: auto;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  hyphens: auto;
  text-shadow: 0 0.25rem 2.5rem rgba(0, 0, 0, 0.4);
}

.daily-quote-progress {
  width: min(15rem, 50vw);
  margin: clamp(2rem, 6vh, 4.5rem) auto 0;
}

.daily-quote-progress__track {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 9999px;
  background: rgba(207, 250, 254, 0.4);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03);
}

.daily-quote-progress__fill {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, #2dd4bf, #67e8f9 55%, #a5b4fc);
  box-shadow: 0 0 1rem rgba(103,232,249,0.75);
  will-change: transform;
}

[dir="rtl"] .daily-quote-progress__fill { transform-origin: right center; }

.daily-quote-text:lang(ar),
.daily-quote-text:lang(fa),
.daily-quote-text:lang(he),
.daily-quote-text:lang(ur) {
  letter-spacing: normal;
  line-height: 1.35;
}

.daily-quote-source {
  max-width: 34rem;
  margin: clamp(1.1rem, 3vh, 1.75rem) auto 0;
  color: rgba(226, 232, 240, 0.82);
  font-family: "Source Sans 3", sans-serif;
  font-size: clamp(0.82rem, 1.6vw, 0.98rem);
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.025em;
  line-height: 1.5;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.daily-quote-source cite { font-style: normal; }

.daily-quote-recovery {
  width: min(100%, 30rem);
  margin: 1.5rem auto 0;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(254, 202, 202, 0.28);
  border-radius: 1rem;
  color: #fee2e2;
  background: rgba(69, 10, 10, 0.72);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: center;
}

.daily-quote-recovery[hidden] { display: none; }

.daily-quote-recovery button {
  margin-top: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 9999px;
  padding: 0.55rem 1.15rem;
  color: #0f172a;
  background: #cffafe;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.daily-quote-recovery button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

@keyframes daily-quote-arrive {
  from { opacity: 0; transform: translateY(1.25rem) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes daily-quote-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(0.96); }
  to { transform: translate3d(4%, 3%, 0) scale(1.08); }
}

@media (max-width: 480px) {
  .daily-quote-card { min-height: 19rem; display: grid; align-items: center; }
  .daily-quote-text { font-size: clamp(1.85rem, 9vw, 2.6rem); line-height: 1.16; }
}

@media (prefers-reduced-motion: reduce) {
  .daily-quote-composition, .daily-quote-orb { animation: none; }
  .daily-quote-progress__fill { transform: scaleX(0.4) !important; will-change: auto; }
}

@media (forced-colors: active) {
  .daily-quote-stage:focus-visible { outline: 3px solid Highlight; outline-offset: -4px; }
  .daily-quote-progress__track { height: 5px; border: 1px solid CanvasText; background: Canvas; forced-color-adjust: none; }
  .daily-quote-progress__fill { background: Highlight; box-shadow: none; forced-color-adjust: none; }
  .daily-quote-recovery, .daily-quote-recovery button { border-color: CanvasText; color: CanvasText; background: Canvas; }
}

/* Keep native summary focus obvious in standard and high-contrast modes. */
.locale-summary:focus-visible { outline: 3px solid #4f46e5; outline-offset: 4px; }

@media (forced-colors: active) {
  .locale-summary:focus-visible { outline-color: Highlight; }
}

/* ---------- Article shell ---------- */
.post-shell {
  width: 100%;
  max-width: calc(68ch + 16rem + 2.5rem);
  margin-inline: auto;
  padding: 2.5rem 1rem;
  display: grid;
  grid-template-columns: minmax(0, 68ch);
  justify-content: center;
}

.post-main {
  min-width: 0;
}

.post-article,
.post-footer {
  width: 100%;
  max-width: 68ch;
  margin-inline: auto;
}

/* ---------- Base typography ---------- */
.post-content {
  font-family: "Source Serif 4", Charter, "Bitstream Charter", Georgia, Cambria, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  hyphens: auto;
  color: #2a2622;
}

/* ---------- Headings ---------- */
.post-content :where(h1, h2, h3, h4, h5, h6) {
  font-family: "Source Sans 3", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.15;
  color: #111827;
  scroll-margin-top: 5rem;
}

.post-content h1 {
  font-size: 2.25rem;
  margin-bottom: 1rem;
  margin-top: 0;
}

.post-content h2 {
  font-size: 1.75rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #e5e7eb;
}

.post-content h3 {
  font-size: 1.375rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-content h4 {
  font-size: 1.125rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

/* ---------- Paragraphs & lists ---------- */
.post-content :where(p, li) {
  text-wrap: pretty;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.post-content ul {
  list-style-type: disc;
}

.post-content ol {
  list-style-type: decimal;
}

.post-content li {
  margin-bottom: 0.4rem;
}

.post-content li > ul,
.post-content li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

/* ---------- Links ---------- */
.post-content :where(a) {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.12em;
  text-decoration-skip-ink: auto;
  transition: color 0.15s ease;
}

.post-content a:hover {
  color: #1d4ed8;
}

/* ---------- Blockquotes ---------- */
.post-content blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 1.25rem;
  margin: 1.75rem 0;
  font-style: italic;
  color: #4b5563;
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

/* ---------- Inline code ---------- */
.post-content :where(code):not(pre code) {
  font-size: 0.85em;
  padding: 0.15em 0.35em;
  background-color: #f1ece0;
  border-radius: 0.25rem;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  hyphens: none;
}

/* ---------- Code blocks ---------- */
.post-content pre {
  font-size: 0.9em;
  line-height: 1.65;
  background: #f1ece0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin: 1.75rem 0;
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* Commonmarker syntax-highlighted blocks override */
.post-content pre[style*="background-color"] {
  border-color: rgba(0, 0, 0, 0.06);
}

.post-content pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-ligatures: none;
  font-size: inherit;
}

/* Custom scrollbar for code blocks */
.post-content pre::-webkit-scrollbar {
  height: 10px;
}

.post-content pre::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
}

.post-content pre::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Images ---------- */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.post-content figure {
  margin: 1.75rem 0;
}

.post-content figcaption {
  font-size: 0.875rem;
  color: #6b7280;
  text-align: center;
  margin-top: 0.5rem;
}

/* ---------- Horizontal rule ---------- */
.post-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 2.5rem 0;
}

/* ---------- Tables ---------- */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75rem 0;
  font-size: 0.925em;
}

.post-content th,
.post-content td {
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.post-content th {
  background-color: #f3f4f6;
  font-family: "Source Sans 3", "Helvetica Neue", sans-serif;
  font-weight: 600;
}

/* ==========================================================================
   Table of Contents sidebar
   ========================================================================== */

.toc-sidebar {
  display: none;
  font-family: "Source Sans 3", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  font-size: 0.8125rem;
  line-height: 1.4;
  width: 14rem;
  max-height: calc(100vh - 6rem);
  padding-right: 0.5rem;
  overflow-y: auto;
  position: sticky;
  top: 5rem;
}

.toc-sidebar .toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.toc-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
}

/* Vertical line on the left */
.toc-sidebar > ul {
  padding-left: 0;
}

.toc-sidebar > ul::before {
  content: "";
  position: absolute;
  top: 0.25rem;
  bottom: 0.25rem;
  left: 0;
  width: 1px;
  background-color: #e5e7eb;
}

.toc-sidebar .toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.25rem;
  color: #6b7280;
  text-decoration: none;
  transition: all 0.15s ease;
  word-break: break-word;
  position: relative;
}

.toc-sidebar .toc-link::before {
  content: "#";
  opacity: 0.3;
  flex-shrink: 0;
  font-weight: 600;
}

.toc-sidebar .toc-link:hover {
  background-color: #f3f4f6;
  color: #111827;
}

/* Active TOC link */
.toc-sidebar .toc-link.active {
  background-color: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.toc-sidebar .toc-link.active::before {
  opacity: 0.6;
  color: #1d4ed8;
}

/* TOC nesting indentation */
.toc-sidebar .toc-level-2 {
  padding-left: 0.75rem;
}

.toc-sidebar .toc-level-3 {
  padding-left: 1.5rem;
}

/* ---------- Article header ---------- */
.post-header {
  width: 100%;
}

.post-header h1 {
  font-family: "Source Sans 3", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #111827;
}

/* ---------- Back navigation ---------- */
.post-footer {
  width: 100%;
}

/* ---------- Responsive article layout ---------- */
@media (min-width: 1024px) {
  .post-shell--with-toc {
    grid-template-columns: 14rem minmax(0, 68ch);
    column-gap: 2.5rem;
    align-items: start;
    padding-inline: 1.5rem;
  }

  .post-shell--with-toc .post-article,
  .post-shell--with-toc .post-footer {
    margin-inline: 0;
  }

  .toc-sidebar {
    display: block;
  }
}

@media (max-width: 640px) {
  .post-shell {
    padding-block: 2rem;
  }

  .post-content {
    font-size: 18px;
  }
}

/* ---------- Line clamp utility ---------- */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
