/* site-additions.css -- styles for behaviour that lives in JS, plus the shared
 * utility classes the pages need.
 *
 * Link it from every page that loads assets/js/intake-submit.js, and from any
 * page using .visually-hidden:
 *   <link rel="stylesheet" href="assets/css/site-additions.css">
 *
 * The panel below is built entirely by showCopyPanel() in
 * G:\Projects\Yan Consulting\public_html\assets\js\intake-submit.js. Its markup
 * is fixed, so these selectors must track that function exactly:
 *
 *   #intake-copy-panel                    role="dialog" aria-modal="true"
 *     .intake-copy-panel__box
 *       h2                                title
 *       p                                 help text
 *       textarea                          readonly, holds the JSON payload
 *       .intake-copy-panel__actions
 *         button.btn-primary              Copy
 *         button.btn-secondary            Close
 *
 * Why it exists at all: inside the WeChat in-app browser neither a mailto:
 * link nor a Blob download works, so when the POST to submit.php fails, the
 * only route left is "show the data as selectable text and let the client
 * paste it into a chat message". That route is worthless if the text is
 * unreadable or the buttons are off-screen, which is what this file prevents.
 *
 * These rules stand alone -- the intake wizards do not all load style.css, so
 * every colour has a literal fallback inside var().
 */

/* ------------------------------------------------------------- utilities */

/* Available to a screen reader, invisible on screen. For labels that the
   visual design carries by position or placeholder alone. Not display:none --
   that would remove it from the accessibility tree as well. */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* The submit.php honeypot wrapper. The field name lives in submit.php as
   HONEYPOT_FIELD -- do not restate it here, or the two drift apart.
   Hidden from sight AND from the tab order, so no human fills it, while a bot
   scraping the DOM for inputs still finds and fills it:

   <div class="hp-field" aria-hidden="true">
     <label for="...">Leave this field empty</label>
     <input type="text" id="..." name="..." tabindex="-1" autocomplete="off">
   </div>

   Off-screen rather than display:none is deliberate -- a bot reads the computed
   style and skips a display:none field. The cost, learned 2026-08-10, is that
   an off-screen input is exactly what browser autofill treats as fillable, so
   the field NAME is the only thing keeping autofill off it. Keep it
   meaningless.                                                              */
.hp-field {
    position: absolute !important;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ------------------------------------------------- WeChat fallback panel */

#intake-copy-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    /* Above the fixed site header, which sits at z-index 1000. */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.62);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    animation: intake-copy-fade 0.18s ease-out;
}

@keyframes intake-copy-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    #intake-copy-panel {
        animation: none;
    }
}

#intake-copy-panel .intake-copy-panel__box {
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    /* dvh keeps the panel off the WeChat toolbar when it slides in/out. */
    max-height: 90dvh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 12px;
    background: var(--bg-white, #ffffff);
    color: var(--text-dark, #1a1a1a);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    /* Inputs inherit the page font; the panel must not depend on style.css. */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
}

#intake-copy-panel .intake-copy-panel__box h2 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    line-height: 1.3;
    font-weight: 700;
    color: var(--primary, #002b5b);
}

#intake-copy-panel .intake-copy-panel__box p {
    margin: 0 0 14px;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-muted, #555555);
}

#intake-copy-panel .intake-copy-panel__box textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 200px;
    max-height: 45vh;
    padding: 12px;
    border: 1px solid #cfd4da;
    border-radius: 8px;
    background: #fbfbfc;
    color: var(--text-dark, #1a1a1a);
    /* 16px exactly: iOS Safari and the WeChat WebView zoom the whole page in
       when a focused control's text is smaller than that, and the client then
       cannot reach the Copy button. */
    font-size: 16px;
    line-height: 1.45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    resize: vertical;
    /* The value is JSON; let it wrap rather than scroll sideways forever. */
    white-space: pre-wrap;
    word-break: break-word;
}

#intake-copy-panel .intake-copy-panel__box textarea:focus {
    outline: 3px solid var(--accent, #c5a059);
    outline-offset: 2px;
    border-color: var(--accent, #c5a059);
}

#intake-copy-panel .intake-copy-panel__actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* Buttons. style.css styles .btn-primary for <a> elements only, so everything
   a <button> needs -- font inheritance, no UA border, pointer -- is set here.
   Scoped to the panel so the site's own buttons are untouched. */
#intake-copy-panel .btn-primary,
#intake-copy-panel .btn-secondary {
    flex: 1 1 auto;
    /* 44px is the minimum comfortable touch target on a phone. */
    min-height: 44px;
    padding: 12px 18px;
    border: 2px solid transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

#intake-copy-panel .btn-primary {
    background: var(--accent, #c5a059);
    color: #ffffff;
}

#intake-copy-panel .btn-primary:hover,
#intake-copy-panel .btn-primary:active {
    background: #b08d4b;
}

#intake-copy-panel .btn-secondary {
    background: #ffffff;
    color: var(--primary, #002b5b);
    border-color: var(--primary, #002b5b);
}

#intake-copy-panel .btn-secondary:hover,
#intake-copy-panel .btn-secondary:active {
    background: var(--primary, #002b5b);
    color: #ffffff;
}

#intake-copy-panel .btn-primary:focus-visible,
#intake-copy-panel .btn-secondary:focus-visible {
    outline: 3px solid var(--primary, #002b5b);
    outline-offset: 2px;
}

/* Very small phones: stack the buttons so neither label truncates in Chinese. */
@media (max-width: 380px) {
    #intake-copy-panel {
        padding: 10px;
    }

    #intake-copy-panel .intake-copy-panel__box {
        padding: 16px;
    }

    #intake-copy-panel .intake-copy-panel__actions {
        flex-direction: column;
    }
}

/* Landscape on a phone leaves almost no vertical room; give it back. */
@media (max-height: 480px) {
    #intake-copy-panel .intake-copy-panel__box textarea {
        min-height: 110px;
    }
}

@media (prefers-contrast: more) {
    #intake-copy-panel .intake-copy-panel__box {
        border: 2px solid var(--primary, #002b5b);
    }

    #intake-copy-panel .intake-copy-panel__box textarea {
        border-width: 2px;
        border-color: var(--primary, #002b5b);
    }
}
