/**
 * TFM Glossary — the floating book of the Academy
 * /wp-content/themes/blocksy-child/css/tfm-glossary.css
 *
 * Markup comes from js/tfm-glossary.js, everything inside #tfm-gl:
 *   .tfm-gl-book     closed book floating top right (below the header)
 *   .tfm-gl-veil     dims the page while the book is open
 *   .tfm-gl-tome     the open book (dialog): left leaf index + search,
 *                    right leaf the entry; on phones one leaf at a time
 *
 * #tfm-gl in the selectors: the theme and the Elementor kit style <button>
 * and <input> globally; the id outranks them without !important.
 * Accent from the area variables (Academy green), gold for the ornaments.
 */

#tfm-gl {
  --gl-acc: var(--area-accent, #5ab87a);
  --gl-acc-soft: var(--area-accent-soft, #a5e8b8);
  --gl-gold: #d9b871;
  --gl-parch: #f0e8d8;
  --gl-page: #17111f;
  --gl-page-2: #110c18;
  --gl-muted: #9a8fbb;
  --gl-top: 104px;
  --gl-village: #d4a843;
  --gl-academy: #5ab87a;
  --gl-square: #40d9b0;
  --gl-training: #cc3355;
}

#tfm-gl button,
#tfm-gl input {
  all: unset;
  box-sizing: border-box;
}
#tfm-gl button {
  cursor: pointer;
}
#tfm-gl button:disabled {
  cursor: default;
}
#tfm-gl :focus-visible {
  outline: 2px solid var(--gl-acc-soft);
  outline-offset: 2px;
}

/* ============================================================
   1. THE CLOSED BOOK
   ============================================================ */

#tfm-gl .tfm-gl-book {
  position: fixed;
  z-index: 990;
  top: var(--gl-top);
  right: 26px;
  width: 58px;
  height: 74px;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.6));
  animation: tfmGlBob 4.5s ease-in-out infinite;
  transition: opacity 0.3s ease;
}
#tfm-gl.is-open .tfm-gl-book {
  opacity: 0;
  pointer-events: none;
}
.tfm-gl-cover {
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  background: linear-gradient(135deg, #1f4a33, #0f2a1c 70%);
  border: 1px solid color-mix(in srgb, var(--gl-gold) 55%, transparent);
  box-shadow: inset 5px 0 0 rgba(0, 0, 0, 0.35), 0 0 22px color-mix(in srgb, var(--gl-acc) 35%, transparent);
}
.tfm-gl-cover::before {
  content: '';
  position: absolute;
  inset: 7px 7px 7px 11px;
  border: 1px solid color-mix(in srgb, var(--gl-gold) 45%, transparent);
  border-radius: 2px 5px 5px 2px;
}
.tfm-gl-cover::after {
  content: '✦';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 18px;
  color: var(--gl-gold);
  text-shadow: 0 0 10px color-mix(in srgb, var(--gl-gold) 70%, transparent);
}
.tfm-gl-pages {
  position: absolute;
  right: -3px;
  top: 4px;
  bottom: 4px;
  width: 5px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(180deg, #e8dcc2 0 1px, #cdbf9f 1px 2px);
}
.tfm-gl-label {
  position: absolute;
  right: 72px;
  top: 50%;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--gl-acc) 45%, transparent);
  background: rgba(8, 6, 14, 0.9);
  white-space: nowrap;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gl-acc-soft);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#tfm-gl .tfm-gl-book:hover .tfm-gl-label,
#tfm-gl .tfm-gl-book:focus-visible .tfm-gl-label {
  opacity: 1;
  transform: translateY(-50%);
}
.tfm-gl-spark {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gl-gold);
  opacity: 0;
  animation: tfmGlSpark 3.2s ease-in-out infinite;
}
@keyframes tfmGlBob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-9px) rotate(2deg); }
}
@keyframes tfmGlSpark {
  0%   { opacity: 0; transform: translate(0, 0); }
  30%  { opacity: 0.9; }
  100% { opacity: 0; transform: translate(var(--dx, 0px), -26px); }
}

/* ============================================================
   2. VEIL + TOME
   ============================================================ */

/* above the Blocksy header (z-index 999999) */
.tfm-gl-veil {
  position: fixed;
  z-index: 1000000;
  inset: 0;
  background: rgba(4, 2, 8, 0.72);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
#tfm-gl.is-open .tfm-gl-veil {
  opacity: 1;
  pointer-events: auto;
}
body.tfm-gl-lock {
  overflow: hidden !important;
}

.tfm-gl-tome {
  position: fixed;
  z-index: 1000001;
  left: 50%;
  top: 50%;
  width: min(980px, 92vw);
  height: min(600px, 86vh);
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.08);
  transform-origin: 100% 0;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease, visibility 0s 0.6s;
  visibility: hidden;
  perspective: 1600px;
  color: #ddd4f0;
  font-family: 'Cormorant Garamond', serif;
}
#tfm-gl.is-open .tfm-gl-tome {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  visibility: visible;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease, visibility 0s;
}

