/* =========================================================
   NAVBAR — Classical Layout with Title Above Border
   For theme: flatly
========================================================= */

/* Reset Flatly’s gray background and padding */
.navbar {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  margin: 0 auto 3rem !important;
  padding: 0 !important;
  max-width: 796px !important;   /* keep constant width */
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  box-sizing: border-box !important;
}


/* ---------------------------------------------------------
   BRAND: Show above top border (floating heading)
--------------------------------------------------------- */
.navbar-brand {
  font-family: "EB Garamond", serif !important;
  font-weight: 700 !important;
  font-size: 2.6rem !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #111 !important;
  background: transparent !important;
  text-align: center;
  pointer-events: none;
  margin-bottom: 1.6rem !important; /* space between brand & top border */
}

/* ---------------------------------------------------------
   NAVIGATION BAR (double border style)
--------------------------------------------------------- */
.navbar-nav {
  display: flex !important;
  flex-direction: row !important;
  justify-content: center !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  gap: 2.2rem !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0.8rem 0 !important;
  width: 100%;
  border-top: 1px solid #bbb !important;
  border-bottom: 1px solid #bbb !important;
}

/* Navigation links */
.navbar-nav > li > a.nav-link {
  font-family: "Inter", sans-serif !important;
  font-weight: 500 !important;
  font-size: 0.95rem !important;
  color: #222 !important;
  text-decoration: none !important;
  letter-spacing: 0.02em;
  background: transparent !important;
  padding: 0.25rem 0 !important;
  transition: color 0.2s ease;
}

.navbar-nav > li > a.nav-link:hover,
.navbar-nav > li.active > a.nav-link {
  color: #000 !important;
  text-decoration: underline !important;
}

