/*
Theme Name: Fictioneer Child - Moonlight Parser Blocked
Template: fictioneer
Author: Tetrakern, Robbie
Author URI: https://github.com/Tetrakern
Donate link: https://ko-fi.com/tetrakern
Contributors: tetrakern

License: GNU General Public License v3.0 or later
License URI: http://www.gnu.org/licenses/gpl.html

Requires at least: 5.5
Tested up to: 6.5.0
Requires PHP: 7.4
Version: 1.1.3

Description: Moonlight variant of Fictioneer child theme with parser-blocking JS-gated chapter delivery while preserving CMPPP paid-content containers.

Fictioneer Child WordPress Theme, (C) 2023 Tetrakern
Fictioneer Child is distributed under the terms of the GNU GPL.
*/

/* =============================================================================
   CHAPTER NOTES STYLING - Compact & Minimalist with Pseudo Headings
   (Global Note, Foreword, Afterword)
============================================================================= */

.chapter__global-note,
.chapter__foreword,
.chapter__afterword {
  position: relative;
  background: var(--ssn-background, rgba(102, 126, 234, 0.04));
  border: 1px solid var(--ssn-border, rgba(102, 126, 234, 0.12));
  border-radius: 6px;
  padding: 2.5rem 1rem 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
  font-size: 12px;
  line-height: 1.5;
}

