/*
 * Content page sections (block markup contract of content/pages/*.html and the
 * «Trioni: páginas» patterns): .tg-page-intro, .tg-section, .tg-steps (+ .tg-steps__list),
 * .tg-facts, .tg-faq, .tg-cta, .tg-note, and the button styles is-style-tg-primary /
 * is-style-tg-secondary. Loaded only when one of them renders (Markup\render_group,
 * Markup\render_button) and in the editor. Printed after content.css (dependency), so the
 * section rules win over the generic .prose ones.
 */

/* ---------- Rhythm between sections ---------- */
.page-content > :is(.tg-section, .tg-steps, .tg-facts, .tg-faq, .tg-cta) {
  margin-top: clamp(var(--s-6), 4vw, var(--s-7));
}

.prose--legal > :is(.tg-section, .tg-steps, .tg-facts, .tg-faq, .tg-cta) {
  margin-top: var(--s-6);
}

.page-content > .tg-note {
  margin-top: var(--s-4);
}

/* base.css zeroes margins: restore a vertical flow inside every section. */
:is(.tg-page-intro, .tg-section, .tg-steps, .tg-facts, .tg-faq, .tg-cta, .tg-note) > * + * {
  margin-top: var(--s-3);
}

:is(.tg-section, .tg-steps, .tg-facts, .tg-faq, .tg-cta) > h2 + * {
  margin-top: var(--s-3);
}

.tg-section > :is(h3, h4) {
  margin-top: var(--s-5);
}

.tg-section > :is(h3, h4) + * {
  margin-top: var(--s-2);
}

/* Text keeps a readable measure on wide pages; blocks such as tables or columns do not. */
:is(.tg-page-intro, .tg-section, .tg-steps, .tg-faq) > :is(h2, h3, h4, p, ul, ol, .wp-block-quote, .wp-block-details) {
  max-width: var(--measure);
}

:is(.tg-section, .tg-steps, .tg-facts, .tg-faq) > h2 {
  max-width: 30ch;
}

.tg-section .wp-block-quote p {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-style: italic;
  line-height: 1.5;
}

/* ---------- Buttons (core/button styles «Principal» and «Secundario») ---------- */
:is(.tg-page-intro, .tg-section, .tg-cta, .tg-note, .tg-facts) .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

.wp-block-button:is(.is-style-tg-primary, .is-style-tg-secondary) > .wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.wp-block-button.is-style-tg-primary > .wp-block-button__link {
  background: var(--gold);
  color: var(--ink);
}

.wp-block-button.is-style-tg-primary > .wp-block-button__link:hover {
  background: var(--gold-hover);
}

.wp-block-button.is-style-tg-secondary > .wp-block-button__link {
  border-color: var(--field-border);
  background: transparent;
  color: var(--ink);
}

.wp-block-button.is-style-tg-secondary > .wp-block-button__link:hover {
  border-color: var(--ink);
  background: var(--surface);
}

.tg-cta .wp-block-button.is-style-tg-secondary > .wp-block-button__link {
  border-color: #6d695d;
  color: var(--on-ink);
}

.tg-cta .wp-block-button.is-style-tg-secondary > .wp-block-button__link:hover {
  border-color: var(--gold-on-ink);
  background: transparent;
  color: var(--gold-on-ink);
}

/* ---------- Intro: one sentence and the main actions under the H1 ---------- */
.tg-page-intro > p {
  max-width: 62ch;
  color: var(--text-soft);
  font-size: var(--fs-md);
  line-height: 1.55;
}

.tg-page-intro > .wp-block-buttons {
  margin-top: var(--s-4);
}

/* ---------- Steps: numbered, a title and one line each, with a connecting line ---------- */
.tg-steps .tg-steps__list {
  display: grid;
  gap: var(--s-3);
  max-width: var(--measure);
  margin-top: var(--s-4);
  padding-left: 0;
  list-style: none;
  counter-reset: tg-step;
}

.tg-steps .tg-steps__list > li {
  position: relative;
  min-height: 32px;
  margin-top: 0;
  padding-left: 48px;
  color: var(--text-soft);
  font-size: var(--fs-sm);
  line-height: 1.45;
  counter-increment: tg-step;
}

.tg-steps .tg-steps__list > li::before {
  content: counter(tg-step, decimal-leading-zero);
  content: counter(tg-step, decimal-leading-zero) / '';
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--gold-ui);
  border-radius: 50%;
  background: var(--paper);
  color: var(--gold-text);
  font-family: var(--font-serif);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}

.tg-steps .tg-steps__list > li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 32px;
  bottom: calc(-1 * var(--s-3));
  left: 16px;
  width: 1px;
  background: var(--line-strong);
}

.tg-steps .tg-steps__list > li > strong:first-child {
  display: block;
  padding-top: 5px;
  color: var(--text);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
}

.tg-steps .tg-steps__list > li::marker {
  content: none;
}

/* Wide screens: two columns of steps (the connecting line only joins a single column). */
@media (min-width: 960px) {
  .tg-steps .tg-steps__list,
  .prose--wide .tg-steps .tg-steps__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3) var(--s-6);
    max-width: none;
  }

  .tg-steps .tg-steps__list > li:not(:last-child)::after {
    content: none;
  }
}

