/*
 * 稿图页眉 小部件样式
 * 1:1 复刻 meizhuan/Luckilyring.html 页眉区域（顶部条 + 导航 + 下拉搜索）
 * 不依赖 Tailwind，使用原生 CSS；Tailwind 色值参考 v3 默认调色板
 */

/* ---------- 基础变量 ---------- */
.gt-header,
.gt-header * {
    box-sizing: border-box;
    border-radius: 0 !important;
}

.gt-header {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #1f2937; /* text-gray-800 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.gt-header ::selection {
    background: #e5e7eb; /* bg-gray-200 */
    color: #000;
}

.gt-header .gt-serif {
    font-family: 'Noto Serif SC', serif;
}

/* 整体内容最大宽度 1440px */
.gt-header .gt-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- 顶部条 ---------- */
.gt-topbar {
    background-color: #f9fafb; /* bg-gray-50 */
    border-bottom: 1px solid #f3f4f6; /* border-gray-100 */
    font-size: 0.75rem; /* text-xs */
    line-height: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.gt-topbar .gt-topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #6b7280; /* text-gray-500 */
    letter-spacing: 0.05em; /* tracking-wider */
}

/* ---------- 头部主体 ---------- */
.gt-header-main {
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid #f3f4f6;
}

.gt-header-bar {
    position: relative;
    z-index: 10;
    background: #fff;
}

.gt-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
}

@media (min-width: 768px) {
    .gt-header-flex {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }
}

/* Logo */
.gt-logo {
    display: inline-flex;
    align-items: center;
    color: #000;
    text-decoration: none;
    line-height: 1;
}

.gt-logo img {
    display: block;
    width: 140px;
    height: auto;
    max-width: 100%;
    transition: opacity 0.25s ease;
}

.gt-logo-text {
    font-size: 1.5rem; /* text-2xl */
    line-height: 2rem;
    font-weight: 700;
    font-family: 'Noto Serif SC', serif;
    letter-spacing: 0.1em; /* tracking-widest */
    color: inherit;
    transition: color 0.15s ease;
}

/* ---------- 桌面菜单 ---------- */
.gt-desktop {
    display: none;
    align-items: center;
}

@media (min-width: 768px) {
    .gt-desktop {
        display: flex;
    }
}

.gt-desktop > * + * {
    margin-left: 2.5rem; /* space-x-10 */
}

.gt-nav {
    display: flex;
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

.gt-nav > li,
.gt-nav > * + * {
    margin: 0;
}

.gt-nav > li + li,
.gt-nav > * + * {
    margin-left: 2.5rem;
}

.gt-nav li {
    list-style: none;
}

.gt-nav a {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid transparent;
    display: inline-block;
}

.gt-nav a:hover {
    color: #000;
    border-bottom-color: currentColor;
}

.gt-nav a.current,
.gt-nav a.is-active,
.gt-nav .current-menu-item > a,
.gt-nav .current_page_item > a {
    color: #000;
    font-weight: 500;
    border-bottom-color: #000;
}

/* 分隔线 */
.gt-divider {
    width: 1px;
    height: 1rem;
    background: #d1d5db;
}

/* 搜索图标（span） */
.gt-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.15s ease;
    line-height: 0;
    user-select: none;
}

.gt-search-toggle:hover {
    color: #000;
}

.gt-search-toggle:focus {
    outline: none;
}

.gt-icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* ---------- 移动端图标 ---------- */
.gt-mobile {
    display: flex;
    align-items: center;
}

.gt-mobile > * + * {
    margin-left: 1.25rem; /* space-x-5 */
}

@media (min-width: 768px) {
    .gt-mobile {
        display: none;
    }
}

.gt-mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    color: #000;
    line-height: 0;
    user-select: none;
    position: relative;
}

