/* ==========================================================================
   MARLIN blog — scoped styles for "The Marlin Framework" blog section.
   Loaded only on pages with `blog_page: true` (see _includes/head_custom.html).
   Uses the brand tokens defined in _sass/custom/custom.scss (--marlin-*).
   Dark teal-green theme: white text, dark surfaces, orange accents.
   ========================================================================== */

:root {
  --blog-ink: var(--marlin-text, #ffffff);         /* headings / primary text */
  --blog-body: #d8e3e3;                             /* body copy on dark */
  --blog-green: var(--marlin-green, #1a4950);
  --blog-accent: var(--marlin-orange, #ff5c00);
  --blog-surface: var(--marlin-surface, #143037);  /* cards, callouts, gallery */
  --blog-deep: var(--marlin-surface-2, #0a1f22);   /* carousel + media backgrounds */
  --blog-muted: var(--marlin-muted, #9fb3b3);
  --blog-line: var(--marlin-border, #21474e);
  --blog-glass: rgba(18, 46, 52, 0.55);          /* frosted surface */
  --blog-glass-border: rgba(255, 255, 255, 0.10);
  --blog-radius: 16px;
  --blog-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 30px rgba(0, 0, 0, 0.38);
  --blog-shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.30), 0 22px 48px rgba(0, 0, 0, 0.48);
  --blog-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Content width is handled site-wide in _sass/custom/custom.scss
   (left-aligned, full width). The container queries below keep the chapter
   layout correct at whatever width the content column ends up. */

/* Wrapper opted into container-based responsiveness so the chapter layout
   keys off available content width, not the viewport. */
.marlin-blog {
  container-type: inline-size;
  container-name: blog;
}

.marlin-blog,
.marlin-blog p,
.marlin-blog li {
  font-family: var(--body-font-family, "IBM Plex Sans", system-ui, sans-serif);
}

.marlin-blog h1,
.marlin-blog h2,
.marlin-blog h3 {
  color: var(--blog-ink);
  letter-spacing: -0.015em;
}

/* Headings, labels and UI bits in JetBrains Mono; body copy stays IBM Plex Sans */
.marlin-blog h1, .marlin-blog h2, .marlin-blog h3,
.post-hero h1, .post-chapter__text h2, .blog-card__title, .blog-welcome h1,
.post-hero__eyebrow, .post-chapter__eyebrow, .blog-welcome .eyebrow,
.blog-card__meta, .blog-card__more, .blog-btn, .post-hero__meta {
  font-family: var(--marlin-font-head, "JetBrains Mono", ui-monospace, monospace);
}

/* ---------------------------------------------------------------- Buttons */
.blog-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.6em 1.1em;
  border-radius: 999px;
  background: var(--blog-accent);
  color: #fff !important;
  font-weight: 600;
  font-size: 0.86rem;
  text-decoration: none !important;
  transition: transform 0.2s var(--blog-ease), box-shadow 0.2s var(--blog-ease);
}
.blog-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(255, 92, 0, 0.32); }

/* =====================================================  BLOG INDEX (landing) */
.blog-welcome {
  margin: 0 0 2.2rem;
  padding: 2rem 0 1.6rem;
  border-bottom: 1px solid var(--blog-line);
}
.blog-welcome .eyebrow {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blog-accent);
  margin-bottom: 0.6rem;
}
.blog-welcome h1 { font-size: clamp(1.9rem, 4cqi, 2.8rem); margin: 0 0 0.5rem; }
.blog-welcome p { font-size: 1.05rem; color: var(--blog-muted); max-width: 60ch; margin: 0; }

.blog-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.4rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--blog-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--blog-glass-border);
  border-radius: var(--blog-radius);
  overflow: hidden;
  box-shadow: var(--blog-shadow);
  transition: transform 0.28s var(--blog-ease), box-shadow 0.28s var(--blog-ease);
}
.blog-card:hover { transform: translateY(-4px); box-shadow: var(--blog-shadow-hover); }

.blog-card__media {
  aspect-ratio: 16 / 9;
  background: var(--blog-deep);
  overflow: hidden;
}
.blog-card__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--blog-ease);
}
.blog-card:hover .blog-card__media img { transform: scale(1.04); }

