/**
 * PTA Knowledge Hub — Front-end Search Page Styles
 *
 * Mobile-first, clean card grid, 44px+ touch targets.
 * Designed to look good inside any WordPress theme.
 */

/* ============================================
   Reset & Container
   ============================================ */

.ptk-search-wrap {
    max-width: 820px;
    margin: 0 auto;
    padding: 24px 16px 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #374151;
    line-height: 1.5;
    min-height: 80vh;
}
.ptk-search-wrap *, .ptk-search-wrap *::before, .ptk-search-wrap *::after {
    box-sizing: border-box;
}

/* ============================================
   Hero Section
   ============================================ */

.ptk-search-wrap .ptk-hero {
    text-align: center;
    padding: 32px 0 24px;
}
.ptk-search-wrap .ptk-hero-title {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 6px;
}
.ptk-search-wrap .ptk-hero-subtitle {
    font-size: 15px;
    color: #6b7280;
    margin: 0 0 20px;
}

/* ============================================
   Search Box
   ============================================ */

.ptk-search-wrap .ptk-search-box {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
}
.ptk-search-wrap .ptk-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #9ca3af;
    pointer-events: none;
}
.ptk-search-wrap .ptk-search-input {
    width: 100%;
    height: 52px;
    padding: 0 48px 0 48px;
    font-size: 16px; /* Prevents iOS zoom */
    color: #111827;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
}
.ptk-search-wrap .ptk-search-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.ptk-search-wrap .ptk-search-input::placeholder {
    color: #9ca3af;
}
.ptk-search-wrap .ptk-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 8px;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}
.ptk-search-wrap .ptk-search-clear:hover {
    color: #374151;
    background: #f3f4f6;
}
.ptk-search-wrap .ptk-search-clear svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   Category Filters
   ============================================ */

.ptk-search-wrap .ptk-category-filters {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 16px 0;
}
.ptk-search-wrap .ptk-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ptk-search-wrap .ptk-filter-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}
.ptk-search-wrap .ptk-filter-active {
    background: #111827 !important;
    color: #fff !important;
    border-color: #111827 !important;
}
.ptk-search-wrap .ptk-filter-count {
    font-size: 11px;
    background: rgba(0,0,0,0.08);
    padding: 1px 6px;
    border-radius: 6px;
}
.ptk-search-wrap .ptk-filter-active .ptk-filter-count {
    background: rgba(255,255,255,0.2);
}

/* ============================================
   Suggested Searches
   ============================================ */