/* paper: dark pages, green gilt edge, gold corners */
.tfm-gl-leaf {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 26px 26px 18px;
  border: 1px solid color-mix(in srgb, var(--gl-acc) 30%, transparent);
  background:
    radial-gradient(ellipse at 30% 0%, color-mix(in srgb, var(--gl-acc) 6%, transparent), transparent 60%),
    linear-gradient(180deg, var(--gl-page), var(--gl-page-2));
}
.tfm-gl-leaf.is-reg {
  border-radius: 8px 0 0 8px;
  box-shadow: inset -18px 0 24px -16px rgba(0, 0, 0, 0.75), 0 24px 60px rgba(0, 0, 0, 0.6);
}
.tfm-gl-leaf.is-ent {
  border-radius: 0 8px 8px 0;
  box-shadow: inset 18px 0 24px -16px rgba(0, 0, 0, 0.75), 0 24px 60px rgba(0, 0, 0, 0.6);
}
.tfm-gl-orn {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 0 solid color-mix(in srgb, var(--gl-gold) 50%, transparent);
  pointer-events: none;
}
.tfm-gl-orn.is-tl { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.tfm-gl-orn.is-tr { top: 8px; right: 8px; border-width: 1px 1px 0 0; }
.tfm-gl-orn.is-bl { bottom: 8px; left: 8px; border-width: 0 0 1px 1px; }
.tfm-gl-orn.is-br { bottom: 8px; right: 8px; border-width: 0 1px 1px 0; }

/* the cover swings open */
.tfm-gl-lid {
  position: absolute;
  z-index: 2;
  inset: 0 0 0 50%;
  display: grid;
  place-items: center;
  border-radius: 0 8px 8px 0;
  border: 1px solid color-mix(in srgb, var(--gl-gold) 55%, transparent);
  background: linear-gradient(135deg, #1f4a33, #0f2a1c 70%);
  font-size: 2.2rem;
  color: var(--gl-gold);
  transform-origin: 0 50%;
  backface-visibility: hidden;
  pointer-events: none;
  transition: transform 0.9s 0.25s cubic-bezier(0.4, 0.1, 0.2, 1);
}
#tfm-gl.is-open .tfm-gl-lid {
  transform: rotateY(-180deg);
}

#tfm-gl .tfm-gl-x {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--gl-acc) 45%, transparent);
  background: rgba(10, 7, 16, 0.6);
  font-size: 14px;
  color: var(--gl-acc-soft);
}
#tfm-gl .tfm-gl-x:hover {
  background: color-mix(in srgb, var(--gl-acc) 18%, transparent);
}

/* ============================================================
   3. LEFT LEAF — head, search, A–Z, list
   ============================================================ */

.tfm-gl-head {
  margin-bottom: 10px;
}
.tfm-gl-head small {
  display: block;
  font-family: 'Jost', sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--gl-acc) 80%, transparent);
}
.tfm-gl-head h2 {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--gl-parch);
}

.tfm-gl-search {
  position: relative;
  margin-bottom: 8px;
}
.tfm-gl-search::before {
  content: '⌕';
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-52%);
  font-size: 17px;
  color: color-mix(in srgb, var(--gl-acc) 80%, transparent);
  pointer-events: none;
}
#tfm-gl .tfm-gl-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--gl-acc) 35%, transparent);
  background: rgba(5, 3, 10, 0.55);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  color: var(--gl-parch);
}
#tfm-gl .tfm-gl-search input:focus {
  border-color: var(--gl-acc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gl-acc) 15%, transparent);
}
#tfm-gl .tfm-gl-search input::placeholder {
  color: var(--gl-muted);
}

.tfm-gl-az {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-bottom: 10px;
}
#tfm-gl .tfm-gl-az button {
  min-width: 21px;
  padding: 2px 0;
  border-radius: 4px;
  text-align: center;
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--gl-acc-soft);
}
#tfm-gl .tfm-gl-az button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--gl-acc) 15%, transparent);
}
#tfm-gl .tfm-gl-az button:disabled {
  color: #4a4258;
}
#tfm-gl .tfm-gl-az button.is-on {
  background: var(--gl-acc);
  color: #06120a;
}

