/* Graded stories: the library (/stories/) and the reader (?story=<key>).
   Tokens only: both themes come from base.css. */

/* The library uses the full width for three columns; the reader stays a
   comfortable reading measure. */
#clh-stories {
	--clh-story-pad: 16px;
	box-sizing: border-box;
	width: 100%;
	max-width: 1040px;
	margin-left: auto;
	margin-right: auto;
}

#clh-stories.is-reader {
	max-width: 720px;
}

@media (max-width: 380px) {
	#clh-stories {
		--clh-story-pad: 12px;
	}
}

/* ---- Library ---- */

.clh-stories-head {
	margin: 8px 0 22px;
}

.clh-stories-title {
	margin: 4px 0 6px;
	font-size: 1.9rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.15;
}

.clh-stories-sub {
	margin: 0;
	color: var(--clh-text-muted);
}

.clh-stories-empty {
	margin: 24px 0;
	color: var(--clh-text-muted);
}

/* The story that is ready for the learner: a featured card. */
.clh-stories-next {
	margin-bottom: 26px;
	padding: 20px;
	border-left: 5px solid var(--clh-accent);
	background: var(--clh-accent-soft);
}

.clh-stories-next-zh {
	margin-top: 4px;
	font-family: var(--clh-font-cn);
	font-size: calc(1.7rem * var(--clh-zh-scale, 1));
	font-weight: 700;
	line-height: 1.3;
}

.clh-stories-next-en {
	font-size: 1.05rem;
	font-weight: 700;
}

.clh-stories-next-summary {
	margin: 6px 0 0;
	color: var(--clh-text-muted);
}

.clh-stories-next-meta {
	margin: 4px 0 14px;
	font-size: 0.85rem;
	color: var(--clh-text-muted);
}

/* ---- Levels and cards ---- */

.clh-stories-level {
	margin-bottom: 28px;
}

.clh-stories-level-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.clh-stories-level-title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 800;
	letter-spacing: 0.02em;
}

.clh-stories-level-count {
	flex: none;
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--clh-text-muted);
}

.clh-stories-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 14px;
}

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

@media (min-width: 1000px) {
	.clh-stories-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.clh-story-card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 16px;
	color: var(--clh-text);
	text-decoration: none;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.clh-story-card:hover {
	color: var(--clh-text);
	text-decoration: none;
	transform: translateY(-2px);
}

.clh-story-card-zh {
	font-family: var(--clh-font-cn);
	font-size: calc(1.35rem * var(--clh-zh-scale, 1));
	font-weight: 700;
	line-height: 1.3;
}

.clh-story-card-en {
	font-weight: 700;
}

.clh-story-card-summary {
	margin: 0;
	font-size: 0.92rem;
	color: var(--clh-text-muted);
}

.clh-story-card-meta {
	font-size: 0.82rem;
	color: var(--clh-text-muted);
}

/* A state chip. Every state has its words, never colour alone. */
.clh-story-chip {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 5px;
	margin-top: 4px;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--clh-sunken);
	color: var(--clh-text-muted);
	font-size: 0.78rem;
	font-weight: 800;
	line-height: 1.5;
}

.clh-story-chip .clh-icon {
	font-size: 0.95em;
}

.clh-story-chip.is-read {
	background: var(--clh-green-soft);
	color: var(--clh-green);
}

.clh-story-chip.is-ready {
	background: var(--clh-gold-soft);
	color: var(--clh-warm);
}

/* ---- Reader: top bar ---- */

.clh-story-bar {
	position: sticky;
	top: var(--clh-sticky-top, 0px);
	z-index: 10;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin: 0 calc(-1 * var(--clh-story-pad));
	padding: 8px var(--clh-story-pad);
	background: var(--clh-bg);
}

.clh-story-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 6px;
	font-weight: 700;
	color: var(--clh-text);
	text-decoration: none;
}

.clh-story-back:hover {
	color: var(--clh-accent-text);
	text-decoration: none;
}

.clh-story-back-icon {
	transform: rotate(180deg);
}

