/* ==========================================================================
   Spotlight search — macOS Tahoe style

   Hidden until invoked with Cmd/Ctrl+K, "/" or the header search button.
   The field stays centred in the viewport; quick actions sit beneath it when
   the query is empty and the results panel replaces them while typing.
   ========================================================================== */

.ss-scrim {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(16, 18, 24, 0.32);
    -webkit-backdrop-filter: blur(10px) saturate(115%);
    backdrop-filter: blur(10px) saturate(115%);
    opacity: 0;
    transition: opacity 300ms ease;
    -webkit-tap-highlight-color: transparent;
}

.ss-scrim.is-visible {
    opacity: 1;
}

.ss-dock {
    --ss-text: #1d1d1f;
    --ss-muted: rgba(29, 29, 31, 0.62);
    --ss-faint: rgba(29, 29, 31, 0.42);
    --ss-glass: rgba(243, 244, 248, 0.7);
    --ss-glass-strong: rgba(255, 255, 255, 0.86);
    --ss-border: rgba(255, 255, 255, 0.92);
    --ss-row: rgba(255, 255, 255, 0.36);
    --ss-row-active: rgba(60, 60, 67, 0.1);
    --ss-line: rgba(255, 255, 255, 0.55);
    --ss-mark: rgba(10, 132, 255, 0.16);
    --ss-focus: rgba(10, 132, 255, 0.22);
    --ss-shadow:
        0 28px 70px -18px rgba(16, 20, 36, 0.46),
        0 6px 20px -8px rgba(16, 20, 36, 0.22);

    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 10001;
    width: min(680px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -50%) scale(0.96);
    transform-origin: 50% 50%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    font-family: var(--wp--preset--font-family--inter-display, "Inter Display", sans-serif);
    color: var(--ss-text);
    -webkit-font-smoothing: antialiased;
    transition:
        opacity 220ms ease,
        transform 460ms cubic-bezier(0.2, 0.9, 0.2, 1),
        visibility 0s linear 460ms;
}

.ss-dock.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
    transition:
        opacity 220ms ease,
        transform 460ms cubic-bezier(0.2, 0.9, 0.2, 1),
        visibility 0s linear 0s;
}

body.is-dark .ss-dock {
    --ss-text: #f5f5f7;
    --ss-muted: rgba(245, 245, 247, 0.6);
    --ss-faint: rgba(245, 245, 247, 0.4);
    --ss-glass: rgba(34, 36, 43, 0.66);
    --ss-glass-strong: rgba(48, 50, 58, 0.82);
    --ss-border: rgba(255, 255, 255, 0.18);
    --ss-row: rgba(255, 255, 255, 0.06);
    --ss-row-active: rgba(255, 255, 255, 0.13);
    --ss-line: rgba(255, 255, 255, 0.09);
    --ss-mark: rgba(100, 210, 255, 0.26);
    --ss-focus: rgba(100, 210, 255, 0.26);
    --ss-shadow:
        0 30px 76px -18px rgba(0, 0, 0, 0.76),
        0 8px 26px -10px rgba(0, 0, 0, 0.55);
}

html.ss-locked {
    overflow: hidden;
}

.ss-dock,
.ss-dock *,
.ss-scrim {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Header trigger
   -------------------------------------------------------------------------- */

.header-search {
    pointer-events: auto;
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-right: 8px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.52);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    color: #1d1d1f;
    cursor: pointer;
    box-shadow:
        0 3px 12px -4px rgba(20, 24, 40, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1), background 240ms ease, box-shadow 240ms ease;
}

.header-search svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.header-search:hover {
    transform: scale(1.07);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 5px 16px -4px rgba(20, 24, 40, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.header-search:active {
    transform: scale(0.94);
}

.header-search:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.24), 0 3px 12px -4px rgba(20, 24, 40, 0.22);
}

body.is-dark .header-search {
    background: rgba(34, 36, 43, 0.64);
    border-color: rgba(255, 255, 255, 0.18);
    color: #f5f5f7;
    box-shadow: 0 3px 12px -4px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

body.is-dark .header-search:hover {
    background: rgba(58, 60, 68, 0.8);
}

/* --------------------------------------------------------------------------
   Glass material
   -------------------------------------------------------------------------- */

.ss-bar {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ss-field,
.ss-action,
.ss-panel {
    position: relative;
    isolation: isolate;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.16) 58%, rgba(255, 255, 255, 0.26)),
        var(--ss-glass);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--ss-border);
    box-shadow:
        0 0 0 1px rgba(15, 18, 30, 0.05),
        var(--ss-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 1px rgba(255, 255, 255, 0.2);
}

body.is-dark .ss-field,
body.is-dark .ss-action,
body.is-dark .ss-panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02) 58%, rgba(255, 255, 255, 0.05)),
        var(--ss-glass);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.24),
        var(--ss-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        inset 0 -1px 1px rgba(0, 0, 0, 0.24);
}

