/**
 * CM Storytelling Toolkit - Zen Mode Styles
 * Version: 3.0.0
 * 
 * Distraction-free reading mode for blog posts
 * Unlike eReader, this maintains normal scrolling but removes all distractions
 */

/* ==========================================================================
   ZEN MODE BUTTON STYLES
   ========================================================================== */


.cm-zen-button {
  display: inline-block;
  padding: 12px 24px;
  background: #333333;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.cm-zen-button:hover {
  background: #222222;
  transform: translateY(-1px);
}



.cm-zen-button::before {
  content: '🧘';
  margin-right: var(--cm-spacing-xs);
}

.cm-zen-button:hover::before {
  content: '✨';
}

/* Active state when zen mode is on */
.cm-zen-button--active {
  background: var(--cm-primary-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cm-zen-button--active::before {
  content: '🌙';
}

/* ==========================================================================
   ZEN MODE OVERLAY
   ========================================================================== */

.cm-zen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--cm-background);
  z-index: var(--cm-z-overlay);
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  /* scroll-behavior: smooth; - Removed for responsive mouse wheel */
}

.cm-zen-overlay--active {
  opacity: 1;
  visibility: visible;
  z-index: 999999;
}

.cm-zen-overlay--loading {
  cursor: wait;
}

/* ==========================================================================
   ZEN MODE HEADER
   ========================================================================== */

.cm-zen-header {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: var(--cm-spacing-sm) var(--cm-spacing-md);
  z-index: var(--cm-z-navigation);
  transition: all 0.3s ease;
}

/* Header hiding disabled for better mobile UX */
.cm-zen-header--hidden {
  /* transform: translateY(-100%); */
  /* opacity: 0; */
}

.cm-zen-header__content {
  max-width: var(--cm-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cm-spacing-md);
}

.cm-zen-header__title {
  font-family: var(--cm-font-family-ui);
  font-size: 1.1em;
  font-weight: var(--cm-font-weight-bold);
  color: var(--cm-text);
  margin: 0;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 0px;
}

.cm-zen-header__controls {
  display: flex;
  align-items: center;
  gap: var(--cm-spacing-xs);
}

.cm-zen-header__button {
  @extend .cm-navigation__button;
  min-width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 14px;
}

.cm-zen-header__button:hover {
  background: rgba(255, 255, 255, 1);
  border-color: var(--cm-primary);
}

.cm-zen-header__close::before {
  content: '✕';
  font-size: 16px;
}

.cm-zen-header__settings::before {
  content: '⚙';
  font-size: 14px;
}

/* ==========================================================================
   ZEN MODE CONTENT
   ========================================================================== */

.cm-zen-content {
  max-width: var(--cm-max-width);
  margin: 0 auto;
  padding: var(--cm-spacing-xl) var(--cm-spacing-md);
  min-height: calc(100vh - 80px); /* Account for header */
}

.cm-zen-article {
  font-family: var(--cm-font-family);
  font-size: var(--cm-font-size-base);
  line-height: var(--cm-line-height-base);
  color: var(--cm-text);
  word-wrap: break-word;
  hyphens: auto;
}

/* Enhanced typography for zen mode */
.cm-zen-article h1,
.cm-zen-article h2,
.cm-zen-article h3,
.cm-zen-article h4,
.cm-zen-article h5,
.cm-zen-article h6 {
  font-family: var(--cm-font-family-ui);
  font-weight: var(--cm-font-weight-bold);
  line-height: 1.3;
  margin-top: var(--cm-spacing-xl);
  margin-bottom: var(--cm-spacing-md);
  color: var(--cm-text);
  scroll-margin-top: 100px; /* Account for sticky header */
}

.cm-zen-article h1 { 
  font-size: 2.5em; 
  margin-top: 0;
  margin-bottom: var(--cm-spacing-lg);
  text-align: center;
  border-bottom: 2px solid var(--cm-border);
  padding-bottom: var(--cm-spacing-md);
}

.cm-zen-article h2 { 
  font-size: 2em;
  border-bottom: 1px solid var(--cm-border);
  padding-bottom: var(--cm-spacing-xs);
}

.cm-zen-article h3 { font-size: 1.6em; }
.cm-zen-article h4 { font-size: 1.3em; }
.cm-zen-article h5 { font-size: 1.1em; }
.cm-zen-article h6 { font-size: 1em; }