/* ---------- Facts: 2–4 short cards ---------- */
.tg-facts {
  container-type: inline-size;
}

.tg-facts .wp-block-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--s-3);
  margin-top: var(--s-4);
}

/*
 * Four cards never end as 3 + 1 (e.g. /vender-oro-barcelona/ in the ~72ch column): between the
 * width of two cards (2 × 220 + gap) and the width of four (4 × 220 + 3 gaps) they go two by two.
 */
@container (min-width: 456px) and (max-width: 927.98px) {
  .tg-facts .wp-block-columns:has(> .wp-block-column:nth-child(4):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tg-facts .wp-block-column {
  display: grid;
  align-content: start;
  gap: var(--s-1);
  margin: 0;
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}

.tg-facts .wp-block-column > * {
  margin-top: 0;
}

.tg-facts h3 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1.15;
}

.tg-facts .wp-block-column p {
  color: var(--text-soft);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* ---------- FAQ: native <details>, one open at a time is not forced ---------- */
.tg-faq .wp-block-details {
  max-width: var(--measure);
  margin-top: 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.tg-faq > h2 + .wp-block-details,
.tg-faq > .wp-block-details:first-child {
  margin-top: var(--s-4);
  border-top: 1px solid var(--ink);
}

.tg-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 48px;
  padding-block: var(--s-2);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: var(--lh-snug);
  list-style: none;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}

.tg-faq summary::-webkit-details-marker {
  display: none;
}

.tg-faq summary::after {
  content: '';
  width: 14px;
  height: 14px;
  flex: none;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat;
  color: var(--gold-ui);
  transition: transform var(--dur-fast) var(--ease);
}

.tg-faq details[open] > summary::after {
  transform: rotate(45deg);
}

.tg-faq summary:hover {
  color: var(--gold-text);
}

.tg-faq .wp-block-details > :not(summary) {
  max-width: 64ch;
  color: var(--text-soft);
}

.tg-faq .wp-block-details > summary + * {
  margin-top: var(--s-1);
}

.tg-faq .wp-block-details > * + :not(summary) {
  margin-top: var(--s-3);
}

.tg-faq .wp-block-details > :last-child:not(summary) {
  padding-bottom: var(--s-4);
}

/* ---------- CTA: ink panel ---------- */
.tg-cta {
  --focus: var(--gold-on-ink);
  position: relative;
  padding: clamp(var(--s-5), 3vw, var(--s-6));
  border-radius: 8px;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(201, 171, 112, 0.16), transparent 60%),
    var(--ink);
  color: var(--on-ink);
  box-shadow: 0 34px 60px -34px rgba(25, 25, 20, 0.7);
}

.tg-cta::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 5px;
  border-top: 1px solid rgba(201, 171, 112, 0.5);
  border-bottom: 1px solid rgba(201, 171, 112, 0.5);
}

.tg-cta h2 {
  max-width: 24ch;
  color: var(--on-ink);
}

.tg-cta h2 em {
  color: var(--gold-on-ink);
}

.tg-cta > p {
  max-width: 60ch;
  color: var(--on-ink-muted);
}

.tg-cta > p strong {
  color: var(--on-ink);
}

.prose .tg-cta :is(p, li) a:not(.btn):not(.wp-element-button) {
  color: var(--on-ink);
  text-decoration-color: var(--gold-on-ink);
}

.prose .tg-cta :is(p, li) a:not(.btn):not(.wp-element-button):hover {
  color: var(--gold-on-ink);
}

.tg-cta > .wp-block-buttons {
  margin-top: var(--s-4);
}

/* Wide pages: the sentence on the left, the buttons in one row on the right. */
@media (min-width: 960px) {
  .prose--wide .tg-cta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--s-6);
    align-items: center;
  }

  .prose--wide .tg-cta > * {
    grid-column: 1;
  }

  .prose--wide .tg-cta > .wp-block-buttons {
    grid-column: 2;
    grid-row: 1 / span 6;
    justify-content: flex-end;
    margin-top: 0;
  }
}

/* ---------- Note: identity and legal requirements ---------- */
.tg-note {
  max-width: var(--measure);
  padding: var(--s-3) var(--s-4);
  border-left: 2px solid var(--gold-ui);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--gold-wash);
  color: var(--text-soft);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.tg-note > * + * {
  margin-top: var(--s-2);
}

.tg-note strong {
  color: var(--text);
}

/* ---------- Small screens ---------- */
@media (max-width: 559px) {
  .tg-cta .wp-block-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  /* Intro actions: two side by side when they fit (from 360 px). */
  .tg-page-intro .wp-block-buttons {
    gap: var(--s-2);
  }

  .tg-page-intro .wp-block-buttons > .wp-block-button {
    flex: 1 1 0;
    min-width: max-content;
  }

  :is(.tg-cta, .tg-page-intro) .wp-block-buttons .wp-block-button__link {
    width: 100%;
  }

  .tg-page-intro .wp-block-buttons .wp-block-button__link {
    padding-inline: var(--s-3);
  }

  .tg-note {
    padding: var(--s-3);
  }
}

@media (max-width: 359px) {
  .tg-page-intro .wp-block-buttons {
    flex-direction: column;
    align-items: stretch;
  }
}
