/*
 * TFM Town Square — core styles for all single post pages
 * /wp-content/themes/blocksy/css/tfm-townsquare-core.css
 *
 * Registered by php/tfm-townsquare-core.php. Each single page file
 * (games-inspirations, mantras, later the daily task) loads it as a
 * dependency, so the shared parts exist only here:
 *   card with ornament frame, header, eyebrow + title, body text with the
 *   editor formats, end ornament + ending text, post navigation.
 *
 * COLORS: only the global variables from the "TFM Color Theme CSS"
 * (--area-accent, --area-accent-soft, --area-accent-glow). The page gets
 * body.tfm-area-square from tfm-townsquare.php.
 *
 * Layout values (spacing, sizes, gaps) are set in Elementor. Padding in this
 * file is NOT marked !important, so whatever you set in Elementor wins.
 *
 * ── STRUCTURE ────────────────────────────────────────────────
 *  1. Card with ornament frame        .tfm-sq-single-card
 *  2. Header (featured image)         .tfm-sq-single-head
 *  3. Eyebrow + title                 .tfm-sq-single-eyebrow / -title
 *  4. Body text (ACF WYSIWYG)         .tfm-sq-single-body
 *  5. End ornament + ending text      .tfm-sq-end / .tfm-sq-single-ending
 *  6. Post navigation                 .tfm-sq-pn
 *  7. Responsive + reduced motion
 */

/* ============================================================
   1. CARD WITH ORNAMENT FRAME
   Class on the container that holds the whole page content. The four
   corner pieces are injected by the JS file (Elementor containers use
   ::before / ::after themselves, so they cannot be drawn with those).
   ============================================================ */

.tfm-sq-single-card {
  position: relative;
  overflow: hidden;
  background: rgba(30, 22, 52, 0.72) !important;
  border: 1px solid color-mix(in srgb, var(--area-accent) 22%, transparent) !important;
  border-radius: 14px !important;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .75), 0 0 40px -18px var(--area-accent-glow);
}

.tfm-sq-corner {
  position: absolute;
  z-index: 3;
  width: 26px;
  height: 26px;
  border: 0 solid var(--area-accent-soft);
  opacity: .75;
  pointer-events: none;
}
.tfm-sq-corner--tl { top: 12px;    left: 12px;  border-top-width: 2px;    border-left-width: 2px;  border-top-left-radius: 6px; }
.tfm-sq-corner--tr { top: 12px;    right: 12px; border-top-width: 2px;    border-right-width: 2px; border-top-right-radius: 6px; }
.tfm-sq-corner--bl { bottom: 12px; left: 12px;  border-bottom-width: 2px; border-left-width: 2px;  border-bottom-left-radius: 6px; }
.tfm-sq-corner--br { bottom: 12px; right: 12px; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 6px; }

/* ============================================================
   2. HEADER (featured image as card header)
   Container class. In Elementor: background image = Dynamic Tag
   "Featured Image", background overlay = gradient. The gradient below is
   only the fallback for posts WITHOUT a featured image: Elementor's own
   background-image rule is more specific and replaces it whenever an
   image exists.
   ============================================================ */

