/* THC Core — THC Consent (1.7.0): the cookie notice and the Choose panel.
   A small card in a corner (never a full-screen overlay); on phones a compact bar, at most 30% of the screen,
   sitting above Tutor's fixed bottom bars (--thc-consent-bottom is measured by the script).
   z-index 99990/99991: under WooCommerce's cart drawer (100000), the top bar's open panels and the Display &
   reading panel (10000001). Colours follow the Display & reading tokens, so Dark and High contrast apply. */

/* The child theme's --thc-* tokens (flipped by Display & reading's Dark and High contrast), with the THC palette as
   literal fallbacks — deliberately not the block theme's accent presets, which differ between style variations. */
:root {
  --thc-c-bg: var(--thc-surface-raised, #fcf8ef);
  --thc-c-muted: var(--thc-surface-muted, #ece4d9);
  --thc-c-border: var(--thc-border, #d9d0bc);
  --thc-c-text: var(--thc-text, #332d25);
  --thc-c-deep: var(--thc-leaf-deep, #3f5c3b);
  --thc-c-on-deep: #ffffff;
}
html[data-thc-theme="dark"] { --thc-c-on-deep: #15130f; }

.thc-consent, .thc-consent-panel {
  position: fixed; z-index: 99990; box-sizing: border-box;
  bottom: calc(var(--thc-consent-bottom, 0px) + 1rem);
  color: var(--thc-c-text); background: var(--thc-c-bg);
  border: 1px solid var(--thc-c-border); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  font-family: var(--wp--preset--font-family--fira-sans, "Segoe UI", Arial, sans-serif);
  font-size: .92rem; line-height: 1.45; text-align: start;
}
.thc-consent *, .thc-consent-panel * { box-sizing: border-box; }
.thc-consent { width: min(26rem, calc(100vw - 2rem)); max-width: 26rem; padding: .85rem 1rem .9rem; }
.thc-consent:empty { padding: 0; border: 0; box-shadow: none; }
.thc-consent--bottom-left { left: 1rem; }
.thc-consent--bottom-right { right: 1rem; }
.thc-consent--bottom-bar { left: 0; right: 0; bottom: var(--thc-consent-bottom, 0px); width: auto; max-width: none; border-radius: 0; border-width: 1px 0 0; padding: .7rem max(1rem, calc((100vw - 72rem) / 2)); display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.25rem; }
.thc-consent--bottom-bar .thc-consent__title { flex: 0 0 auto; margin: 0; }
.thc-consent--bottom-bar .thc-consent__text { flex: 1 1 24rem; margin: 0; }
.thc-consent--bottom-bar .thc-consent__actions { flex: 0 0 auto; margin: 0; }
.thc-consent[hidden], .thc-consent-panel[hidden] { display: none; }

.thc-consent__title { margin: 0 0 .25rem; font-weight: 700; font-size: 1rem; line-height: 1.3; }
.thc-consent__text { margin: 0 0 .65rem; }
.thc-consent__link, .thc-consent-panel a { color: var(--thc-c-deep); font-weight: 600; text-decoration: underline; text-underline-offset: .15em; }
.thc-consent__actions { display: flex; flex-wrap: wrap; gap: .45rem; }

/* Accept and reject are the same button: same colour, size and weight. Choose is outlined. */
.thc-consent__btn {
  flex: 1 1 auto; min-height: 44px; min-width: 6.5rem; margin: 0; padding: .45rem .9rem;
  border: 2px solid var(--thc-c-deep); border-radius: 999px;
  background: var(--thc-c-deep); color: var(--thc-c-on-deep);
  font: inherit; font-weight: 700; font-size: .9rem; line-height: 1.2; cursor: pointer; text-transform: none; letter-spacing: normal;
}
.thc-consent__btn:hover { filter: brightness(1.12); }
.thc-consent__btn--ghost { background: transparent; color: var(--thc-c-text); border-color: var(--thc-c-border); }
.thc-consent__btn--ghost:hover { background: var(--thc-c-muted); filter: none; }
.thc-consent__btn:focus-visible, .thc-consent__x:focus-visible, .thc-consent-link:focus-visible,
.thc-consent-panel summary:focus-visible, .thc-consent-panel input:focus-visible, .thc-consent-panel__title:focus-visible,
.thc-consent__link:focus-visible { outline: 3px solid var(--thc-c-deep); outline-offset: 2px; }
.thc-consent-panel__title:focus:not(:focus-visible) { outline: none; }

.thc-consent__x {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; margin: -.4rem -.5rem 0 0; padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: inherit; font: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.thc-consent__x:hover { background: var(--thc-c-muted); }

/* A link-looking button: the GPC note, [thc_consent_settings_link]. */
.thc-consent-link {
  display: inline; margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--thc-c-deep); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: .15em;
}

/* GPC: one line and a close button. */
.thc-consent--note { display: flex; align-items: flex-start; gap: .5rem; padding: .6rem .8rem; }
.thc-consent--note .thc-consent__text { margin: 0; flex: 1 1 auto; }

/* ---------- the Choose panel ---------- */
.thc-consent-panel {
  z-index: 99991; width: min(32rem, calc(100vw - 2rem));
  max-height: min(40rem, calc(100vh - var(--thc-consent-bottom, 0px) - 2rem)); overflow: auto; overscroll-behavior: contain;
  padding: .75rem 1rem 1rem;
}
.thc-consent-panel--bottom-left, .thc-consent-panel--bottom-bar { left: 1rem; }
.thc-consent-panel--bottom-right { right: 1rem; }
.thc-consent-panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.thc-consent-panel__title { margin: .25rem 0 .35rem; font-size: 1.15rem; font-weight: 700; line-height: 1.25; color: inherit; font-family: inherit; }
.thc-consent-panel__intro { margin: 0 0 .6rem; }
.thc-consent-cat { padding: .55rem 0; border-top: 1px solid var(--thc-c-border); }
.thc-consent-cat__head { display: flex; align-items: center; gap: .6rem; margin: 0; font-weight: 700; min-height: 32px; cursor: default; }
label.thc-consent-cat__head { cursor: pointer; }
.thc-consent-cat__head input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--thc-c-deep); flex: none; }
.thc-consent-cat__always { margin-inline-start: auto; font-size: .8rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; background: var(--thc-c-muted); }
.thc-consent-cat__desc { margin: .2rem 0 .3rem; font-size: .87rem; }
.thc-consent-cat__cookies summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--thc-c-deep); padding: .2rem 0; min-height: 28px; }
.thc-consent-cat__scroll { overflow-x: auto; }
.thc-consent-table, .thc-cookie-table { width: 100%; border-collapse: collapse; font-size: .8rem; line-height: 1.35; margin: .3rem 0 0; }
.thc-consent-table th, .thc-consent-table td { padding: .3rem .4rem; border: 1px solid var(--thc-c-border); text-align: start; vertical-align: top; }
.thc-consent-table thead th { background: var(--thc-c-muted); }
.thc-consent-table code { font-size: .78rem; word-break: break-word; background: none; color: inherit; }
.thc-consent-panel__actions { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--thc-c-border); }

/* [thc_cookie_table] on the privacy page. */
.thc-cookie-table caption { text-align: start; font-weight: 700; padding: 0 0 .4rem; }
.thc-cookie-table th, .thc-cookie-table td { padding: .4rem .5rem; border: 1px solid var(--thc-c-border); text-align: start; vertical-align: top; }
.thc-cookie-table thead th { background: var(--thc-c-muted); }

/* ---------- phones: a compact bar, ≤ 30% of the screen, above Tutor's bottom bars ---------- */
@media (max-width: 600px) {
  .thc-consent, .thc-consent--bottom-bar {
    left: .5rem; right: .5rem; width: auto; max-width: none; bottom: calc(var(--thc-consent-bottom, 0px) + .5rem);
    max-height: 30vh; max-height: 30svh; overflow-y: auto; overscroll-behavior: contain;
    padding: .55rem .7rem .6rem; border-radius: 10px; border-width: 1px; font-size: .84rem; line-height: 1.35; display: block;
  }
  .thc-consent__title { font-size: .9rem; margin-bottom: .1rem; }
  .thc-consent__text { margin-bottom: .45rem; }
  .thc-consent__actions { flex-wrap: nowrap; gap: .35rem; }
  .thc-consent__btn { min-width: 0; flex: 1 1 0; padding: .35rem .4rem; min-height: 40px; font-size: .84rem; }
  .thc-consent--note { display: flex; }
  .thc-consent-panel { left: .5rem; right: .5rem; width: auto; bottom: calc(var(--thc-consent-bottom, 0px) + .5rem); max-height: calc(100vh - var(--thc-consent-bottom, 0px) - 1rem); max-height: calc(100svh - var(--thc-consent-bottom, 0px) - 1rem); }
  .thc-consent-panel__actions { flex-wrap: wrap; }
}

/* High contrast (Display & reading). */
html[data-thc-contrast="high"] .thc-consent, html[data-thc-contrast="high"] .thc-consent-panel { border: 2px solid #000; box-shadow: none; }

/* A gentle entrance, unless motion is reduced (device setting or Display & reading). */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-thc-motion="reduce"]) .thc-consent:not(:empty) { animation: thc-consent-in .18s ease-out; }
  html:not([data-thc-motion="reduce"]) .thc-consent__btn { transition: filter .15s ease, background-color .15s ease; }
}
@keyframes thc-consent-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media print {
  .thc-consent, .thc-consent-panel { display: none !important; }
}
