/* ==========================================================================
   ToolsGrove Design System - Components
   Requires tg-tokens.css. Every rule is scoped under .tg-section or
   body.tg-surface so nothing leaks into WordPress admin or plugin markup.
   ========================================================================== */

.tg-section { position: relative; isolation: isolate; }
.tg-section *, .tg-section *::before, .tg-section *::after { box-sizing: border-box; }
.tg-section :where(a) { color: inherit; text-decoration: none; }
.tg-section :where(button) { margin: 0; padding: 0; border: 0; font: inherit; cursor: pointer; }
.tg-section svg { display: block; }

/* --------------------------------------------------------------------------
   1. Container
   -------------------------------------------------------------------------- */
.tg-container {
    width: min(100% - (var(--tg-gutter) * 2), var(--tg-container));
    margin-inline: auto;
}

/* --------------------------------------------------------------------------
   2. Ambient background. Two radial green washes over a vertical fade,
      plus an optional grid that is masked out before it reaches the fold.
      This is the signature ToolsGrove page ground.
   -------------------------------------------------------------------------- */
.tg-ground {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 8% 5%,  rgba(16, 185, 129, 0.075), transparent 25rem),
        radial-gradient(circle at 94% 26%, rgba(5, 150, 105, 0.05),  transparent 24rem),
        linear-gradient(180deg, var(--tg-page-bg-top) 0%, var(--tg-white) 44%, var(--tg-page-bg) 100%);
}

.tg-grid-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(5, 150, 105, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(5, 150, 105, 0.035) 1px, transparent 1px);
    background-size: 52px 52px;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,0.72) 45%, transparent 92%);
            mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,0.72) 45%, transparent 92%);
}

/* --------------------------------------------------------------------------
   3. Eyebrow / badge pill. Opens almost every section.
      Frosted white pill, green-deep text, dot or icon on the left.
   -------------------------------------------------------------------------- */
.tg-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    padding: 7px 14px 7px 8px;
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-r-pill);
    background: rgba(255, 255, 255, 0.85);
    color: var(--tg-green-deep);
    font-size: 11px;
    font-weight: 650;
    box-shadow: var(--tg-shadow-pill);
    backdrop-filter: blur(12px);
}

.tg-eyebrow-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--tg-green-light);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

/* --------------------------------------------------------------------------
   4. Section header
   -------------------------------------------------------------------------- */
.tg-section-head { max-width: 720px; margin: 0 auto 40px; text-align: center; }
.tg-section-head .tg-display,
.tg-section-head .tg-h2 { margin: 0 0 14px; }
.tg-section-head p { margin: 0; color: var(--tg-muted); font-size: 15px; line-height: 1.65; }

/* Gradient highlight on one phrase in a heading. One phrase only. */
.tg-highlight {
    background: linear-gradient(120deg, var(--tg-green-light), var(--tg-green-deep));
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --------------------------------------------------------------------------
   5. Card. THE signature surface: 19px radius, near-white translucent fill,
      hairline green border, soft green shadow with a white inner top edge.
   -------------------------------------------------------------------------- */
.tg-card {
    position: relative;
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    padding: 22px;
    border: 1px solid var(--tg-border-light);
    border-radius: var(--tg-r-md);
    background: rgba(255, 255, 255, 0.94);
    color: inherit;
    box-shadow: var(--tg-shadow-card);
    transition: transform var(--tg-dur-base) var(--tg-ease),
                border-color var(--tg-dur-base) var(--tg-ease),
                box-shadow var(--tg-dur-base) var(--tg-ease);
}

.tg-card:hover {
    transform: translateY(-4px);
    border-color: var(--tg-border-green);
    box-shadow: var(--tg-shadow-hover);
}

/* Featured variant: a green top rule that appears on hover. */
.tg-card-featured::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--tg-green-light), var(--tg-green-deep));
}

.tg-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

/* --------------------------------------------------------------------------
   6. Icon chip. Soft green square that fronts a card or list row.
   -------------------------------------------------------------------------- */
