/* ==========================================================================
   TINY RISKS — theme.css
   A hard-edged instrument panel (deep navy + teal) around a primitive craft.
   Mobile-first, hand-rolled responsive. Tokens mirror theme.json.
   ========================================================================== */

:root {
	/* palette */
	--void: #05090F;
	--abyss: #0A1422;
	--surface: #0F2034;
	--surface-2: #16304A;
	--ink: #DCE7F2;
	--ink-dim: #7E93AB;
	--ink-bright: #F2F8FF;
	--teal: #2DE2C5;
	--teal-bright: #5CFFE6;
	--blue: #2D7FF9;
	--signal: #FF5470;

	--line: rgba(45, 226, 197, 0.16);
	--line-strong: rgba(45, 226, 197, 0.42);
	--glow: 0 0 0 1px var(--line-strong), 0 0 28px -8px var(--teal);

	/* type */
	--f-display: "Chakra Petch", system-ui, sans-serif;
	--f-body: "Spline Sans", system-ui, sans-serif;
	--f-mono: "JetBrains Mono", ui-monospace, monospace;

	/* space */
	--gap: clamp(1.25rem, 4vw, 2.5rem);
	--bleed: clamp(1.1rem, 5vw, 4rem);
	--maxw: 76rem;
	--readw: 44rem;

	--ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* --- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
img, picture, canvas { display: block; max-width: 100%; height: auto; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-bright); }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
::selection { background: var(--teal); color: var(--void); }

body {
	font-family: var(--f-body);
	font-size: 1.05rem;
	line-height: 1.7;
	color: var(--ink);
	background: var(--void);
	/* layered atmosphere: two radial glows + a fine grid */
	background-image:
		radial-gradient(60rem 40rem at 80% -10%, rgba(45, 127, 249, 0.10), transparent 60%),
		radial-gradient(50rem 40rem at -10% 10%, rgba(45, 226, 197, 0.08), transparent 55%),
		linear-gradient(transparent 95%, var(--line) 95%),
		linear-gradient(90deg, transparent 95%, var(--line) 95%);
	background-size: auto, auto, 2.4rem 2.4rem, 2.4rem 2.4rem;
	background-attachment: fixed;
	min-height: 100svh;
	overflow-x: hidden;
}

.tr-mono { font-family: var(--f-mono); letter-spacing: 0.04em; }

/* moving scanline veil */
.tr-scanlines {
	position: fixed; inset: 0; z-index: 1; pointer-events: none;
	background: repeating-linear-gradient(
		to bottom, transparent 0 3px, rgba(5, 9, 15, 0.35) 3px 4px
	);
	mix-blend-mode: multiply; opacity: 0.5;
}

.tr-skip {
	position: absolute; left: -999px; top: 0; z-index: 50;
	background: var(--teal); color: var(--void); padding: 0.6rem 1rem;
	font-family: var(--f-mono);
}
.tr-skip:focus { left: 0; }

/* --- layout helpers ------------------------------------------------------- */
.tr-main { position: relative; z-index: 2; }
.tr-head, .tr-foot, .tr-hero, .tr-series, .tr-feed, .tr-module,
.tr-single, .tr-404 {
	padding-inline: var(--bleed);
}
.tr-hero, .tr-series, .tr-feed, .tr-module, .tr-single, .tr-404 {
	max-width: var(--maxw); margin-inline: auto;
}