.ptk-search-wrap .ptk-suggested {
    text-align: center;
    padding: 8px 0 24px;
}
.ptk-search-wrap .ptk-suggested-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 10px;
}
.ptk-search-wrap .ptk-suggested-tags {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.ptk-search-wrap .ptk-suggested-tag {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.ptk-search-wrap .ptk-suggested-tag:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* ============================================
   Loading
   ============================================ */

.ptk-search-wrap .ptk-loading {
    text-align: center;
    padding: 40px 0;
    color: #6b7280;
    font-size: 14px;
}
.ptk-search-wrap .ptk-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: ptk-spin 0.6s linear infinite;
    margin: 0 auto 12px;
}
@keyframes ptk-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Results
   ============================================ */

.ptk-search-wrap .ptk-results {
    padding-top: 8px;
}
.ptk-search-wrap .ptk-result-count {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    margin-top: 24px;
}

/* Group headings */
.ptk-search-wrap .ptk-group {
    margin-bottom: 28px;
}
.ptk-search-wrap .ptk-group-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}
/* Colored group headings */
.ptk-search-wrap .ptk-group-title-howto    { color: #1e40af; border-bottom-color: #2563eb; }
.ptk-search-wrap .ptk-group-title-event    { color: #065f46; border-bottom-color: #10b981; }
.ptk-search-wrap .ptk-group-title-faq      { color: #5b21b6; border-bottom-color: #8b5cf6; }
.ptk-search-wrap .ptk-group-title-resource { color: #9a3412; border-bottom-color: #f97316; }
.ptk-search-wrap .ptk-group-title-glossary { color: #115e59; border-bottom-color: #14b8a6; }
.ptk-search-wrap .ptk-group-title-checklist { color: #166534; border-bottom-color: #22c55e; }
.ptk-search-wrap .ptk-group-title-policy   { color: #334155; border-bottom-color: #64748b; }
.ptk-search-wrap .ptk-group-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* ============================================
   Error State
   ============================================ */

.ptk-search-wrap .ptk-error {
    text-align: center;
    padding: 48px 16px;
}
.ptk-search-wrap .ptk-hint {
    font-size: 14px;
    color: #6b7280;
    margin: 12px 0 0;
    font-style: italic;
}
.ptk-search-wrap .ptk-did-you-mean {
    font-size: 15px;
    color: #374151;
    margin: 16px 0 0;
}
.ptk-search-wrap .ptk-dym-link {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.ptk-search-wrap .ptk-dym-link:hover {
    color: #1d4ed8;
}

/* ============================================
   Cards — Shared
   ============================================ */

.ptk-search-wrap .ptk-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
}
.ptk-search-wrap .ptk-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.ptk-search-wrap .ptk-card:active {
    transform: scale(0.98);
}

.ptk-search-wrap .ptk-card-thumb {
    height: 140px;
    overflow: hidden;
    background: #f9fafb;
}
.ptk-search-wrap .ptk-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ptk-search-wrap .ptk-thumb-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1d5db;
}

.ptk-search-wrap .ptk-card-body {
    padding: 14px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ptk-search-wrap .ptk-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 0;
    margin-bottom: 4px;
}

.ptk-search-wrap .ptk-card-badge-wrap {
    padding: 16px 16px 0;
}
.ptk-search-wrap .ptk-card-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 0;
}

.ptk-search-wrap .ptk-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    margin: 0 0 6px;
}
.ptk-search-wrap .ptk-card-title-link {
    text-decoration: none;
    color: inherit;
}
.ptk-search-wrap .ptk-card-title-link:hover .ptk-card-title {
    color: #2563eb;
}

.ptk-search-wrap .ptk-card-excerpt {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0 0 10px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.ptk-search-wrap .ptk-card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.ptk-search-wrap .ptk-card-tag {
    font-size: 11px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 999px;
}

.ptk-search-wrap .ptk-card-link {
    font-size: 13px;
    font-weight: 500;
    margin-top: auto;
}

/* ============================================
   Cards — Category Colors
   ============================================ */

/* How-To Guide — Blue */
.ptk-search-wrap .ptk-badge-howto  { background: #dbeafe; color: #1e40af; }
.ptk-search-wrap .ptk-link-howto   { color: #2563eb; }

/* Event Playbook — Green */
.ptk-search-wrap .ptk-badge-event  { background: #d1fae5; color: #065f46; }
.ptk-search-wrap .ptk-link-event   { color: #059669; }

/* FAQ — Purple */
.ptk-search-wrap .ptk-badge-faq    { background: #ede9fe; color: #5b21b6; }
.ptk-search-wrap .ptk-link-faq     { color: #7c3aed; }

/* Resource — Orange */
.ptk-search-wrap .ptk-badge-resource { background: #ffedd5; color: #9a3412; }
.ptk-search-wrap .ptk-link-resource  { color: #ea580c; }

/* Glossary — Teal */
.ptk-search-wrap .ptk-badge-glossary { background: #ccfbf1; color: #115e59; }
.ptk-search-wrap .ptk-link-glossary  { color: #0d9488; }

/* Checklist — Emerald */
.ptk-search-wrap .ptk-badge-checklist { background: #dcfce7; color: #166534; }
.ptk-search-wrap .ptk-link-checklist  { color: #16a34a; }

/* Policy — Slate */
.ptk-search-wrap .ptk-badge-policy { background: #e2e8f0; color: #334155; }
.ptk-search-wrap .ptk-link-policy  { color: #475569; }

/* ============================================
   Copy Button
   ============================================ */

.ptk-search-wrap .ptk-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.ptk-search-wrap .ptk-copy-btn:hover {
    color: #374151;
    background: #f9fafb;
    border-color: #d1d5db;
}
.ptk-search-wrap .ptk-copy-btn.ptk-copied {
    color: #059669;
    border-color: #a7f3d0;
    background: #ecfdf5;
}

/* ============================================
   Best Answer
   ============================================ */

.ptk-search-wrap .ptk-best-answer {
    margin-bottom: 28px;
}
.ptk-search-wrap .ptk-best-answer-card {
    background: linear-gradient(135deg, #eff6ff, #f5f3ff);
    border: 2px solid #93c5fd;
    border-radius: 16px;
    padding: 20px;
    position: relative;
}
.ptk-search-wrap .ptk-best-answer-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #2563eb;
    margin-bottom: 10px;
}
.ptk-search-wrap .ptk-best-answer-label svg {
    width: 14px;
    height: 14px;
}
.ptk-search-wrap .ptk-best-answer-card .ptk-card-title {
    font-size: 20px;
}
.ptk-search-wrap .ptk-best-answer-card .ptk-card-excerpt {
    font-size: 14px;
    -webkit-line-clamp: 4;
}
.ptk-search-wrap .ptk-best-answer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    margin-top: 12px;
    transition: background 0.15s;
}
.ptk-search-wrap .ptk-best-answer-link:hover {
    background: #1d4ed8;
    color: #fff;
}

/* ============================================
   Empty State
   ============================================ */

.ptk-search-wrap .ptk-empty {
    text-align: center;
    padding: 48px 16px;
}
.ptk-search-wrap .ptk-empty-icon {
    width: 48px;
    height: 48px;
    color: #d1d5db;
    margin: 0 auto 16px;
    display: block;
}
.ptk-search-wrap .ptk-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 6px;
}
.ptk-search-wrap .ptk-empty-text {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* ============================================
   Responsive — Tablet+
   ============================================ */

@media (min-width: 640px) {
    .ptk-search-wrap .ptk-hero-title { font-size: 34px; }
    .ptk-search-wrap .ptk-search-input { height: 56px; font-size: 17px; }
    .ptk-search-wrap .ptk-group-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .ptk-search-wrap .ptk-group-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   Print
   ============================================ */

/* ============================================
   Focus Visible — Keyboard accessibility
   ============================================ */

.ptk-search-wrap .ptk-filter-btn:focus-visible,
.ptk-search-wrap .ptk-suggested-tag:focus-visible,
.ptk-search-wrap .ptk-copy-btn:focus-visible,
.ptk-search-wrap .ptk-dym-link:focus-visible,
.ptk-search-wrap .ptk-search-clear:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.ptk-search-wrap .ptk-card:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.ptk-search-wrap .ptk-card-title-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}

.ptk-search-wrap .ptk-best-answer-link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px #2563eb;
}

.ptk-search-wrap .ptk-card-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .ptk-search-wrap .ptk-spinner { animation: none; }
    .ptk-search-wrap .ptk-card:active { transform: none; }
    .ptk-search-wrap * { transition-duration: 0.01ms !important; }
}

/* ============================================
   Print
   ============================================ */

@media print {
    .ptk-search-wrap .ptk-hero,
    .ptk-search-wrap .ptk-category-filters,
    .ptk-search-wrap .ptk-suggested,
    .ptk-search-wrap .ptk-recent-section,
    .ptk-search-wrap .ptk-copy-btn { display: none; }
    .ptk-search-wrap .ptk-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================
   Recently Added Section
   ============================================ */

.ptk-search-wrap .ptk-recent-section {
    margin-bottom: 28px;
}

.ptk-search-wrap .ptk-recent-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 12px;
}

.ptk-search-wrap .ptk-recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* Remove category color bars from recently added cards */
.ptk-search-wrap .ptk-recent-grid .ptk-card {
    border-left: 1px solid #e5e7eb;
}

@media (max-width: 480px) {
    .ptk-search-wrap .ptk-recent-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Autocomplete Dropdown
   ============================================ */

.ptk-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    max-height: 320px;
    overflow-y: auto;
}

.ptk-ac-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none !important;
    color: #1e293b !important;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
    cursor: pointer;
}

.ptk-ac-item:last-child {
    border-bottom: none;
}

.ptk-ac-item:hover,
.ptk-ac-item.ptk-ac-active {
    background: #f8fafc;
}

.ptk-ac-title {
    font-size: 0.95rem;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ptk-ac-title strong {
    font-weight: 700;
    color: #2563eb;
}

.ptk-ac-cat {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Fresh-install empty state (v2.7.0) */
.ptk-search-wrap .ptk-empty-install {
    text-align: center;
    padding: 48px 24px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    margin: 20px 0 40px;
}
.ptk-search-wrap .ptk-empty-install-icon {
    width: 56px;
    height: 56px;
    color: #94a3b8;
    margin: 0 auto 14px;
    display: block;
}
.ptk-search-wrap .ptk-empty-install-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px;
}
.ptk-search-wrap .ptk-empty-install-text {
    font-size: 15px;
    color: #475569;
    max-width: 380px;
    margin: 0 auto 18px;
    line-height: 1.55;
}
.ptk-search-wrap .ptk-empty-install-cta {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 22px;
    background: #2563eb;
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.15s;
}
.ptk-search-wrap .ptk-empty-install-cta:hover {
    background: #1d4ed8;
    color: #fff !important;
}

/* T2.5 — Filter button press state so click registers on touch (v2.8.0) */
.ptk-search-wrap .ptk-filter-btn:active {
    transform: translateY(1px);
}

/* T2.6 — Explicit transition on filter buttons (avoid 'all' surprises) */
.ptk-search-wrap .ptk-filter-btn {
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* Retry button in the search error state */
.ptk-retry-btn {
    min-height: 44px;
    padding: 10px 28px;
    margin-top: 8px;
    border: none;
    border-radius: 8px;
    background: #4f46e5;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.ptk-retry-btn:hover { background: #4338ca; }
.ptk-retry-btn:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }
.ptk-error-fallback { margin-top: 12px; font-size: 13px; color: #9ca3af; }