.cm-zen-article p {
  margin-bottom: 0.5em;
  text-align: justify;
  text-justify: inter-word;
}

.cm-zen-article p:first-of-type {
  margin-bottom: var(--cm-spacing-xl);
}

.cm-zen-article p:first-of-type::first-letter {
  float: left;
  font-size: 3.5em;
  line-height: 0.8;
  margin: 0.1em 0.1em 0 0;
  font-weight: var(--cm-font-weight-bold);
  color: var(--cm-primary);
}

.cm-zen-article blockquote {
  border-left: 4px solid var(--cm-primary);
  padding: var(--cm-spacing-md) var(--cm-spacing-lg);
  margin: var(--cm-spacing-xl) 0;
  background: var(--cm-background-dark);
  border-radius: 0 var(--cm-border-radius) var(--cm-border-radius) 0;
  font-style: italic;
  font-size: 1.05em;
  color: var(--cm-text-light);
  position: relative;
}

.cm-zen-article blockquote::before {
  content: '"';
  position: absolute;
  top: -10px;
  left: var(--cm-spacing-md);
  font-size: 3em;
  color: var(--cm-primary);
  opacity: 0.3;
}

.cm-zen-article ul,
.cm-zen-article ol {
  margin: var(--cm-spacing-lg) 0;
  padding-left: var(--cm-spacing-xl);
}

.cm-zen-article li {
  margin-bottom: var(--cm-spacing-sm);
  line-height: 1.7;
}

.cm-zen-article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--cm-spacing-xl) auto;
  border-radius: var(--cm-border-radius);
  box-shadow: 0 4px 20px var(--cm-shadow);
}

.cm-zen-article figure {
  margin: var(--cm-spacing-xl) 0;
  text-align: center;
}

.cm-zen-article figcaption {
  font-size: 0.9em;
  color: var(--cm-text-light);
  margin-top: var(--cm-spacing-sm);
  font-style: italic;
}

.cm-zen-article a {
  color: var(--cm-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

.cm-zen-article a:hover {
  color: var(--cm-primary-dark);
  text-decoration-thickness: 2px;
}

.cm-zen-article code {
  background: var(--cm-background-dark);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
}

.cm-zen-article pre {
  background: var(--cm-background-dark);
  padding: var(--cm-spacing-md);
  border-radius: var(--cm-border-radius);
  overflow-x: auto;
  margin: var(--cm-spacing-lg) 0;
}

.cm-zen-article pre code {
  background: none;
  padding: 0;
}

/* ==========================================================================
   ZEN MODE SETTINGS PANEL
   ========================================================================== */

.cm-zen-settings {
  position: fixed;
  top: 80px;
  right: var(--cm-spacing-md);
  background: var(--cm-background);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-border-radius);
  padding: var(--cm-spacing-md);
  box-shadow: 0 8px 30px var(--cm-shadow);
  min-width: 280px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s ease;
  z-index: var(--cm-z-modal);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cm-zen-settings--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.cm-zen-settings__title {
  font-family: var(--cm-font-family-ui);
  font-size: 1.1em;
  font-weight: var(--cm-font-weight-bold);
  margin: 0 0 var(--cm-spacing-md) 0;
  color: var(--cm-text);
  text-align: center;
}

.cm-zen-settings__group {
  margin-bottom: var(--cm-spacing-md);
}

.cm-zen-settings__group:last-child {
  margin-bottom: 0;
}

.cm-zen-settings__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--cm-font-family-ui);
  font-size: 14px;
  font-weight: var(--cm-font-weight-normal);
  color: var(--cm-text-light);
  margin-bottom: var(--cm-spacing-xs);
}

.cm-zen-settings__value {
  font-weight: var(--cm-font-weight-bold);
  color: var(--cm-primary);
}

.cm-zen-settings__slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--cm-border);
  outline: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.cm-zen-settings__slider::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cm-primary);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--cm-shadow);
  transition: all 0.2s ease;
  border: 2px solid white;
  margin-top: -8px;
}

.cm-zen-settings__slider::-webkit-slider-thumb:hover,
.cm-zen-settings__slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
  box-shadow: 0 4px 12px var(--cm-shadow);
}

.cm-zen-settings__slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cm-primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 8px var(--cm-shadow);
  margin-top: -8px;
}