/* notched corner utility — the hard-edged "cut" motif */
.tr-notch {
	clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.tr-head {
	position: sticky; top: 0; z-index: 30;
	background: color-mix(in oklab, var(--void) 86%, transparent);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--line);
}
.tr-head__rail {
	max-width: var(--maxw); margin-inline: auto;
	display: flex; align-items: center; gap: var(--gap);
	min-height: 4rem;
}
.tr-head__brand { display: flex; align-items: center; gap: 0.7rem; margin-right: auto; }
.tr-wordmark { display: flex; flex-direction: column; line-height: 1; }
.tr-wordmark__main {
	font-family: var(--f-display); font-weight: 700; font-size: 1.15rem;
	letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-bright);
}
.tr-wordmark__tag {
	font-family: var(--f-mono); font-size: 0.62rem; color: var(--ink-dim);
	letter-spacing: 0.02em; margin-top: 0.25rem; max-width: 22ch;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* nav */
.tr-nav__toggle {
	display: none; align-items: center; gap: 0.5rem;
	font-family: var(--f-mono); font-size: 0.7rem; color: var(--ink-dim);
}
.tr-nav__toggle span {
	display: block; width: 18px; height: 2px; background: var(--teal);
	transition: transform 0.25s var(--ease), opacity 0.2s;
}
.tr-nav__toggle span + span { margin-top: -10px; } /* stacked via flex hack below */
.tr-nav__list {
	list-style: none; display: flex; gap: 1.5rem; padding: 0;
	font-family: var(--f-mono); font-size: 0.82rem; text-transform: uppercase;
	letter-spacing: 0.06em;
}
.tr-nav__list a { color: var(--ink-dim); position: relative; padding-block: 0.3rem; }
.tr-nav__list a:hover, .tr-nav__list .current-menu-item a { color: var(--ink-bright); }
.tr-nav__list a::after {
	content: ""; position: absolute; left: 0; bottom: 0; width: 0; height: 2px;
	background: var(--teal); transition: width 0.25s var(--ease);
}
.tr-nav__list a:hover::after, .tr-nav__list .current-menu-item a::after { width: 100%; }

/* audio toggle */
.tr-audio {
	display: flex; align-items: center; gap: 0.55rem;
	border: 1px solid var(--line); padding: 0.45rem 0.8rem;
	font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.08em;
	color: var(--ink-dim); transition: border-color 0.25s, color 0.25s, box-shadow 0.25s;
}
.tr-audio:hover { color: var(--ink-bright); border-color: var(--line-strong); }
.tr-audio[aria-pressed="true"] { color: var(--teal); box-shadow: var(--glow); }
.tr-audio__viz { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.tr-audio__viz i { width: 3px; height: 4px; background: var(--ink-dim); transition: background 0.25s; }
.tr-audio[aria-pressed="true"] .tr-audio__viz i {
	background: var(--teal);
	animation: tr-eq 0.9s var(--ease) infinite alternate;
}
.tr-audio__viz i:nth-child(2) { animation-delay: 0.1s; }
.tr-audio__viz i:nth-child(3) { animation-delay: 0.2s; }
.tr-audio__viz i:nth-child(4) { animation-delay: 0.3s; }
.tr-audio__viz i:nth-child(5) { animation-delay: 0.15s; }
@keyframes tr-eq { from { height: 3px; } to { height: 14px; } }

/* readout strip */
.tr-head__readout {
	max-width: var(--maxw); margin-inline: auto;
	display: flex; gap: 1.5rem; flex-wrap: wrap;
	font-family: var(--f-mono); font-size: 0.62rem; color: var(--ink-dim);
	padding-block: 0.4rem; border-top: 1px solid var(--line);
	letter-spacing: 0.05em;
}
.tr-pulse { color: var(--teal); animation: tr-blink 1.6s steps(1) infinite; }
@keyframes tr-blink { 50% { opacity: 0.25; } }

/* ==========================================================================
   HERO
   ========================================================================== */
.tr-hero { position: relative; padding-block: clamp(3.5rem, 10vw, 7rem) clamp(2.5rem, 7vw, 5rem); }
.tr-hero__eyebrow { color: var(--teal); font-size: 0.72rem; margin-bottom: 1.4rem; }
.tr-hero__title {
	font-family: var(--f-display); font-weight: 700;
	font-size: clamp(2.4rem, 8vw, 5rem); line-height: 1.0;
	letter-spacing: -0.01em; color: var(--ink-bright); text-wrap: balance;
}
.tr-hl {
	color: var(--teal);
	text-shadow: 0 0 32px rgba(45, 226, 197, 0.35);
}
.tr-hero__lede {
	margin-top: 1.5rem; max-width: 40ch; color: var(--ink-dim); font-size: 1.1rem;
}
.tr-hero__actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 2.2rem; }
.tr-hero__frame {
	position: absolute; inset-block: 1.5rem; right: var(--bleed); width: 38%;
	border: 1px solid var(--line);
	background:
		linear-gradient(135deg, transparent 49.5%, var(--line) 49.5% 50.5%, transparent 50.5%),
		radial-gradient(circle at 70% 30%, rgba(45, 226, 197, 0.12), transparent 60%);
	clip-path: polygon(0 0, 100% 0, 100% 100%, 24px 100%, 0 calc(100% - 24px));
	pointer-events: none; opacity: 0.7;
}
@media (max-width: 760px) { .tr-hero__frame { display: none; } }

/* buttons */
.tr-btn {
	display: inline-flex; align-items: center; gap: 0.5rem;
	font-family: var(--f-mono); font-size: 0.8rem; letter-spacing: 0.06em;
	text-transform: uppercase; padding: 0.8rem 1.3rem;
	border: 1px solid var(--teal); transition: all 0.2s var(--ease);
	clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.tr-btn--solid { background: var(--teal); color: var(--void); }
.tr-btn--solid:hover { background: var(--teal-bright); box-shadow: 0 0 30px -6px var(--teal); transform: translateY(-2px); }
.tr-btn--ghost { color: var(--teal); border-color: var(--line-strong); }
.tr-btn--ghost:hover { color: var(--void); background: var(--teal); transform: translateY(-2px); }

/* ==========================================================================
   SECTION HEADS
   ========================================================================== */
.tr-section-head {
	display: flex; align-items: baseline; justify-content: space-between;
	gap: 1rem; flex-wrap: wrap; padding-bottom: 1rem; margin-bottom: 2rem;
	border-bottom: 1px solid var(--line);
}
.tr-section-head--page { margin-block: clamp(2.5rem, 7vw, 4.5rem) 2.5rem; }
.tr-section-head__eyebrow { color: var(--teal); font-size: 0.7rem; flex-basis: 100%; margin-bottom: 0.4rem; }
.tr-section-head__title {
	font-family: var(--f-display); font-weight: 600;
	font-size: clamp(1.5rem, 4vw, 2.2rem); color: var(--ink-bright); letter-spacing: -0.01em;
}
.tr-section-head__meta { font-size: 0.68rem; color: var(--ink-dim); }
.tr-section-head__desc { flex-basis: 100%; color: var(--ink-dim); margin-top: 0.6rem; }

/* ==========================================================================
   SERIES RAIL (the 3-part specimen list)
   ========================================================================== */
.tr-series { padding-block: clamp(2rem, 6vw, 4rem); }
.tr-series__list { list-style: none; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.tr-specimen {
	display: flex; align-items: stretch; gap: 1.2rem;
	background: var(--abyss); padding: 1.3rem var(--gap);
	transition: background 0.2s, transform 0.2s var(--ease);
}
.tr-specimen:hover { background: var(--surface); transform: translateX(6px); }
.tr-specimen__no {
	font-size: 1.6rem; color: var(--teal); align-self: center;
	min-width: 2.5ch; opacity: 0.7;
}
.tr-specimen__body { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.tr-specimen__code { font-size: 0.62rem; color: var(--ink-dim); }
.tr-specimen__title {
	font-family: var(--f-display); font-weight: 600; font-size: 1.2rem; color: var(--ink-bright);
}
.tr-specimen__read { font-size: 0.62rem; color: var(--ink-dim); }
.tr-specimen:hover .tr-specimen__title { color: var(--teal); }

/* ==========================================================================
   CARDS / FEED
   ========================================================================== */
.tr-feed { padding-block: clamp(2rem, 6vw, 4rem); }
.tr-cards {
	display: grid; gap: 1px; background: var(--line);
	border: 1px solid var(--line);
	grid-template-columns: 1fr;
}
@media (min-width: 620px) { .tr-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .tr-cards { grid-template-columns: 1fr 1fr 1fr; } }

.tr-card { background: var(--abyss); transition: background 0.25s; }
.tr-card:hover { background: var(--surface); }
.tr-card__link { display: flex; flex-direction: column; height: 100%; }
.tr-card__media { overflow: hidden; aspect-ratio: 16 / 10; border-bottom: 1px solid var(--line); }
.tr-card__img { width: 100%; height: 100%; object-fit: cover; filter: saturate(0.85) contrast(1.05); transition: transform 0.5s var(--ease), filter 0.4s; }
.tr-card:hover .tr-card__img { transform: scale(1.05); filter: saturate(1.1) contrast(1.1); }
.tr-card__body { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.3rem var(--gap); flex: 1; }
.tr-card__meta { font-size: 0.64rem; color: var(--teal); }
.tr-card__title { font-family: var(--f-display); font-weight: 600; font-size: 1.25rem; color: var(--ink-bright); line-height: 1.2; }
.tr-card:hover .tr-card__title { color: var(--teal); }
.tr-card__excerpt { color: var(--ink-dim); font-size: 0.95rem; flex: 1; }
.tr-card__more { font-size: 0.64rem; color: var(--ink-dim); margin-top: 0.4rem; }

.tr-empty { color: var(--ink-dim); padding: 3rem 0; text-align: center; }

/* pager */
.tr-pager { margin-top: 2.5rem; }
.tr-pager .page-numbers {
	display: inline-flex; min-width: 2.6rem; justify-content: center;
	padding: 0.5rem 0.8rem; border: 1px solid var(--line); color: var(--ink-dim); margin: 0 2px;
}
.tr-pager .page-numbers.current { color: var(--void); background: var(--teal); border-color: var(--teal); }
.tr-pager a.page-numbers:hover { color: var(--ink-bright); border-color: var(--line-strong); }

/* ==========================================================================
   SYNTH MODULE
   ========================================================================== */
.tr-module { padding-block: clamp(2.5rem, 7vw, 5rem); }
.tr-module__inner {
	border: 1px solid var(--line); background:
		linear-gradient(180deg, var(--surface), var(--abyss));
	padding: var(--gap);
	clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
}
.tr-module__copy { color: var(--ink-dim); max-width: 52ch; margin-bottom: 1.6rem; }
.tr-module__panel { display: flex; flex-direction: column; gap: 1.2rem; align-items: flex-start; }
.tr-module__canvas {
	width: 100%; height: 120px; border: 1px solid var(--line);
	background: rgba(5, 9, 15, 0.6);
}

/* ==========================================================================
   SINGLE / PROSE
   ========================================================================== */
.tr-single { padding-block: clamp(2rem, 6vw, 3.5rem) clamp(3rem, 8vw, 6rem); }
.tr-single__head { margin-bottom: 2rem; }
.tr-single__rail {
	display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: 0.68rem;
	color: var(--ink-dim); padding-bottom: 1.2rem; align-items: center;
}
.tr-single__code { color: var(--teal); }
.tr-single__chan { color: var(--ink-dim); border: 1px solid var(--line); padding: 0.15rem 0.5rem; }
.tr-single__chan:hover { color: var(--ink-bright); border-color: var(--line-strong); }
.tr-single__title {
	font-family: var(--f-display); font-weight: 700;
	font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.05; color: var(--ink-bright);
	letter-spacing: -0.01em; text-wrap: balance; max-width: 22ch;
}
.tr-single__media { margin-block: 2rem; border: 1px solid var(--line); }
.tr-single__img { width: 100%; }

.tr-prose { max-width: var(--readw); }
.tr-prose > * + * { margin-top: 1.4rem; }
.tr-prose p { color: var(--ink); }
.tr-prose h2 {
	font-family: var(--f-display); font-weight: 600; font-size: 1.7rem; color: var(--ink-bright);
	margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); letter-spacing: -0.01em;
}
.tr-prose h3 { font-family: var(--f-display); font-weight: 600; font-size: 1.3rem; color: var(--ink-bright); margin-top: 2.2rem; }
.tr-prose a { border-bottom: 1px solid var(--line-strong); }
.tr-prose a:hover { border-color: var(--teal); }
.tr-prose blockquote {
	border-left: 2px solid var(--teal); padding: 0.4rem 0 0.4rem 1.4rem;
	color: var(--ink-bright); font-family: var(--f-display); font-size: 1.3rem; font-style: normal;
}
.tr-prose code {
	font-family: var(--f-mono); font-size: 0.88em; background: var(--surface);
	padding: 0.12em 0.4em; border: 1px solid var(--line); color: var(--teal-bright);
}
.tr-prose pre {
	font-family: var(--f-mono); background: var(--abyss); border: 1px solid var(--line);
	padding: 1.2rem; overflow-x: auto; font-size: 0.85rem;
}
.tr-prose pre code { background: none; border: 0; padding: 0; }
.tr-prose img { border: 1px solid var(--line); }
.tr-prose ul, .tr-prose ol { padding-left: 1.4rem; }
.tr-prose li::marker { color: var(--teal); }
.tr-prose figcaption { font-family: var(--f-mono); font-size: 0.7rem; color: var(--ink-dim); margin-top: 0.5rem; }

.tr-single__tags { max-width: var(--readw); margin-top: 2.5rem; font-size: 0.72rem; }
.tr-single__tags a { color: var(--ink-dim); }
.tr-single__tags a:hover { color: var(--teal); }

.tr-single__nav {
	max-width: var(--readw); display: flex; justify-content: space-between; gap: 1rem;
	margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-size: 0.78rem;
}
.tr-single__nav a { color: var(--ink-dim); max-width: 45%; }
.tr-single__nav a:hover { color: var(--teal); }
.tr-single__next { text-align: right; margin-left: auto; }

/* ==========================================================================
   404
   ========================================================================== */
.tr-404 { padding-block: clamp(4rem, 12vw, 9rem); text-align: center; }
.tr-404__code { color: var(--signal); margin-bottom: 1.2rem; }
.tr-404__title { font-family: var(--f-display); font-weight: 700; font-size: clamp(2rem, 6vw, 3.5rem); color: var(--ink-bright); }
.tr-404__copy { color: var(--ink-dim); max-width: 40ch; margin: 1rem auto 2rem; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.tr-foot {
	margin-top: clamp(3rem, 8vw, 6rem); border-top: 1px solid var(--line);
	background: linear-gradient(180deg, transparent, rgba(10, 20, 34, 0.6));
	position: relative; z-index: 2;
}
.tr-foot__grid {
	max-width: var(--maxw); margin-inline: auto; display: grid; gap: var(--gap);
	grid-template-columns: 1fr; padding-block: clamp(2.5rem, 6vw, 4rem);
}
@media (min-width: 720px) { .tr-foot__grid { grid-template-columns: 2fr 1fr 1fr; } }
.tr-foot__cell--brand .tr-wordmark__main { font-size: 1.4rem; }
.tr-foot__blurb { color: var(--ink-dim); margin-top: 0.8rem; max-width: 32ch; }
.tr-foot__h { font-family: var(--f-mono); font-size: 0.7rem; color: var(--teal); letter-spacing: 0.1em; margin-bottom: 1rem; }
.tr-foot__list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.tr-foot__list a { color: var(--ink-dim); font-size: 0.9rem; }
.tr-foot__list a:hover { color: var(--ink-bright); }
.tr-foot__base {
	max-width: var(--maxw); margin-inline: auto; display: flex; justify-content: space-between;
	flex-wrap: wrap; gap: 0.8rem; padding-block: 1.2rem; border-top: 1px solid var(--line);
	font-family: var(--f-mono); font-size: 0.66rem; color: var(--ink-dim);
}

/* ==========================================================================
   REVEAL ANIMATION (driven by app.js IntersectionObserver)
   ========================================================================== */
[data-tr-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
[data-tr-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
	html { scroll-behavior: auto; }
	[data-tr-reveal] { opacity: 1; transform: none; }
}

/* ==========================================================================
   RESPONSIVE — mobile nav
   ========================================================================== */
@media (max-width: 880px) {
	.tr-nav__toggle { display: inline-flex; }
	.tr-nav__list {
		position: fixed; inset: 4rem 0 auto 0; z-index: 25;
		flex-direction: column; gap: 0; background: var(--abyss);
		border-bottom: 1px solid var(--line-strong);
		transform: translateY(-120%); transition: transform 0.35s var(--ease);
		font-size: 1rem;
	}
	.tr-nav.is-open .tr-nav__list { transform: none; }
	.tr-nav__list li { border-top: 1px solid var(--line); }
	.tr-nav__list a { display: block; padding: 1rem var(--bleed); }
	.tr-wordmark__tag { display: none; }
}
