/*
 * Readora main stylesheet.
 *
 * 1. Tokens
 * 2. Base
 * 3. Layout
 * 4. Header and navigation
 * 5. Posts and cards
 * 6. Single post
 * 7. Ads
 * 8. Sidebar and widgets
 * 9. Comments
 * 10. Footer
 * 11. Forms and pagination
 * 12. Blocks
 */

/* 1. Tokens -------------------------------------------------------------
 * Light is the default. Dark applies when <html data-theme="dark">, or when
 * the device prefers dark and the reader/site has not forced light.
 * --readora-accent and --readora-text-custom come from the Customizer.
 */
:root {
	color-scheme: light;
	--readora-accent: #2563eb;
	--readora-link: var(--readora-accent);
	--readora-text: var(--readora-text-custom, #1f2933);
	--readora-muted: #616e7c;
	--readora-border: #e4e7eb;
	--readora-surface: #f5f7fa;
	--readora-bg: #fff;
	--readora-header-bg: rgba(255, 255, 255, 0.92);
	--readora-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
	--readora-radius: 10px;
	--readora-gap: 2rem;
	--readora-container: 1200px;
	--readora-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--readora-font-serif: Georgia, "Times New Roman", serif;
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--readora-link: color-mix(in srgb, var(--readora-accent) 60%, #fff);
	--readora-text: #e5e9f0;
	--readora-muted: #9aa5b4;
	--readora-border: #2b3544;
	--readora-surface: #19212d;
	--readora-bg: #10161f;
	--readora-header-bg: rgba(16, 22, 31, 0.92);
	--readora-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--readora-link: color-mix(in srgb, var(--readora-accent) 60%, #fff);
		--readora-text: #e5e9f0;
		--readora-muted: #9aa5b4;
		--readora-border: #2b3544;
		--readora-surface: #19212d;
		--readora-bg: #10161f;
		--readora-header-bg: rgba(16, 22, 31, 0.92);
		--readora-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	}
}

/* 2. Base --------------------------------------------------------------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--readora-bg);
	color: var(--readora-text);
	font-family: var(--readora-font);
	font-size: 1.0625rem;
	line-height: 1.7;
}

img,
video,
iframe {
	max-width: 100%;
	height: auto;
}

a {
	color: var(--readora-link);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

a:hover,
a:focus {
	text-decoration: none;
}

:focus-visible {
	outline: 2px solid var(--readora-accent);
	outline-offset: 2px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	line-height: 1.25;
	margin: 1.5em 0 0.5em;
}

h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.75rem); }
h3 { font-size: 1.3rem; }

blockquote {
	margin: 1.5em 0;
	padding-inline-start: 1.25em;
	border-inline-start: 4px solid var(--readora-accent);
	font-family: var(--readora-font-serif);
	font-size: 1.15em;
}

pre {
	overflow-x: auto;
	padding: 1em;
	background: var(--readora-surface);
	border-radius: var(--readora-radius);
}

table {
	width: 100%;
	border-collapse: collapse;
}

th,
td {
	padding: 0.5em;
	border: 1px solid var(--readora-border);
}

/* 3. Layout ------------------------------------------------------------- */
.container {
	width: 100%;
	max-width: var(--readora-container);
	margin-inline: auto;
	padding-inline: 1rem;
}

.site-content {
	display: grid;
	grid-template-columns: minmax(0, 1fr); /* Never wider than the screen. */
	gap: var(--readora-gap);
	padding-block: 2rem 3rem;
}

@media (min-width: 960px) {
	.readora-sidebar-right .site-content {
		grid-template-columns: minmax(0, 1fr) 320px;
	}

	.readora-sidebar-left .site-content {
		grid-template-columns: 320px minmax(0, 1fr);
	}

	.readora-sidebar-left .site-main {
		order: 2;
	}
}

.site-main--full {
	max-width: 860px;
	width: 100%;
	margin-inline: auto;
}

/* 4. Header and navigation --------------------------------------------- */
.site-header {
	position: relative;
	z-index: 40;
	border-bottom: 1px solid var(--readora-border);
	background: var(--readora-header-bg);
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	min-height: 72px;
	flex-wrap: nowrap;
}

.site-branding {
	margin-inline-end: auto;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.site-title {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 800;
	line-height: 1.2;
}

.site-title a {
	color: var(--readora-text);
	text-decoration: none;
}

.site-description {
	margin: 0;
	color: var(--readora-muted);
	font-size: 0.9rem;
}

/* Small screens: keep logo, menu and toggle on one row. */
@media (max-width: 639px) {
	.site-description {
		display: none;
	}
}

.menu-toggle,
.theme-toggle {
	flex-shrink: 0;
}

.custom-logo {
	display: block;
	max-height: 56px;
	width: auto;
}

.main-navigation ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.main-navigation a {
	display: block;
	padding: 0.5rem 0.75rem;
	color: var(--readora-text);
	font-weight: 600;
	text-decoration: none;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a {
	color: var(--readora-link);
}

/* Light/dark toggle */
.theme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--readora-border);
	border-radius: 999px;
	background: transparent;
	color: var(--readora-text);
	cursor: pointer;
}

.theme-toggle:hover {
	border-color: var(--readora-link);
	color: var(--readora-link);
}

.theme-toggle__sun {
	display: none;
}

:root[data-theme="dark"] .theme-toggle__sun {
	display: block;
}

:root[data-theme="dark"] .theme-toggle__moon {
	display: none;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle__sun {
		display: block;
	}

	:root:not([data-theme="light"]) .theme-toggle__moon {
		display: none;
	}
}

.menu-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 1px solid var(--readora-border);
	border-radius: var(--readora-radius);
	background: transparent;
	cursor: pointer;
}

.menu-toggle__bar,
.menu-toggle__bar::before,
.menu-toggle__bar::after {
	display: block;
	width: 20px;
	height: 2px;
	background: var(--readora-text);
	position: relative;
}

.menu-toggle__bar::before,
.menu-toggle__bar::after {
	content: "";
	position: absolute;
}

.menu-toggle__bar::before { top: -6px; }
.menu-toggle__bar::after { top: 6px; }

.main-navigation > ul,
.main-navigation .menu {
	display: none;
}

/* Mobile menu opens as a panel under the header. */
.main-navigation.toggled > ul,
.main-navigation.toggled .menu {
	display: block;
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	padding: 0.5rem 1rem 1rem;
	background: var(--readora-bg);
	border-bottom: 1px solid var(--readora-border);
	box-shadow: var(--readora-shadow);
}

.main-navigation .sub-menu {
	padding-inline-start: 1rem;
}

@media (min-width: 960px) {
	.menu-toggle {
		display: none;
	}

	.main-navigation > ul,
	.main-navigation .menu,
	.main-navigation.toggled > ul,
	.main-navigation.toggled .menu {
		display: flex;
		position: static;
		padding: 0;
		background: none;
		border: 0;
		box-shadow: none;
	}

	.main-navigation li {
		position: relative;
	}

	.main-navigation .sub-menu {
		position: absolute;
		top: 100%;
		left: 0;
		z-index: 50;
		min-width: 220px;
		padding: 0.5rem 0;
		background: var(--readora-bg);
		border: 1px solid var(--readora-border);
		border-radius: var(--readora-radius);
		box-shadow: var(--readora-shadow);
		opacity: 0;
		visibility: hidden;
	}

	.main-navigation li:hover > .sub-menu,
	.main-navigation li:focus-within > .sub-menu {
		opacity: 1;
		visibility: visible;
	}
}

/* 5. Posts and cards ---------------------------------------------------- */
.page-header {
	margin-bottom: 1.5rem;
}

.page-title {
	margin-top: 0;
}

.post-grid {
	display: grid;
	gap: 1.5rem;
}

@media (min-width: 640px) {
	.post-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 960px) {
	.post-grid--3,
	.readora-sidebar-none .post-grid--grid,
	.readora-sidebar-none .post-grid--magazine {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* List layout: image beside text. */
.post-grid.post-grid--list,
.post-grid.post-grid--classic {
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
	.card.card--list {
		flex-direction: row;
	}

	/* Image fills its column; absolute so its real size cannot stretch the card. */
	.card.card--list .post-thumbnail {
		position: relative;
		flex: 0 0 38%;
		aspect-ratio: auto;
		min-height: 200px;
	}

	.card.card--list .post-thumbnail img {
		position: absolute;
		inset: 0;
	}

	.card.card--list .card__body {
		align-self: center;
	}
}

/* Classic layout: one column, large images. */
.card--classic .card__body {
	padding: 1.5rem 1.75rem 1.75rem;
}

.card.card--classic .entry-title {
	font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
}

.card.card--classic .entry-summary p {
	font-size: 1.05rem;
}

/* Magazine layout: big featured first post spanning the grid. */
.hero {
	grid-column: 1 / -1;
	position: relative;
	overflow: hidden;
	border-radius: var(--readora-radius);
	background: var(--readora-surface);
	border: 1px solid var(--readora-border);
}

.hero__body {
	padding: 1.5rem;
}

.hero__title {
	margin: 0.5rem 0;
	font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem);
	line-height: 1.15;
}

.hero__title a {
	color: var(--readora-text);
	text-decoration: none;
}

.hero__excerpt p {
	margin: 0 0 0.75rem;
	color: var(--readora-muted);
	font-size: 1.05rem;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
}

.hero__media img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

/* With an image: text sits over the photo on a dark gradient. */
@media (min-width: 768px) {
	.hero--image .hero__body {
		position: absolute;
		inset: auto 0 0 0;
		padding: 4rem 2rem 2rem;
		background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
		color: #fff;
	}

	.hero--image .hero__title a,
	.hero--image .hero__excerpt p,
	.hero--image .entry-meta {
		color: #fff;
	}

	.hero--image .hero__excerpt p {
		max-width: 46rem;
		opacity: 0.9;
	}

	.hero--image .hero__media img {
		aspect-ratio: 21 / 9;
	}
}

.category-badge {
	display: inline-block;
	margin-bottom: 0.4rem;
	color: var(--readora-link);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-decoration: none;
	text-transform: uppercase;
}

.hero--image .category-badge {
	padding: 0.2rem 0.6rem;
	border-radius: 999px;
	background: var(--readora-accent);
	color: #fff;
}

.card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--readora-border);
	border-radius: var(--readora-radius);
	background: var(--readora-bg);
}