/* Remove Quarto’s default shadow / bg */
.bg-light,
.navbar-light,
.navbar-default {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

/* Hide hamburger toggle */
.navbar-toggler {
  display: none !important;
}

/* =========================================================
   BRAND ABOVE NAVBAR (Flatly-compatible patch)
   ========================================================= */

/* Lift brand above the nav container visually */
.navbar-brand {
  position: absolute !important;
  top: 8rem; /* adjust vertical offset */
  left: 50%;
  transform: translateX(-50%);
  font-family: "Cormorant Garamond", serif !important;
  font-weight: 700 !important;
  font-size: 2.6rem !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #111 !important;
  text-align: center;
  background: transparent !important;
  pointer-events: auto !important; /* clickable again */
  z-index: 10;
}

.navbar-nav {
  position: relative !important;
  top: 12rem !important; /*align with brand */
  z-index: 10;
}

/* Keep navbar centered under it */
.navbar {
  position: relative !important;
  margin-top: 3.6rem !important; /* create space for lifted brand */
}

/* Optional hover feedback for brand */
.navbar-brand:hover {
  text-decoration: none !important;
  color: #000 !important;
}

/* =========================================================
   RESPONSIVE FIX — Keep Navbar in One Row on Smaller Screens
   ========================================================= */

/* Applies from large phones to tablets */
@media (max-width: 825px) {

  /* Container adjustments */
  .navbar,
  .navbar-container,
  .navbar-collapse {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    overflow-x: visible !important;
  }

   .navbar-nav {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;

    /* ✅ Adaptive spacing and padding */
    gap: clamp(0.6rem, 2.5vw, 1.4rem) !important;
    padding: clamp(0.4rem, 1.5vw, 0.7rem) 0 !important;

    /* ✅ Borders that visually scale with screen size */
    border-top: 1px solid #bbb !important;
    border-bottom: 1px solid #bbb !important;
    width: 100% !important;
    max-width: 100% !important;

    /* ✅ Prevent scroll bars from appearing */
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .navbar-nav > li > a.nav-link {
    font-size: 0.8rem !important;
  }
}

/* =========================================================
   WIDTH SYNC — Fix mismatch between navbar, collapse & nav-scroll
========================================================= */

.navbar.navbar-expand-lg,
.navbar.navbar-expand-lg .collapse.navbar-collapse,
.navbar-nav.navbar-nav-scroll.ms-auto {
  max-width: 825px !important;   /* ✅ perfectly matches .content */
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box !important;
  display: flex !important;
  justify-content: center !important;   /* ✅ keeps links centered */
  align-items: center !important;
}

/* =========================================================
   FIX — Remove unwanted vertical scroll bar in navbar
========================================================= */

/* Disable Bootstrap's forced scroll on .navbar-nav-scroll */
.navbar-nav-scroll {
  overflow-y: visible !important;
  overflow-x: visible !important;
  max-height: none !important;
}

/* On mobile, ensure navbar items stay centered and don't clip */
@media (max-width: 1024px) {
  .navbar-nav-scroll {
    overflow: visible !important;
  }

  /* Prevent navbar items from stretching off-screen */
  .navbar-nav {
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
}

/* Prevent Quarto's mobile wrapper from forcing scroll */
.navbar-collapse.collapse.show,
.navbar-collapse.collapse {
  overflow: visible !important;
  max-height: none !important;
}

/* =========================================================
   ULTRA-SMALL SCREEN OPTIMIZATION (width < 360px)
   ========================================================= */

@media (max-width: 360px) {

  .navbar-nav > li > a.nav-link {
    font-size: 0.65rem !important; /* tighter, proportional nav links */
    letter-spacing: 0.01em !important;
  }

  .navbar-nav {
    gap: 0.8rem !important; /* reduce spacing between tabs */
  }
}

/* =========================================================
   ACTIVE TAB STYLING — Elegant underline indicator
========================================================= */

/* Base: all links are neutral */
.navbar-nav > li > a.nav-link {
  color: #222 !important;
  text-decoration: none !important;
  position: relative;
  transition: color 0.2s ease;
}

/* Subtle hover feedback */
.navbar-nav > li > a.nav-link:hover {
  color: #000 !important;
}

/* Active link — underline accent */
.navbar-nav > li.active > a.nav-link,
.navbar-nav > li > a.nav-link.active {
  color: #000 !important;
  font-weight: 600 !important;  /* small typographic lift */
}

/* =========================================================
   CUSTOM TOOLTIP — Minimal Floating Text on Hover
========================================================= */

/* Base tooltip container (hidden by default) */
.navbar-nav > li > a[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -4em;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
}

/* Fade in tooltip on hover */
.navbar-nav > li > a[data-tooltip]:hover::after {
  opacity: 1;
  transform: translate(-50%, -2.2em);
}

/* =========================================================
   GLOBAL BACKGROUND — Parchment Swirl Texture
   ========================================================= */
html, body {
  height: 100%;
  background-color: #f7f2e8; /* base parchment tone */
  background-image: url("../media/images/background.png");
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
  background-position: top center;
  color: #1b1b1b;
  font-family: "Source Serif 4", "Georgia", serif;
  line-height: 1.6;
  margin: 0 auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(247, 242, 232, 0.4); /* soft overlay */
  pointer-events: none;
  z-index: -1;
}

.navbar-logo {
  display: block;
  margin: 0 auto;
  max-height: 120px; /* adjust image height */
  padding-bottom: 0.5rem;
}

.navbar-title {
  margin-top: 0;
}

/* =========================================================
   HEADER IMAGE ABOVE NAVBAR (RESPONSIVE + CLEAN)
   ========================================================= */
.site-header {
  top: -2rem;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  overflow: hidden;
  margin: 0 auto;
  padding: 0;
  position: relative;
  z-index: 5;
}

.site-header-img {
  width: 100%;
  max-width: 825px; /* matches navbar width */
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 0;
}

@media (max-width: 730px) and (min-width: 581px) {
  .navbar-brand {
    top: 6rem !important;
  }
  .navbar-nav {
    top: 10rem !important;
  }
}

@media (max-width: 580px) and (min-width: 501px) {
  .navbar-brand {
    top: 4rem !important;
  }
  .navbar-nav {
    top: 8rem !important;
  }
}

@media (max-width: 500px) and (min-width: 361px) {
  .navbar-brand {
    top: 1em !important;
  }
  .navbar-nav {
    top: 7rem !important;
  }
}

@media (max-width: 360px) { 
  .navbar-brand { 
    top: 1rem !important; 
  } 
  .navbar-nav { 
    top: 5rem !important; 
  }  
};

/* =========================================================
   MAYANK LAL — CALM INTELLIGENT TYPOGRAPHY SYSTEM
   Inspired by Minimalist Japanese + Editorial Aesthetics
========================================================= */

/* -------- Base Type System -------- */
html {
  font-size: 16px; /* Root for consistent rem scaling */
  scroll-behavior: smooth;
}

body {
  font-family: "Source Serif 4", "Georgia", serif;
  font-weight: 400;
  color: #1b1b1b;
  background: transparent;
  font-size: 1.06rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* =========================================================
   HEADINGS — Modern Serif-Sans Blend with Visual Hierarchy
========================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: "EB Garamond", "Inter", sans-serif;
  font-weight: 600;
  line-height: 1.25;
  color: #111;
  letter-spacing: 0.01em;
  text-align: center;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  text-transform: none;
  letter-spacing: 0.015em;
  padding-bottom: 0.3em;
}

h2 {
  font-size: clamp(1.6rem, 3.2vw, 2rem);
  border-left: 3px solid rgba(0,0,0,0.1);
  padding-left: 0.75rem;
  margin-top: 2.2rem;
  margin-bottom: 0.8rem;
}

h3 {
  font-size: clamp(1.3rem, 2.4vw, 1.6rem);
  font-weight: 500;
  color: #222;
  margin-top: 1.8rem;
  margin-bottom: 0.5rem;
}

h4, h5, h6 {
  font-size: 1.1rem;
  font-weight: 500;
  color: #333;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

/* =========================================================
   PARAGRAPHS — Gentle Contrast, Longform Readability
========================================================= */
p {
  max-width: 72ch;
  /* margin: 0 auto 1.3em; */
  text-align: justify;
  color: #2a2a2a;
  line-height: 1.75;
  font-size: clamp(1rem, 1.2vw, 1.06rem);
}

/* Small visual rhythm tweak for paragraph spacing */
p + p {
  margin-top: 0.8em;
}

/* =========================================================
   EMPHASIS & INLINE ELEMENTS
========================================================= */
em, i {
  font-style: italic;
  color: #444;
  letter-spacing: 0.01em;
}

strong, b {
  font-weight: 600;
  color: #111;
}

/* =========================================================
   FOOTER TYPOGRAPHY — Quiet, Grounded Presence
========================================================= */
.page-footer {
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  color: #444;
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.4;
  padding: 2rem 1rem 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.1);
  background: rgba(255, 255, 255, 0.25);
}

.page-footer a {
  color: #8c1b0f;
  font-weight: 500;
  text-decoration: none;
}

.page-footer a:hover {
  color: #b8321a;
  text-decoration: underline;
}

/* -----------------------------------------------------
   MOBILE — Make it smaller & centered neatly below footer
------------------------------------------------------ */
@media (max-width: 1024px) {
  .image-attribution {
    font-size: 0.65rem !important;
    text-align: center;
    line-height: 1.3;
    white-space: normal;   /* allow wrapping if needed */
    margin-top: 0.3rem;
  }
}

/* =========================================================
   RESPONSIVE TYPE SCALE — Fluid Adaptation
========================================================= */
@media (max-width: 1024px) {
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.6rem; }
  h3 { font-size: 1.3rem; }
  p   { font-size: 1rem; line-height: 1.65; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }
  p   { font-size: 0.8rem; line-height: 1.6; }
  blockquote { font-size: 0.95rem; padding-left: 1rem; }
  .page-footer { font-size: 0.85rem; line-height: 1.3; }
}

/* =========================================================
   PAGE TITLE — "Quantitative Storyteller" Style
   ========================================================= */
h1.title,
.page-title,
.quarto-title-block .title {
  font-family: "Cormorant Garamond", serif !important;
  font-style: italic !important;
  font-weight: 500 !important;
  font-size: clamp(1.8rem, 3vw + 1rem, 2.6rem) !important;
  color: #1a1a1a !important;
  text-align: center !important;
  letter-spacing: 0.02em;
  word-spacing: 0.05em;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* -----------------------------------------------------
   Footer Alignment Fix — Always Centered
------------------------------------------------------ */
.nav-footer {
  background-color: inherit !important;  /* same as page background */
  color: inherit !important;              /* same as main text */
  text-align: center;
  justify-content: center;
  width: 100%;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: none;
}

/* Target the <p> tag inside footer and center it */
.nav-footer-center p {
  margin: 0 auto;
  text-align: center;
  max-width: none;          /* remove Quarto’s inner limit */
  width: fit-content;       /* adapt exactly to text width */
  display: inline-block;    /* ensures true centering */
}

.nav-footer-left {
  display: none !important;
}

/* On smaller screens — keep centered, slightly smaller */
@media (max-width: 1024px) {
    .nav-footer {
    padding: 0;          /* less padding vertically on mobile */
  }

  .nav-footer-center p {
    margin-top: 0;         /* snug to the border */
  }
}

/* ----------------------------------------------------
   Sync grid width with main document content on mobile
---------------------------------------------------- */
@media (max-width: 1024px) {
  .grid {
    width: 100% !important;
    max-width: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  main.quarto-document-content.content {
    width: 100% !important;
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box;
  }
}

/* =========================================================
   DISABLE HEADROOM.JS — Keep Navbar Always Visible
========================================================= */

.headroom.fixed-top {
  position: absolute !important;
  top: 3rem !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1000 !important;
  background: transparent !important;
  transform: none !important;
  transition: none !important;
}

.headroom.fixed-top .navbar {
  max-width: 825px !important;
  margin: 0 auto !important;
}

/* =========================================================
   FIX: Prevent body title/content overlap with fixed navbar
========================================================= */

main.content,
main.quarto-document-content,
#quarto-content {
  padding-top: 2rem !important;  /* adjust height of header + brand + navbar */
  position: relative;
  z-index: 1;
}

/* =========================================================
   FOOTER — Re-arranged Layout with Attribution Below Center
   ========================================================= */

/* Stack center footer text and attribution vertically */
footer .nav-footer {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 0.25rem !important;
  padding-bottom: 0.5rem !important;
}

/* Keep main "Powered by Quarto · Mayank Lal © 2025" centered */
footer .nav-footer .nav-footer-center {
  order: 1 !important;
  width: 100% !important;
  text-align: center !important;
}

/* Move the right-block attribution to its own row */
footer .nav-footer .nav-footer-right {
  order: 2 !important;
  width: 100% !important;
  text-align: right !important;
  padding-right: 1rem !important;
}

/* =========================================================
   HEADER IMAGE + ATTRIBUTION — Unified Layout
   ========================================================= */
.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  margin: 0 auto;
  max-width: 825px; /* matches navbar width */
  width: 100%;
  background: transparent;
}

.site-header-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 0;
}

/* Attribution: sits directly under image, matching width */
.site-header .image-attribution {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial !important;
  font-size: 0.7rem !important;
  color: rgba(60, 40, 20, 0.7) !important;
  text-align: right !important;
  width: 100% !important;
  max-width:825px;
  line-height: 1.1 !important;
  letter-spacing: 0.01em !important;
  opacity: 0.85 !important;
  margin-top: 0.25rem !important;
  margin-bottom: 0 !important;
  padding-right: 0.5rem !important;
  box-sizing: border-box !important;
}

.site-header .image-attribution a {
  color: #8c1b0f !important;
  text-decoration: none !important;
  font-weight: 500 !important;
  transition: color 0.2s ease !important;
}

.site-header .image-attribution a:hover {
  color: #b8321a !important;
  text-decoration: underline !important;
}

/* CC icon size + alignment */
.site-header .image-attribution .cc-icon {
  height: 1em !important;
  width: auto !important;
  vertical-align: text-bottom !important;
  margin-left: 3px !important;
  opacity: 0.85 !important;
  transition: opacity 0.2s ease !important;
}

.site-header .image-attribution a:hover .cc-icon {
  opacity: 1 !important;
}

/* Mobile: center attribution */
@media (max-width: 1024px) {
  .site-header .image-attribution {
    text-align: right !important;
    font-size: 0.62rem !important;
    padding-right: 0 !important;
    margin-top: 0.3rem !important;
  }
}

/* Optional: smooth fade-in */
.site-header .image-attribution {
  opacity: 0;
  animation: fadeInAttribution 0.6s ease-in forwards;
  animation-delay: 0.3s;
}

@keyframes fadeInAttribution {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 0.85; transform: translateY(0); }
}