.chapter__global-note:hover,
.chapter__foreword:hover,
.chapter__afterword:hover {
  background: var(--ssn-background-hover, rgba(102, 126, 234, 0.06));
  border-color: var(--ssn-border-hover, rgba(102, 126, 234, 0.18));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Dark mode */
:root[data-mode="dark"] .chapter__global-note,
:root[data-mode="dark"] .chapter__foreword,
:root[data-mode="dark"] .chapter__afterword {
  background: var(--ssn-background-dark, rgba(102, 126, 234, 0.06));
  border-color: var(--ssn-border-dark, rgba(102, 126, 234, 0.15));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

:root[data-mode="dark"] .chapter__global-note:hover,
:root[data-mode="dark"] .chapter__foreword:hover,
:root[data-mode="dark"] .chapter__afterword:hover {
  background: var(--ssn-background-dark-hover, rgba(102, 126, 234, 0.09));
  border-color: var(--ssn-border-dark-hover, rgba(102, 126, 234, 0.22));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Light mode */
:root[data-mode="light"] .chapter__global-note,
:root[data-mode="light"] .chapter__foreword,
:root[data-mode="light"] .chapter__afterword {
  background: var(--ssn-background-light, rgba(102, 126, 234, 0.025));
  border-color: var(--ssn-border-light, rgba(102, 126, 234, 0.1));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

:root[data-mode="light"] .chapter__global-note:hover,
:root[data-mode="light"] .chapter__foreword:hover,
:root[data-mode="light"] .chapter__afterword:hover {
  background: var(--ssn-background-light-hover, rgba(102, 126, 234, 0.04));
  border-color: var(--ssn-border-light-hover, rgba(102, 126, 234, 0.15));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* Pseudo Heading Styles - Compact Badge */
.chapter__global-note::before,
.chapter__foreword::before,
.chapter__afterword::before {
  position: absolute;
  top: 0.85rem;
  left: 1rem;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--badge-background);
  color: var(--badge-color);
  border: 1px solid var(--badge-border);
}

.chapter__global-note::before {
  content: 'Global Note';
  --badge-background: rgba(96, 125, 139, 0.15);
  --badge-color: #607d8b;
  --badge-border: rgba(96, 125, 139, 0.3);
}

.chapter__foreword::before {
  content: 'Foreword';
  --badge-background: rgba(103, 58, 183, 0.15);
  --badge-color: #673ab7;
  --badge-border: rgba(103, 58, 183, 0.3);
}

.chapter__afterword::before {
  content: 'Afterword';
  --badge-background: rgba(0, 188, 212, 0.15);
  --badge-color: #00bcd4;
  --badge-border: rgba(0, 188, 212, 0.3);
}

/* Dark mode pseudo heading colors */
:root[data-mode="dark"] .chapter__global-note::before {
  --badge-background: rgba(96, 125, 139, 0.2);
  --badge-color: #90a4ae;
}

:root[data-mode="dark"] .chapter__foreword::before {
  --badge-background: rgba(103, 58, 183, 0.2);
  --badge-color: #9575cd;
}

:root[data-mode="dark"] .chapter__afterword::before {
  --badge-background: rgba(0, 188, 212, 0.2);
  --badge-color: #4dd0e1;
}

/* Light mode pseudo heading colors */
:root[data-mode="light"] .chapter__global-note::before {
  --badge-background: rgba(96, 125, 139, 0.1);
  --badge-color: #455a64;
}

:root[data-mode="light"] .chapter__foreword::before {
  --badge-background: rgba(103, 58, 183, 0.1);
  --badge-color: #512da8;
}

:root[data-mode="light"] .chapter__afterword::before {
  --badge-background: rgba(0, 188, 212, 0.1);
  --badge-color: #0097a7;
}

/* =============================================================================
   STORY HEADER & THUMBNAIL - Moonlight layout override
   Forces centered, large cover + identity stack regardless of customizer tweaks.
   Target: .story__header._no-tax._float-top-left
============================================================================= */

:root {
  --moon-accent: #9fb8ff;
  --moon-accent-soft: rgba(159, 184, 255, 0.12);
  --moon-divider: linear-gradient(90deg, transparent 0%, rgba(159, 184, 255, 0.22) 35%, rgba(159, 184, 255, 0.22) 65%, transparent 100%);
}

.story__header._float-top-left {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.8rem;
  padding: 0 clamp(0.75rem, 3vw, 1.25rem);
  width: min(100%, var(--site-width));
  max-width: 900px;
  margin: clamp(0.35rem, 1vw, 0.8rem) auto 0.5rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
}

.story__header._float-top-left::after { display: none; }

.story__header._float-top-left .story__thumbnail {
  float: none !important;
  margin: 0 auto !important;
  width: clamp(210px, 34vw, 340px);
  max-width: 100%;
  border-radius: var(--layout-border-radius-large);
}

.story__header._float-top-left .story__thumbnail a,
.story__header._float-top-left .story__thumbnail img,
.story__header._float-top-left .story__thumbnail-image {
  display: block;
  width: 100% !important;
  height: auto;
  object-fit: cover;
}

.story__header._float-top-left .story__thumbnail img {
  aspect-ratio: 3 / 4;
  border-radius: var(--layout-border-radius-large);
}

.story__header._float-top-left .story__thumbnail-image {
  box-shadow: var(--recommendation-cover-box-shadow, var(--box-shadow-xl));
}

.story__header._float-top-left .story__identity {
  width: min(42rem, 100%);
  padding: 0;
  position: relative;
}

.story__header._float-top-left .story__identity::after {
  content: '';
  display: block;
  height: 1px;
  margin: 0.75rem auto 0;
  width: min(120px, 30%);
  background: var(--moon-divider);
}

.story__header._float-top-left .story__identity-title {
  font-family: var(--ff-story-title, var(--ff-heading, var(--ff-base)));
  font-size: clamp(1.65rem, 1.9vw + 1rem, 2.45rem);
  letter-spacing: 0;
  line-height: 1.15;
  color: inherit;
  text-wrap: balance;
  text-shadow: none;
}

.story__header._float-top-left .story__taxonomies {
  width: min(44rem, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  padding-top: 0;
}

.story__header._float-top-left .story__taxonomies :is(a, span, button, .tag) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--layout-lineart-color);
  background: rgb(var(--dark-shade-rgb) / 4%);
  color: var(--fg-700);
  font-size: var(--fs-xs);
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-decoration: none;
  box-shadow: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.story__header._float-top-left .story__taxonomies :is(a, span, button, .tag):hover {
  border-color: var(--bg-200);
  background: rgb(var(--dark-shade-rgb) / 7%);
}

/* If taxonomy stack renders outside header (action hook), align with header width */
.story__article > .story__taxonomy-stack {
  max-width: var(--site-width);
  width: min(100%, var(--site-width));
  margin: 0.2rem auto 0;
  padding: 0 clamp(0.75rem, 3vw, 1.25rem);
}

/* Divider immediately after taxonomy stack */
.story__taxonomy-stack + hr {
  max-width: var(--site-width);
  width: min(calc(100% - 1.5rem), var(--site-width));
  margin: 0.6rem auto 1.25rem;
  border: 0;
  height: 14px;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--fg-700) 16%, transparent) 0 1.2px, transparent 1.3px) center / 14px 14px repeat-x,
    linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--layout-lineart-color) 78%, transparent) 18%, color-mix(in srgb, var(--layout-lineart-color) 78%, transparent) 82%, transparent 100%) center / 100% 1px no-repeat;
  opacity: 0.78;
}

.story__summary.content-section > :first-child {
  margin-top: 0;
}