.tfm-sq-single-head {
  background-image:
    radial-gradient(circle at 72% 28%, rgba(64, 217, 176, .5), transparent 38%),
    radial-gradient(circle at 24% 62%, rgba(176, 110, 255, .45), transparent 44%),
    linear-gradient(135deg, #1b1038, #0e2a30);
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid color-mix(in srgb, var(--area-accent) 25%, transparent);
}

/* ============================================================
   3. EYEBROW + TITLE (both sit inside the header container)
   ============================================================ */

.tfm-sq-single-eyebrow,
.tfm-sq-single-eyebrow * {
  font-family: 'Jost', sans-serif !important;
  font-size: .72rem !important;
  font-weight: 500 !important;
  letter-spacing: .22em !important;
  text-transform: uppercase !important;
  color: var(--area-accent-soft) !important;
}
/* text-shadow without !important and not on the wildcard, so a shadow set in
   Elementor still works (same approach as the hub hero). */
.tfm-sq-single-eyebrow {
  text-shadow: 0 2px 10px rgba(0, 0, 0, .7);
}

.tfm-sq-single-title,
.tfm-sq-single-title * {
  font-family: 'Cormorant Garamond', serif !important;
  font-size: clamp(2.1rem, 4.6vw, 3.1rem) !important;
  font-weight: 600 !important;
  line-height: 1.1 !important;
  color: var(--ink, #f6f1ea) !important;
}
.tfm-sq-single-title {
  text-shadow: 0 4px 18px rgba(0, 0, 0, .85), 0 1px 5px rgba(0, 0, 0, 1);
}
.tfm-sq-single-title .elementor-heading-title::after {
  content: '';
  display: block;
  width: 56px;
  height: 2px;
  margin-top: .6rem;
  background: linear-gradient(90deg, var(--area-accent), transparent);
}

/* ============================================================
   4. BODY TEXT (Text Editor widget with the ACF WYSIWYG field)
   ============================================================ */

.tfm-sq-single-body {
  padding: 36px 44px 6px;
}
.tfm-sq-single-body,
.tfm-sq-single-body * {
  font-family: 'Cormorant Garamond', serif !important;
}
.tfm-sq-single-body p,
.tfm-sq-single-body li {
  font-size: 1.2rem !important;
  line-height: 1.8 !important;
  color: var(--body-text, #e4ddf0) !important;
}
.tfm-sq-single-body p {
  margin: 0 0 1.2em;
}

.tfm-sq-single-body h2,
.tfm-sq-single-body h3,
.tfm-sq-single-body h4 {
  font-weight: 600 !important;
  line-height: 1.2 !important;
  color: var(--ink, #f6f1ea) !important;
  margin: 1.7em 0 .6em;
}
.tfm-sq-single-body h2 { font-size: 1.7rem !important; }
.tfm-sq-single-body h3 { font-size: 1.4rem !important; }
.tfm-sq-single-body h4 { font-size: 1.2rem !important; }
.tfm-sq-single-body h2::before {
  content: '\2726';
  display: inline-block;
  margin-right: .6em;
  font-size: .5em;
  vertical-align: .35em;
  color: var(--area-accent-soft);
}

.tfm-sq-single-body a {
  color: var(--area-accent-soft) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color .2s ease;
}
.tfm-sq-single-body a:hover {
  color: var(--ink, #f6f1ea) !important;
}
.tfm-sq-single-body strong,
.tfm-sq-single-body b {
  font-weight: 600 !important;
  color: var(--ink, #f6f1ea) !important;
}

.tfm-sq-single-body ul,
.tfm-sq-single-body ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}
.tfm-sq-single-body li::marker {
  color: var(--area-accent-soft);
}

.tfm-sq-single-body blockquote {
  margin: 1.6em 0;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--area-accent);
}
.tfm-sq-single-body blockquote p {
  font-style: italic;
}

.tfm-sq-single-body figure,
.tfm-sq-single-body .wp-caption {
  margin: 1.6em 0;
  max-width: 100%;
}
.tfm-sq-single-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--area-accent) 18%, transparent);
}
.tfm-sq-single-body figcaption,
.tfm-sq-single-body .wp-caption-text {
  margin-top: .6em;
  text-align: center;
  font-style: italic;
  font-size: .98rem !important;
  color: var(--muted, #b6afc7) !important;
}

/* The three formats from the editor's format dropdown. !important where the
   generic paragraph rules above would otherwise win (the format may sit on a
   <p>). */
.tfm-sq-single-body .tfm-highlight {
  color: var(--ink, #f6f1ea);
  background: linear-gradient(transparent 58%, color-mix(in srgb, var(--area-accent) 32%, transparent) 58%);
  padding: 0 .1em;
}
.tfm-sq-single-body .tfm-instruct {
  margin: 1.6em 0;
  padding: 18px 22px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--area-accent) 32%, transparent);
  background: color-mix(in srgb, var(--area-accent) 7%, transparent);
}
.tfm-sq-single-body .tfm-instruct::before {
  content: 'Exercise';
  display: block;
  margin-bottom: .5em;
  font-family: 'Jost', sans-serif;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--area-accent-soft);
}
.tfm-sq-single-body .tfm-instruct p {
  margin: 0;
}
.tfm-sq-single-body .tfm-margin {
  margin: 1.6em 0 1.6em 2.2rem;
  padding: 4px 0 4px 18px;
  border-left: 2px dashed color-mix(in srgb, var(--area-accent) 45%, transparent);
  font-style: italic;
  font-size: 1.05rem !important;
  line-height: 1.6 !important;
  color: var(--muted, #b6afc7) !important;
}

/* ============================================================
   5. END ORNAMENT + ENDING TEXT
   .tfm-sq-end: Text widget containing only the star. Lines to both sides.
   .tfm-sq-single-ending: Text Editor widget with the ACF ending-text field.
   The JS hides it (class is-empty) when the field is empty, so no space
   is left over.
   ============================================================ */

.tfm-sq-end {
  margin: 10px 44px 0;
}
.tfm-sq-end .elementor-widget-container {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--area-accent-soft);
  font-size: .9rem;
}
.tfm-sq-end .elementor-widget-container::before,
.tfm-sq-end .elementor-widget-container::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--area-accent) 40%, transparent), transparent);
}
.tfm-sq-end,
.tfm-sq-end * {
  color: var(--area-accent-soft) !important;
  margin-top: 0;
  margin-bottom: 0;
}