/* Specular rim */
.ss-field::after,
.ss-action::after,
.ss-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg,
        rgba(255, 255, 255, 0.95),
        rgba(255, 255, 255, 0.08) 34%,
        rgba(255, 255, 255, 0.02) 62%,
        rgba(255, 255, 255, 0.55));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.85;
}

body.is-dark .ss-field::after,
body.is-dark .ss-action::after,
body.is-dark .ss-panel::after {
    background: linear-gradient(140deg,
        rgba(255, 255, 255, 0.42),
        rgba(255, 255, 255, 0.04) 40%,
        rgba(255, 255, 255, 0) 66%,
        rgba(255, 255, 255, 0.18));
    opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Search field
   -------------------------------------------------------------------------- */

.ss-field {
    width: 100%;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    border-radius: 999px;
    color: var(--ss-text);
    transition: box-shadow 260ms ease, background 260ms ease;
}

.ss-field:hover {
    box-shadow:
        var(--ss-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

.ss-field:focus-within {
    box-shadow:
        var(--ss-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 0 0 3px rgba(10, 132, 255, 0.16);
    outline: none;
}

body.is-dark .ss-field:focus-within {
    box-shadow:
        var(--ss-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        0 0 0 3px rgba(100, 210, 255, 0.22);
}

.ss-search-icon {
    flex: none;
    width: 21px;
    height: 21px;
    color: var(--ss-muted);
    stroke-width: 2;
}

.ss-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 18px;
    font-weight: 400;
    letter-spacing: -0.01em;
    caret-color: var(--ss-text);
}

.ss-input::placeholder {
    color: var(--ss-muted);
    opacity: 1;
}

.ss-input::-webkit-search-cancel-button {
    display: none;
}

.ss-clear {
    flex: none;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(29, 29, 31, 0.18);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.7);
    pointer-events: none;
    transition: opacity 160ms ease, transform 200ms cubic-bezier(0.2, 0.9, 0.2, 1), background 160ms ease;
}

body.is-dark .ss-clear {
    background: rgba(255, 255, 255, 0.24);
    color: #1d1d1f;
}

.ss-clear svg {
    width: 13px;
    height: 13px;
    stroke-width: 2.4;
}

.ss-clear:hover {
    background: rgba(29, 29, 31, 0.32);
}

.ss-field.has-value .ss-clear {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Quick actions (empty query)
   -------------------------------------------------------------------------- */

.ss-actions {
    position: absolute;
    top: calc(100% + 16px);
    left: 50%;
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateX(-50%);
    opacity: 1;
    transition:
        opacity 180ms ease,
        transform 320ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.ss-dock.has-query .ss-actions,
.ss-dock:not(.is-open) .ss-actions {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.9);
    pointer-events: none;
}

.ss-dock:not(.is-open) .ss-action {
    animation: none;
}

.ss-action {
    flex: none;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    color: var(--ss-text);
    cursor: pointer;
    transition:
        transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1),
        box-shadow 240ms ease,
        background 240ms ease;
    animation: ss-pop-in 380ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
    animation-delay: calc(110ms + var(--ss-i, 0) * 45ms);
}

.ss-action svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

.ss-action:hover {
    transform: translateY(-3px) scale(1.05);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.16)),
        var(--ss-glass-strong);
}

.ss-action:active {
    transform: scale(0.93);
}

.ss-action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--ss-focus), var(--ss-shadow);
}

/* --------------------------------------------------------------------------
   Results panel (typed query)
   -------------------------------------------------------------------------- */

.ss-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.985);
    transform-origin: 50% 0;
    max-height: 0;
    padding: 0;
    transition:
        opacity 200ms ease,
        transform 320ms cubic-bezier(0.2, 0.9, 0.2, 1),
        max-height 380ms cubic-bezier(0.2, 0.9, 0.2, 1),
        padding 300ms ease,
        visibility 380ms ease;
}

.ss-dock.is-open.has-query .ss-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    max-height: min(44vh, 420px);
    padding: 6px;
}

.ss-panel__scroll {
    flex: 1 1 auto;
    max-height: min(34vh, 330px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--ss-faint) transparent;
    padding-bottom: 2px;
}

.ss-panel__scroll::-webkit-scrollbar {
    width: 8px;
}

.ss-panel__scroll::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--ss-faint);
    background-clip: content-box;
}

.ss-group {
    padding: 2px 0 6px;
    animation: ss-item-in 300ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
    animation-delay: calc(var(--ss-i, 0) * 30ms);
}

.ss-group + .ss-group {
    border-top: 1px solid var(--ss-line);
    padding-top: 6px;
    margin-top: 2px;
}

