/* Period 3 portal search — modal overlay + results list + mobile FAB.
   Triggered by tapping the floating button, clicking the commandbar
   search input, or pressing Cmd/Ctrl+K. Backed by /pagefind/. */

/* ---------- Floating action button (always visible) ---------- */
.p3search-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 8500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px 0 14px;
  border: 1px solid var(--accent-dark, #1d4e51);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent, #2f6f73) 0%, var(--accent-dark, #1d4e51) 100%);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(20, 54, 57, 0.28), 0 1px 0 rgba(255,255,255,0.18) inset;
  transition: transform 80ms ease, box-shadow 120ms ease, filter 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.p3search-fab:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(20, 54, 57, 0.32), 0 1px 0 rgba(255,255,255,0.2) inset; }
.p3search-fab:active { transform: translateY(1px); }
.p3search-fab svg { width: 18px; height: 18px; flex: 0 0 auto; }
.p3search-fab .p3search-fab-shortcut {
  display: none;
  padding: 1px 5px;
  margin-left: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 4px;
  color: #fff;
}
@media (hover: hover) and (min-width: 768px) {
  .p3search-fab .p3search-fab-shortcut { display: inline-block; }
}
@media print { .p3search-fab { display: none !important; } }


.p3search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.06in;
  padding: 0.05in 0.1in;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.p3search-trigger:hover {
  background: var(--soft);
}
.p3search-trigger kbd {
  display: inline-block;
  padding: 1px 5px;
  margin-left: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9pt;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* Backdrop */
.p3search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 31, 33, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: none;
  padding: clamp(36px, 8vh, 96px) 16px 16px;
  overflow-y: auto;
}
.p3search-overlay.open {
  display: block;
}

/* Modal */
.p3search-modal {
  width: min(620px, 100%);
  margin: 0 auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(20, 54, 57, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.6);
}

/* Input row */
.p3search-inputrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfc 100%);
}
.p3search-inputrow svg {
  width: 18px; height: 18px;
  color: var(--accent);
  flex: 0 0 auto;
}
.p3search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  /* 17px keeps iOS Safari from auto-zooming on focus (zoom kicks in <16px). */
  font-size: 17px;
  color: var(--ink);
  padding: 8px 0;
}
.p3search-input::placeholder { color: #95a0a8; }
.p3search-close {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 9pt;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
}
.p3search-close:hover { color: var(--accent-dark); background: var(--soft); }

/* Status / hint line */
.p3search-status {
  padding: 8px 16px;
  font-size: 10pt;
  color: var(--muted);
  background: #fafbfb;
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.02em;
}
.p3search-status.empty { background: #fff; }

/* Results list */
.p3search-results {
  list-style: none;
  margin: 0;
  padding: 4px 0 8px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
}
.p3search-result {
  padding: 0;
  border-bottom: 1px solid var(--line);
}
.p3search-result:last-child { border-bottom: 0; }
.p3search-result a {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--ink);
  transition: background-color 80ms ease;
}
.p3search-result a:hover,
.p3search-result.focused a {
  background: var(--soft);
}
.p3search-result .p3search-title {
  display: block;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 11.5pt;
  line-height: 1.25;
  margin-bottom: 4px;
}
.p3search-result .p3search-excerpt {
  display: block;
  color: var(--muted);
  font-size: 10.5pt;
  line-height: 1.45;
}
.p3search-result .p3search-excerpt mark {
  background: rgba(47, 111, 115, 0.16);
  color: var(--accent-dark);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 700;
}
.p3search-result .p3search-path {
  display: block;
  margin-top: 6px;
  color: #93a0a7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9pt;
  letter-spacing: 0.02em;
}

/* Footer */
.p3search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fafbfb;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9.5pt;
  letter-spacing: 0.02em;
}
.p3search-footer kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9pt;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* Empty state */
.p3search-empty {
  padding: 24px 16px 28px;
  color: var(--muted);
  text-align: center;
  font-size: 10.5pt;
}
.p3search-empty strong { color: var(--accent-dark); }

/* ---------- Mobile: full-screen flex modal that survives the keyboard ---------- */
@media (max-width: 640px) {
  .p3search-overlay {
    padding: 0;
    overflow: hidden;
    /* dvh adapts when the iOS keyboard opens; vh fallback for older Safari. */
    height: 100vh;
    height: 100dvh;
    overscroll-behavior: contain;
  }
  .p3search-modal {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .p3search-inputrow {
    flex: 0 0 auto;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }
  .p3search-input { font-size: 17px; padding: 10px 0; }
  .p3search-close {
    min-height: 40px;
    min-width: 44px;
    padding: 8px 12px;
    font-size: 11px;
  }
  .p3search-status { flex: 0 0 auto; }
  .p3search-results {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .p3search-result a { padding: 14px 14px; }
  .p3search-result .p3search-title { font-size: 16px; }
  .p3search-result .p3search-excerpt { font-size: 14px; }
  .p3search-footer {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .p3search-footer kbd { display: none; }
  .p3search-footer span:last-child::before { content: "Tap a result to open"; }
  .p3search-footer span:last-child > * { display: none; }
  .p3search-fab {
    padding: 0 14px;
    min-height: 52px;
    font-size: 15px;
  }
}

/* Hide the FAB while the modal is open so it doesn't cover the close button. */
.p3search-overlay.open ~ .p3search-fab,
body.p3search-modal-open .p3search-fab {
  display: none;
}

