/* ==========================================================================
   Block design engine + v31 modules
   --------------------------------------------------------------------------
   Everything here is driven by the per-section controls in the admin builder
   (App\Libraries\Modules::appearanceFields). The renderer emits classes and a
   few custom properties; this file turns those into layout, colour and motion.

   Nothing in here applies unless a section opted into it, so existing pages
   are untouched by loading this file.
   ========================================================================== */

/* ---------- background media ------------------------------------------- */
.sec { position: relative; }

.sec--hasbg {
  background-image: var(--sec-bg-photo);
  background-position: var(--sec-bg-pos, center);
  background-repeat: no-repeat;
}
.sec--bgsize-cover   { background-size: cover; }
.sec--bgsize-contain { background-size: contain; }
.sec--bgsize-repeat  { background-size: auto; background-repeat: repeat; }
.sec--bgfixed        { background-attachment: fixed; }

/* A custom colour pair renders as a gradient band. */
.sec--bg-custom { background-color: var(--sec-bg); }
.sec--bg-custom[style*="--sec-bg-image"] { background-image: var(--sec-bg-image); }
.sec--bg-custom.sec--hasbg { background-image: var(--sec-bg-photo); }

.sec__overlay {
  position: absolute;
  inset: 0;
  background: var(--sec-overlay, #000);
  opacity: var(--sec-overlay-a, .45);
  pointer-events: none;
}
.sec__overlay + .sec__inner { position: relative; z-index: 1; }

/* ---------- exact spacing, capped width -------------------------------- */
.sec[style*="--sec-pt"] { padding-top: var(--sec-pt) !important; }
.sec[style*="--sec-pb"] { padding-bottom: var(--sec-pb) !important; }

.sec[style*="--sec-maxw"] > .sec__inner {
  max-width: var(--sec-maxw);
  margin-inline: auto;
}

/* ---------- colour tinting --------------------------------------------- */
.sec--tinted { color: var(--sec-text, inherit); }
.sec--tinted .sec__inner,
.sec--tinted .prose,
.sec--tinted p,
.sec--tinted li,
.sec--tinted td,
.sec--tinted figcaption { color: var(--sec-text, inherit); }

.sec--tinted h1, .sec--tinted h2, .sec--tinted h3,
.sec--tinted h4, .sec--tinted .block__head {
  color: var(--sec-head, var(--sec-text, inherit));
}

.sec--tinted a:not(.btn) { color: var(--sec-link, inherit); }
.sec--tinted .btn--primary {
  background: var(--sec-link, currentColor);
  border-color: var(--sec-link, currentColor);
}
.sec--tinted .kt__icon,
.sec--tinted .tl__marker,
.sec--tinted .acc__mark::before,
.sec--tinted .acc__mark::after { color: var(--sec-link, inherit); }

/* ---------- alignment, type scale -------------------------------------- */
.sec--right, .sec--right .sec__inner { text-align: right; }
.sec--scale-sm { font-size: .94rem; }
.sec--scale-lg { font-size: 1.08rem; }
.sec--scale-xl { font-size: 1.2rem; }
.sec--scale-lg .block__head { font-size: clamp(1.5rem, 2.4vw, 2.1rem); }
.sec--scale-xl .block__head { font-size: clamp(1.8rem, 3.2vw, 2.7rem); }

/* ---------- corners, borders, shadow ----------------------------------- */
.sec--radius-none { border-radius: 0; }
.sec--radius-sm   { border-radius: 6px; overflow: hidden; }
.sec--radius-md   { border-radius: 14px; overflow: hidden; }
.sec--radius-lg   { border-radius: 26px; overflow: hidden; }
.sec--radius-pill { border-radius: 999px; overflow: hidden; }

.sec--bordered {
  border: var(--sec-border-w, 1px) solid var(--sec-border-c, rgba(15, 32, 45, .12));
}

.sec--shadow-sm    { box-shadow: 0 1px 3px rgba(12, 26, 38, .08); }
.sec--shadow-md    { box-shadow: 0 10px 26px rgba(12, 26, 38, .10); }
.sec--shadow-lg    { box-shadow: 0 26px 60px rgba(12, 26, 38, .18); }
.sec--shadow-glow  { box-shadow: 0 12px 40px color-mix(in srgb, var(--sec-link, #1c7c54) 32%, transparent); }
.sec--shadow-inset { box-shadow: inset 0 2px 10px rgba(12, 26, 38, .12); }

/* ---------- visibility, sticky ----------------------------------------- */
@media (max-width: 760px) { .sec--only-desktop { display: none !important; } }
@media (min-width: 761px) { .sec--only-mobile  { display: none !important; } }

.sec--sticky { position: sticky; top: 84px; z-index: 2; }
@media (max-width: 860px) { .sec--sticky { position: static; } }

/* ---------- scroll animation ------------------------------------------- */
.sec--anim { opacity: 0; transition: opacity .7s ease, transform .7s cubic-bezier(.22, .8, .3, 1); will-change: opacity, transform; }
.sec--anim-up    { transform: translateY(26px); }
.sec--anim-down  { transform: translateY(-26px); }
.sec--anim-left  { transform: translateX(-32px); }
.sec--anim-right { transform: translateX(32px); }
.sec--anim-zoom  { transform: scale(.96); }
.sec--anim.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .sec--anim { opacity: 1; transform: none; transition: none; }
}
/* JavaScript off: never hide content. */
.no-js .sec--anim { opacity: 1; transform: none; }

/* ==========================================================================
   Accordion
   ========================================================================== */
.acc__intro { margin-bottom: 14px; }

.acc__row {
  border: 1px solid rgba(15, 32, 45, .12);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
  overflow: hidden;
}
.acc--plain .acc__row {
  border: 0;
  border-bottom: 1px solid rgba(15, 32, 45, .12);
  border-radius: 0;
  background: none;
  margin-bottom: 0;
}

.acc__q {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.acc__q::-webkit-details-marker { display: none; }
.acc__q:hover { background: rgba(15, 32, 45, .03); }

.acc__mark { position: relative; width: 14px; height: 14px; flex: 0 0 14px; }
.acc__mark::before, .acc__mark::after {
  content: ""; position: absolute; background: currentColor; border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.acc__mark::before { inset: 6px 0; height: 2px; }
.acc__mark::after  { inset: 0 6px; width: 2px; }
.acc__row[open] .acc__mark::after { transform: scaleY(0); opacity: 0; }

.acc__a { padding: 0 18px 16px; }

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid rgba(15, 32, 45, .12);
  margin-bottom: 16px;
}
.tabs__tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  opacity: .62;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__tab:hover  { opacity: .9; }
.tabs__tab.is-on  { opacity: 1; border-bottom-color: var(--sec-link, currentColor); }

.tabs__panel { display: none; }
.tabs__panel.is-on { display: block; }
.tabs__fallback { display: none; }
/* JavaScript off: show everything, labelled. */
.no-js .tabs__bar { display: none; }
.no-js .tabs__panel { display: block; margin-bottom: 20px; }
.no-js .tabs__fallback { display: block; }

.tabs--side .tabs__shell { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 24px; }
.tabs--side .tabs__bar {
  flex-direction: column;
  border-bottom: 0;
  border-right: 1px solid rgba(15, 32, 45, .12);
  margin: 0;
}
.tabs--side .tabs__tab { text-align: left; border-bottom: 0; border-right: 2px solid transparent; margin: 0 -1px 0 0; }
.tabs--side .tabs__tab.is-on { border-right-color: var(--sec-link, currentColor); }
@media (max-width: 720px) {
  .tabs--side .tabs__shell { grid-template-columns: 1fr; }
  .tabs--side .tabs__bar { flex-direction: row; border-right: 0; border-bottom: 1px solid rgba(15, 32, 45, .12); }
}

/* ==========================================================================
   Gallery + lightbox
   ========================================================================== */
.gal__grid { display: grid; gap: 14px; }
.gal__grid--2 { grid-template-columns: repeat(2, 1fr); }
.gal__grid--3 { grid-template-columns: repeat(3, 1fr); }
.gal__grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .gal__grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (max-width: 520px) { .gal__grid { grid-template-columns: 1fr !important; } }

.gal__item { margin: 0; }
.gal__frame { display: block; overflow: hidden; border-radius: 12px; background: rgba(15, 32, 45, .05); }
.gal__frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.gal__frame:hover img { transform: scale(1.04); }
.gal__frame--1-1  { aspect-ratio: 1 / 1; }
.gal__frame--4-3  { aspect-ratio: 4 / 3; }
.gal__frame--16-9 { aspect-ratio: 16 / 9; }
.gal__frame--3-4  { aspect-ratio: 3 / 4; }
.gal__frame--none img { height: auto; }
.gal__item figcaption { font-size: .86rem; opacity: .72; margin-top: 6px; }

.lbx {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 16, 24, .88);
  padding: 24px;
}
.lbx[hidden] { display: none; }
.lbx img { max-width: 92vw; max-height: 86vh; border-radius: 10px; }
.lbx__close {
  position: absolute; top: 18px; right: 20px;
  appearance: none; border: 0; background: rgba(255, 255, 255, .14); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer;
}

/* ==========================================================================
   Timeline
   ========================================================================== */
.tl__intro { margin-bottom: 16px; }
.tl__list { list-style: none; margin: 0; padding: 0; position: relative; }
.tl__list::before {
  content: ""; position: absolute; left: 27px; top: 8px; bottom: 8px;
  width: 2px; background: rgba(15, 32, 45, .12);
}
.tl__item { position: relative; display: flex; gap: 18px; padding: 0 0 22px 0; }
.tl__marker {
  position: relative; z-index: 1;
  flex: 0 0 56px; min-height: 56px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 2px solid currentColor;
  font-size: .74rem; font-weight: 700; line-height: 1.1; text-align: center;
  padding: 4px;
}
.tl--dot .tl__marker { flex-basis: 16px; min-height: 16px; margin-left: 20px; background: currentColor; }
.tl__when  { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; opacity: .66; }
.tl__title { margin: 2px 0 4px; font-size: 1.06rem; }
.tl__text  { margin: 0; }

/* ==========================================================================
   Key takeaways
   ========================================================================== */
.kt { border-radius: 16px; padding: 22px 26px; }
.kt--brand { background: color-mix(in srgb, var(--sec-link, #1c7c54) 10%, #fff); }
.kt--paper { background: rgba(15, 32, 45, .04); }
.kt--ink   { background: #10202c; color: #eef4f8; }
.kt--ink .kt__head { color: #fff; }
.kt__head { margin: 0 0 10px; font-size: 1.12rem; }
.kt__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.kt__list li { display: flex; gap: 10px; align-items: flex-start; }
.kt__icon { flex: 0 0 auto; font-weight: 700; }

/* ==========================================================================
   Embed + code
   ========================================================================== */
.emb__frame { position: relative; }
.emb__frame > iframe, .emb__frame > video { width: 100%; border: 0; }
.emb__frame--16-9 { aspect-ratio: 16 / 9; }
.emb__frame--4-3  { aspect-ratio: 4 / 3; }
.emb__frame--1-1  { aspect-ratio: 1 / 1; }
.emb__frame--16-9 > iframe,
.emb__frame--4-3 > iframe,
.emb__frame--1-1 > iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

.code__shell { position: relative; }
.code__lang {
  position: absolute; top: 8px; right: 10px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  opacity: .6;
}
.code__pre {
  margin: 0; padding: 18px 20px;
  background: #0f1b24; color: #dbe7ef;
  border-radius: 12px;
  overflow-x: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .86rem; line-height: 1.6;
}

/* Per-section colour (TOC / Rich text) ----------------------------------- */
.block--tint            { --block-tint: var(--brand); padding-left: 16px; border-left: 3px solid var(--block-tint); }
.block--tint-brand      { --block-tint: var(--brand); }
.block--tint-accent     { --block-tint: var(--accent, var(--warn)); }
.block--tint-good       { --block-tint: var(--good, #17a97a); }
.block--tint-warn       { --block-tint: var(--warn, #b3610f); }
.block--tint-ink        { --block-tint: var(--ink); }
.block--tint-muted      { --block-tint: var(--muted); }
.block--tint .block__head { color: var(--block-tint); }
.block--tint .prose a     { color: var(--block-tint); }
.block--tint-fill {
  padding: 18px 20px;
  border-radius: var(--radius, 12px);
  background: color-mix(in srgb, var(--block-tint) 8%, transparent);
}