.clh-story-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* English labels on these two switches keep the UI font, not the CJK one. */
.clh-story-slow .clh-switch-label,
.clh-story-translations .clh-switch-label {
	font-family: inherit;
	font-size: 0.9rem;
}

/* ---- Reader: header ---- */

.clh-story-head {
	margin: 16px 0 0;
}

.clh-story-head .clh-kicker {
	color: var(--clh-accent-text);
}

.clh-story-title {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 12px;
	margin: 4px 0 2px;
	font-size: 1.6rem;
	line-height: 1.3;
}

.clh-story-title-zh {
	font-family: var(--clh-font-cn);
	font-size: calc(2rem * var(--clh-zh-scale, 1));
	font-weight: 700;
	line-height: 1.3;
}

.clh-story-title-play {
	min-width: 44px;
	min-height: 44px;
}

.clh-story-title-en {
	margin: 2px 0 0;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--clh-text-muted);
}

.clh-story-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 8px 0 0;
	font-size: 0.85rem;
	color: var(--clh-text-muted);
}

.clh-story-meta .clh-story-chip {
	margin-top: 0;
}

/* ---- Reader: tools ---- */

.clh-story-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin: 16px 0;
}

.clh-story-tools .clh-btn,
.clh-story-tools .clh-switch {
	min-height: 44px;
}

.clh-story-tools .clh-btn {
	padding-top: 8px;
	padding-bottom: 8px;
}

.clh-story-play .clh-icon {
	font-size: 1.2em;
}

/* ---- Reader: the text ---- */

.clh-story-text {
	max-width: 720px;
	margin: 8px auto 0;
}

.clh-story-p {
	margin: 0 0 22px;
}

.clh-story-s {
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr) 44px;
	align-items: start;
	gap: 8px;
	padding: 6px;
	border-inline-start: 3px solid transparent;
	border-radius: 12px;
	scroll-margin-top: calc(var(--clh-sticky-top, 0px) + 80px);
	transition: background 0.2s ease;
}

/* The sentence being read: a soft background AND a brand-blue edge. */
.clh-story-s.is-playing {
	background: var(--clh-select-soft);
	border-inline-start-color: var(--clh-select);
}

.clh-story-s-audio {
	display: block;
	width: 44px;
	height: 1px;
}

.clh-story-s-play {
	min-width: 44px;
	min-height: 44px;
}

.clh-story-s-body {
	min-width: 0;
}

.clh-story-zh {
	display: block;
	font-family: var(--clh-font-cn);
	font-size: calc(1.4rem * var(--clh-zh-scale, 1));
	font-weight: 500;
	line-height: 1.7;
}

.clh-story-en {
	margin: 2px 0 0;
	font-size: 0.92rem;
	color: var(--clh-text-muted);
}

.clh-story-en[hidden] {
	display: none;
}

.clh-story-en-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	border: 2px solid var(--clh-control-border);
	border-radius: 999px;
	background: transparent;
	color: var(--clh-text-muted);
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	cursor: pointer;
}

.clh-story-en-btn:hover {
	background: var(--clh-sunken);
	color: var(--clh-text);
}

.clh-story-en-btn[aria-expanded="true"] {
	border-color: var(--clh-select);
	background: var(--clh-select-soft);
	color: var(--clh-select);
}

/* ---- Reader: questions and summary ---- */

.clh-story-questions {
	max-width: 720px;
	margin: 28px auto 0;
	padding-top: 20px;
	border-top: 1px solid var(--clh-border);
}

.clh-story-questions-title {
	margin: 0 0 4px;
	font-size: 1.35rem;
	font-weight: 800;
}

.clh-story-questions-sub {
	margin: 0 0 16px;
	font-size: 0.95rem;
	color: var(--clh-text-muted);
}

.clh-story-question-count {
	margin: 0 0 8px;
	font-size: 0.82rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	color: var(--clh-text-muted);
}

.clh-story-done {
	max-width: 720px;
	margin: 20px auto 0;
	text-align: center;
}

