/* Breakpoint variables for responsive design */
:root {
  --breakpoint-mobile: 768px;
  --breakpoint-tablet: 992px;
}

/* Use corporate variables when available; fallbacks ensure orange corporate color */
body {
  background: var(--page-bg, #ffffff);
  color: var(--page-text, #1e293b);
  font-family:
    Montserrat,
    Inter,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial;
}
.container {
  max-width: 1000px;
  margin: 32px auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
/* Modal base styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000005;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}
.modal[aria-hidden='false'] {
  opacity: 1;
  visibility: visible;
}
.modal-dialog {
  position: relative;
  max-width: 90vw;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  margin-top: 90px; /* espacio adecuado para no quedar muy junto al hellobar */
  display: flex;
  flex-direction: column;
}
/* Media query para móvil debe aparecer DESPUÉS de la regla general para sobrescribirla */
@media (max-width: 768px) {
  .modal {
    align-items: flex-start;
  }
  .modal-dialog {
    margin-top: 80px; /* sube el modal en móvil para aprovechar más altura */
    max-height: calc(100vh - 100px);
  }
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  z-index: 10001;
}
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 24px;
  z-index: 10001;
  transition: background 0.2s ease;
  font-weight: bold;
}
.modal-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}
.modal-nav-prev {
  left: 10px;
}
.modal-nav-next {
  right: 10px;
}
.modal-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
/* Modal header bar */
.modal-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10002;
  border-radius: 8px 8px 0 0;
}
.modal-indicator {
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.9;
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}
.modal-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}
.modal-close {
  position: relative;
  top: auto;
  right: auto;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  z-index: 10001;
  transition: background 0.2s;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal-close:focus-visible,
.modal-nav:focus-visible,
.modal-action-btn:focus-visible {
  outline: 2px solid var(--cy-focus-ring, rgba(49, 152, 157, 0.35));
  outline-offset: 2px;
}
.modal-keyboard-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 10002;
}
.modal-keyboard-hint span {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 500;
}
.modal-dialog:hover .modal-keyboard-hint {
  opacity: 1;
}
@media (max-width: 768px) {
  .modal-keyboard-hint {
    display: none;
  }
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  background: transparent;
}
.section-title {
  color: var(--color-primary, #e67542);
  font-size: 28px;
  margin: 0 0 6px;
}
.section-subtitle {
  color: var(--muted, rgba(30, 41, 59, 0.8));
  margin: 0 0 18px;
}
.news-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
/* Tablet+Desktop override: force 3 columns for tablet and up */
@media (min-width: 992px) {
  .news-panel {
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
  }
}
.post-card {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.01));
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
}
.post-media {
  width: 100%;
  aspect-ratio: 16/9;
  height: auto;
  background-size: contain;
  background-position: center;
}
.post-content {
  padding: 16px;
}
.post-title {
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--page-text, #1e293b);
}
.post-excerpt {
  color: var(--muted, rgba(30, 41, 59, 0.7));
  margin: 0 0 12px;
}
.post-tags {
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  background: var(--color-secundario, #e67542);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--avatar-border-color, #ffffff);
}
.cta-btn {
  background: var(--color-primary, #e67542);
  color: var(--color-white, #ffffff);
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
}
.post-full .cover {
  width: 100%;
  aspect-ratio: 16/9;
  height: auto;
  border-radius: 12px;
  background-size: contain;
  background-position: center;
  margin-bottom: 12px;
}
.modal .modal-content .post-full {
  background: transparent;
  color: var(--page-text, #1e293b);
  padding: 0;
  margin: 0; /* remove container margin when post is rendered in modal */
}
/* Higher-specificity overrides to eliminate leftover container margins/padding */
.modal .modal-content .post-full.container,
.modal .modal-content article.post-full.container {
  margin: 0 !important;
  padding: 0 !important;
}
.modal .modal-content .post-header {
  margin: 0 !important;
  padding: 0 !important;
}
.modal .modal-content .post-header .cover {
  margin-top: 0 !important;
  display: block;
}
/* Also target posts rendered inside the Quill editor wrapper (.ql-editor) */
.modal .modal-content .ql-editor .post-full,
.modal .modal-content .ql-editor article.post-full,
.modal .modal-content .ql-editor .post-full.container {
  margin: 0 !important;
  padding: 0 !important;
}
.modal .modal-content .ql-editor .post-header {
  margin: 0 !important;
  padding: 0 !important;
}
.modal .modal-content .ql-editor .post-header .cover {
  margin: 0 !important;
  margin-bottom: 0 !important;
  display: block;
}
/* Force remove Quill default spacing that may cause large empty area */
.modal .modal-content .ql-container {
  padding: 0 !important;
  margin: 0 !important;
}
.modal .modal-content .ql-editor {
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
}
/* Clean: remove debug outlines and ensure compact header */
.modal .modal-content .ql-editor .post-header,
.modal .modal-content .post-header {
  outline: none !important;
  background: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
}
/* Ensure modal-rendered posts match published post styles */
.modal .modal-content .post-full .cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;
  height: auto;
  max-height: 240px;
  border-radius: 12px;
  /* preserve whole image without crop */
  background-size: contain;
  background-position: center center;
  background-repeat: no-repeat;
  margin-bottom: 8px;
  display: block;
}

/* Tablet: 320px cover height */
@media (width >= 769px) and (width <= 991px) {
  .modal .modal-content .post-full .cover {
    aspect-ratio: 16 / 9;
    min-height: 280px;
    max-height: 320px;
    margin-bottom: 8px;
  }
}

/* Desktop: 450px cover height */
@media (width >= 992px) {
  .modal .modal-content .post-full .cover {
    aspect-ratio: 16 / 9;
    min-height: 380px;
    max-height: 450px;
    margin-bottom: 8px;
  }
}
.modal .modal-content .post-full .post-body {
  padding: 18px;
  color: var(--page-text, #1e293b);
  line-height: 1.7;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 16px;
}

.modal .modal-dialog .modal-content {
  padding: 0;
  background: var(--cy-surface, white);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  padding-bottom: 72px; /* espacio para que los iconos sociales no queden cortados */
}
.modal .modal-dialog .modal-content .post-headline {
  margin-top: 0;
  padding: 12px 16px 0 16px;
}
.modal .modal-dialog .modal-content .post-headline h1 {
  margin: 0 0 2px 0;
  font-size: 20px;
}
.modal .modal-dialog .modal-content .post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  margin-top: -1px;
  padding: 0 16px;
}
.modal .modal-dialog .modal-content .meta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal .modal-dialog .modal-content .post-meta .post-tags {
  margin: 0 0 0 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-basis: 100%;
  margin-top: 8px;
}
.modal .modal-content .post-full .post-body {
  padding: 12px 16px 16px 16px !important;
}

/* Quill Editor styles in modal - ensure consistency with editor preview */
/* Quill Editor styles in modal - definitive overrides to prevent extra spacing */
.modal .modal-content .ql-container {
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  font-family: inherit !important;
  font-size: 16px !important;
}

.modal .modal-content .ql-editor {
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  color: var(--page-text, #1e293b) !important;
  line-height: 1.7 !important;
  font-family: inherit !important;
}

/* Reset direct children margins to avoid top gaps from editors */
.modal .modal-content .ql-editor > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* Neutral modal wrapper for posts: avoids Quill stylesheet interference */
.modal .modal-content .post-modal-wrapper,
.modal .modal-content .post-modal-body {
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  font-family: inherit !important;
  box-sizing: border-box !important;
}

/* Ensure embedded media (video, iframe) scale responsively inside modal */
.modal .modal-content .post-modal-body img,
.modal .modal-content .post-modal-body video,
.modal .modal-content .post-modal-body iframe {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
}

.modal .modal-content .post-modal-body .cover {
  width: 100% !important;
  aspect-ratio: 16 / 9 !important;
  min-height: 240px !important;
  height: auto !important;
  max-height: 450px !important;
  margin: 0 0 8px 0 !important;
  background-size: contain !important;
  background-position: center center !important;
}

.modal .modal-content .ql-editor p {
  margin: 0.5em 0;
}

.modal .modal-content .ql-editor h1,
.modal .modal-content .ql-editor h2,
.modal .modal-content .ql-editor h3,
.modal .modal-content .ql-editor h4,
.modal .modal-content .ql-editor h5,
.modal .modal-content .ql-editor h6 {
  margin: 0.5em 0 0.25em 0;
}

/* Modal-specific overrides: tighten spacing and ensure headings in .post-headline are compact */
.modal .modal-dialog .modal-content .post-tags {
  margin-bottom: 0; /* gap before article body */
}

.modal .modal-content .ql-editor ul,
.modal .modal-content .ql-editor ol {
  margin: 0.5em 0;
  padding-left: 2em;
}

.modal .modal-content .ql-editor li {
  margin: 0.25em 0;
}

.modal .modal-content .ql-editor blockquote {
  margin: 0.5em 0;
  padding-left: 1em;
  border-left: 3px solid var(--color-secundario, #e67542);
}

.modal .modal-content .ql-editor code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: monospace;
}

.modal .modal-content .ql-editor pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
}

.modal .modal-content .ql-editor strong {
  font-weight: bold;
}

.modal .modal-content .ql-editor em {
  font-style: italic;
}

.modal .modal-content .ql-editor a {
  color: var(--color-secundario, #e67542);
  text-decoration: none;
}

.modal .modal-content .ql-editor a:hover {
  text-decoration: underline;
}

/* Ensure share icons stay perfectly round inside modal on all screens */
.modal #modal-content .post-share-section .share-buttons a,
.modal #modal-content .post-share-section .share-buttons button {
  display: inline-grid !important;
  place-items: center !important;
  width: 40px !important;
  height: 40px !important;
  inline-size: 40px !important;
  block-size: 40px !important;
  aspect-ratio: 1 / 1 !important;
  min-width: 40px !important;
  min-height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
  flex: 0 0 40px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}
.modal #modal-content .post-share-section .share-buttons a svg,
.modal #modal-content .post-share-section .share-buttons button svg {
  display: block;
}
.modal #modal-content .post-share-section .share-buttons a i,
.modal #modal-content .post-share-section .share-buttons button i,
.modal #modal-content .post-share-section .share-buttons a svg,
.modal #modal-content .post-share-section .share-buttons button svg {
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px !important;
}
.modal #modal-content .post-share-section .share-buttons {
  align-items: center !important;
  padding: 14px 18px !important;
  border-top: 1px solid var(--cy-border, rgba(0, 0, 0, 0.08)) !important;
  background: var(--cy-surface, rgba(255, 255, 255, 0.85)) !important;
  border-radius: 10px !important;
  gap: 10px !important;
}