/* =========================================================
   FAIRYTALE DROP CAP — Only for main body paragraph
   ========================================================= */

/* Apply to the first paragraph in the main article body
   but exclude paragraphs inside blockquotes or footers */
main.content > p:first-of-type::first-letter,
main.quarto-document-content > p:first-of-type::first-letter,
#quarto-content > p:first-of-type::first-letter {
  font-family: "Cormorant Unicase", "Cormorant Garamond", serif !important;
  font-weight: 600 !important;
  font-size: 4.8rem !important;
  line-height: 0.8 !important;
  float: left !important;
  margin-right: 0.15em !important;
  margin-top: 0.05em !important;
  margin-bottom: 0.05em !important;
  color: #2a1d14 !important;
  text-transform: uppercase !important;
  initial-letter: 2 !important;
  font-feature-settings: "swsh", "liga", "clig" !important;
  padding: 0.05em 0.1em !important;
}

/* Reduce vertical space after first paragraph */
main.content > p:first-of-type,
main.quarto-document-content > p:first-of-type,
#quarto-content > p:first-of-type {
  margin-bottom: 0.4em !important; /* was likely 1.3em — tighten it */
  line-height: 1.55 !important;    /* balanced for smoother flow */
}

/* Ensure paragraphs inside blockquotes are never styled */
blockquote p::first-letter {
  all: unset !important;
}

