/*
Theme Name: Andrapp
Theme URI: https://example.com/
Author: Built with Claude
Description: A security-first, SEO-correct-by-design WordPress theme for app/APK catalog and download sites, with a dark app-store-style front end.
Version: 1.1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: andrapp
Requires at least: 6.0
Requires PHP: 7.4
*/

/* ---------- Design tokens (dark = default, matching the app-store aesthetic) ---------- */
:root {
	--bg: #0d1117;
	--surface: #161b26;
	--surface-2: #1c2330;
	--border: #262d3d;
	--text: #f2f4f7;
	--text-secondary: #9aa4b5;
	--text-muted: #6b7383;
	--accent: #16d9a3;
	--accent-text: #06251d;
	--star: #f5c518;
	--radius: 14px;
}
[data-theme="light"] {
	--bg: #f5f6f8;
	--surface: #ffffff;
	--surface-2: #f0f2f5;
	--border: #e4e7eb;
	--text: #14171c;
	--text-secondary: #565d68;
	--text-muted: #8a919c;
	--accent: #0ea77f;
	--accent-text: #ffffff;
	--star: #d99a00;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--text);
	background: var(--bg);
	line-height: 1.55;
	transition: background .2s ease, color .2s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; color: var(--text); }
.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 10000; background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 0 0 6px 0; }
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
#site-header {
	background: var(--surface);
	border-bottom: 2px solid var(--accent);
	position: sticky; top: 0; z-index: 500;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.site-branding { display: flex; align-items: center; gap: 10px; }
.site-branding img { height: 32px; width: auto; }
.site-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -.01em; }
.site-title a { color: inherit; }
.site-title a:hover { text-decoration: none; }

#primary-menu { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
#primary-menu li { position: relative; }
#primary-menu li a {
	display: flex; align-items: center; gap: 4px; padding: 8px 16px; border-radius: 999px; color: var(--text-secondary); font-weight: 600; font-size: .92rem;
}
#primary-menu li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
#primary-menu li.current-menu-item a {
	background: var(--accent); color: var(--accent-text);
}
#primary-menu li.menu-item-has-children > a::after {
	content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
	transform: rotate(45deg); margin-top: -3px;
}
#primary-menu .sub-menu {
	list-style: none; margin: 0; padding: 6px; position: absolute; top: 100%; left: 0;
	background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
	min-width: 180px; box-shadow: 0 12px 28px rgba(0,0,0,.35);
	opacity: 0; visibility: hidden; transform: translateY(4px);
	transition: opacity .15s ease, transform .15s ease; z-index: 700;
}
#primary-menu li.menu-item-has-children:hover > .sub-menu,
#primary-menu li.menu-item-has-children:focus-within > .sub-menu {
	opacity: 1; visibility: visible; transform: translateY(0);
}
#primary-menu .sub-menu li a { border-radius: 8px; padding: 8px 10px; }
#primary-menu .sub-menu .sub-menu { top: 0; left: 100%; }

.theme-toggle {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
	padding: 6px 10px; cursor: pointer; color: var(--text-secondary); font-size: 13px;
	min-height: 44px; min-width: 44px;
}
.theme-toggle:hover { color: var(--text); }

.header-search { flex: 1; max-width: 300px; position: relative; }
.header-search input[type="search"] {
	width: 100%; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
	font-size: .92rem; background: var(--surface-2); color: var(--text);
}
.header-search input[type="search"]::placeholder { color: var(--text-muted); }
.header-search input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#live-search-results {
	position: absolute; top: 110%; left: 0; right: 0;
	background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
	box-shadow: 0 12px 28px rgba(0,0,0,.35);
	max-height: 360px; overflow-y: auto; z-index: 600; display: none;
}
#live-search-results.is-open { display: block; }
#live-search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 12px; color: var(--text); }
#live-search-results a:hover { background: var(--surface-2); text-decoration: none; }
#live-search-results img { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }

/* ---------- Hero banner (home page only) ---------- */
.hero-banner {
	position: relative; padding: 64px 0 48px; text-align: center; overflow: hidden;
	background: var(--surface); border-bottom: 2px solid var(--accent);
}
.hero-banner .hero-bg {
	position: absolute; inset: 0; background-size: cover; background-position: center;
	opacity: .28; z-index: 0;
}
.hero-banner .hero-inner { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 0 20px; }
.hero-banner h1 { font-size: 2rem; font-weight: 700; margin-bottom: 12px; }
.hero-banner p { color: var(--text-secondary); margin-bottom: 24px; font-size: 1rem; }
.hero-search { position: relative; max-width: 480px; margin: 0 auto 20px; }
.hero-search input[type="search"] {
	width: 100%; padding: 14px 56px 14px 20px; border-radius: 999px; border: 0;
	background: var(--bg); color: var(--text); font-size: 1rem;
}
.hero-search button {
	position: absolute; right: 4px; top: 4px; bottom: 4px; width: 44px;
	background: var(--accent); color: var(--accent-text); border: 0; border-radius: 999px; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.hero-social { display: flex; justify-content: center; gap: 10px; }
.hero-social a {
	width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2);
	display: flex; align-items: center; justify-content: center; color: var(--text-secondary);
	border: 1px solid var(--border);
}
.hero-social a:hover { color: var(--text); text-decoration: none; }

