/* ==========================================================================
   Sage Flexible - Consolidated Stylesheet
   Refactored: all inline <style> blocks merged here for cacheability.
   ========================================================================== */

/* 1. Imports & Fonts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap");

:root {
  /* These values are injected dynamically in default.hbs from @custom settings,
       but we provide defaults here for stability and Dev UI clarity. */
  --bg-color: #faf9f6;
  --text-color: #2d312e;
  --card-bg: #ffffff;
  --ghost-accent-color: #ff1a75; /* Standard Ghost Accent Fallback */

  --font-serif: "Lora", serif;
  --font-sans: "Inter", sans-serif;

  --container-width: 1200px;
  --content-width: 720px;
  --wide-width: 1000px;

  --border-radius: 8px;
  --spacing: 2rem;
}

/* 2. Resets & Globals */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1.1rem;
  line-height: 1.65;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* 3. Typography
   Ghost 6+ injects --gh-font-body and --gh-font-heading via {{ghost_head}}
   when the site owner picks custom fonts. We use those with a fallback to
   the theme's own fonts (controlled by the typography_style custom setting).
   The html class (is-serif / is-sans) picks which theme font is the fallback. */
html.is-serif body {
  font-family: var(--gh-font-body, var(--font-serif));
}
html.is-sans body {
  font-family: var(--gh-font-body, var(--font-sans));
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  margin-top: 0;
  font-weight: 600;
}

/* Ghost custom heading font with fallback to theme's own */
html.is-serif h1, html.is-serif h2, html.is-serif h3,
html.is-serif h4, html.is-serif h5, html.is-serif h6 {
  font-family: var(--gh-font-heading, var(--font-serif));
}
html.is-sans h1, html.is-sans h2, html.is-sans h3,
html.is-sans h4, html.is-sans h5, html.is-sans h6 {
  font-family: var(--gh-font-heading, var(--font-sans));
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

/* 4. Layout Shell */
.gh-viewport {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.gh-main {
  flex-grow: 1;
}

.gh-container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
}

/* 5. Header & Navigation */
.gh-head {
  height: 80px;
  display: flex;
  align-items: center;
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.gh-head-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
}

.gh-head-brand {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
}

.gh-head-menu ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  padding: 0;
  margin: 0;
}

.gh-head-actions {
  display: flex;
  justify-content: flex-end;
}

