/* ==========================================================================
   ACP Codes - the code tracker block.

   Matches the ACP theme's card treatment (white ground, mint hairline, no radius, no shadow,
   border turns green on hover), but every theme variable it borrows has a literal fallback so
   the block still looks right under any other theme. Nothing here names Obviously or Proxima
   Nova: those are Adobe Fonts the theme loads, so type is inherited rather than declared.

   A server's own colour arrives as --acp-codes-accent on its panel and its tab, set inline by
   includes/render.php; servers without one inherit ACP green from the block root, which is why
   the fallback is declared here rather than repeated at every use.

   Sized and spaced to match the pin tracker, so the two pages read as one site.
   ========================================================================== */

.acp-codes {
	--acp-codes-ink: var(--wp--preset--color--contrast, #0f1f16);
	--acp-codes-muted: var(--wp--preset--color--muted, #5c6e63);
	--acp-codes-card: var(--acp-card-bg, var(--wp--preset--color--base, #fff));
	--acp-codes-line: var(--acp-card-border, var(--wp--preset--color--border, #d3e8da));
	--acp-codes-surface: var(--wp--preset--color--surface, #f2f8f4);
	--acp-codes-green: var(--acp-green, var(--wp--preset--color--primary, #00793d));
	--acp-codes-green-dark: var(--acp-green-dark, var(--wp--preset--color--primary-dark, #005a2d));
	--acp-codes-accent-warm: var(--acp-accent, var(--wp--preset--color--accent, #e3be92));
	--acp-codes-gap: var(--acp-gap, 1.75rem);

	/* Overridden inline per server. */
	--acp-codes-accent: var(--acp-codes-green);
}

/* The theme's header is fixed and about 86px tall, so a jump link would otherwise land with
   the server heading tucked underneath it. */
.acp-codes__panel {
	scroll-margin-top: calc(var(--acp-header-h, 86px) + 1.5rem);
}

.acp-codes__panel + .acp-codes__panel {
	margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

/* With JS the panels are switched rather than stacked, so the gap between them is meaningless
   and the one on show should sit right under the tabs. */
.acp-codes.is-tabbed .acp-codes__panel + .acp-codes__panel {
	margin-top: 0;
}

/* Stated rather than assumed: codes.js hides a panel with the hidden attribute, and a theme
   that has no [hidden] rule of its own would leave every server on the page at once. */
.acp-codes__panel[hidden] {
	display: none;
}

/* --- The switcher -----------------------------------------------------------
   Server-side this is a plain list of jump links; assets/codes.js gives it the tab roles once
   it can honour them. Both states are styled the same, because both do the same job.
   -------------------------------------------------------------------------- */

.acp-codes__tabs {
	margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
	border-bottom: 1px solid var(--acp-codes-line);
}

.acp-codes__tablist {
	display: flex;
	flex-wrap: wrap;
	gap: 0 .35rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.acp-codes__tab-item {
	margin: 0;
}

.acp-codes__tab {
	display: block;
	padding: .7rem 1.1rem;
	/* Sits on top of the tablist's own hairline so the current tab's marker replaces it rather
	   than doubling it. */
	margin-bottom: -1px;
	border-bottom: 3px solid transparent;
	color: var(--acp-codes-muted);
	font-size: .9rem;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	text-decoration: none;
	transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}

.acp-codes__tab:hover,
.acp-codes__tab:focus {
	color: var(--acp-codes-green);
	background: var(--acp-codes-surface);
}

/* aria-selected is what codes.js sets; .is-current is the same state for the no-JS case, where
   nothing is selected and so nothing carries it. Both are listed so the rule survives either. */
.acp-codes__tab[aria-selected="true"],
.acp-codes__tab.is-current {
	color: var(--acp-codes-ink);
	border-bottom-color: var(--acp-codes-accent);
	background: transparent;
}

/* --- Panel head ------------------------------------------------------------- */

.acp-codes__panel-head {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1rem;
}

.acp-codes__logo {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 120px;
}

.acp-codes__logo img {
	display: block;
	max-width: 100%;
	height: auto;
}

/* Sized like .acp-section__title in the theme, but without its green left bar: the switcher
   above already says which server this is. */
.acp-codes__server {
	margin: 0;
	font-size: clamp(1.6rem, 3vw, 2.35rem);
	font-weight: 800;
	line-height: 1;
	text-transform: uppercase;
}

/* The theme gives every h2 and h3 inside page content a top margin (theme.css:409); the tracker
   sets its own rhythm, so these out-specify it rather than fighting it per-property. */
.acp-codes .acp-codes__panel-head .acp-codes__server,
.acp-codes .acp-codes__group .acp-codes__group-title,
.acp-codes .acp-codes__archive .acp-codes__group-title,
.acp-codes .acp-codes__claim .acp-codes__group-title {
	margin-top: 0;
}

.acp-codes__intro {
	margin: -.35rem 0 clamp(1.5rem, 3vw, 2rem);
	color: var(--acp-codes-muted);
	font-size: .95rem;
	line-height: 1.6;
}

/* --- Groups ----------------------------------------------------------------- */

.acp-codes__group,
.acp-codes__archive,
.acp-codes__claim {
	margin-bottom: clamp(2rem, 4vw, 3rem);
}

.acp-codes__group:last-child,
.acp-codes__archive:last-child,
.acp-codes__claim:last-child {
	margin-bottom: 0;
}

/* No left bar, and sized clearly above the code strings beneath it: a section heading that is
   the same size as the rows it contains reads as another row. Matches the pin tracker. */
.acp-codes__group-title {
	margin: 0 0 1.1rem;
	font-size: 1.4rem;
	font-weight: 800;
	line-height: 1;
	letter-spacing: .05em;
	text-transform: uppercase;
}

/* --- One code --------------------------------------------------------------- */

.acp-codes__list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.acp-code {
	padding: clamp(1.1rem, 2.2vw, 1.5rem);
	background: var(--acp-codes-card);
	border: 1px solid var(--acp-codes-line);
	transition: border-color .2s ease;
}

.acp-code:hover {
	border-color: var(--acp-codes-green);
}

.acp-code__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .6rem 1rem;
}

/* --- The code string --------------------------------------------------------
   The one thing on the page anybody is here for, and the one thing they have to reproduce
   exactly, so it is set as a field to be taken rather than as a heading to be read.

   A monospaced stack with real tracking is not decoration: these are typed into a game by hand
   when the copy button is not available, and 0/O and 1/I have to be told apart.
   -------------------------------------------------------------------------- */

.acp-code__string {
	display: inline-flex;
	align-items: center;
	gap: .5rem;
	margin: 0;
	padding: .5rem .75rem;
	background: var(--acp-codes-surface);
	border: 1px solid var(--acp-codes-line);
}

.acp-code__value {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	font-size: clamp(1.05rem, 1.8vw, 1.3rem);
	font-weight: 700;
	letter-spacing: .08em;
	line-height: 1.2;
	color: var(--acp-codes-ink);
	overflow-wrap: anywhere;
	/* Double-click should select the code and nothing else. */
	user-select: all;
}

/* Injected by codes.js, so it never exists where it could not work. */
.acp-code__copy {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: .25rem .5rem;
	background: transparent;
	border: 1px solid var(--acp-codes-line);
	border-radius: 0;
	color: var(--acp-codes-green-dark);
	font-family: inherit;
	font-size: .7rem;
	font-weight: 800;
	letter-spacing: .06em;
	line-height: 1.4;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.acp-code__copy:hover,
.acp-code__copy:focus-visible {
	background: var(--acp-codes-green);
	border-color: var(--acp-codes-green);
	color: var(--wp--preset--color--base, #fff);
}

.acp-code__copy.is-copied {
	background: var(--acp-codes-accent-warm);
	border-color: var(--acp-codes-accent-warm);
	color: var(--acp-codes-ink);
}

/* --- Expiry and badge ------------------------------------------------------- */

.acp-code__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .4rem .6rem;
	margin: 0;
}

.acp-code__expiry {
	color: var(--acp-codes-muted);
	font-size: .78rem;
	font-weight: 800;
	letter-spacing: .06em;
	text-transform: uppercase;
}

.acp-code__badge {
	display: inline-block;
	padding: .2em .6em;
	border-radius: 999px;
	background: var(--acp-codes-accent-warm);
	color: var(--acp-codes-ink);
	font-size: .62rem;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
	white-space: nowrap;
}

/* --- What it unlocks --------------------------------------------------------
   A run of chips rather than a bulleted column: most codes unlock one or two things, but the
   Pride and accessibility codes unlock ten, and ten bullets is a wall where ten chips is a line.
   -------------------------------------------------------------------------- */

.acp-code__rewards {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem .45rem;
	margin: .9rem 0 0;
	padding: 0;
	list-style: none;
}

.acp-code__reward {
	margin: 0;
	padding: .2em .6em;
	background: var(--acp-codes-surface);
	border: 1px solid var(--acp-codes-line);
	color: var(--acp-codes-ink);
	font-size: .85rem;
	line-height: 1.5;
}

.acp-code__note {
	margin-top: .8rem;
	color: var(--acp-codes-muted);
	font-size: .95rem;
	line-height: 1.6;
}

.acp-code__note > :first-child { margin-top: 0; }
.acp-code__note > :last-child { margin-bottom: 0; }

/* --- The screenshot ---------------------------------------------------------
   At size, like the pin tracker's: the picture is what shows you what you are getting. The
   theme's lightbox (assets/js/lightbox.js) picks these up on its own.
   -------------------------------------------------------------------------- */

.acp-code__shots {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	align-items: start;
	gap: .75rem;
	margin-top: 1rem;
}

/* The doubled class is load-bearing. The theme centres every figure in post content with
   `margin-left: auto; margin-right: auto` (theme.css:755) at a specificity of three classes and
   an element, and an auto margin on a grid item shrinks it to its content and centres it. This
   has to out-specify that rule, not merely follow it. */
.acp-codes .acp-code__shots figure.acp-code__shot.acp-code__shot {
	margin: 0;
	border: 1px solid var(--acp-codes-line);
	background: var(--acp-codes-surface);
}

/* Never cropped: what is in the picture is the whole point of the code. */
.acp-codes .acp-code__shot img {
	display: block;
	width: 100%;
	height: auto;
	margin-left: 0;
	margin-right: 0;
	cursor: zoom-in;
}

/* --- Expired codes ----------------------------------------------------------
   Hairline-separated bands rather than boxed codes: the archive is a record to scan, and a
   dead code laid out like a live one invites somebody to try it.
   -------------------------------------------------------------------------- */

.acp-codes__rows {
	margin: 0;
	padding: 0;
	list-style: none;
	background: var(--acp-codes-card);
	border: 1px solid var(--acp-codes-line);
}

.acp-code-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: .2rem .9rem;
	margin: 0;
	padding: .9rem 1.25rem;
}

.acp-code-row + .acp-code-row {
	border-top: 1px solid var(--acp-codes-line);
}

.acp-code-row__string {
	margin: 0;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	font-weight: 700;
	letter-spacing: .06em;
	/* Struck through, because the one thing worth knowing about it is that it will not work. */
	text-decoration: line-through;
	color: var(--acp-codes-muted);
	overflow-wrap: anywhere;
}

.acp-code-row__rewards {
	margin: 0;
	color: var(--acp-codes-muted);
	font-size: .88rem;
}

/* Pushed to the end of the row so the dates line up down the list rather than trailing each
   code at a different place. */
.acp-code-row__dates {
	margin: 0 0 0 auto;
	color: var(--acp-codes-muted);
	font-size: .82rem;
	white-space: nowrap;
}

/* --- How to claim ----------------------------------------------------------- */

.acp-codes__claim-body {
	background: var(--acp-codes-card);
	border: 1px solid var(--acp-codes-line);
	padding: clamp(1.25rem, 2.5vw, 2rem);
	color: var(--acp-codes-ink);
	font-size: .98rem;
	line-height: 1.7;
}

.acp-codes__claim-body > :first-child { margin-top: 0; }
.acp-codes__claim-body > :last-child { margin-bottom: 0; }

.acp-codes__claim-body img {
	height: auto;
	max-width: 100%;
}

/* --- Footer links ----------------------------------------------------------- */

.acp-codes__links {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem 1.5rem;
	margin: clamp(1.5rem, 3vw, 2rem) 0 0;
	padding-top: 1rem;
	border-top: 1px solid var(--acp-codes-line);
}

.acp-codes__link {
	color: var(--acp-codes-green-dark);
	font-size: .85rem;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	text-decoration: none;
	transition: color .15s ease;
}

.acp-codes__link:hover,
.acp-codes__link:focus {
	color: var(--acp-codes-green);
	text-decoration: underline;
}

/* --- The copy announcement --------------------------------------------------
   Hidden but readable. Declared here rather than borrowed from the theme's .screen-reader-text,
   because codes.js appends this element and it must not appear as a blank gap under the codes
   in a theme that never defined that class.
   -------------------------------------------------------------------------- */

.acp-codes__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --- Empty state ------------------------------------------------------------ */

.acp-codes__empty {
	margin: 0;
	padding: 2rem;
	background: var(--acp-codes-surface);
	border: 1px dashed var(--acp-codes-line);
	text-align: center;
	color: var(--acp-codes-muted);
}

/* --- Responsive ------------------------------------------------------------- */

@media (max-width: 600px) {
	/* Three servers in a wide display face do not fit a phone, and wrapping them onto two rows
	   makes the switcher taller than the heading under it. One scrolling row keeps it a
	   switcher. */
	.acp-codes__tablist {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: thin;
	}

	.acp-codes__tab {
		white-space: nowrap;
	}

	.acp-codes__panel-head {
		gap: .75rem;
	}

	.acp-codes__logo {
		max-width: 72px;
	}

	/* The code field takes the width rather than sitting beside the expiry, so a long code has
	   somewhere to go. */
	.acp-code__string {
		display: flex;
		width: 100%;
	}

	.acp-code-row__dates {
		margin-left: 0;
	}
}

@media (max-width: 480px) {
	.acp-code__shots {
		gap: .5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.acp-code,
	.acp-codes__tab,
	.acp-code__copy,
	.acp-codes__link {
		transition: none;
	}
}
