/* Overrides + additions on top of Forty (HTML5 UP, CC-BY 3.0) for Yanxi's pages.
 * Loaded AFTER forty/css/main.css so these rules win.
 *
 * Recolor later: tweak the variables below. (Forty's own palette is compiled into
 * forty/css/main.css; these vars cover the bits we add — banner, avatar, chatbot.) */
:root {
    --y-accent: #9bf1ff;     /* Forty's cyan highlight */
    --y-cyan: #6fc3df;       /* Forty accent (chat bubble / user msg) */
    --y-bg-deep: #242943;    /* Forty's dark navy */
    --y-bg-deep-2: #3a2f5a;  /* gradient partner */
    --y-bg-alt: #2a2f4a;     /* panel surface */
    --y-bg-msg: #353b5c;     /* bot bubble / input surface */
    --y-text: #f4f4ff;       /* light text on dark */
    --y-border: rgba(212, 212, 255, 0.15);
}

/* --- Banner: CC0 photo + dark overlay for readable text, + avatar --- */
#banner {
    background-image:
        linear-gradient(to top, rgba(36, 41, 67, 0.88), rgba(36, 41, 67, 0.5)),
        url("../img/tiles/banner.jpg");
    background-size: cover;
    background-position: center;
}

.banner-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--y-accent);
    margin-bottom: 1.5rem;
}

/* ===== In-page info modals (About / Work / Education tiles + "Learn more") ===== */
.yx-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    background: rgba(0, 0, 0, 0.6);
}

.yx-modal.is-open {
    display: flex;
    animation: chatbotPop 0.18s ease;
}

.yx-modal-card {
    position: relative;
    display: flex;
    flex-direction: column;         /* card stays fixed; the body inside scrolls */
    width: min(720px, 100%);
    max-height: 85vh;
    overflow: hidden;               /* card itself never scrolls → the × stays pinned */
    background: var(--y-bg-alt);
    border: 1px solid var(--y-border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.yx-modal-body {
    overflow-y: auto;               /* tall content scrolls HERE; × above stays put */
    padding: 2.5em 2.5em 2em;
    color: var(--y-text);
    /* thin scrollbar in the site's colours (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: rgba(155, 241, 255, 0.3) transparent;
}

/* thin scrollbar in the site's colours (Chrome/Edge/Safari) */
.yx-modal-body::-webkit-scrollbar { width: 8px; }
.yx-modal-body::-webkit-scrollbar-track { background: transparent; }
.yx-modal-body::-webkit-scrollbar-thumb { background: rgba(155, 241, 255, 0.25); border-radius: 4px; }
.yx-modal-body::-webkit-scrollbar-thumb:hover { background: rgba(155, 241, 255, 0.45); }

/* reset Forty's global button styling on the ×; pinned to the card top-right.
   A solid circle bg (card colour) keeps it legible as content scrolls under it. */
.yx-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 36px;
    height: 36px;
    min-width: 0;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: var(--y-bg-alt);
    border: none;
    border-radius: 50%;
    color: var(--y-text);
    font-size: 24px;
    font-weight: 400;
    letter-spacing: 0;      /* Forty adds letter-spacing → shifts the single × left */
    text-transform: none;
    text-indent: 0;
    cursor: pointer;
    opacity: 0.85;
}

.yx-modal-close:hover { opacity: 1; background: var(--y-bg-msg); }
.yx-modal-body h2 { color: var(--y-accent); }

/* Each work/education entry: hover tint + left accent bar so item boundaries
   are clear and easier to scan. */
.yx-item {
    padding: 0.9em 1.1em;
    border-radius: 8px;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.yx-item:hover {
    background-color: rgba(155, 241, 255, 0.06);
    box-shadow: inset 3px 0 0 var(--y-cyan);
}

.yx-item + .yx-item {
    margin-top: 0.5em;
}

/* keep the padding tidy: no stray top/bottom margin from the first/last child */
.yx-item > :first-child { margin-top: 0; }
.yx-item > :last-child { margin-bottom: 0; }

/* freeze the page scroll while a modal is open */
body.yx-modal-lock { overflow: hidden; }

@media (max-width: 736px) {
    .yx-modal-card { max-height: 88vh; }
    .yx-modal-body { padding: 2em 1.4em 1.6em; }
    /* phones: near-full (60vw would be too narrow here) */
    .yx-modal-chat { width: calc(100vw - 32px); height: 88vh; }
}

/* ===== Email contact popup (copyable) ===== */
.email-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
}

.email-popup.is-open {
    display: flex;
    animation: chatbotPop 0.18s ease;
}

.email-popup-card {
    position: relative;
    width: 340px;
    max-width: 90vw;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--y-bg-alt);
    border: 1px solid var(--y-border);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    padding: 40px 26px 24px;
    text-align: center;
}

/* reset Forty's global button styling (height/padding/min-width) on the × */
.email-popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 32px;
    height: 32px;
    min-width: 0;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: none;
    border: none;
    color: var(--y-text);
    font-size: 24px;
    cursor: pointer;
}