.gh-btn-subscribe {
  background-color: var(--ghost-accent-color);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

/* 6. Post Feed (Grid vs List via data-attribute) */
.post-feed {
  display: grid;
  gap: var(--spacing);
  margin: var(--spacing) 0;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.post-feed[data-layout="column"] {
  grid-template-columns: 1fr;
  max-width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
}

.post-card {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.post-card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--border-radius);
}

.post-card-content {
  padding: 1.5rem;
}

.post-card-tag {
  color: var(--ghost-accent-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: block;
}

/* 7. Post Content Styles */
.gh-content {
  max-width: var(--content-width);
  margin: 0 auto;
}

.gh-content blockquote {
  border-left: 3px solid var(--ghost-accent-color);
  margin: 2rem 0;
  padding: 0 0 0 1.5rem;
  font-style: italic;
  font-size: 1.2rem;
}

/* Image Styles mapped to @custom.image_style */
.image-wide {
  max-width: var(--wide-width);
  width: 100%;
  margin: 2rem calc(50% - var(--wide-width) / 2);
}

.image-standard {
  max-width: var(--content-width);
  width: 100%;
  margin: 2rem auto;
}

/* Koenig Editor Width Classes (required by Ghost) */
.gh-content .kg-width-wide {
  max-width: var(--wide-width);
  margin-left: calc(50% - var(--wide-width) / 2);
  margin-right: calc(50% - var(--wide-width) / 2);
}

.gh-content .kg-width-full {
  max-width: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  width: 100vw;
}

.kg-width-wide img,
.kg-width-full img {
  width: 100%;
}

/* Full-width card stacking (Ghost canonical recs) */
.kg-width-full + .kg-width-full {
  margin-top: 0;
}

.page-template .gh-content > .kg-width-full:first-child {
  margin-top: calc(-1 * var(--spacing));
}

.page-template .gh-content > .kg-width-full:last-child {
  margin-bottom: calc(-1 * var(--spacing));
}

.kg-width-full.kg-card-hascaption + .kg-width-full {
  margin-top: var(--spacing);
}

/* 8. Footer */
.gh-foot {
  padding: 4rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* 9. Responsiveness (global breakpoint) */
@media (max-width: 800px) {
  .gh-head-inner {
    grid-template-columns: 1fr 1fr;
  }
  .gh-head-menu {
    display: none;
  }
}

/* 10. Dark Mode
   Consolidated: :is() selector targets both manual dark and auto-dark 
   to eliminate rule duplication. */
:root {
  --dark-bg: #1a1a1a;
  --dark-text: #e8e6e1;
  --dark-card-bg: #242424;
  --dark-border: rgba(255, 255, 255, 0.08);
}

html.is-dark {
  --bg-color: var(--dark-bg);
  --text-color: var(--dark-text);
  --card-bg: var(--dark-card-bg);
}

@media (prefers-color-scheme: dark) {
  html.is-auto {
    --bg-color: var(--dark-bg);
    --text-color: var(--dark-text);
    --card-bg: var(--dark-card-bg);
  }
}

/* Shared dark mode component overrides.
   :is() lets us write these once instead of duplicating for .is-dark and .is-auto. */
:is(html.is-dark) .gh-head {
  border-bottom: 1px solid var(--dark-border);
}
:is(html.is-dark) .post-card {
  border: 1px solid var(--dark-border);
}
:is(html.is-dark) .gh-foot {
  border-top: 1px solid var(--dark-border);
}
:is(html.is-dark) .gh-hero-input {
  background: rgba(255, 255, 255, 0.1);
  color: var(--dark-text);
  border-color: var(--dark-border);
}
:is(html.is-dark) .gh-auth-input {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-color);
}
:is(html.is-dark) .message-success {
  background: #1a3a2a;
  color: #a3d9b1;
  border-color: #2a5a3a;
}
:is(html.is-dark) .message-error {
  background: #3a1a1a;
  color: #d9a3a3;
  border-color: #5a2a2a;
}
:is(html.is-dark) .gh-author-card {
  background: rgba(255, 255, 255, 0.03);
}

@media (prefers-color-scheme: dark) {
  :is(html.is-auto) .gh-head {
    border-bottom: 1px solid var(--dark-border);
  }
  :is(html.is-auto) .post-card {
    border: 1px solid var(--dark-border);
  }
  :is(html.is-auto) .gh-foot {
    border-top: 1px solid var(--dark-border);
  }
  :is(html.is-auto) .gh-hero-input {
    background: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
    border-color: var(--dark-border);
  }
  :is(html.is-auto) .gh-auth-input {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
  }
  :is(html.is-auto) .message-success {
    background: #1a3a2a;
    color: #a3d9b1;
    border-color: #2a5a3a;
  }
  :is(html.is-auto) .message-error {
    background: #3a1a1a;
    color: #d9a3a3;
    border-color: #5a2a2a;
  }
  :is(html.is-auto) .gh-author-card {
    background: rgba(255, 255, 255, 0.03);
  }
}

/* 11. Header Style Variants */

/* Transparent: floats over the hero */
.gh-head.is-transparent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  border-bottom: none;
  z-index: 1000;
}

.gh-head.is-transparent .gh-head-brand a,
.gh-head.is-transparent .gh-head-menu a {
  color: #fff;
}

/* Minimal: no frills, just nav */
.gh-head.is-minimal {
  height: 60px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* 12. Search Button */
.gh-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  padding: 0.4rem;
  margin-right: 0.5rem;
}

.gh-search:hover {
  opacity: 1;
}

/* 13. Related Posts */
.gh-related {
  margin-top: 6rem;
  padding-top: 4rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.gh-related-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  opacity: 0.5;
  margin-bottom: 2rem;
}

.gh-related-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--spacing);
}

/* ==========================================================================
   Sections 14-19: Absorbed from inline <style> blocks
   ========================================================================== */

/* 14. Hero Section (from index.hbs) */
.gh-hero {
  padding: 10vh 0;
  background-color: var(--bg-color);
}

.gh-hero.is-centered {
  text-align: center;
}

.gh-hero.is-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  text-align: left;
}