.modal #modal-content .post-share-section {
  margin: 0 !important;
}

.modal #modal-content .post-share-section .post-share-label {
  font-size: 0.9rem !important;
  color: var(--cy-text-muted, #6c757d) !important;
  font-weight: 600 !important;
}

.modal #modal-content .post-share-section .share-buttons span {
  color: var(--cy-text-muted, #6c757d) !important;
  font-weight: 700 !important;
}

.modal #modal-content .post-share-section .share-button {
  position: relative !important;
  color: #fff !important;
  text-decoration: none !important;
  border: none !important;
  cursor: pointer !important;
  transition:
    transform 0.2s ease,
    background 0.2s ease !important;
}

.modal #modal-content .post-share-section .share-button:hover {
  transform: translateY(-2px);
}

.modal #modal-content .copy-feedback-tooltip {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.modal #modal-content .copy-feedback-tooltip.is-visible {
  opacity: 1;
}

/* Hide per-button text labels in modal to avoid clipped white stripes */
.modal #modal-content .post-share-section .share-buttons a span,
.modal #modal-content .post-share-section .share-buttons button span {
  display: none !important;
}
.modal #modal-content .service-cta-row {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  align-items: center !important;
}
.modal #modal-content .about-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: transparent !important;
  color: var(--cy-brand, var(--color-principal, #37284f)) !important;
  border: 2px solid var(--cy-brand, var(--color-principal, #37284f)) !important;
  padding: 12px 35px !important;
  border-radius: 50px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  text-transform: uppercase !important;
  letter-spacing: 1px !important;
  font-size: 0.9rem !important;
}
.modal #modal-content .about-btn:hover {
  background-color: var(--cy-brand, var(--color-principal, #37284f)) !important;
  color: #fff !important;
}
.modal #modal-content .post-share-section .share-buttons .share-instagram {
  background: linear-gradient(
    45deg,
    #f09433 0%,
    #e6683c 25%,
    #dc2743 50%,
    #cc2366 75%,
    #bc1888 100%
  ) !important;
}
.modal #modal-content .post-share-section .share-buttons .share-whatsapp {
  background: #25d366 !important;
}
.modal #modal-content .post-share-section .share-buttons .share-facebook {
  background: #1877f2 !important;
}
.modal #modal-content .post-share-section .share-buttons .share-twitter {
  background: #000 !important;
}
.modal #modal-content .post-share-section .share-buttons .share-link {
  background: var(--cy-accent, #e67542) !important;
}
@media (max-width: 600px) {
  .modal #modal-content .about-btn {
    background-color: transparent !important;
    color: var(--cy-brand, var(--color-principal, #37284f)) !important;
    border-color: var(--cy-brand, var(--color-principal, #37284f)) !important;
  }
  .modal #modal-content .post-share-section .share-buttons a,
  .modal #modal-content .post-share-section .share-buttons button {
    width: 36px !important;
    height: 36px !important;
    inline-size: 36px !important;
    block-size: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    flex: 0 0 36px !important;
  }
  .modal #modal-content .post-share-section .share-buttons a i,
  .modal #modal-content .post-share-section .share-buttons button i,
  .modal #modal-content .post-share-section .share-buttons a svg,
  .modal #modal-content .post-share-section .share-buttons button svg {
    width: 16px !important;
    height: 16px !important;
  }
  .modal #modal-content .post-share-section .share-buttons .share-instagram {
    background: linear-gradient(
      45deg,
      #f09433 0%,
      #e6683c 25%,
      #dc2743 50%,
      #cc2366 75%,
      #bc1888 100%
    ) !important;
  }
  .modal #modal-content .post-share-section .share-buttons .share-whatsapp {
    background: #25d366 !important;
  }
  .modal #modal-content .post-share-section .share-buttons .share-facebook {
    background: #1877f2 !important;
  }
  .modal #modal-content .post-share-section .share-buttons .share-twitter {
    background: #000 !important;
  }
  .modal #modal-content .post-share-section .share-buttons .share-link {
    background: #e67542 !important;
  }
}