.tfm-sq-single-ending {
  max-width: 560px;
  margin: 0 auto;
  padding: 26px 44px 8px;
  text-align: center;
}
.tfm-sq-single-ending,
.tfm-sq-single-ending * {
  font-family: 'Cormorant Garamond', serif !important;
  font-style: italic !important;
  font-size: 1.28rem !important;
  line-height: 1.7 !important;
  color: var(--ink, #f6f1ea) !important;
}
.tfm-sq-single-ending p {
  margin: 0;
}
.tfm-sq-single-ending.is-empty {
  display: none !important;
}

/* ============================================================
   6. POST NAVIGATION (Elementor "Post Navigation" widget)
   Previous / next entry of the same post type. Class on the widget. Label
   texts, arrow and whether titles show are set in the widget itself. The
   selectors follow the widget's own markup; if the boxes do not show up,
   check the class names with the browser's inspector.
   ============================================================ */

.tfm-sq-pn {
  padding: 28px 44px 44px;
}
.tfm-sq-pn .elementor-post-navigation {
  display: flex;
  gap: 16px;
}
.tfm-sq-pn .elementor-post-navigation__prev,
.tfm-sq-pn .elementor-post-navigation__next {
  flex: 1;
  margin: 0;
}
.tfm-sq-pn .elementor-post-navigation__separator-wrapper {
  display: none;
}
.tfm-sq-pn .elementor-post-navigation__link a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--area-accent) 40%, transparent);
  background: color-mix(in srgb, var(--area-accent) 10%, transparent);
  transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.tfm-sq-pn .elementor-post-navigation__next a {
  justify-content: flex-end;
  text-align: right;
}
.tfm-sq-pn .elementor-post-navigation__link a:hover {
  background: color-mix(in srgb, var(--area-accent) 22%, transparent);
  border-color: var(--area-accent);
  box-shadow: 0 0 18px -4px var(--area-accent-glow);
}
.tfm-sq-pn .post-navigation__prev--label,
.tfm-sq-pn .post-navigation__next--label {
  display: block;
  margin-bottom: 4px;
  font-family: 'Jost', sans-serif !important;
  font-size: .66rem !important;
  font-weight: 600 !important;
  letter-spacing: .14em !important;
  text-transform: uppercase !important;
  color: var(--area-accent-soft) !important;
}
.tfm-sq-pn .post-navigation__prev--title,
.tfm-sq-pn .post-navigation__next--title {
  display: block;
  font-family: 'Cormorant Garamond', serif !important;
  font-size: 1.2rem !important;
  font-weight: 600 !important;
  color: var(--ink, #f6f1ea) !important;
}
.tfm-sq-pn .post-navigation__arrow-wrapper,
.tfm-sq-pn .post-navigation__arrow-wrapper * {
  color: var(--area-accent-soft) !important;
  fill: var(--area-accent-soft) !important;
}

/* ============================================================
   7. RESPONSIVE + REDUCED MOTION
   ============================================================ */

@media (max-width: 700px) {
  /* Smaller corners closer to the edge, so they do not run into the
     eyebrow when the card has little padding on phones. */
  .tfm-sq-corner {
    width: 18px;
    height: 18px;
  }
  .tfm-sq-corner--tl { top: 7px;    left: 7px; }
  .tfm-sq-corner--tr { top: 7px;    right: 7px; }
  .tfm-sq-corner--bl { bottom: 7px; left: 7px; }
  .tfm-sq-corner--br { bottom: 7px; right: 7px; }
  .tfm-sq-single-eyebrow,
  .tfm-sq-single-eyebrow * {
    font-size: .78rem !important;
  }
  .tfm-sq-pn .post-navigation__prev--label,
  .tfm-sq-pn .post-navigation__next--label {
    font-size: .74rem !important;
  }
  .tfm-sq-single-body {
    padding: 28px 24px 4px;
  }
  .tfm-sq-single-body p,
  .tfm-sq-single-body li {
    font-size: 1.12rem !important;
  }
  .tfm-sq-single-body .tfm-margin {
    margin-left: .6rem;
  }
  .tfm-sq-end {
    margin: 10px 24px 0;
  }
  .tfm-sq-single-ending {
    padding: 22px 24px 6px;
  }
  .tfm-sq-single-ending,
  .tfm-sq-single-ending * {
    font-size: 1.15rem !important;
  }
  .tfm-sq-pn {
    padding: 24px 24px 32px;
  }
  .tfm-sq-pn .elementor-post-navigation {
    flex-direction: column;
  }
  .tfm-sq-pn .elementor-post-navigation__next a {
    justify-content: flex-start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tfm-sq-pn .elementor-post-navigation__link a,
  .tfm-sq-single-body a {
    transition: none !important;
  }
}