.blog-card__body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.blog-card__meta { font-size: 0.76rem; color: var(--blog-muted); letter-spacing: 0.02em; }
.blog-card__meta .dot { margin: 0 0.45em; opacity: 0.5; }
.blog-card__title { margin: 0; font-size: 1.22rem; line-height: 1.25; }
.blog-card__title a { color: var(--blog-ink) !important; text-decoration: none !important; }
.blog-card:hover .blog-card__title a { color: var(--blog-accent) !important; }
.blog-card__excerpt { margin: 0; font-size: 0.92rem; color: var(--blog-muted); line-height: 1.5; }
.blog-card__more { margin-top: auto; padding-top: 0.7rem; font-size: 0.82rem; font-weight: 600; color: var(--blog-accent); }

/* Full-card click target */
.blog-card__link { position: absolute; inset: 0; z-index: 1; text-indent: -9999px; overflow: hidden; }
.blog-card a:not(.blog-card__link) { position: relative; z-index: 2; }

/* =====================================================  BLOG POST (article) */
.post-hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  margin: 0.5rem 0 2.6rem;
  min-height: clamp(320px, 46cqi, 520px);
  display: flex;
  align-items: flex-end;
  box-shadow: var(--blog-shadow);
  isolation: isolate;
}
.post-hero img {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%;
  object-fit: cover;
}
.post-hero::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(13,37,40,0.10) 0%, rgba(13,37,40,0.30) 45%, rgba(13,37,40,0.82) 100%);
}
.post-hero__inner { padding: clamp(1.4rem, 4cqi, 2.8rem); color: #fff; max-width: 64ch; }
.post-hero__eyebrow {
  display: inline-block;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: #fff; background: var(--blog-accent);
  padding: 0.3em 0.7em; border-radius: 999px; margin-bottom: 0.9rem;
}
.post-hero h1 { color: #fff !important; font-size: clamp(2rem, 6cqi, 3.4rem); line-height: 1.05; margin: 0 0 0.6rem; }
.post-hero__sub { font-size: clamp(1rem, 2.4cqi, 1.25rem); color: rgba(255,255,255,0.92); margin: 0 0 1rem; }
.post-hero__meta { font-size: 0.84rem; color: rgba(255,255,255,0.82); letter-spacing: 0.02em; }
.post-hero__meta .dot { margin: 0 0.45em; opacity: 0.6; }

.scroll-cue {
  position: absolute; bottom: 1rem; right: 1.3rem; z-index: 1;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.7);
  display: grid; place-items: center;
  color: #fff !important;
  cursor: pointer;
  text-decoration: none !important;
  background: rgba(13, 37, 40, 0.18);
  animation: cueBob 1.8s var(--blog-ease) infinite;
  transition: background 0.2s var(--blog-ease), border-color 0.2s var(--blog-ease);
}
.scroll-cue:hover { background: var(--blog-accent); border-color: var(--blog-accent); }
.scroll-cue:focus-visible { outline: 3px solid var(--blog-accent); outline-offset: 3px; }
.scroll-cue svg { width: 16px; height: 16px; }
@keyframes cueBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* Lede paragraph under the hero */
.post-lede { font-size: 1.18rem; line-height: 1.6; color: var(--blog-ink); max-width: 64ch; margin: 0 auto 2.4rem; }

/* ---- Chapters (alternating image / text) ---- */
.post-chapter {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3cqi, 2.2rem);
  align-items: center;
  margin: 0 0 clamp(2.4rem, 7cqi, 4.6rem);
}
.post-chapter__media { flex: 1 1 0; width: 100%; min-width: 0; }
.post-chapter__media img {
  width: 100%;
  border-radius: var(--blog-radius);
  box-shadow: var(--blog-shadow);
  display: block;
}
.post-chapter__media figcaption {
  margin-top: 0.6rem; font-size: 0.8rem; color: var(--blog-muted); text-align: center;
}
.post-chapter__text { flex: 1 1 0; min-width: 0; }
.post-chapter__eyebrow {
  display: block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--blog-accent); margin-bottom: 0.5rem;
}
.post-chapter__text h2 { margin: 0 0 0.7rem; font-size: clamp(1.4rem, 3.4cqi, 2rem); line-height: 1.15; }
.post-chapter__text p { font-size: 1.02rem; line-height: 1.62; color: var(--blog-body); margin: 0 0 0.9rem; }
.post-chapter__text p:last-child { margin-bottom: 0; }

@container blog (min-width: 720px) {
  .post-chapter { flex-direction: row; gap: clamp(2rem, 4cqi, 3.4rem); }
  .post-chapter--reverse { flex-direction: row-reverse; }
  .post-lede { font-size: 1.24rem; }
}