/* Modernizacion visual incremental (fase 1) */
.news-panel {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.post-card {
  transition:
    transform var(--cy-duration-normal, 0.3s) var(--cy-ease-default, ease),
    box-shadow var(--cy-duration-normal, 0.3s) var(--cy-ease-default, ease);
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--cy-shadow-lg, 0 16px 36px rgba(24, 40, 52, 0.12));
}

.post-card:hover .post-media {
  transform: scale(1.02);
}

.post-media {
  transition: transform var(--cy-duration-normal, 0.3s) var(--cy-ease-default, ease);
}

.post-card:first-child {
  background: var(--cy-glass-bg, rgba(255, 255, 255, 0.6));
  border: 1px solid var(--cy-glass-border, rgba(255, 255, 255, 0.25));
  backdrop-filter: var(--cy-glass-blur, blur(16px));
}

.section-title,
.post-title {
  text-wrap: balance;
}

.hero-controls button:focus-visible,
.hero-dot:focus-visible,
.post-card:focus-visible {
  outline: 2px solid var(--cy-focus-ring, rgba(49, 152, 157, 0.35));
  outline-offset: 2px;
}

.section-title {
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
}

.post-title {
  font-size: clamp(1.08rem, 1.35vw, 1.35rem);
}

.tag {
  border-radius: 999px;
}

[data-theme='dark'] body {
  --page-bg: var(--cy-bg, #0f1419);
  --page-text: var(--cy-text, #e8ecf0);
  --muted: var(--cy-text-muted, #8a97a5);
  background: var(--cy-bg, #0f1419);
  color: var(--cy-text, #e8ecf0);
}

[data-theme='dark'] .modal .modal-dialog .modal-content {
  background: var(--cy-surface, #1a2028);
}

[data-theme='dark'] .post-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border-color: var(--cy-border, #2a3440);
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-keyboard-hint,
  .post-card,
  .post-media,
  .hero-track {
    transition: none !important;
  }

  .modal-keyboard-hint {
    display: none;
  }
}
