/**
 * Thrift Weekly Community — feed, card, single find, sidebar, gallery.
 *
 * Reddit-shaped information hierarchy, Thrift Weekly branding. Every value
 * comes from tokens.css.
 *
 * Layout model: two columns on desktop (content + 320px rail), one column
 * below 1024px with the rail moving under the feed. The card itself is a
 * two-column grid — vote rail plus body — which collapses to a horizontal
 * rail on phones so the photo keeps full width.
 */

/* ==========================================================================
   Feed shell
   ========================================================================== */

.twc-feed {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-4);
	max-width: 100%;
}

.twc-feed__tabs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--twc-space-1);
	padding-bottom: var(--twc-space-3);
	border-bottom: 1px solid var(--twc-gray-border);
}

.twc-feed__tab {
	padding: 8px 16px;
	border-radius: var(--twc-radius-pill);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-nav);
	font-weight: var(--twc-fw-semi);
	line-height: var(--twc-lh-nav);
	color: var(--twc-ink-muted);
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--twc-transition), color var(--twc-transition);
}

.twc-feed__tab:hover {
	background: var(--twc-gray-light);
	color: var(--twc-ink);
}

.twc-feed__tab.is-active {
	color: var(--twc-teal);
	box-shadow: inset 0 -2px 0 var(--twc-teal);
	border-radius: 0;
}

.twc-feed__cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
	padding: 9px 18px;
	border-radius: var(--twc-radius-pill);
	background: var(--twc-teal);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-button);
	font-weight: var(--twc-fw-bold);
	line-height: var(--twc-lh-button);
	color: var(--twc-white);
	text-decoration: none;
	white-space: nowrap;
}

.twc-feed__cta:hover {
	background: var(--twc-teal-dark);
	color: var(--twc-white);
}

/* ---- Category pills ---- */

.twc-pills {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--twc-space-2);
	overflow-x: auto;
	padding-bottom: 4px;
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

.twc-pill {
	flex: none;
	padding: 6px 14px;
	border: 1px solid var(--twc-gray-border);
	border-radius: var(--twc-radius-pill);
	background: var(--twc-white);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-pill);
	font-weight: var(--twc-fw-semi);
	line-height: var(--twc-lh-pill);
	color: var(--twc-ink-muted);
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--twc-transition), border-color var(--twc-transition), color var(--twc-transition);
}

.twc-pill:hover {
	border-color: var(--twc-teal);
	color: var(--twc-teal);
}

.twc-pill.is-active {
	background: var(--twc-teal);
	border-color: var(--twc-teal);
	color: var(--twc-white);
}

/* ---- List and windowing ---- */

.twc-feed__list {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-4);
	transition: opacity var(--twc-transition);
}

.twc-feed__item {
	/* content-visibility lets the browser skip layout and paint for cards
	   that are off-screen but still in the DOM — a second line of defence
	   alongside the JavaScript that detaches them entirely. */
	content-visibility: auto;
	contain-intrinsic-size: auto 520px;
}

/* A parked card is emptied by JavaScript and holds its measured height, so
   the page never changes length and the scroll position never jumps. */
.twc-feed__item[data-twc-parked="1"] {
	background: var(--twc-gray-light);
	border-radius: var(--twc-radius);
	opacity: 0.35;
}

.twc-feed__sentinel {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--twc-space-6) 0;
}

.twc-feed__spinner {
	width: 24px;
	height: 24px;
	border: 2px solid var(--twc-gray-border);
	border-top-color: var(--twc-teal);
	border-radius: 50%;
	animation: twc-spin 700ms linear infinite;
}

@keyframes twc-spin {
	to { transform: rotate( 360deg ); }
}

@media (prefers-reduced-motion: reduce) {
	.twc-feed__spinner {
		animation-duration: 2.5s;
	}

	.twc-feed__list,
	.twc-pill,
	.twc-feed__tab {
		transition: none;
	}
}

.twc-feed__end,
.twc-feed__noscript {
	padding: var(--twc-space-5) 0;
	text-align: center;
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-meta);
	color: var(--twc-ink-subtle);
}

.twc-feed__more {
	width: 100%;
	margin-top: var(--twc-space-4);
}

/* ==========================================================================
   Find card
   ========================================================================== */