.tg-icon-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: 1px solid var(--tg-soft-2);
    border-radius: var(--tg-r-sm);
    background: var(--tg-soft);
    color: var(--tg-green-deep);
    transition: transform var(--tg-dur-fast) var(--tg-ease);
}
.tg-icon-chip svg { width: 20px; height: 20px; }
.tg-card:hover .tg-icon-chip { transform: scale(1.06); }

/* Solid variant for hero and CTA contexts. */
.tg-icon-chip-solid {
    border-color: transparent;
    background: linear-gradient(135deg, var(--tg-green-light), var(--tg-green-dark));
    color: var(--tg-white);
    box-shadow: var(--tg-shadow-brand);
}

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */
.tg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: var(--tg-r-pill);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    transition: transform var(--tg-dur-fast) var(--tg-ease),
                box-shadow var(--tg-dur-fast) var(--tg-ease),
                background var(--tg-dur-fast) var(--tg-ease);
}
.tg-btn:hover { transform: translateY(-2px); }
.tg-btn svg { width: 16px; height: 16px; }

/* Both classes are used so these win over the `a` and `button` colour resets
   in the section and header scopes, which are the same specificity as a single
   class and, being in a later stylesheet, would otherwise repaint the label. */
.tg-btn.tg-btn-primary {
    background: linear-gradient(120deg, var(--tg-green-light), var(--tg-green-dark));
    color: var(--tg-white);
    box-shadow: var(--tg-shadow-brand);
}
.tg-btn.tg-btn-primary:hover { box-shadow: 0 16px 29px rgba(5, 150, 105, 0.27); }

.tg-btn.tg-btn-ghost {
    border-color: var(--tg-border-green);
    background: rgba(255, 255, 255, 0.85);
    color: var(--tg-green-deep);
    backdrop-filter: blur(10px);
}
.tg-btn.tg-btn-ghost:hover { border-color: var(--tg-green); background: var(--tg-white); }

/* On a dark green band, primary inverts to white. */
.tg-on-dark .tg-btn.tg-btn-primary {
    background: var(--tg-white);
    color: var(--tg-green-deep);
    box-shadow: 0 13px 27px rgba(0, 0, 0, 0.13);
}
.tg-on-dark .tg-btn.tg-btn-ghost {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
    color: var(--tg-white);
}

/* --------------------------------------------------------------------------
   8. Dark green band. Used for the closing CTA and the footer top.
   -------------------------------------------------------------------------- */
.tg-band {
    position: relative;
    overflow: hidden;
    color: var(--tg-white);
    background:
        radial-gradient(circle at 17% -150%, rgba(52, 211, 153, 0.65), transparent 33%),
        radial-gradient(circle at 83%  170%, rgba(16, 185, 129, 0.30), transparent 35%),
        linear-gradient(110deg, #064e3b 0%, var(--tg-green-deep) 45%, var(--tg-green-dark) 100%);
}
.tg-band::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 30px 30px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}
/* One property flips every heading inside the band. */
.tg-band { --tg-heading: var(--tg-white); }
.tg-band p { color: rgba(255, 255, 255, 0.82); }

/* --------------------------------------------------------------------------
   9. FAQ accordion. Pairs with the JS in tg-behaviors.js.
   -------------------------------------------------------------------------- */
.tg-faq-list { display: grid; gap: 10px; }

.tg-faq-item {
    overflow: hidden;
    border: 1px solid var(--tg-border-light);
    border-radius: var(--tg-r-sm);
    background: rgba(255, 255, 255, 0.94);
    transition: border-color var(--tg-dur-fast) var(--tg-ease);
}
.tg-faq-item.is-open { border-color: var(--tg-border-green); }

.tg-faq-list .tg-faq-question {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 15px 17px;
    background: transparent;
    color: var(--tg-ink);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
}
.tg-faq-icon { transition: transform var(--tg-dur-base) var(--tg-ease); }
.tg-faq-item.is-open .tg-faq-icon { transform: rotate(180deg); }

/* max-height is driven from JS so the transition can animate. */
.tg-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--tg-dur-base) var(--tg-ease);
}
.tg-faq-answer > div { padding: 0 17px 16px; color: var(--tg-muted); font-size: 14px; line-height: 1.65; }