.card .post-thumbnail {
	display: block;
	aspect-ratio: 16 / 9;
	background: var(--readora-surface);
}

.card .post-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.card__body {
	padding: 1.25rem;
}

.card .entry-title {
	margin: 0 0 0.5rem;
	font-size: 1.2rem;
}

.card .entry-title a {
	color: var(--readora-text);
	text-decoration: none;
}

.card .entry-title a:hover {
	color: var(--readora-link);
}

/* Clamp by lines, not words: works for languages without spaces (Thai, Chinese, Japanese). */
.card .entry-summary p {
	margin: 0.5rem 0 0;
	color: var(--readora-muted);
	font-size: 0.95rem;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

.sticky-badge {
	display: inline-block;
	margin-bottom: 0.5rem;
	padding: 0.15rem 0.6rem;
	border-radius: 999px;
	background: var(--readora-accent);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
}

.entry-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	color: var(--readora-muted);
	font-size: 0.85rem;
}

.entry-meta a {
	color: inherit;
	text-decoration: none;
}

/* 6. Single post -------------------------------------------------------- */
.entry .entry-title {
	margin-top: 0.25rem;
}

.breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 0.85rem;
	color: var(--readora-muted);
}

.breadcrumbs li + li::before {
	content: "/";
	margin-inline-end: 0.25rem;
}