.ss-group__label {
    display: block;
    padding: 7px 12px 5px;
    color: var(--ss-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.ss-result {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    outline: none;
    transition: background 140ms ease, transform 140ms ease;
}

.ss-result + .ss-result {
    margin-top: 1px;
}

.ss-result.is-active {
    background: var(--ss-row-active);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.ss-result.is-active .ss-result__arrow {
    opacity: 1;
    transform: translateX(0);
}

.ss-result__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    color: #5b5b60;
    background: rgba(255, 255, 255, 0.45);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

body.is-dark .ss-result__icon {
    color: rgba(245, 245, 247, 0.8);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.ss-result__icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
}

.ss-result[data-icon="home"] .ss-result__icon {
    color: #ff9f0a;
    background: rgba(255, 159, 10, 0.14);
}

.ss-result[data-icon="project"] .ss-result__icon {
    color: #0a84ff;
    background: rgba(10, 132, 255, 0.14);
}

.ss-result[data-icon="article"] .ss-result__icon {
    color: #bf5af2;
    background: rgba(191, 90, 242, 0.14);
}

.ss-result[data-icon="contact"] .ss-result__icon {
    color: #30d158;
    background: rgba(48, 209, 88, 0.15);
}

.ss-result[data-icon="github"] .ss-result__icon {
    color: #1d1d1f;
    background: rgba(29, 29, 31, 0.1);
}

body.is-dark .ss-result[data-icon="github"] .ss-result__icon {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.1);
}

.ss-result[data-icon="link"] .ss-result__icon {
    color: #64d2ff;
    background: rgba(100, 210, 255, 0.16);
}

.ss-result__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ss-result__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-result__desc {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--ss-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-result mark {
    background: var(--ss-mark);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}

.ss-result__arrow {
    flex: none;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    color: var(--ss-muted);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 160ms ease, transform 200ms ease;
}

.ss-result__arrow svg {
    width: 13px;
    height: 13px;
    stroke-width: 2;
}

/* --------------------------------------------------------------------------
   Empty state + footer
   -------------------------------------------------------------------------- */

.ss-empty[hidden] {
    display: none;
}

.ss-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 26px 20px 30px;
    text-align: center;
    color: var(--ss-muted);
    animation: ss-item-in 260ms ease both;
}

.ss-empty svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    opacity: 0.6;
    stroke-width: 1.6;
}

.ss-empty strong {
    color: var(--ss-text);
    font-size: 14px;
    font-weight: 600;
}

.ss-empty span {
    font-size: 12.5px;
}

.ss-empty em {
    font-style: normal;
    color: var(--ss-text);
}

.ss-footer {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 2px;
    padding: 8px 12px;
    border-top: 1px solid var(--ss-line);
    color: var(--ss-muted);
    font-size: 11px;
    font-weight: 500;
}

.ss-footer__hints {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ss-footer__hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.ss-footer__count {
    color: var(--ss-faint);
    white-space: nowrap;
}

.ss-footer kbd {
    display: inline-grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.35);
    color: var(--ss-muted);
    font-family: var(--wp--preset--font-family--jetbrains-mono, "JetBrains Mono", monospace);
    font-size: 10px;
    line-height: 1;
}

body.is-dark .ss-footer kbd {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
}

.ss-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

@keyframes ss-pop-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ss-item-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 700px) {
    .ss-dock {
        width: calc(100vw - 24px);
    }

    .ss-field {
        height: 50px;
        padding: 0 15px;
        border-radius: 18px;
    }

    .ss-input {
        font-size: 16px;
    }

    .ss-action {
        width: 48px;
        height: 48px;
    }

    .ss-action svg {
        width: 20px;
        height: 20px;
    }

    .ss-panel {
        border-radius: 18px;
    }

    .ss-dock.is-open.has-query .ss-panel {
        max-height: min(46dvh, 420px);
    }

    .ss-panel__scroll {
        max-height: min(36dvh, 320px);
    }

    .ss-footer__hints {
        display: none;
    }

    .header-search {
        width: 32px;
        height: 32px;
    }
}

/* --------------------------------------------------------------------------
   Page chrome
   -------------------------------------------------------------------------- */

.header__cta {
    transition: opacity 180ms ease;
}

html.ss-locked .header__cta {
    opacity: 0;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .ss-dock,
    .ss-action,
    .ss-group,
    .ss-empty {
        animation: none !important;
    }

    .ss-field,
    .ss-action,
    .ss-panel,
    .ss-clear,
    .ss-scrim,
    .ss-result,
    .ss-result__arrow,
    .ss-dock {
        transition-duration: 1ms !important;
    }
}

@media (prefers-contrast: more) {
    .ss-field,
    .ss-action,
    .ss-panel {
        border-color: var(--ss-text);
    }

    .ss-result.is-active {
        outline: 2px solid var(--ss-text);
        outline-offset: -2px;
    }
}

/* Anchors under a centred overlay */
#services,
#work,
#articles,
#testimonials,
#contact {
    scroll-margin-top: 110px;
}