.email-popup-label {
    color: var(--y-text);
    opacity: 0.75;
    margin: 0 0 16px;
    font-size: 0.8em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.email-popup-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

#email-addr {
    flex: 1;
    min-width: 0;
    text-align: left;
    background: var(--y-bg-deep);
    color: var(--y-accent);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    line-height: 1.4;
    word-break: break-all;
    user-select: all;
}

/* reset Forty's global button styling so the Copy button isn't oversized/cramped */
.email-copy-btn {
    flex-shrink: 0;
    height: 40px;
    min-width: 0;
    padding: 0 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: var(--y-cyan);
    color: #1a1f33;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    white-space: nowrap;
}

.email-popup-mail {
    display: inline-block;
    margin-top: 2px;
    color: var(--y-accent);
    font-size: 0.85em;
}

/* ===== Chat widget: rendered INSIDE the #modal-chat popup (home page tile) ===== */
/* Size the chat card and lay its contents as a column, so the messages scroll
   while the header / chips / input stay put. The inner pieces
   (.chatbot-header / .chatbot-messages / .chatbot-chips / .chatbot-input) are
   styled further down and reused as-is inside the modal card. */
.yx-modal-chat {
    /* Size relative to the viewport so it scales with the window across monitors;
       caps keep it from getting absurdly large on ultra-wide screens.
       (Phones are handled by the max-width:736px media query below.) */
    width: min(60vw, 900px);
    height: min(78vh, 800px);
    padding: 0;
}

#yanxi-chatbot-mount {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    font-family: "Source Sans Pro", Helvetica, sans-serif;
}

@keyframes chatbotPop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-header {
    background: var(--y-bg-deep);
    color: var(--y-accent);
    padding: 12px 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--y-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-close {
    background: none;
    border: none;
    color: var(--y-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--y-bg-deep);
    /* thin, subtle scrollbar matching the dark theme (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: rgba(155, 241, 255, 0.3) transparent;
}

/* custom scrollbar matching the dark theme (Chrome/Edge/Safari) */
.chatbot-messages::-webkit-scrollbar {
    width: 8px;
}
.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(155, 241, 255, 0.25);
    border-radius: 4px;
}
.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(155, 241, 255, 0.45);
}

.chatbot-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85em;   /* relative to the header title (body size) → always slightly smaller */
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chatbot-msg.bot {
    align-self: flex-start;
    background: var(--y-bg-msg);
    color: var(--y-text);
    border: 1px solid var(--y-border);
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user {
    align-self: flex-end;
    background: var(--y-cyan);
    color: #1a1f33;
    border-bottom-right-radius: 4px;
}

.chatbot-msg.typing {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-msg.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--y-accent);
    animation: chatbotBlink 1.2s infinite both;
}

.chatbot-msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-msg.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbotBlink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

.chatbot-sticker {
    display: block;
    max-width: 120px;
    margin-top: 6px;
}

.chatbot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 6px;
    background: var(--y-bg-deep);
}

