/* 
 * Tattoo Wiki Standalone CSS 
 * Theme: White/Blue, Fullscreen, Mobile-First
 */

:root {
    --xtw-primary: #0066cc;
    /* 行楽蓝 */
    --xtw-primary-dark: #004c99;
    --xtw-bg: #ffffff;
    --xtw-text: #333333;
    --xtw-text-light: #666666;
    --xtw-border: #e0e0e0;
    --xtw-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Reset primitive */
#xtw-app * {
    box-sizing: border-box;
}

#xtw-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--xtw-bg);
    color: var(--xtw-text);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* 全面屏适配：使用 top/left/right/bottom 而非 100vh/100vw */
    z-index: 99999;
    /* 确保覆盖主题元素 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.xtw-header {
    position: fixed;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.xtw-brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #000;
    letter-spacing: -0.5px;
}

.xtw-brand-sub {
    color: var(--xtw-primary);
    margin-left: 4px;
}

.xtw-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Mission Button (Ghost Style) */
.xtw-btn-text {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #666;
    cursor: pointer;
    padding: 6px 14px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.xtw-btn-text:hover {
    border-color: var(--xtw-primary);
    color: var(--xtw-primary);
    background: rgba(0, 102, 204, 0.05);
}

.xtw-btn-ask {
    background: transparent;
    border: 1px solid var(--xtw-primary);
    color: var(--xtw-primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}

.xtw-btn-ask:hover {
    background: var(--xtw-primary);
    color: #fff;
}

/* Mission Modal */
.xtw-mission-body {
    text-align: left;
    padding: 30px 40px;
}

.xtw-mission-body h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.4rem;
    text-align: center;
    color: #000;
}

.xtw-mission-content p {
    margin-bottom: 15px;
    line-height: 1.8;
    color: #444;
    font-size: 1rem;
    text-indent: 2em;
}

.xtw-mission-footer {
    text-align: center;
    text-indent: 0 !important;
    margin-top: 25px;
    font-weight: 700;
    color: var(--xtw-primary) !important;
    font-size: 1.1rem !important;
}

/* Main Content */
.xtw-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    padding-top: calc(65px + env(safe-area-inset-top));
    /* header 高度约 50px + 15px padding */
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.xtw-search-box {
    width: 100%;
    max-width: 600px;
    text-align: center;
    margin-top: 40px;
    margin-bottom: 40px;
}

.xtw-title {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #111;
}

.xtw-subtitle {
    color: var(--xtw-text-light);
    margin-bottom: 30px;
    font-size: 1rem;
}

.xtw-search-wrapper {
    position: relative;
    width: 100%;
}

#xtw-search-input {
    width: 100%;
    padding: 18px 96px 18px 24px;
    font-size: 1.1rem;
    border: 1px solid var(--xtw-border);
    border-radius: 50px;
    outline: none;
    box-shadow: var(--xtw-shadow);
    transition: box-shadow 0.3s, border-color 0.3s;
}

#xtw-search-input:focus {
    box-shadow: 0 8px 24px rgba(0, 102, 204, 0.15);
    border-color: var(--xtw-primary);
}

#xtw-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 70px;
    height: 40px;
    padding: 0 18px;
    background: var(--xtw-primary);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

#xtw-search-btn:hover,
#xtw-search-btn:focus {
    background: #0052a3;
}

#xtw-search-btn:active {
    transform: translateY(-50%) scale(0.98);
}

.xtw-loading {
    position: absolute;
    right: 88px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--xtw-primary);
    border-radius: 50%;
    animation: xtw-spin 0.8s linear infinite;
}

@keyframes xtw-spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Suggestions */
.xtw-suggestions {
    margin-top: 10px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.xtw-suggestion-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.xtw-suggestion-item:last-child {
    border-bottom: none;
}

.xtw-suggestion-item:hover {
    background: #f5f9ff;
}

/* Popular Section (Hot Search Style) */
.xtw-popular-section {
    margin-top: 40px;
    width: 100%;
    max-width: 400px;
    /* Limit width for list view */
    margin-left: auto;
    margin-right: auto;
    animation: xtw-fade-in 0.8s ease-out;
}

.xtw-popular-label {
    font-size: 1rem;
    color: #333;
    margin-bottom: 15px;
    font-weight: 700;
    text-align: left;
    padding-left: 10px;
    border-left: 4px solid var(--xtw-primary);
}

.xtw-hot-search-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.xtw-hot-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
}