.cm-zen-settings__slider::-moz-range-thumb:hover,
.cm-zen-settings__slider::-moz-range-thumb:active {
  transform: scale(1.2);
  box-shadow: 0 4px 12px var(--cm-shadow);
}

/* ==========================================================================
   ZEN MODE READING PROGRESS
   ========================================================================== */

.cm-zen-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  z-index: var(--cm-z-tooltip);
  pointer-events: none;
}

.cm-zen-progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cm-primary), var(--cm-primary-dark));
  transition: width 0.2s ease;
}

/* ==========================================================================
   ZEN MODE RESPONSIVE DESIGN
   ========================================================================== */

/* Mobile Portrait */
@media (max-width: 480px) {
  .cm-zen-header {
    padding: var(--cm-spacing-xs) var(--cm-spacing-sm);
  }
  
  .cm-zen-header__title {
    font-size: 1em;
  }
  
  .cm-zen-content {
    padding: var(--cm-spacing-lg) var(--cm-spacing-sm);
  }
  
  .cm-zen-article h1 {
    font-size: 2em;
  }
  
  .cm-zen-article h2 {
    font-size: 1.6em;
  }
  
  .cm-zen-article p:first-of-type::first-letter {
    font-size: 2.5em;
    margin: 0.05em 0.05em 0 0;
  }
  
  .cm-zen-article p {
    text-align: left; /* Better for small screens */
  }
  
  .cm-zen-settings {
    top: 60px;
    left: var(--cm-spacing-sm);
    right: var(--cm-spacing-sm);
    min-width: auto;
    width: auto;
  }
}

/* Mobile Landscape */
@media (max-width: 768px) and (orientation: landscape) {
  .cm-zen-header {
    padding: var(--cm-spacing-xs) var(--cm-spacing-md);
  }
  
  .cm-zen-content {
    padding: var(--cm-spacing-md) var(--cm-spacing-md);
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .cm-zen-article {
    font-size: 19px;
    line-height: 1.7;
  }
  
  .cm-zen-content {
    padding: var(--cm-spacing-xl) var(--cm-spacing-lg);
  }
}

/* Desktop */
@media (min-width: 1025px) {
  .cm-zen-article {
    font-size: 20px;
    line-height: 1.8;
  }
  
  .cm-zen-content {
    padding: calc(var(--cm-spacing-xl) * 2) var(--cm-spacing-xl);
  }
  
  .cm-zen-article h1 {
    font-size: 3em;
  }
  
  .cm-zen-article h2 {
    font-size: 2.2em;
  }
  
  /* Show hover effects */
  .cm-zen-header__button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--cm-shadow);
  }
}

/* Large Desktop */
@media (min-width: 1400px) {
  .cm-zen-content {
    max-width: 900px;
  }
  
  .cm-zen-article {
    font-size: 21px;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .cm-zen-header {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  
  .cm-zen-settings {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .cm-zen-overlay {
    --cm-background: #1a1a1a;
    --cm-background-dark: #2a2a2a;
    --cm-text: #e0e0e0;
    --cm-text-light: #b0b0b0;
    --cm-border: rgba(255, 255, 255, 0.1);
    --cm-shadow: rgba(0, 0, 0, 0.5);
  }
  
  .cm-zen-header {
    background: rgba(26, 26, 26, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }
  
  .cm-zen-header__button {
    background: rgba(42, 42, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
  }
  
  .cm-zen-header__button:hover {
    background: rgba(42, 42, 42, 1);
  }
  
  .cm-zen-article p:first-of-type::first-letter {
    color: #4a9eff;
  }
  
  .cm-zen-progress {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Print Styles */
@media print {
  .cm-zen-overlay,
  .cm-zen-header,
  .cm-zen-settings,
  .cm-zen-progress {
    display: none !important;
  }
  
  .cm-zen-article {
    font-size: 12pt;
    line-height: 1.4;
    color: #000;
  }
  
  .cm-zen-article h1,
  .cm-zen-article h2,
  .cm-zen-article h3 {
    page-break-after: avoid;
  }
  
  .cm-zen-article p {
    text-align: left;
    orphans: 3;
    widows: 3;
  }
  
  .cm-zen-article p:first-of-type::first-letter {
    color: #000;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .cm-zen-overlay,
  .cm-zen-header,
  .cm-zen-settings,
  .cm-zen-progress__bar {
    transition: none !important;
  }
  
  .cm-zen-header__button {
    transform: none !important;
  }
}/* CSS Document */