/* Responsive scaling */
@media (max-width: 1024px) {
  main.content > p:first-of-type::first-letter,
  main.quarto-document-content > p:first-of-type::first-letter,
  #quarto-content > p:first-of-type::first-letter {
    font-size: 3.2rem !important;
    line-height: 0.9 !important;
  }
}

/* =========================================================
   BLOCKQUOTE — Clean Literary Styling with Proper Attribution
========================================================= */

/* Base blockquote styling (you can keep your existing one if it’s already set) */
main.content blockquote,
main.quarto-document-content blockquote,
#quarto-content blockquote {
  text-align: left !important;
  text-justify: auto;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0.75rem !important;
  border-left: 3px solid rgba(0, 0, 0, 0.15) !important;
  font-style: italic !important;
  font-size: 1.3rem !important;
  line-height: 1.7 !important;
  color: #444 !important;
  max-width: none !important;   /* ✅ disables 72ch centering */
  width: 100% !important;       /* ✅ ensures full text width alignment */
  box-sizing: border-box !important;
}

/* -------------------------------------
   Attribution line — the one starting with an em dash (—)
------------------------------------- */
blockquote p:last-of-type {
  text-align: right !important;
  font-style: normal !important;
  font-weight: 500 !important;
  color: #2a2a2a !important;
  margin-top: 0.6rem !important;
}