/* --------------------------------------------------------------------------
   10. Live search. Pairs with the REST endpoint in the child theme.
   -------------------------------------------------------------------------- */
.tg-search { position: relative; max-width: 640px; margin-inline: auto; }

.tg-search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 18px;
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-r-pill);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 22px rgba(6, 95, 70, 0.05);
    backdrop-filter: blur(12px);
    transition: border-color var(--tg-dur-fast) var(--tg-ease),
                box-shadow var(--tg-dur-fast) var(--tg-ease);
}
.tg-search-field:focus-within {
    border-color: var(--tg-green);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.tg-search-input {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--tg-ink);
    font-size: 14px;
    outline: none;
}
.tg-search-input::placeholder { color: var(--tg-muted-light); }

/* GeneratePress styles bare inputs, so a square filled box with its own border
   is drawn inside the rounded search pill. Two classes here to outrank its
   input[type="search"] rule. */
.tg-search-field .tg-search-input {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    outline: none;
}
.tg-search-field .tg-search-input:focus { background: transparent; box-shadow: none; outline: none; }
/* WebKit also paints its own magnifier and clear button inside a search input. */
.tg-search-input::-webkit-search-decoration,
.tg-search-input::-webkit-search-cancel-button,
.tg-search-input::-webkit-search-results-button,
.tg-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    display: none;
}

.tg-search-results {
    position: absolute;
    z-index: 30;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    display: none;
    overflow: hidden;
    padding: 6px;
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-r-md);
    background: var(--tg-white);
    box-shadow: 0 20px 42px rgba(6, 95, 70, 0.08);
}
.tg-search-results.is-visible { display: block; }

.tg-search-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--tg-r-sm);
    transition: background var(--tg-dur-fast) var(--tg-ease);
}
.tg-search-item:hover { background: var(--tg-soft); }
.tg-search-item strong { display: block; color: var(--tg-ink); font-size: 14px; font-weight: 700; }
.tg-search-item span   { display: block; color: var(--tg-muted); font-size: 12.5px; }

.tg-search-status { padding: 14px; color: var(--tg-muted); font-size: 13px; text-align: center; }

.tg-search-loader {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--tg-soft-2);
    border-top-color: var(--tg-green);
    border-radius: 50%;
    animation: tg-spin 0.65s linear infinite;
}

/* --------------------------------------------------------------------------
   11. Prose. Long-form content inside a tool description or blog post.
      Headings carry a green vertical rule on the left.
   -------------------------------------------------------------------------- */
.tg-prose h2, .tg-prose h3, .tg-prose h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--tg-ink);
    line-height: 1.3;
}
.tg-prose h2 { margin: 30px 0 16px; font-size: 22px; font-weight: 700; }
.tg-prose h3 { margin: 24px 0 12px; font-size: 19px; font-weight: 600; }
.tg-prose h4 { margin: 20px 0 10px; font-size: 17px; font-weight: 600; }

.tg-prose h2::before, .tg-prose h3::before, .tg-prose h4::before {
    content: "";
    display: inline-block;
    width: 3px;
    flex-shrink: 0;
    border-radius: 3px;
    background: var(--tg-green);
}
.tg-prose h2::before { height: 26px; }
.tg-prose h3::before { height: 21px; }
.tg-prose h4::before { height: 18px; }

.tg-prose p  { margin: 0 0 16px; color: var(--tg-text); font-size: 15px; line-height: 1.75; }
.tg-prose a  { color: var(--tg-green-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.tg-prose ul, .tg-prose ol { margin: 0 0 16px; padding-left: 22px; color: var(--tg-text); line-height: 1.75; }

/* --------------------------------------------------------------------------
   12. Responsive. Only the four canonical breakpoints.
   -------------------------------------------------------------------------- */
@media (max-width: 1050px) {
    .tg-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .tg-card-grid { grid-template-columns: 1fr; }
    .tg-section-head { margin-bottom: 30px; text-align: left; }
    .tg-search { max-width: none; }
}
@media (max-width: 520px) {
    .tg-card { padding: 18px; }
    .tg-btn  { width: 100%; }
}
@media (max-width: 430px) {
    .tg-container { width: calc(100% - 28px); }
}
