/**
 * Codes pages (/codes/<game>/) and the /codes/ index (inc/codes-page*.php,
 * inc/codes-index.php). Built on the theme tokens; under the Game OS layout
 * (body.osx) the same tokens are mapped to the --o-* palette, so one set of
 * rules serves both shells. Flat surfaces, one accent, the Cut on tiles.
 * Mobile first: the code tables turn into one card per code below 700px.
 */

.cxp {
	--cxp-display: var(--wp--preset--font-family--display, inherit);
	--cxp-body: var(--wp--preset--font-family--body, inherit);
	--cxp-tile: var(--surface);
	--cxp-tile-ink: var(--ink);
	--cxp-tile-muted: var(--muted);
	--cxp-gap: 18px;
	display: grid;
	gap: var(--cxp-gap);
	min-width: 0;
	color: var(--ink);
	font-family: var(--cxp-body);
}
.osx .cxp {
	--surface: var(--o-ground); --bg: var(--o-card); --ink: var(--o-ink); --muted: var(--o-muted); --line: var(--o-line);
	--accent: var(--o-accent-text); --accent-graphic: var(--o-accent-hi); --accent-ink: var(--o-accent-ink);
	--wp--preset--font-family--mono: var(--o-mono, ui-monospace, monospace);
	--cxp-display: var(--o-display); --cxp-body: var(--o-body);
	--cxp-tile: var(--o-tile); --cxp-tile-ink: var(--o-tile-ink); --cxp-tile-muted: var(--o-tile-muted);
	--cxp-gap: var(--o-gap);
}
.cxp-page .cxp { max-width: 1320px; margin: 24px auto 48px; padding-inline: 16px; }

