/* Mobile header (<=799px, the theme's mobile breakpoint). Built by js/sf-mobile-header.js from the
   existing top-bar and primary menus; loaded by functions.php on every theme header. Desktop untouched.
   Layout follows the usual news-site pattern (NTD, LTN, CNA, BBC 中文): utility links row, logo bar with one
   CTA + menu icon, text section tabs with an underline, full menu in a drawer. */

/* Hidden on desktop. The theme forces `.header .nav_row .container > div` visible, so match its specificity. */
.sfm-util, .sfm-tabs, .sfm-drawer, .sfm-overlay,
.header .nav_row .container > .sfm-actions { display: none !important; }

@media (max-width: 799px) {
	/* replaced by the rows below */
	.header .navigation-wrap, .header .top_row { display: none !important; }

	/* 1. utility row: same gold links as the desktop top row */
	.sfm-util {
		display: flex !important; align-items: center; height: 32px; padding: 0 12px; background: #142652;
		border-bottom: 1px solid rgba(255,255,255,.12); font-size: 13px; line-height: 32px;
	}
	.sfm-util nav { display: flex; flex: 1; overflow-x: auto; scrollbar-width: none; }
	.sfm-util nav::-webkit-scrollbar { display: none; }
	.sfm-util a { color: #F8C623 !important; font-weight: bold; text-decoration: none; white-space: nowrap; padding-right: 16px; }
	.sfm-util button {
		flex: 0 0 auto; background: none; border: 0; padding: 0 0 0 12px; color: #fff; font-size: 13px;
		line-height: 32px; cursor: pointer; border-left: 1px solid rgba(255,255,255,.25);
	}

	/* 2. logo bar */
	.header .nav_row { display: block; height: auto; line-height: normal; margin: 0; }
	.header .nav_row .container {
		display: flex !important; align-items: center; justify-content: space-between; width: 100%;
		height: 60px; padding: 0 4px 0 12px; box-sizing: border-box;
	}
	.header .ntd_logo { float: none !important; width: auto !important; height: auto !important; margin: 0; }
	.header .ntd_logo a { display: block; line-height: 0; }
	.header .ntd_logo img { width: auto !important; height: 38px !important; max-width: 50vw; }
	.header .nav_row .container > .sfm-actions { display: flex !important; float: none !important; align-items: center; }
	.sfm-sub {
		display: block; background: #F8C623; color: #192f65 !important; font-size: 15px; font-weight: bold;
		line-height: 32px; height: 32px; padding: 0 14px; border-radius: 3px; text-decoration: none; white-space: nowrap;
	}
	.sfm-burger {
		display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
		width: 48px; height: 48px; margin-left: 4px; padding: 0; background: none; border: 0; cursor: pointer;
	}
	.sfm-burger span { display: block; width: 22px; height: 2px; background: #fff; }

	/* 3. section tabs */
	.sfm-tabs {
		display: flex !important; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
		border-top: 1px solid rgba(255,255,255,.12); padding: 0 4px; line-height: normal;
	}
	.sfm-tabs::-webkit-scrollbar { display: none; }
	.sfm-tabs a {
		flex: 0 0 auto; display: block; padding: 11px 10px 9px; color: #fff !important; font-size: 15px;
		text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent;
	}
	.sfm-tabs a[aria-current] { border-bottom-color: #F8C623; font-weight: bold; }
	/* fade the right edge while more tabs are off-screen (class set by the script) */
	.sfm-tabs.sfm-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }

	/* 4. drawer */
	.sfm-overlay {
		display: block !important; position: fixed; inset: 0; z-index: 100002; background: rgba(0,0,0,.45);
		opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
	}
	.sfm-drawer {
		display: flex !important; flex-direction: column; position: fixed; top: 0; right: 0; bottom: 0; z-index: 100003;
		width: min(86vw, 360px); background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,.25);
		transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
		line-height: normal; font-size: 16px;
	}
	html.sfm-open { overflow: hidden; }
	html.sfm-open .sfm-overlay { opacity: 1; visibility: visible; }
	html.sfm-open .sfm-drawer { transform: translateX(0); visibility: visible; }

	.sfm-head { display: flex; align-items: center; justify-content: space-between; background: #192f65; padding: 0 4px 0 16px; height: 60px; }
	.sfm-head img { height: 32px; width: auto; }
	.sfm-close { width: 48px; height: 48px; background: none; border: 0; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; padding: 0; }
	.sfm-date { padding: 10px 16px; font-size: 13px; color: #6b7280; border-bottom: 1px solid #e6e9f0; }
	.sfm-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }

	.sfm-menu, .sfm-menu ul { list-style: none; margin: 0; padding: 0; }
	.sfm-menu > li { border-bottom: 1px solid #e6e9f0; }
	.sfm-row { display: flex; align-items: stretch; }
	.sfm-row > a { flex: 1; display: block; padding: 15px 16px; color: #192f65 !important; font-size: 17px; font-weight: bold; text-decoration: none; }
	.sfm-menu .current-menu-item > .sfm-row > a,
	.sfm-menu .current-menu-parent > .sfm-row > a,
	.sfm-menu .current-menu-ancestor > .sfm-row > a { box-shadow: inset 4px 0 0 #F8C623; }
	.sfm-toggle { width: 52px; background: none; border: 0; border-left: 1px solid #eef0f5; cursor: pointer; color: #192f65; font-size: 0; }
	.sfm-toggle::before {
		content: ""; display: inline-block; width: 9px; height: 9px; border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -4px; transition: transform .2s;
	}
	.sfm-toggle[aria-expanded="true"]::before { transform: rotate(-135deg); margin-top: 4px; }
	.sfm-menu ul { display: none; background: #f5f7fb; padding: 4px 0; }
	.sfm-menu ul.sfm-shown { display: block; }
	.sfm-menu ul a { display: block; padding: 11px 16px 11px 30px; color: #333 !important; font-size: 15px; text-decoration: none; }
	.sfm-menu ul .current-menu-item > a { color: #192f65 !important; font-weight: bold; }

	.sfm-section { padding: 20px 0 0; }
	.sfm-section h2 { font-size: 13px; color: #6b7280; font-weight: normal; margin: 0; padding: 0 16px 6px; }
	.sfm-links { list-style: none; margin: 0; padding: 0; border-top: 1px solid #e6e9f0; }
	.sfm-links li { border-bottom: 1px solid #e6e9f0; }
	.sfm-links a, .sfm-links button {
		display: block; width: 100%; text-align: left; padding: 13px 16px; background: none; border: 0;
		color: #192f65 !important; font-size: 16px; text-decoration: none; cursor: pointer; font-family: inherit;
	}
}