/* ---- Pull quote (origin chapter) ---- */
.pull-quote {
  margin: 0 0 clamp(2.4rem, 7cqi, 4.6rem);
  padding: 1.4rem 0 1.4rem 1.6rem;
  border-left: 4px solid var(--blog-accent);
  font-size: clamp(1.3rem, 3.4cqi, 1.9rem);
  line-height: 1.3;
  color: var(--blog-ink);
  font-weight: 500;
}
.pull-quote cite { display: block; margin-top: 0.7rem; font-size: 0.85rem; font-style: normal; color: var(--blog-muted); }

/* ---- Callout (credentials note) ---- */
.blog-callout {
  display: flex; gap: 0.9rem; align-items: flex-start;
  background: var(--blog-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--blog-glass-border);
  border-left: 4px solid var(--blog-accent);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin: 0 0 clamp(2.4rem, 7cqi, 4.6rem);
  box-shadow: var(--blog-shadow);
}
.blog-callout svg { flex: 0 0 auto; width: 22px; height: 22px; color: var(--blog-accent); margin-top: 2px; }
.blog-callout p { margin: 0; font-size: 0.95rem; line-height: 1.55; color: var(--blog-body); }
.blog-callout strong { color: var(--blog-ink); }

/* ---- Carousel (galleries) ---- */
.blog-carousel { margin: 0 0 clamp(2.4rem, 7cqi, 4.6rem); }
.carousel {
  position: relative;
  border-radius: var(--blog-radius);
  overflow: hidden;
  background: var(--blog-deep);
  box-shadow: var(--blog-shadow);
}
.carousel__track { display: flex; transition: transform 0.5s var(--blog-ease); will-change: transform; }
.carousel__slide { position: relative; flex: 0 0 100%; min-width: 0; }
.carousel__slide img { width: 100%; display: block; aspect-ratio: 16 / 9; object-fit: cover; background: #0d2528; }
.carousel__caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1.4rem 1.2rem 0.9rem;
  background: linear-gradient(180deg, rgba(13,37,40,0) 0%, rgba(13,37,40,0.78) 100%);
  color: #fff; font-size: 0.86rem;
}

.carousel__btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(255,255,255,0.9); color: var(--blog-deep);
  display: grid; place-items: center;
  transition: background 0.2s var(--blog-ease), transform 0.2s var(--blog-ease);
  z-index: 2;
}
.carousel__btn:hover { background: var(--blog-accent); color: #fff; }
.carousel__btn:focus-visible { outline: 3px solid var(--blog-accent); outline-offset: 2px; }
.carousel__btn svg { width: 18px; height: 18px; }
.carousel__btn--prev { left: 0.8rem; }
.carousel__btn--next { right: 0.8rem; }

.carousel__dots { display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.9rem; }
.carousel__dot {
  width: 9px; height: 9px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: var(--blog-line);
  transition: background 0.2s var(--blog-ease), transform 0.2s var(--blog-ease);
}
.carousel__dot[aria-selected="true"] { background: var(--blog-accent); transform: scale(1.25); }

/* ---- Product gallery (recorders) ---- */
.blog-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
  margin: 0 0 clamp(2rem, 6cqi, 3.4rem);
  padding: 0; list-style: none;
}
.blog-gallery li {
  background: var(--blog-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--blog-glass-border); border-radius: var(--blog-radius);
  overflow: hidden; box-shadow: var(--blog-shadow); text-align: center;
}
.blog-gallery img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.blog-gallery figcaption { padding: 0.7rem; font-size: 0.86rem; font-weight: 600; color: var(--blog-ink); }

/* ---- Closing / back-to-index ---- */
.post-end {
  margin-top: clamp(2.4rem, 7cqi, 4rem);
  padding-top: 1.6rem;
  border-top: 1px solid var(--blog-line);
  display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; justify-content: space-between;
}
.post-end p { margin: 0; color: var(--blog-muted); font-size: 0.92rem; }

/* =====================================================  Scroll reveal
   Hidden state applies ONLY when JS is active (html.marlin-js, set
   synchronously in the head). Without JS — or if blog.js fails — content
   stays fully visible, never stuck hidden. */
.marlin-js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s var(--blog-ease), transform 0.7s var(--blog-ease);
  will-change: opacity, transform;
}
.marlin-js .reveal.is-visible { opacity: 1; transform: none; }
.marlin-js .reveal--delay-1 { transition-delay: 0.08s; }
.marlin-js .reveal--delay-2 { transition-delay: 0.16s; }

/* Respect users who prefer reduced motion: show everything, no transforms */
@media (prefers-reduced-motion: reduce) {
  .marlin-js .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .carousel__track { transition: none !important; }
  .scroll-cue { animation: none !important; }
  .blog-card, .blog-card__media img, .blog-btn { transition: none !important; }
}