.gt-mobile-menu svg {
    width: 1.5rem;
    height: 1.5rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* 默认显示汉堡图标，隐藏关闭图标 */
.gt-mobile-menu .gt-mobile-menu-icon-close {
    display: none;
}

/* 打开状态：显示 X，隐藏汉堡 */
.gt-mobile-menu.is-open .gt-mobile-menu-icon-open {
    display: none;
}
.gt-mobile-menu.is-open .gt-mobile-menu-icon-close {
    display: inline-block;
}

/* ---------- 移动端抽屉菜单 ---------- */
.gt-mobile-drawer {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.gt-mobile-drawer.is-open {
    opacity: 1;
    max-height: 80vh;
    overflow-y: auto;
}

.gt-mobile-drawer-inner {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

/* 抽屉内的菜单改为垂直布局 */
.gt-mobile-drawer .gt-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.gt-mobile-drawer .gt-nav > li + li,
.gt-mobile-drawer .gt-nav > * + * {
    margin-left: 0;
}

.gt-mobile-drawer .gt-nav a {
    display: block;
    padding: 0.875rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.gt-mobile-drawer .gt-nav a:hover {
    border-bottom-color: #f3f4f6;
    color: #000;
}

/* 桌面端隐藏抽屉 */
@media (min-width: 768px) {
    .gt-mobile-drawer {
        display: none;
    }
}

/* ---------- 搜索栏（下滑显示） ---------- */
.gt-searchbar {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.gt-searchbar.is-open {
    max-height: 120px;
    opacity: 1;
}

.gt-header .gt-searchbar-inner {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gt-header .gt-search-field {
    position: relative;
    width: 100%;
    max-width: 42rem; /* max-w-2xl */
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.gt-header .gt-search-icon {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    line-height: 0;
    pointer-events: none;
}

.gt-header .gt-search-icon svg {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

.gt-header .gt-search-input {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    border: 0 !important;
    border-bottom: 1px solid #d1d5db !important;
    border-radius: 0 !important;
    padding: 0.5rem 4rem 0.5rem 2rem !important;
    font-size: 0.875rem;
    line-height: 1.5;
    letter-spacing: 0.1em;
    background: transparent !important;
    color: #1f2937;
    box-shadow: none !important;
    transition: border-color 0.15s ease;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.gt-header .gt-search-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.gt-header .gt-search-input:focus {
    outline: none !important;
    border-bottom-color: #000 !important;
    box-shadow: none !important;
}

.gt-header .gt-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.gt-header .gt-search-submit {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0;
    color: #000 !important;
    font-size: 0.75rem;
    line-height: 1;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.15s ease;
    box-shadow: none !important;
    border-radius: 0 !important;
    min-height: 0;
}

.gt-header .gt-search-submit:hover {
    color: #6b7280 !important;
}

.gt-header .gt-search-submit:focus {
    outline: none;
}

/* ==========================================================================
 * 子菜单（下拉）— 极简高端风格
 * ========================================================================== */

/* 顶级带子菜单的项：作为定位基准 */
.gt-nav > li.has-submenu {
    position: relative;
}

.gt-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.gt-nav-label {
    display: inline-block;
}

/* 箭头 */
.gt-nav-caret {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    transition: transform 0.25s ease;
    opacity: 0.5;
}

.gt-nav > li.has-submenu:hover > a .gt-nav-caret,
.gt-nav > li.has-submenu:focus-within > a .gt-nav-caret {
    transform: rotate(180deg);
    opacity: 1;
}

/* ---------- 桌面端下拉面板 ---------- */
.gt-nav .gt-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    transform: translateY(4px);
    min-width: 140px;
    margin: 0;
    padding: 1rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid #f3f4f6;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 60;
}

/* 桌面悬停 / 键盘焦点：显示下拉 */
@media (min-width: 768px) {
    .gt-nav > li.has-submenu:hover > .gt-submenu,
    .gt-nav > li.has-submenu:focus-within > .gt-submenu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }
}

/* 子菜单项 */
.gt-nav .gt-submenu li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gt-nav .gt-submenu li + li {
    margin: 0;
}

.gt-nav .gt-submenu a {
    display: block;
    padding: 0.4rem 1.25rem;
    color: #9ca3af;
    font-size: 0.8125rem;
    letter-spacing: 0.1em;
    border-bottom: 0;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.gt-nav .gt-submenu a:hover,
.gt-nav .gt-submenu a:focus {
    color: #000;
    border-bottom-color: transparent;
}

.gt-nav .gt-submenu .current-menu-item > a,
.gt-nav .gt-submenu a.current,
.gt-nav .gt-submenu a.is-active {
    color: #000;
    border-bottom-color: transparent;
}

/* 桌面端隐藏移动端切换按钮 */
@media (min-width: 768px) {
    .gt-nav .gt-submenu-toggle {
        display: none;
    }
}

/* ---------- 三级及以上：右侧飞出 ---------- */
.gt-nav .gt-submenu .gt-submenu {
    top: -1rem;
    left: 100%;
    transform: translateX(4px) translateY(0);
}

@media (min-width: 768px) {
    .gt-nav .gt-submenu li.has-submenu:hover > .gt-submenu,
    .gt-nav .gt-submenu li.has-submenu:focus-within > .gt-submenu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0) translateY(0);
    }
}

/* ==========================================================================
 * 移动端抽屉：子菜单折叠
 * ========================================================================== */
.gt-mobile-drawer .gt-nav a {
    /* 为切换按钮预留空间 */
    padding-right: 2.5rem;
    position: relative;
}

.gt-mobile-drawer .gt-submenu-toggle {
    position: absolute;
    right: 0;
    top: 0;
    width: 2.5rem;
    height: 100%;
    min-height: 2.75rem;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    transition: transform 0.25s ease, color 0.15s ease;
}

.gt-mobile-drawer li.has-submenu {
    position: relative;
}

.gt-mobile-drawer .gt-nav-caret {
    display: none; /* 移动端用 toggle 按钮 */
}

.gt-mobile-drawer .gt-submenu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    box-shadow: none;
    border: 0;
    background: #fafafa;
    max-height: 0;
    overflow: hidden;
    padding: 0;
    transition: max-height 0.3s ease;
}

.gt-mobile-drawer li.is-open > .gt-submenu {
    max-height: 800px;
    padding: 0.25rem 0;
}

.gt-mobile-drawer li.is-open > a > .gt-submenu-toggle,
.gt-mobile-drawer li.is-open > .gt-submenu-toggle {
    transform: rotate(180deg);
    color: #000;
}

.gt-mobile-drawer .gt-submenu a {
    padding: 0.625rem 1.5rem;
    font-size: 0.8125rem;
    color: #6b7280;
    letter-spacing: 0.1em;
    border-bottom: 1px solid #f3f4f6;
}

.gt-mobile-drawer .gt-submenu .gt-submenu a {
    padding-left: 2.5rem;
}