.chatbot-chip {
    display: inline-flex;          /* center the label vertically + horizontally */
    align-items: center;
    justify-content: center;
    height: auto;                  /* reset Forty's fixed button height */
    line-height: 1.35;             /* reset Forty's tall button line-height */
    background: rgba(111, 195, 223, 0.12);
    color: var(--y-accent);
    border: 1px solid rgba(111, 195, 223, 0.5);
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 0.75em;   /* bigger than before, still clearly under the header title */
    text-align: center;
    cursor: pointer;
    transition: background 0.12s ease;
}

.chatbot-chip:hover { background: rgba(111, 195, 223, 0.28); }

/* shown in place of chips once the user has clicked through all guide questions */
.chatbot-invite {
    display: block;
    width: 100%;
    color: rgba(244, 244, 255, 0.6);
    font-size: 12.5px;
    font-style: italic;
    padding: 2px 4px;
}

.chatbot-input {
    display: flex;
    border-top: 1px solid var(--y-border);
    padding: 8px;
    gap: 8px;
    background: var(--y-bg-deep);
}

/* explicit values so Forty's global input/button styles don't bleed in */
.chatbot-input input {
    flex: 1;
    height: auto;
    border: 1px solid var(--y-border);
    border-radius: 18px;
    padding: 9px 14px;
    font-size: 0.85em;   /* match the message bubbles */
    outline: none;
    background: var(--y-bg-msg);
    color: var(--y-text);
    font-family: inherit;
}

.chatbot-input input::placeholder { color: rgba(244, 244, 255, 0.45); }
.chatbot-input input:focus { border-color: var(--y-cyan); }

.chatbot-input button {
    background: var(--y-cyan);
    color: #1a1f33;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    min-width: 0;
    padding: 0;
    font-size: 15px;
    line-height: 1;
    letter-spacing: 0;      /* Forty adds letter-spacing → shifts the single ➤ left */
    text-indent: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: pointer;
    flex-shrink: 0;
}

/* ===== Sub-page banner (compact title header for Hobbies / Places) ===== */
#banner.sub {
    height: auto;
    min-height: 0;
    padding: 9em 0 5em;
}

/* ===== Hobby rows (Hobbies page) — text left, photo right, on dark ===== */
.yanxi-hobby {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    max-width: 780px;
    margin: 0 auto;
    padding: 30px 0;
    border-bottom: 1px solid var(--y-border);
}

.yanxi-hobby:last-child {
    border-bottom: 0;
}

.yanxi-hobby .hobby-text {
    flex: 1;
}

.yanxi-hobby .hobby-text h3 {
    margin-bottom: 8px;
    color: var(--y-accent);
}

/* Fixed-width column so every photo sits in the same slot → tidy vertical column. */
.hobby-icon-wrap {
    flex-shrink: 0;
    width: 160px;
    display: flex;
    justify-content: center;
}

/* Uniform square thumbnails so different photo sizes still line up neatly. */
.yanxi-hobby .hobby-photo {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    border: 1px solid var(--y-border);
}

/* On narrow screens, stack the photo under the text so nothing overflows. */
@media (max-width: 736px) {
    .yanxi-hobby {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }
    .hobby-icon-wrap {
        width: auto;
        justify-content: flex-start;
    }
}

/* ===== Leaflet map (used on the Places page) ===== */
.visited-map {
    height: 460px;
    max-width: 860px;
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid var(--y-border);
}

/* ===== Timeline posts feed (Timeline page) ===== */
.post {
    background: var(--y-bg-alt);
    border: 1px solid var(--y-border);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 16px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.post .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--y-border);
    background: var(--y-bg-deep);
}

.post-header strong {
    color: var(--y-text);
    font-size: 1.05em;
}

.post-meta {
    color: rgba(244, 244, 255, 0.55);
    font-size: 0.8em;
    margin-bottom: 10px;
    word-break: break-word;
}

.post-content {
    color: var(--y-text);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

/* Timeline form submit status (validation / server errors, success) */
.timeline-status {
    min-height: 1.2em;
    margin: 0.6em 0 0;
    font-size: 0.9em;
}
.timeline-status.is-error { color: #ff9b9b; }
.timeline-status.is-success { color: var(--y-accent); }