.gh-hero-title {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.gh-hero-description {
  font-size: 1.25rem;
  max-width: 600px;
  margin: 0 auto 2rem;
  opacity: 0.8;
}

.gh-hero.is-split .gh-hero-description {
  margin-left: 0;
}

.gh-hero-form {
  display: flex;
  gap: 1rem;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
}

.gh-hero-input {
  flex-grow: 1;
  padding: 0.8rem 1.2rem;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
}

.gh-hero-btn {
  background: var(--ghost-accent-color);
  color: #fff;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Hero with background image: overlay for readability */
.gh-hero[style*="background-image"] {
  color: #fff;
  position: relative;
}

.gh-hero[style*="background-image"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.gh-hero[style*="background-image"] .gh-container {
  position: relative;
  z-index: 1;
}

/* 15. Article Header & Feature Image (from post.hbs, page.hbs) */
.gh-article-header {
  padding: 4rem 0;
  text-align: center;
}

.gh-article-meta {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-bottom: 1rem;
}

.gh-article-meta-sep {
  margin: 0 0.5rem;
}

.gh-article-title {
  font-size: 4rem;
  margin-bottom: 2rem;
}

.gh-article-excerpt {
  font-size: 1.5rem;
  opacity: 0.7;
  max-width: 800px;
  margin: 0 auto 3rem;
  line-height: 1.4;
}

/* 16. Author Card & Post Navigation (from post.hbs) */
.gh-author-card {
  display: flex;
  gap: 2rem;
  align-items: center;
  padding: 3rem;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  margin-top: 4rem;
  text-align: left;
}

.gh-author-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.gh-author-name {
  margin: 0 0 0.5rem;
}

.gh-author-bio {
  margin: 0;
  opacity: 0.8;
  font-size: 1rem;
}

.gh-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  padding: 4rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  margin-top: 4rem;
}

.gh-navigation-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.5;
  margin-bottom: 0.5rem;
}

.gh-navigation-next {
  text-align: right;
}

/* 17. Archive Pages (from author.hbs, tag.hbs, archive.hbs) */
.gh-archive-header {
  padding: 6rem 0 4rem;
  text-align: center;
}

/* Round profile image for author pages */
.gh-archive-image-round {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 2rem;
}

/* Wide feature image for tag pages */
.gh-archive-image-wide {
  width: 100%;
  max-width: 800px;
  height: 300px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 2rem;
}

.gh-archive-title {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.gh-archive-description {
  font-size: 1.25rem;
  opacity: 0.7;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.gh-archive-meta {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.5;
  text-transform: uppercase;
}

/* 18. Auth Pages (from signin.hbs, signup.hbs — previously duplicated) */
.gh-auth-page {
  max-width: 480px;
  margin: 15vh auto;
  text-align: center;
  padding: 2rem;
}

.gh-auth-title {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.gh-auth-description {
  font-size: 1.25rem;
  opacity: 0.8;
  margin-bottom: 3rem;
}

.gh-auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gh-auth-input {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-color);
  font-family: inherit;
  font-size: 1.1rem;
  outline: none;
}

.gh-auth-input:focus {
  border-color: var(--ghost-accent-color);
}

.gh-auth-btn {
  width: 100%;
  padding: 1.2rem 1.5rem;
  background: var(--ghost-accent-color);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
}

.gh-auth-btn:hover {
  opacity: 0.9;
}

.gh-btn-loader {
  display: none;
}

.gh-auth-form.loading .gh-btn-content {
  display: none;
}

.gh-auth-form.loading .gh-btn-loader {
  display: inline-block;
}

.message-success,
.message-error {
  display: none;
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.95rem;
}

.message-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.message-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.gh-auth-form.success .message-success {
  display: block;
}

.gh-auth-form.error .message-error {
  display: block;
}

.gh-auth-form.success .gh-auth-input,
.gh-auth-form.success .gh-auth-btn {
  display: none;
}

.gh-auth-alternate {
  margin-top: 3rem;
  font-size: 1rem;
  opacity: 0.8;
}

.gh-auth-alternate a {
  font-weight: 700;
  color: var(--ghost-accent-color);
  text-decoration: underline;
}

/* 19. Error Page (from error.hbs) */
.gh-error {
  padding: 20vh 0;
  text-align: center;
}

.gh-error-code {
  font-size: 10rem;
  margin: 0;
  line-height: 1;
  opacity: 0.1;
}

.gh-error-description {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  font-weight: 600;
}

.gh-error-link {
  font-weight: 700;
  text-decoration: underline;
}

/* ==========================================================================
   20. Responsive Overrides (consolidated)
   ========================================================================== */
@media (max-width: 800px) {
  .gh-article-title {
    font-size: 2.5rem;
  }

  .gh-navigation {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .gh-related-feed {
    grid-template-columns: 1fr;
  }

  .gh-hero.is-split {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .gh-hero.is-split .gh-hero-description {
    margin-left: auto;
  }

  .gh-hero-title {
    font-size: 2.5rem;
  }
}