.clh-story-done .clh-complete-actions {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.clh-story-done .clh-btn {
	width: 100%;
	max-width: 340px;
}

.clh-story-done-note {
	max-width: 440px;
	margin: 0 auto 18px;
	color: var(--clh-text-muted);
}

.clh-story-passed {
	margin: 0 0 8px;
	font-weight: 800;
	color: var(--clh-green);
}

/* ---- Motion ---- */

@media (prefers-reduced-motion: reduce) {
	.clh-story-card,
	.clh-story-s {
		transition: none;
	}

	.clh-story-card:hover {
		transform: none;
	}

	.clh-story-text,
	#clh-stories {
		scroll-behavior: auto;
	}
}

/* ---- News (/news/): the list ---- */

.clh-news-tabs {
	display: flex;
	gap: 6px;
	margin: 0 0 14px;
	border-bottom: 1px solid var(--clh-border);
}

.clh-news-tab {
	padding: 8px 12px;
	border-bottom: 3px solid transparent;
	margin-bottom: -1px;
	color: var(--clh-text-muted);
	font-weight: 700;
	text-decoration: none;
}

.clh-news-tab:hover {
	color: var(--clh-text);
	text-decoration: none;
}

.clh-news-tab.is-active {
	border-bottom-color: var(--clh-accent);
	color: var(--clh-text);
}

.clh-news-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 16px;
}

.clh-news-filter-btn {
	min-height: 40px;
	min-width: 48px;
	padding: 6px 14px;
	border: 1px solid var(--clh-control-border);
	border-radius: 999px;
	background: var(--clh-raised);
	color: var(--clh-text);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.clh-news-filter-btn.is-active {
	border-color: var(--clh-accent);
	background: var(--clh-accent);
	color: #fff;
}

.clh-news-card-top {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 0.82rem;
}

/* The level: a small seal-red badge, the same on the card and in the reader. */
.clh-news-level {
	padding: 1px 8px;
	border-radius: 6px;
	background: var(--clh-accent-soft);
	color: var(--clh-accent-text);
	font-weight: 800;
	letter-spacing: 0.02em;
}

.clh-news-date {
	color: var(--clh-text-muted);
	font-weight: 600;
}

.clh-news-card-sources {
	font-size: 0.8rem;
	color: var(--clh-text-muted);
}

/* ---- News: the reader ---- */

.clh-news-preview {
	margin: 0 0 12px;
	padding: 10px 14px;
	border-radius: var(--clh-radius-sm);
	background: var(--clh-gold-soft);
	color: var(--clh-warm);
	font-weight: 700;
}

.clh-news-glossary {
	margin: 0 0 18px;
	padding: 14px 16px;
}

.clh-news-glossary-title {
	margin: 0 0 8px;
	font-size: 1rem;
}

.clh-news-glossary-list {
	display: grid;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.clh-news-glossary-item {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
}

.clh-news-glossary-zh {
	font-family: var(--clh-font-cn);
	font-size: calc(1.2rem * var(--clh-zh-scale, 1));
	font-weight: 700;
	background: var(--clh-gold-soft);
	border-radius: 4px;
	padding: 0 4px;
}

.clh-news-glossary-py {
	color: var(--clh-text-muted);
}

.clh-news-glossary-en {
	flex-basis: 100%;
	font-size: 0.92rem;
}

@media (min-width: 640px) {
	.clh-news-glossary-en {
		flex-basis: auto;
	}
}

/* A glossed word in the text: highlighted like a marker pen, also in dark mode. */
.clh-story-zh mark.clh-gloss {
	background: var(--clh-gold-soft);
	color: inherit;
	border-radius: 3px;
	padding: 0 1px;
}

.clh-news-sources {
	margin: 18px 0;
	font-size: 0.88rem;
	color: var(--clh-text-muted);
}

.clh-news-sources-note {
	margin: 0 0 4px;
}

.clh-news-sources-list {
	margin: 0;
	padding-left: 1.2em;
}