/* Hero: breadcrumb, H1 with the month, freshness line, over the game art */
.cxp-hero { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 230px; overflow: hidden; background: var(--cxp-tile); color: #fff; }
.cxp-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cxp-hero__scrim { position: absolute; inset: 0; background: rgb(20 10 28 / 0.66); }
.cxp-hero__body { position: relative; z-index: 1; display: grid; gap: 12px; padding: 28px 30px; }
.cxp-hero--index { min-height: 0; }
.cxp-hero--index .cxp-hero__body { padding-block: 30px 32px; }
.cxp-crumbs { display: flex; flex-wrap: wrap; gap: 6px 8px; font-size: 14px; color: #E7DCEE; }
.cxp-crumbs a { color: inherit; text-decoration: none; }
.cxp-crumbs a:hover { color: #fff; text-decoration: underline; }
.cxp-crumbs [aria-current] { color: #fff; }
.cxp-title { margin: 0; max-width: 24ch; font: 900 clamp(30px, 3.6vw, 50px)/1 var(--cxp-display); font-stretch: 108%; letter-spacing: -0.015em; color: #fff; text-wrap: balance; }
.cxp-fresh { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 15px; color: #E7DCEE; }
.cxp-fresh strong { color: #fff; }
.cxp-hero .cxp-lede { color: #F1EAF5; max-width: 70ch; }

/* Columns: the reading tile and a side column */
.cxp-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: var(--cxp-gap); align-items: start; }
.cxp-read { min-width: 0; padding: 32px 38px 38px; background: var(--bg); box-shadow: 0 1px 0 var(--line); font-size: 17px; line-height: 1.65; }
.osx .cxp-read { color: var(--o-body-ink); box-shadow: 0 1px 0 var(--o-line), var(--o-shade); }
.cxp-read a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.cxp-lede { margin: 0; font-size: 19px; line-height: 1.55; color: var(--ink); }
.cxp-sec { scroll-margin-top: 20px; }
.cxp-sec h2, .cxp-content h2 { margin: 2.4rem 0 0.9rem; padding-bottom: 14px; font: 900 clamp(26px, 2.6vw, 34px)/1.05 var(--cxp-display); font-stretch: 80%; color: var(--ink); text-wrap: balance;
	background-image: linear-gradient(var(--accent-graphic), var(--accent-graphic)), linear-gradient(var(--line), var(--line)); background-position: 0 100%, 0 calc(100% - 1px); background-size: 56px 3px, 100% 1px; background-repeat: no-repeat; }
.cxp-sec h3, .cxp-content h3 { margin: 1.6rem 0 0.5rem; font: 800 20px/1.2 var(--cxp-display); color: var(--ink); }
.cxp-sec p, .cxp-content p { margin: 0.7rem 0 0; }
.cxp-muted { color: var(--muted); }
.cxp-empty { margin: 0; padding: 16px 18px; background: var(--surface); color: var(--muted); }

/* The page's own content (item 7): plain HTML, often moved from an old
   guide, so its figures, tables and callouts are styled here (guide-v2.css
   does not load on codes pages). */
.cxp-content { margin-top: 0.5rem; }
.cxp-content figure { margin: 2rem 0 0; }
.cxp-content img { display: block; max-width: 100%; height: auto; }
.cxp-content figure img { width: 100%; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%); }
.cxp-content figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }
.cxp-content ul, .cxp-content ol { margin: 0.7rem 0 0; padding-left: 1.25rem; }
.cxp-content li + li { margin-top: 0.35rem; }
.cxp-content .g2-table-wrap { margin-top: 1rem; overflow-x: auto; }
.cxp-content table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.cxp-content th, .cxp-content td { padding: 10px 12px 10px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.cxp-content thead th { font-size: 14px; color: var(--muted); }
.cxp-content tbody th { font-weight: 700; color: var(--ink); }
.cxp-content .g2-callout { margin-top: 1.25rem; padding: 14px 16px; background: var(--surface); border-inline-start: 3px solid var(--accent-graphic); }
.cxp-content .g2-callout p { margin: 0; }

/* Code tables */
.cxp-table-wrap { margin-top: 4px; }
.cxp-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.cxp-table th { padding: 0 12px 10px 0; text-align: left; font-weight: 700; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); }
.cxp-table td { padding: 16px 12px 16px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.cxp-table td:last-child, .cxp-table th:last-child { padding-right: 0; }
.cxp-table .cx-code { display: table-row; padding: 0; background: none; }
.cxp-t__code { width: 1%; white-space: nowrap; }
.cxp-table .cx-code__reward { display: block; font-weight: 600; color: var(--ink); line-height: 1.4; }
.cxp-table .cx-code__meta { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.cxp-note { margin: 4px 0 0 !important; font-size: 14px; color: var(--muted); }
.cxp-table time { white-space: nowrap; }
.cxp-ends { display: block; font-size: 14px; color: var(--muted); }
.cxp-table .cx-new { float: none; display: inline-block; margin: 0 0 0 6px; vertical-align: 1px; }
.cxp-table--old td { color: var(--muted); padding-block: 12px; }
.cxp-table--old .cx-code__code { padding: 0; background: none; color: var(--muted); text-decoration: line-through; font-size: 15px; }
.cxp-table--old .cx-code--expired { border: 0; }

/* How to redeem */
.cxp-steps { margin: 0.4rem 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.cxp-steps li { counter-increment: s; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.cxp-steps li::before { content: counter(s); display: grid; place-items: center; width: 32px; height: 32px; background: var(--accent-graphic); color: var(--accent-ink); font: 800 15px/1 var(--cxp-display); align-self: start; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%); }
.cxp-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 1rem; padding: 11px 18px; background: var(--accent-graphic); color: var(--accent-ink) !important; font-weight: 800; text-decoration: none; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%); }
.cxp-btn:hover { background: var(--ink); color: var(--bg) !important; }

/* Lists: not working, channels, sources */
.cxp-list { margin: 0.6rem 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.cxp-list li { position: relative; padding-left: 22px; }
.cxp-list li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 9px; height: 9px; background: var(--accent-graphic); transform: skewX(-17.745deg); }
.cxp-list--src code { font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace); font-weight: 700; color: var(--ink); margin-right: 6px; }

/* FAQ */
.cxp-faq { border-bottom: 1px solid var(--line); }
.cxp-faq summary { position: relative; padding: 16px 36px 16px 0; cursor: pointer; list-style: none; font-weight: 700; font-size: 17px; color: var(--ink); }
.cxp-faq summary::-webkit-details-marker { display: none; }
.cxp-faq summary::after { content: "+"; position: absolute; right: 4px; top: 12px; font: 700 24px/1 var(--cxp-display); color: var(--accent); }
.cxp-faq[open] summary::after { content: "\2212"; }
.cxp-faq p { margin: 0 0 16px !important; }

/* More guides */
.cxp-guides { margin: 0.4rem 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cxp-guides a { display: grid; gap: 6px; text-decoration: none; color: var(--ink) !important; }
.cxp-guides img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface); clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%); }
.cxp-guide__kind { font-size: 14px; font-weight: 700; color: var(--accent); }
.cxp-guide__title { font-weight: 700; line-height: 1.3; }
.cxp-guides a:hover .cxp-guide__title { text-decoration: underline; }
.cxp-more { display: inline-block; margin-top: 1rem; font-weight: 700; text-decoration: none; }
.cxp-more:hover { text-decoration: underline; }

/* Side column */
.cxp-side { position: sticky; top: 16px; display: grid; gap: var(--cxp-gap); min-width: 0; }
.cxp-side > * { max-width: 100%; box-sizing: border-box; }
.cxp-gcard { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px; background: var(--bg); color: var(--ink); text-decoration: none; box-shadow: 0 1px 0 var(--line); }
.cxp-gcard--plain { grid-template-columns: minmax(0, 1fr); }
.cxp-gcard img { width: 64px; aspect-ratio: 3 / 4; object-fit: cover; }
.cxp-gcard strong { display: block; font: 800 18px/1.15 var(--cxp-display); }
.cxp-gcard span span { font-size: 14px; color: var(--accent); }
.cxp-toc { padding: 18px 20px; background: var(--bg); box-shadow: 0 1px 0 var(--line); }
.cxp-toc__head { margin: 0 0 8px; font: 800 16px/1.2 var(--cxp-display); color: var(--ink); }
.cxp-toc ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.cxp-toc a { display: block; padding: 6px 0; color: var(--muted); text-decoration: none; font-size: 15px; }
.cxp-toc a:hover { color: var(--accent); }

/* Index cards */
.cxp-cards { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--cxp-gap); }
.cxp-card { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px; align-items: center; height: 100%; padding: 16px; background: var(--bg); color: var(--ink); text-decoration: none; box-shadow: 0 1px 0 var(--line); }
.osx .cxp-card, .osx .cxp-gcard, .osx .cxp-toc { box-shadow: 0 1px 0 var(--o-line), var(--o-shade); }
.cxp-card img, .cxp-card__ph { width: 84px; aspect-ratio: 3 / 4; object-fit: cover; background: var(--surface); }
.cxp-card__body { display: grid; gap: 4px; min-width: 0; }
.cxp-card__title { font: 800 20px/1.15 var(--cxp-display); }
.cxp-card__n { font-weight: 700; color: var(--muted); }
.cxp-card.is-live .cxp-card__n { color: var(--accent); }
.cxp-card__meta { font-size: 14px; color: var(--muted); }
.cxp-card:hover .cxp-card__title { text-decoration: underline; }

/* Tablet: side column under the text, section list dropped */
@media (max-width: 980px) {
	.cxp-cols { grid-template-columns: minmax(0, 1fr); }
	.cxp-side { position: static; }
	.cxp-toc { display: none; }
}

/* Phone: one card per code, labels from data-label (sentence case) */
@media (max-width: 700px) {
	.cxp-hero { min-height: 200px; }
	.cxp-hero__body { padding: 20px 16px; gap: 10px; }
	.cxp-title { font-size: 30px; }
	.cxp-fresh { font-size: 14px; }
	.cxp-read { padding: 22px 16px 28px; font-size: 16.5px; }
	.osx .cxp-read, .osx .cxp-hero { margin-inline: -12px; }
	.cxp-lede { font-size: 17.5px; }
	.cxp-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	.cxp-table, .cxp-table tbody { display: block; }
	.cxp-table .cx-code { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 14px; margin-bottom: 10px; padding: 14px; background: var(--surface); }
	.cxp-table td { display: block; padding: 0; border: 0; }
	.cxp-t__code, .cxp-t__rew { grid-column: 1 / -1; width: auto; white-space: normal; }
	.cxp-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 13px; font-weight: 700; color: var(--muted); }
	.cxp-table time { white-space: normal; }
	.cxp-table .cx-code__copy { width: 100%; }
	.cxp-table .cx-code__code { flex: 1; font-size: 17px; }
	.cxp-table .cx-code__act { padding-inline: 18px; }
	.cxp-table--old .cx-code { background: none; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
	.cxp-guides { grid-template-columns: minmax(0, 1fr); }
	.cxp-cards { grid-template-columns: minmax(0, 1fr); }
}