.tfm-gl-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
}
.tfm-gl-list h4 {
  margin: 12px 0 4px;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: color-mix(in srgb, var(--gl-acc) 75%, transparent);
}
.tfm-gl-list h4:first-child {
  margin-top: 0;
}
#tfm-gl .tfm-gl-list button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.08rem;
  color: #d6cde6;
}
#tfm-gl .tfm-gl-list button:hover {
  background: color-mix(in srgb, var(--gl-acc) 10%, transparent);
  color: var(--gl-parch);
}
#tfm-gl .tfm-gl-list button.is-on {
  background: color-mix(in srgb, var(--gl-acc) 16%, transparent);
  color: var(--gl-acc-soft);
}
.tfm-gl-list mark {
  background: none;
  color: var(--gl-acc-soft);
  text-decoration: underline;
}
.tfm-gl-none {
  padding: 18px 12px;
  text-align: center;
  font-style: italic;
  color: var(--gl-muted);
}
#tfm-gl .tfm-gl-none button {
  color: var(--gl-acc-soft);
  text-decoration: underline;
}

/* ============================================================
   4. RIGHT LEAF — the entry
   ============================================================ */

.tfm-gl-entry {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 34px;
  scrollbar-width: thin;
}
.tfm-gl-pos,
.tfm-gl-entry h5 {
  font-family: 'Jost', sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--gl-acc) 72%, transparent);
}
.tfm-gl-entry h3 {
  margin: 4px 0 2px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--gl-parch);
}
.tfm-gl-short {
  margin: 4px 0 14px;
  font-style: italic;
  font-size: 1.18rem;
  line-height: 1.5;
  color: var(--gl-acc-soft);
}
.tfm-gl-long p {
  margin: 0 0 10px;
  font-size: 1.08rem;
  line-height: 1.75;
  color: #d9d0ea;
}
.tfm-gl-entry h5 {
  margin: 16px 0 6px;
}
.tfm-gl-see {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#tfm-gl .tfm-gl-see button {
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--gl-acc) 45%, transparent);
  background: color-mix(in srgb, var(--gl-acc) 7%, transparent);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  color: var(--gl-acc-soft);
}
#tfm-gl .tfm-gl-see button:hover {
  background: color-mix(in srgb, var(--gl-acc) 20%, transparent);
}
.tfm-gl-more {
  display: grid;
  gap: 6px;
}
#tfm-gl .tfm-gl-more a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 3, 10, 0.35);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.02rem;
  color: #d6cde6;
  text-decoration: none;
}
#tfm-gl .tfm-gl-more a:hover {
  border-color: var(--area-c);
  color: var(--gl-parch);
}
.tfm-gl-more .is-village  { --area-c: var(--gl-village); }
.tfm-gl-more .is-academy  { --area-c: var(--gl-academy); }
.tfm-gl-more .is-square   { --area-c: var(--gl-square); }
.tfm-gl-more .is-training { --area-c: var(--gl-training); }
.tfm-gl-more i {
  font-style: normal;
  color: var(--area-c);
}
.tfm-gl-more small {
  margin-left: auto;
  font-family: 'Jost', sans-serif;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--area-c);
}

.tfm-gl-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--gl-acc) 15%, transparent);
}
#tfm-gl .tfm-gl-pager button,
#tfm-gl .tfm-gl-back {
  padding: 4px 0;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gl-acc-soft);
}
#tfm-gl .tfm-gl-pager button:disabled {
  color: #4a4258;
}
#tfm-gl .tfm-gl-back {
  display: none;
  margin-bottom: 8px;
}

/* ============================================================
   5. PHONE — smaller book, one leaf at a time
   ============================================================ */

@media (max-width: 699px) {
  #tfm-gl {
    --gl-top: 96px;
  }
  #tfm-gl .tfm-gl-book {
    right: 16px;
    width: 46px;
    height: 60px;
  }
  .tfm-gl-cover::after {
    font-size: 14px;
  }
  .tfm-gl-tome {
    grid-template-columns: 1fr;
    width: 94vw;
    height: 88vh;
  }
  .tfm-gl-leaf.is-reg,
  .tfm-gl-leaf.is-ent {
    border-radius: 8px;
    padding: 20px 18px 14px;
  }
  .tfm-gl-lid {
    inset: 0;
    border-radius: 8px;
  }
  .tfm-gl-tome .tfm-gl-leaf.is-reg { display: none; }
  .tfm-gl-tome.is-index .tfm-gl-leaf.is-reg { display: flex; }
  .tfm-gl-tome.is-index .tfm-gl-leaf.is-ent { display: none; }
  #tfm-gl .tfm-gl-back {
    display: inline-block;
  }
  .tfm-gl-entry {
    padding-right: 4px;
  }
  .tfm-gl-head {
    padding-right: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #tfm-gl .tfm-gl-book,
  .tfm-gl-spark {
    animation: none;
  }
  .tfm-gl-tome,
  #tfm-gl.is-open .tfm-gl-tome {
    transform: translate(-50%, -50%);
    transition: opacity 0.2s ease, visibility 0s;
  }
  .tfm-gl-lid {
    display: none;
  }
}