.entry .post-thumbnail {
	margin: 1.5rem 0;
}

.entry .post-thumbnail img {
	display: block;
	width: 100%;
	border-radius: var(--readora-radius);
}

.entry-content {
	font-size: 1.125rem;
}

.entry-content > * {
	max-width: 760px;
}

.entry-content .alignwide {
	max-width: 1100px;
}

.entry-content .alignfull {
	max-width: none;
}

.entry-footer {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 1px solid var(--readora-border);
	color: var(--readora-muted);
	font-size: 0.9rem;
}

.page-links {
	margin-top: 1.5rem;
	font-weight: 600;
}

.author-box {
	display: flex;
	gap: 1rem;
	margin-top: 2rem;
	padding: 1.25rem;
	background: var(--readora-surface);
	border-radius: var(--readora-radius);
}

.author-box img {
	border-radius: 50%;
	flex-shrink: 0;
}

.author-box__name {
	margin: 0;
	font-weight: 700;
}

.author-box__bio {
	margin: 0.25rem 0 0;
	color: var(--readora-muted);
}

.post-navigation {
	margin-top: 2rem;
}

.post-navigation .nav-links {
	display: grid;
	gap: 1rem;
}

@media (min-width: 640px) {
	.post-navigation .nav-links {
		grid-template-columns: 1fr 1fr;
	}

	.post-navigation .nav-next {
		text-align: end;
	}
}

.post-navigation a {
	display: block;
	padding: 1rem;
	border: 1px solid var(--readora-border);
	border-radius: var(--readora-radius);
	text-decoration: none;
}

.nav-subtitle {
	display: block;
	color: var(--readora-muted);
	font-size: 0.8rem;
	text-transform: uppercase;
}