.twc-card {
	display: grid;
	grid-template-columns: 48px 1fr;
	gap: var(--twc-space-3);
	padding: var(--twc-space-4);
	border: 1px solid var(--twc-gray-border);
	border-radius: var(--twc-radius);
	background: var(--twc-white);
	transition: border-color var(--twc-transition);
}

.twc-card:hover {
	border-color: var(--twc-border-strong, #cfd4d3);
}

.twc-card__rail {
	display: flex;
	justify-content: center;
	padding-top: 2px;
}

.twc-card__main {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-3);
	min-width: 0;
}

.twc-card__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-meta);
	font-weight: var(--twc-fw-medium);
	line-height: var(--twc-lh-meta);
	color: var(--twc-ink-subtle);
}

.twc-card__avatar img {
	display: block;
	width: 24px;
	height: 24px;
	border-radius: 50%;
}

.twc-card__author {
	color: var(--twc-ink);
}

.twc-card__title {
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--twc-space-2);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-title);
	font-weight: var(--twc-fw-bold);
	line-height: var(--twc-lh-title);
}

.twc-card__title a {
	color: var(--twc-ink);
	text-decoration: none;
}

.twc-card__title a:hover {
	color: var(--twc-teal);
}

.twc-card__cat {
	flex: none;
	padding: 3px 10px;
	border-radius: var(--twc-radius-pill);
	background: var(--twc-teal-tint);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-pill);
	font-weight: var(--twc-fw-semi);
	line-height: var(--twc-lh-pill);
	color: var(--twc-teal);
	text-decoration: none;
}

.twc-flag {
	flex: none;
	padding: 3px 9px;
	border-radius: var(--twc-radius-pill);
	font-family: var(--twc-font-display);
	font-size: 11px;
	font-weight: var(--twc-fw-bold);
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.twc-flag--gold {
	background: var(--twc-gold-tint);
	color: #8a6d12;
}

.twc-flag--teal {
	background: var(--twc-teal-tint);
	color: var(--twc-teal);
}

.twc-card__excerpt {
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-body);
	font-weight: var(--twc-fw-regular);
	line-height: var(--twc-lh-body);
	color: var(--twc-ink-muted);
}

.twc-card__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--twc-space-2);
	padding-top: var(--twc-space-1);
}

.twc-card__action {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border: 0;
	border-radius: var(--twc-radius-sm);
	background: transparent;
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-meta);
	font-weight: var(--twc-fw-medium);
	line-height: var(--twc-lh-meta);
	color: var(--twc-ink-muted);
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--twc-transition), color var(--twc-transition);
}

.twc-card__action:hover {
	background: var(--twc-gray-light);
	color: var(--twc-ink);
}

@media (max-width: 600px) {
	.twc-card {
		grid-template-columns: 1fr;
		gap: var(--twc-space-2);
		padding: var(--twc-space-3);
	}

	/* The rail flips horizontal under the actions so the photo keeps the
	   full width of the screen, matching the mobile mockup. */
	.twc-card__rail {
		order: 2;
		justify-content: flex-start;
		padding-top: 0;
	}

	.twc-card__rail .twc-vote--vertical {
		flex-direction: row;
	}

	.twc-card__main {
		order: 1;
	}
}

/* ==========================================================================
   Two-column community layout
   ========================================================================== */

.twc-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: var(--twc-space-5);
	align-items: start;
}

.twc-layout__aside {
	position: sticky;
	top: var(--twc-space-5);
}

@media (max-width: 1024px) {
	.twc-layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.twc-layout__aside {
		position: static;
	}
}

/* ==========================================================================
   Sidebar panels
   ========================================================================== */

.twc-sidebar {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-4);
}

.twc-panel {
	padding: var(--twc-space-5);
	border: 1px solid var(--twc-gray-border);
	border-radius: var(--twc-radius);
	background: var(--twc-white);
}

.twc-panel--award {
	border-color: var(--twc-gold);
	background: linear-gradient( var(--twc-gold-tint), var(--twc-white) 55% );
}

.twc-panel__title {
	display: flex;
	align-items: center;
	gap: var(--twc-space-2);
	margin: 0 0 var(--twc-space-4);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-card);
	font-weight: var(--twc-fw-bold);
	line-height: var(--twc-lh-card);
	color: var(--twc-ink);
}

.twc-panel__cta {
	width: 100%;
	margin-top: var(--twc-space-4);
}

.twc-panel__note {
	margin: var(--twc-space-2) 0 0;
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-small);
	line-height: var(--twc-lh-small);
	color: var(--twc-ink-subtle);
	text-align: center;
}