.story__summary.content-section > :last-child {
  margin-bottom: 0;
}

.has-bl-taxonomy-gap .story__summary {
  margin-top: 0;
}

@media (max-width: 768px) {
  .story__taxonomy-stack + hr {
    width: 96%;
    margin: 0.5rem auto 1rem;
    height: 12px;
    background:
      radial-gradient(circle, color-mix(in srgb, var(--fg-700) 14%, transparent) 0 1.1px, transparent 1.2px) center / 12px 12px repeat-x,
      linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--layout-lineart-color) 74%, transparent) 18%, color-mix(in srgb, var(--layout-lineart-color) 74%, transparent) 82%, transparent 100%) center / 100% 1px no-repeat;
  }
}

/* Header background fade-out so it blends into main content */
.header-background__wrapper.polygon {
  position: relative;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 68%, rgba(0, 0, 0, 0) 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 68%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
          mask-size: 100% 100%;
}

@media (max-width: 768px) {
  .header-background__wrapper.polygon {
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 60%, rgba(0, 0, 0, 0) 100%);
            mask-image: linear-gradient(180deg, #000 0%, #000 60%, rgba(0, 0, 0, 0) 100%);
  }
}

:root[data-mode="light"] .story__header._float-top-left .story__identity-title {
  color: var(--fg-700);
}

:root[data-mode="dark"] .story__header._float-top-left .story__identity-title {
  color: var(--fg-400);
}

:root[data-mode="light"] .story__header._float-top-left .story__taxonomies :is(a, span, button, .tag) {
  border-color: rgb(28 35 65 / 10%);
  background: rgb(28 35 65 / 3%);
  color: var(--fg-700);
}

:root[data-mode="dark"] .story__header._float-top-left .story__taxonomies :is(a, span, button, .tag) {
  border-color: rgb(255 255 255 / 7%);
  background: rgb(255 255 255 / 4%);
  color: var(--fg-500);
}

:root[data-mode="light"] .story__header._float-top-left .story__taxonomies :is(a, span, button, .tag):hover {
  border-color: rgb(28 35 65 / 16%);
  background: rgb(28 35 65 / 6%);
}

:root[data-mode="dark"] .story__header._float-top-left .story__taxonomies :is(a, span, button, .tag):hover {
  border-color: rgb(255 255 255 / 12%);
  background: rgb(255 255 255 / 6%);
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .story__header._float-top-left {
    padding-inline: 0.75rem;
    gap: 0.7rem;
  }

  .story__header._float-top-left .story__thumbnail {
    width: clamp(190px, 72vw, 280px);
  }

  .story__header._float-top-left .story__identity::after {
    width: min(100px, 38%);
  }

  .story__header._float-top-left .story__identity-title {
    font-size: clamp(1.45rem, 7vw, 1.95rem);
  }

  .story__header._float-top-left .story__taxonomies {
    gap: 0.35rem;
  }

  .story__header._float-top-left .story__taxonomies :is(a, span, button, .tag) {
    min-height: 1.72rem;
    padding: 0.24rem 0.62rem;
    font-size: var(--fs-xxs);
  }
}

@media (min-width: 769px) and (max-width: 1080px) {
  .story__header._float-top-left {
    max-width: 860px;
  }
}

@media (min-width: 1200px) {
  .story__header._float-top-left .story__thumbnail {
    width: clamp(220px, 28vw, 340px);
  }
}

/* Content spacing */
.chapter__global-note p:first-child,
.chapter__foreword p:first-child,
.chapter__afterword p:first-child {
  margin-top: 0;
}

.chapter__global-note p:last-child,
.chapter__foreword p:last-child,
.chapter__afterword p:last-child {
  margin-bottom: 0;
}

.chapter__global-note a,
.chapter__foreword a,
.chapter__afterword a {
  color: var(--ssn-link-color, var(--fg-400));
  text-decoration: underline;
}

.chapter__global-note a:hover,
.chapter__foreword a:hover,
.chapter__afterword a:hover {
  color: var(--ssn-link-hover-color, var(--fg-200));
}

/* Responsive */
@media only screen and (max-width: 640px) {
  .chapter__global-note,
  .chapter__foreword,
  .chapter__afterword {
    padding: 2.15rem 0.85rem 0.75rem 0.85rem;
    border-radius: 5px;
  }

  .chapter__global-note::before,
  .chapter__foreword::before,
  .chapter__afterword::before {
    top: 0.75rem;
    left: 0.85rem;
    font-size: 9px;
    padding: 2px 6px;
  }
}