.xtw-hot-item:last-child {
    border-bottom: none;
}

.xtw-hot-item:hover {
    background: #fafafa;
}

.xtw-rank {
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #999;
    margin-right: 12px;
    font-style: italic;
}

.xtw-rank.hot {
    color: #ff4d4f;
    /* Red for top 3 */
    font-size: 1.1rem;
}

.xtw-hot-title {
    flex: 1;
    font-size: 0.95rem;
    color: #333;
    text-align: left;
}

.xtw-hot-icon {
    margin-left: 6px;
    font-size: 0.9rem;
}

.xtw-hot-views {
    font-size: 0.8rem;
    color: #bbb;
    margin-left: 10px;
}

@keyframes xtw-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xtw-last-updated {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #999;
    text-align: center;
}


/* Footer */
.xtw-footer {
    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    text-align: center;
    font-size: 0.8rem;
    color: #999;
}

.xtw-legal-footer {
    margin: 8px auto 0;
    max-width: 32rem;
    font-size: 0.72rem;
    line-height: 1.6;
}

/* Modals */
.xtw-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
    /* 全面屏适配 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.xtw-modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.xtw-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.xtw-modal-content {
    background: #fff;
    width: 90%;
    max-width: 800px;
    height: 80vh;
    border-radius: 16px;
    position: relative;
    z-index: 100001;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.xtw-modal.active .xtw-modal-content {
    transform: scale(1);
}

.xtw-modal-content.xtw-modal-sm {
    max-width: 500px;
    height: auto;
    max-height: 80vh;
}

.xtw-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f0f0f0;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    color: #555;
    cursor: pointer;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.xtw-modal-close:hover {
    background: #ff4d4f;
    color: #fff;
    transform: rotate(90deg);
}

.xtw-entry-body,
.xtw-request-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.xtw-request-body {
    text-align: center;
}

#xtw-entry-title {
    margin-top: 0;
    font-size: 1.8rem;
    color: #000;
}

.xtw-entry-meta {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #666;
}

.xtw-tag {
    background: #eff6ff;
    color: var(--xtw-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

.xtw-article {
    line-height: 1.8;
    color: #333;
    font-size: 1.05rem;
}

.xtw-article img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
}

/* 知识库内容中的链接样式 */
.xtw-article a {
    color: var(--xtw-primary);
    text-decoration: underline;
    transition: color 0.2s;
}

.xtw-article a:hover {
    color: var(--xtw-primary-dark);
}

/* Form */
#xtw-question-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    margin: 20px 0;
    font-size: 1rem;
}

.xtw-btn-primary {
    background: var(--xtw-primary);
    color: #fff;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
}

.xtw-btn-primary:hover {
    background: var(--xtw-primary-dark);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .xtw-header {
        padding: 10px 15px;
        /* 保持 top: env(safe-area-inset-top) 不变 */
    }

    .xtw-brand-sub {
        display: none;
        /* Hide subtitle to save space */
    }

    .xtw-brand-name {
        font-size: 1rem;
    }

    .xtw-header-actions {
        gap: 8px;
    }

    .xtw-btn-text,
    .xtw-btn-ask {
        padding: 5px 10px;
        font-size: 0.85rem;
    }

    .xtw-title {
        font-size: 1.5rem;
    }

    .xtw-modal {
        /* 移动端弹窗全屏 */
        padding: 0;
    }

    .xtw-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-width: none;
    }

    .xtw-modal-content.xtw-modal-sm {
        height: auto;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        position: absolute;
        bottom: 0;
        /* 底部弹窗适配 safe-area */
        padding-bottom: env(safe-area-inset-bottom);
    }

    .xtw-request-body,
    .xtw-mission-body {
        padding-bottom: calc(30px + env(safe-area-inset-bottom));
    }
}