/* Remove automatic dash for the last line (author attribution) */
blockquote p:last-of-type::before {
  content: none !important;
  text-align: left !important;
}

/* =========================================================
   TITLE META — Clean Author + Date (Aligned Left, FT Style)
   ========================================================= */
.quarto-title-meta {
  display: block !important;
  text-align: left !important;
  max-width: 825px !important;
  margin: 0 auto 2rem !important;
  padding-bottom: 0.75rem !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
  font-family: "Inter", "Source Sans 3", sans-serif !important;
  color: #222 !important;
}

.quarto-title-meta-contents {
  display: block !important;
}

/* Hide "AUTHOR" and "PUBLISHED" labels */
.quarto-title-meta-heading {
  display: none !important;
}

/* First paragraph — Author name */
.quarto-title-meta-contents > div > p:first-of-type {
  font-weight: 600 !important;
  font-size: 1rem !important;
  letter-spacing: 0.01em !important;
  margin-bottom: 0.25rem !important;
  color: #111 !important;
}

/* Date line — directly under author, left aligned */
.quarto-title-meta .date {
  display: block !important;
  font-size: 0.7rem !important;
  color: rgba(0, 0, 0, 0.65) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.03em !important;
  font-weight: 400 !important;
  text-align: left !important;
  margin-left: 0 !important;
  margin-top: 0 !important;
  padding-left: 0 !important;
}

/* =========================================================
   FIX — Remove Extra Indentation from Title Meta Block
   ========================================================= */
.quarto-title-meta,
.quarto-title-meta-contents,
.quarto-title-meta-contents > div,
.quarto-title-meta-contents > div > p {
  margin-left: 0 !important;
  padding-left: 0 !important;
  text-indent: 0 !important;
}