.twc-award {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-3);
	text-decoration: none;
}

.twc-award__image img {
	display: block;
	width: 100%;
	max-width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: var(--twc-radius);
}

.twc-award__title {
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-card);
	font-weight: var(--twc-fw-bold);
	line-height: var(--twc-lh-card);
	color: var(--twc-ink);
}

.twc-award__meta {
	margin: var(--twc-space-1) 0 0;
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-meta);
	line-height: var(--twc-lh-meta);
	color: var(--twc-ink-muted);
}

.twc-rail {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

.twc-rail__link {
	display: grid;
	grid-template-columns: 56px 1fr;
	gap: var(--twc-space-3);
	align-items: center;
	text-decoration: none;
}

.twc-rail__thumb img {
	display: block;
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: var(--twc-radius-sm);
}

.twc-rail__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.twc-rail__title {
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-pill);
	font-weight: var(--twc-fw-semi);
	line-height: 1.35;
	color: var(--twc-ink);
}

.twc-rail__link:hover .twc-rail__title {
	color: var(--twc-teal);
}

.twc-rail__meta {
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-small);
	font-weight: var(--twc-fw-medium);
	color: var(--twc-ink-subtle);
}

.twc-rules {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-2);
	margin: 0;
	padding-left: 20px;
}

.twc-rules__item {
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-meta);
	line-height: var(--twc-lh-meta);
	color: var(--twc-ink-muted);
}

/* ==========================================================================
   Single find
   ========================================================================== */

.twc-single {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: var(--twc-space-5);
	align-items: start;
}

.twc-single__main {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr);
	gap: var(--twc-space-4);
	padding: var(--twc-space-5);
	border: 1px solid var(--twc-gray-border);
	border-radius: var(--twc-radius);
	background: var(--twc-white);
}

.twc-single__rail {
	display: flex;
	justify-content: center;
}

.twc-single__rail .twc-vote {
	position: sticky;
	top: var(--twc-space-5);
}

.twc-single__body {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-4);
	min-width: 0;
}

.twc-single__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-meta);
	font-weight: var(--twc-fw-medium);
	color: var(--twc-ink-subtle);
}

.twc-single__title {
	margin: 0;
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-hero);
	font-weight: var(--twc-fw-bold);
	line-height: var(--twc-lh-hero);
	color: var(--twc-ink);
}

.twc-single__story {
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-body);
	line-height: var(--twc-lh-body);
	color: var(--twc-ink);
}

.twc-single__story p {
	margin: 0 0 var(--twc-space-3);
}

.twc-single__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--twc-space-2);
	padding-top: var(--twc-space-2);
	border-top: 1px solid var(--twc-gray-border);
}

.twc-single__aside {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-4);
	position: sticky;
	top: var(--twc-space-5);
}

@media (max-width: 1024px) {
	.twc-single {
		grid-template-columns: minmax(0, 1fr);
	}

	.twc-single__aside {
		position: static;
	}
}

@media (max-width: 600px) {
	.twc-single__main {
		grid-template-columns: minmax(0, 1fr);
		padding: var(--twc-space-3);
	}

	.twc-single__rail {
		order: 2;
		justify-content: flex-start;
	}

	.twc-single__rail .twc-vote {
		position: static;
		flex-direction: row;
	}

	.twc-single__body {
		order: 1;
	}
}

/* ==========================================================================
   Gallery
   ========================================================================== */

.twc-gallery {
	display: flex;
	flex-direction: column;
	gap: var(--twc-space-2);
}

.twc-gallery__stage {
	position: relative;
	margin: 0;
	border-radius: var(--twc-radius);
	overflow: hidden;
	background: var(--twc-gray-light);
}

.twc-gallery__open {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
}

.twc-gallery__main {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	max-height: 68vh;
	object-fit: contain;
	background: var(--twc-gray-light);
}

.twc-gallery__counter {
	position: absolute;
	right: var(--twc-space-3);
	bottom: var(--twc-space-3);
	padding: 4px 10px;
	border-radius: var(--twc-radius-pill);
	background: rgba(17, 17, 17, 0.65);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-small);
	font-weight: var(--twc-fw-semi);
	color: var(--twc-white);
	font-variant-numeric: tabular-nums;
}

.twc-gallery__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	color: var(--twc-ink);
	cursor: pointer;
	box-shadow: var(--twc-shadow-sm);
	transition: background-color var(--twc-transition);
}