/* ---------- Section headings ---------- */
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 14px; }
.section-heading h2 { font-size: 1.15rem; margin: 0; }
.section-nav { display: flex; gap: 6px; }
.section-nav button {
	width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
	background: var(--surface); color: var(--text-secondary); cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.section-nav button:hover { background: var(--surface-2); color: var(--text); }
.section-nav button:disabled { opacity: .35; cursor: default; }

/* ---------- Carousel (Top rated) ---------- */
.app-carousel { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: none; }
.app-carousel::-webkit-scrollbar { display: none; }
.carousel-card {
	scroll-snap-align: start; flex: 0 0 300px;
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 14px; display: flex; align-items: center; gap: 12px;
}
.carousel-card .app-card-icon { width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0; overflow: hidden; background: var(--surface-2); }
.carousel-card h3 { font-size: .95rem; margin: 0 0 2px; }
.carousel-card .app-meta { font-size: .78rem; color: var(--text-muted); }

/* ---------- App grid / cards (Latest apps) ---------- */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin: 8px 0 24px; }
.app-card {
	position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 14px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
	transition: transform .15s ease, border-color .15s ease;
}
.app-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.app-card-icon { width: 72px; height: 72px; border-radius: 18px; overflow: hidden; background: var(--surface-2); }
.app-card-icon img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1 / 1; }
.app-card h3 { font-size: .92rem; margin: 0; }
.app-card h3 a { color: var(--text); }
.app-card .app-meta { font-size: .78rem; color: var(--text-muted); }
.app-rating { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-secondary); }
.app-rating .stars { color: var(--star); letter-spacing: 1px; }

.app-badge {
	position: absolute; top: 10px; left: 10px; font-size: 10px; font-weight: 700;
	text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; color: #fff;
}
.app-badge.is-new { background: #e0453a; }
.app-badge.is-updated { background: var(--accent); color: var(--accent-text); }

/* ---------- Single app page ---------- */
.app-hero {
	display: flex; gap: 20px; background: var(--surface); border: 1px solid var(--border);
	border-radius: 16px; padding: 22px; margin: 24px 0; flex-wrap: wrap;
}
.app-hero-icon { width: 96px; height: 96px; border-radius: 22px; overflow: hidden; background: var(--surface-2); flex-shrink: 0; }
.app-hero-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-hero-info { flex: 1; min-width: 220px; }
.app-hero-info h1 { font-size: 1.5rem; }
.app-hero-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .88rem; color: var(--text-secondary); margin: 8px 0; }
.btn-download {
	display: inline-flex; align-items: center; gap: 8px;
	background: var(--accent); color: var(--accent-text); font-weight: 700;
	padding: 12px 22px; border-radius: 10px; border: 0; cursor: pointer; font-size: 1rem;
}
.btn-download:hover { filter: brightness(1.08); text-decoration: none; }
.download-note { font-size: .8rem; color: var(--text-muted); margin-top: 8px; }

.app-body { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; margin-bottom: 24px; }
.app-screenshots { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.app-screenshots img { height: 320px; width: auto; border-radius: 12px; flex-shrink: 0; }

.rating-widget { display: flex; align-items: center; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.rating-widget .rate-btn {
	background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary);
	border-radius: 8px; padding: 6px 10px; cursor: pointer;
	/* Real touch-target sizing (WCAG 2.5.5 / Apple & Google guidance is
	   ~44px minimum) — found this was ~30px tall when actually checking
	   against touch use, not just desktop mouse use. */
	min-width: 44px; min-height: 44px;
	display: inline-flex; align-items: center; justify-content: center;
}
.rating-widget .rate-btn:hover { color: var(--text); }
.rating-widget .rate-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.version-history { margin-top: 18px; }
.version-history table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: .9rem; }
.version-history th, .version-history td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
/* A 3-column table with real text in it (not just numbers) gets crushed
   unreadable on a narrow phone if forced to 100% width — let it scroll
   horizontally instead of squeezing the "What's new" column to nothing. */
.version-history-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Sidebar / footer / misc ---------- */
.content-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
@media (max-width: 800px) { .content-layout { grid-template-columns: 1fr; } }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 18px; }
.widget h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.widget a { color: var(--text); }
.widget a:hover { color: var(--accent); }

#site-footer { background: var(--surface); border-top: 1px solid var(--border); color: var(--text-secondary); margin-top: 40px; padding: 30px 0; font-size: .9rem; }
#site-footer a { color: var(--text); }

.breadcrumbs { font-size: .85rem; color: var(--text-muted); margin: 14px 0; }
.breadcrumbs a { color: var(--text-secondary); }
.pagination { display: flex; gap: 6px; margin: 24px 0; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-secondary); }
.pagination .current { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

@media (max-width: 640px) {
	.header-inner { position: relative; }
	.site-branding { order: 1; }
	.theme-toggle { order: 2; }
	#menu-toggle { order: 3; }
	.header-search { order: 4; flex-basis: 100%; max-width: none; }

	/* Real mobile dropdown panel, not the desktop horizontal pill row. */
	#primary-menu {
		display: none; flex-direction: column; align-items: stretch; gap: 2px;
		position: absolute; top: 100%; left: 0; right: 0; margin-top: 8px;
		background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
		padding: 8px; box-shadow: 0 12px 28px rgba(0,0,0,.35); z-index: 700;
	}
	#primary-menu.is-open { display: flex; }
	#primary-menu li a { border-radius: 8px; }
	/* Hover doesn't exist on touch — submenus stay open and inline instead
	   of relying on :hover, so children are always reachable on mobile. */
	#primary-menu .sub-menu {
		position: static; opacity: 1; visibility: visible; transform: none;
		box-shadow: none; border: 0; margin: 2px 0 6px 14px; padding: 0;
		background: transparent;
	}
	#primary-menu li.menu-item-has-children > a::after { margin-left: auto; }

	.hero-banner h1 { font-size: 1.5rem; }
	#menu-toggle {
		position: static !important; width: auto !important; height: auto !important;
		overflow: visible !important; clip: auto !important; white-space: normal !important;
		background: var(--surface-2); border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 600; cursor: pointer; color: var(--text);
		min-height: 44px;
	}
}