.nav-title {
	color: var(--readora-text);
	font-weight: 700;
}

.related-posts {
	margin-top: 3rem;
}

/* 7. Ads ---------------------------------------------------------------
 * Ad slots reserve height before the ad loads, so the page does not jump
 * (better Core Web Vitals / CLS). Change the min-height values to match
 * your ad sizes in a child theme.
 */
.readora-ad {
	margin-block: 1.5rem;
	text-align: center;
	overflow: hidden;
}

.readora-ad__label {
	display: block;
	margin-bottom: 0.25rem;
	color: var(--readora-muted);
	font-size: 0.7rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.readora-ad__unit {
	min-height: 100px;
}

.readora-ad--ad-below-header {
	max-width: var(--readora-container);
	margin-inline: auto;
	padding-inline: 1rem;
}

@media (min-width: 768px) {
	.readora-ad--ad-below-header .readora-ad__unit {
		min-height: 90px;
	}
}

.readora-ad--ad-before-post .readora-ad__unit,
.readora-ad--ad-after-post .readora-ad__unit {
	min-height: 250px;
}

.readora-ad--ad-sidebar .readora-ad__unit {
	min-height: 600px;
}

/* 8. Sidebar and widgets ----------------------------------------------- */
.widget {
	margin-bottom: 2rem;
}

.widget-title {
	margin: 0 0 0.75rem;
	font-size: 1rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.widget ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.widget li {
	padding-block: 0.4rem;
	border-bottom: 1px solid var(--readora-border);
}

.widget li a {
	color: var(--readora-text);
	text-decoration: none;
}

.widget li a:hover {
	color: var(--readora-link);
}

@media (min-width: 960px) {
	.widget-area__sticky {
		position: sticky;
		top: 1.5rem;
	}

	.admin-bar .widget-area__sticky {
		top: calc(1.5rem + 32px);
	}
}

/* 9. Comments ----------------------------------------------------------- */
.comments-area {
	margin-top: 3rem;
}

.comment-list,
.comment-list .children {
	list-style: none;
	padding: 0;
}

.comment-list .children {
	padding-inline-start: 1.5rem;
}

.comment-body {
	padding-block: 1rem;
	border-bottom: 1px solid var(--readora-border);
}

.comment-author img {
	border-radius: 50%;
	vertical-align: middle;
	margin-inline-end: 0.5rem;
}

.comment-metadata {
	font-size: 0.8rem;
}

.comment-metadata a {
	color: var(--readora-muted);
}

/* 10. Footer ------------------------------------------------------------ */
.site-footer {
	border-top: 1px solid var(--readora-border);
	background: var(--readora-surface);
	font-size: 0.95rem;
}

.footer-widgets {
	display: grid;
	gap: 2rem;
	padding-block: 2.5rem 0;
}

@media (min-width: 768px) {
	.footer-widgets {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.site-info {
	padding-block: 1.5rem;
	color: var(--readora-muted);
	text-align: center;
}

.footer-menu {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem 1.25rem;
	list-style: none;
	margin: 0 0 0.5rem;
	padding: 0;
}

.footer-menu a {
	color: var(--readora-text);
	text-decoration: none;
}

/* 11. Forms and pagination --------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="password"],
textarea {
	width: 100%;
	padding: 0.65rem 0.8rem;
	border: 1px solid var(--readora-border);
	border-radius: 8px;
	font: inherit;
	color: inherit;
	background: var(--readora-bg);
}

button,
input[type="submit"],
.wp-block-button__link {
	padding: 0.65rem 1.25rem;
	border: 0;
	border-radius: 8px;
	background: var(--readora-accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.search-form {
	display: flex;
	gap: 0.5rem;
}

.pagination {
	margin-top: 2.5rem;
}

.pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.pagination .page-numbers {
	display: inline-block;
	min-width: 44px;
	padding: 0.5rem 0.9rem;
	border: 1px solid var(--readora-border);
	border-radius: 8px;
	text-align: center;
	text-decoration: none;
}

.pagination .current {
	background: var(--readora-accent);
	border-color: var(--readora-accent);
	color: #fff;
}

/* 12. Blocks ------------------------------------------------------------ */
.wp-block-image figcaption {
	color: var(--readora-muted);
	font-size: 0.875rem;
	text-align: center;
}

.wp-block-pullquote {
	border-block: 4px solid var(--readora-accent);
}

.wp-block-separator {
	border: 0;
	border-top: 1px solid var(--readora-border);
}