.twc-gallery__nav:hover {
	background: var(--twc-white);
}

.twc-gallery__nav--prev { left: var(--twc-space-3); }
.twc-gallery__nav--next { right: var(--twc-space-3); }

.twc-gallery__thumbs {
	display: flex;
	gap: var(--twc-space-2);
	overflow-x: auto;
	padding-bottom: 4px;
	-webkit-overflow-scrolling: touch;
}

.twc-gallery__thumb {
	flex: none;
	display: block;
	width: 72px;
	height: 72px;
	border: 2px solid transparent;
	border-radius: var(--twc-radius-sm);
	overflow: hidden;
	transition: border-color var(--twc-transition);
}

.twc-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.twc-gallery__thumb.is-active {
	border-color: var(--twc-teal);
}

.twc-gallery__thumb:hover {
	border-color: var(--twc-ink-subtle);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

body.twc-lightbox-open {
	overflow: hidden;
}

.twc-lightbox {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--twc-space-3);
	padding: var(--twc-space-4);
	background: rgba(17, 17, 17, 0.94);
}

.twc-lightbox__stage {
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	max-height: 92vh;
}

.twc-lightbox__img {
	max-width: 100%;
	max-height: 92vh;
	width: auto;
	height: auto;
	object-fit: contain;
}

.twc-lightbox__nav,
.twc-lightbox__close {
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: var(--twc-white);
	cursor: pointer;
	transition: background-color var(--twc-transition);
}

.twc-lightbox__nav {
	width: 48px;
	height: 48px;
	font-size: 30px;
	line-height: 1;
}

.twc-lightbox__nav:hover,
.twc-lightbox__close:hover {
	background: rgba(255, 255, 255, 0.3);
}

.twc-lightbox__close {
	position: absolute;
	top: var(--twc-space-4);
	right: var(--twc-space-4);
	width: 40px;
	height: 40px;
	font-size: 26px;
	line-height: 1;
}

.twc-lightbox__counter {
	position: absolute;
	left: 50%;
	bottom: var(--twc-space-4);
	transform: translateX(-50%);
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-meta);
	font-weight: var(--twc-fw-semi);
	color: rgba(255, 255, 255, 0.85);
	font-variant-numeric: tabular-nums;
}

.twc-lightbox__nav:focus-visible,
.twc-lightbox__close:focus-visible,
.twc-gallery__nav:focus-visible,
.twc-gallery__thumb:focus-visible,
.twc-gallery__open:focus-visible,
.twc-pill:focus-visible,
.twc-feed__tab:focus-visible {
	outline: 2px solid var(--twc-teal);
	outline-offset: 2px;
}

@media (max-width: 600px) {
	.twc-lightbox {
		grid-template-columns: minmax(0, 1fr);
		padding: var(--twc-space-2);
	}

	/* On a phone the arrows are redundant — swipe handles navigation, and
	   40px buttons over a photo just get in the way of the photo. */
	.twc-lightbox__nav {
		display: none;
	}

	.twc-gallery__nav {
		width: 34px;
		height: 34px;
	}

	.twc-gallery__thumb {
		width: 56px;
		height: 56px;
	}

	/* Leave room for the fixed bottom navigation. */
	.twc-feed,
	.twc-single {
		padding-bottom: 72px;
	}
}

/* ==========================================================================
   Archive page shell
   ========================================================================== */

.twc-archive {
	background: var(--twc-gray-light);
}

.twc-archive__inner {
	max-width: 1180px;
	margin: 0 auto;
	padding-inline: var(--twc-space-4);
	padding-block: var(--twc-space-6) var(--twc-space-7);
}

.twc-archive__head {
	margin-bottom: var(--twc-space-5);
}

.twc-archive__title {
	margin: 0;
	font-family: var(--twc-font-display);
	font-size: var(--twc-fs-hero);
	font-weight: var(--twc-fw-bold);
	line-height: var(--twc-lh-hero);
	color: var(--twc-ink);
}

.twc-archive__desc {
	margin-top: var(--twc-space-2);
	font-family: var(--twc-font-body);
	font-size: var(--twc-fs-body);
	line-height: var(--twc-lh-body);
	color: var(--twc-ink-muted);
}

@media (max-width: 600px) {
	.twc-archive__inner {
		padding-block: var(--twc-space-4) var(--twc-space-6);
	}
}
