/**
 * Organic Growth - component library.
 *
 * Every visual element used across the 27 member screens is defined once here.
 * No screen writes its own button or card styling.
 *
 * Touch targets are at least 44px high throughout. Most of this platform's
 * members will be using a phone, and a control too small to tap reliably is a
 * control that loses you a completed task.
 *
 * @package OrganicGrowth\Core
 * @since   1.4.0
 */

/* =================================================================
   Buttons
   =================================================================

   EVERY BUTTON RULE IS PREFIXED WITH .og-app / .og-scope ON PURPOSE.

   A button is often a link, and both this plugin's own base styles and the
   surrounding WordPress theme will have rules targeting `a`. A theme rule such
   as `.entry-content a { color: ... }` has enough weight to repaint a button's
   text and make it vanish against its own background.

   Prefixing raises these rules above anything a theme is likely to write, so a
   button looks the same on every theme the site may ever use.
   ================================================================= */

.og-app .og-btn,
.og-scope .og-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--og-space-2);
	min-height: 44px;
	padding: 0 var(--og-space-4);
	border: 1px solid transparent;
	border-radius: var(--og-radius);
	background: var(--og-bg-sunken);
	color: var(--og-text);
	font-family: inherit;
	font-size: var(--og-text-sm);
	font-weight: var(--og-weight-semibold);
	line-height: 1;
	letter-spacing: 0.005em;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background var(--og-transition), border-color var(--og-transition),
		color var(--og-transition), box-shadow var(--og-transition),
		transform var(--og-transition);
	-webkit-appearance: none;
	appearance: none;
}

.og-app .og-btn:hover,
.og-scope .og-btn:hover {
	text-decoration: none;
}

.og-app .og-btn:active,
.og-scope .og-btn:active {
	transform: translateY(1px);
	box-shadow: none;
}

.og-app .og-btn[disabled],
.og-app .og-btn[aria-disabled="true"],
.og-scope .og-btn[disabled],
.og-scope .og-btn[aria-disabled="true"] {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
	box-shadow: none;
}

/*
 * The primary button carries a soft tinted shadow rather than a grey one, so it
 * sits on the page rather than floating above it, and lifts very slightly on
 * hover. Restraint is deliberate: an interface a member uses for hours should
 * not be constantly animating at them.
 */
.og-app .og-btn--primary,
.og-scope .og-btn--primary {
	background: var(--og-primary);
	border-color: var(--og-primary);
	color: var(--og-primary-text);
	box-shadow: 0 1px 2px rgba(6, 31, 36, 0.16);
}

.og-app .og-btn--primary:hover,
.og-scope .og-btn--primary:hover {
	background: var(--og-primary-hover);
	border-color: var(--og-primary-hover);
	color: var(--og-primary-text);
	box-shadow: 0 2px 8px rgba(6, 31, 36, 0.2);
	transform: translateY(-1px);
}

.og-app .og-btn--secondary,
.og-scope .og-btn--secondary {
	background: var(--og-bg-raised);
	border-color: var(--og-border-strong);
	color: var(--og-text);
	box-shadow: var(--og-shadow-sm);
}

.og-app .og-btn--secondary:hover,
.og-scope .og-btn--secondary:hover {
	background: var(--og-bg-raised);
	border-color: var(--og-primary);
	color: var(--og-primary);
	transform: translateY(-1px);
}

.og-app .og-btn--ghost,
.og-scope .og-btn--ghost {
	background: transparent;
	border-color: transparent;
	color: var(--og-text-muted);
}

.og-app .og-btn--ghost:hover,
.og-scope .og-btn--ghost:hover {
	background: var(--og-bg-sunken);
	color: var(--og-text);
}

.og-app .og-btn--danger,
.og-scope .og-btn--danger {
	background: var(--og-danger);
	border-color: var(--og-danger);
	color: #fff;
	box-shadow: 0 1px 2px rgba(6, 31, 36, 0.16);
}

.og-app .og-btn--danger:hover,
.og-scope .og-btn--danger:hover {
	filter: brightness(0.93);
	color: #fff;
	transform: translateY(-1px);
}

/* Brass appears on a button only where Coins are spent or claimed. */
.og-app .og-btn--coin,
.og-scope .og-btn--coin {
	background: var(--og-coin);
	border-color: var(--og-coin);
	color: #fff;
	box-shadow: 0 1px 2px rgba(6, 31, 36, 0.16);
}

.og-app .og-btn--coin:hover,
.og-scope .og-btn--coin:hover {
	filter: brightness(0.94);
	color: #fff;
	transform: translateY(-1px);
}

.og-app .og-btn--sm,
.og-scope .og-btn--sm {
	min-height: 34px;
	padding: 0 var(--og-space-3);
	font-size: var(--og-text-xs);
	gap: var(--og-space-1);
}

.og-app .og-btn--lg,
.og-scope .og-btn--lg {
	min-height: 52px;
	padding: 0 var(--og-space-5);
	font-size: var(--og-text-base);
}

.og-app .og-btn--block,
.og-scope .og-btn--block {
	display: flex;
	width: 100%;
}

/* A button waiting on the server. */
.og-app .og-btn.is-busy,
.og-scope .og-btn.is-busy {
	position: relative;
	color: transparent !important;
	pointer-events: none;
	transform: none;
}

.og-app .og-btn.is-busy > *,
.og-scope .og-btn.is-busy > * {
	visibility: hidden;
}

.og-app .og-btn.is-busy::after,
.og-scope .og-btn.is-busy::after {
	content: "";
	position: absolute;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.9);
	border-top-color: transparent;
	border-radius: 50%;
	animation: og-spin 640ms linear infinite;
}

.og-app .og-btn--secondary.is-busy::after,
.og-app .og-btn--ghost.is-busy::after,
.og-scope .og-btn--secondary.is-busy::after,
.og-scope .og-btn--ghost.is-busy::after {
	border-color: var(--og-border-strong);
	border-top-color: transparent;
}

@keyframes og-spin {

	to {
		transform: rotate(360deg);
	}
}

/* =================================================================
   Cards
   ================================================================= */

.og-card {
	background: var(--og-bg-raised);
	border: 1px solid var(--og-border);
	border-radius: var(--og-radius-lg);
	box-shadow: var(--og-shadow-sm);
	overflow: hidden;
	transition: border-color var(--og-transition), box-shadow var(--og-transition);
}

/* Only cards that are themselves clickable respond to the pointer. */
.og-card--interactive:hover {
	border-color: var(--og-border-strong);
	box-shadow: var(--og-shadow);
}

.og-card__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--og-space-3);
	padding: var(--og-space-4) var(--og-space-5);
	border-bottom: 1px solid var(--og-border);
}

.og-card__title {
	margin: 0;
	font-size: var(--og-text-base);
	font-weight: var(--og-weight-semibold);
}

.og-card__body {
	padding: var(--og-space-5);
}

.og-card__footer {
	padding: var(--og-space-4) var(--og-space-5);
	border-top: 1px solid var(--og-border);
	background: var(--og-bg);
}

.og-card--flush .og-card__body {
	padding: 0;
}

/* A statistic card. The figure leads; the label supports it. */
.og-stat {
	padding: var(--og-space-5);
}

.og-stat__label {
	display: block;
	margin-bottom: var(--og-space-2);
	font-size: var(--og-text-2xs);
	font-weight: var(--og-weight-semibold);
	letter-spacing: var(--og-tracking-wide);
	text-transform: uppercase;
	color: var(--og-text-subtle);
}

.og-stat__value {
	display: block;
	font-size: var(--og-text-2xl);
	font-weight: var(--og-weight-bold);
	line-height: 1.15;
	letter-spacing: var(--og-tracking-tight);
}

.og-stat__meta {
	display: block;
	margin-top: var(--og-space-2);
	font-size: var(--og-text-xs);
	color: var(--og-text-muted);
}

/* =================================================================
   Badges
   ================================================================= */

.og-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px;
	border-radius: var(--og-radius-full);
	font-size: var(--og-text-2xs);
	font-weight: var(--og-weight-semibold);
	line-height: 1.6;
	letter-spacing: 0.02em;
	white-space: nowrap;
	background: var(--og-bg-sunken);
	color: var(--og-text-muted);
}

.og-badge--success {
	background: var(--og-success-soft);
	color: var(--og-success);
}

.og-badge--warning {
	background: var(--og-warning-soft);
	color: var(--og-warning);
}

.og-badge--danger {
	background: var(--og-danger-soft);
	color: var(--og-danger);
}

.og-badge--info {
	background: var(--og-info-soft);
	color: var(--og-info);
}

.og-badge--primary {
	background: var(--og-primary-soft);
	color: var(--og-primary);
}

.og-badge--coin {
	background: var(--og-coin-soft);
	color: var(--og-coin);
}

/* =================================================================
   Alerts
   ================================================================= */

/*
 * An alert explains what happened and what to do next. It never merely sets a
 * mood, and it never apologises.
 */

.og-alert {
	display: flex;
	gap: var(--og-space-3);
	padding: var(--og-space-4);
	border: 1px solid var(--og-border);
	border-left-width: 3px;
	border-radius: var(--og-radius);
	background: var(--og-bg-raised);
	font-size: var(--og-text-sm);
}

.og-alert__icon {
	flex-shrink: 0;
	margin-top: 1px;
}

.og-alert--success .og-alert__icon {
	color: var(--og-success);
}

.og-alert--warning .og-alert__icon {
	color: var(--og-warning);
}

.og-alert--danger .og-alert__icon {
	color: var(--og-danger);
}

.og-alert--info .og-alert__icon {
	color: var(--og-info);
}

.og-alert__body {
	flex: 1;
	min-width: 0;
}

.og-alert__title {
	margin: 0 0 var(--og-space-1);
	font-size: var(--og-text-sm);
	font-weight: var(--og-weight-semibold);
}

.og-alert__text {
	margin: 0;
	color: var(--og-text-muted);
	line-height: var(--og-leading-normal);
}

.og-alert--success {
	border-left-color: var(--og-success);
	background: var(--og-success-soft);
}

.og-alert--warning {
	border-left-color: var(--og-warning);
	background: var(--og-warning-soft);
}

.og-alert--danger {
	border-left-color: var(--og-danger);
	background: var(--og-danger-soft);
}

.og-alert--info {
	border-left-color: var(--og-info);
	background: var(--og-info-soft);
}

/* =================================================================
   Forms
   ================================================================= */

.og-field {
	margin-bottom: var(--og-space-4);
}

.og-field__label {
	display: block;
	margin-bottom: var(--og-space-2);
	font-size: var(--og-text-sm);
	font-weight: var(--og-weight-medium);
	color: var(--og-text);
}

.og-field__required {
	color: var(--og-danger);
	margin-left: 2px;
}

.og-input,
.og-select,
.og-textarea {
	display: block;
	width: 100%;
	min-height: 44px;
	padding: var(--og-space-3);
	border: 1px solid var(--og-border-strong);
	border-radius: var(--og-radius);
	background: var(--og-bg-raised);
	color: var(--og-text);
	font-family: inherit;
	font-size: var(--og-text-base);
	line-height: var(--og-leading-normal);
	transition: border-color var(--og-transition), box-shadow var(--og-transition);
	-webkit-appearance: none;
	appearance: none;
}

.og-textarea {
	min-height: 110px;
	resize: vertical;
}

.og-select {
	padding-right: var(--og-space-6);
	background-image: linear-gradient(45deg, transparent 50%, currentcolor 50%),
		linear-gradient(135deg, currentcolor 50%, transparent 50%);
	background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

.og-input:focus,
.og-select:focus,
.og-textarea:focus {
	border-color: var(--og-primary);
	box-shadow: 0 0 0 3px var(--og-primary-soft);
	outline: none;
}

.og-input::placeholder,
.og-textarea::placeholder {
	color: var(--og-text-subtle);
}

.og-input[disabled],
.og-select[disabled],
.og-textarea[disabled] {
	background: var(--og-bg-sunken);
	color: var(--og-text-subtle);
	cursor: not-allowed;
}

/* An example demonstrates. It never doubles as the label. */
.og-field__hint {
	margin-top: var(--og-space-2);
	font-size: var(--og-text-xs);
	color: var(--og-text-muted);
}

.og-field__error {
	display: none;
	margin-top: var(--og-space-2);
	font-size: var(--og-text-xs);
	font-weight: var(--og-weight-medium);
	color: var(--og-danger);
}

.og-field.has-error .og-input,
.og-field.has-error .og-select,
.og-field.has-error .og-textarea {
	border-color: var(--og-danger);
}

.og-field.has-error .og-input:focus,
.og-field.has-error .og-select:focus,
.og-field.has-error .og-textarea:focus {
	box-shadow: 0 0 0 3px var(--og-danger-soft);
}

.og-field.has-error .og-field__error {
	display: block;
}

.og-checkbox {
	display: flex;
	align-items: flex-start;
	gap: var(--og-space-3);
	min-height: 44px;
	padding: var(--og-space-2) 0;
	cursor: pointer;
	font-size: var(--og-text-sm);
}

.og-checkbox input {
	width: 20px;
	height: 20px;
	margin: 2px 0 0;
	accent-color: var(--og-primary);
	flex-shrink: 0;
}

/* =================================================================
   Tables
   ================================================================= */

.og-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.og-table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--og-text-sm);
}

.og-table th,
.og-table td {
	padding: var(--og-space-3) var(--og-space-4);
	text-align: left;
	border-bottom: 1px solid var(--og-border);
	vertical-align: middle;
}

.og-table thead th {
	font-size: var(--og-text-2xs);
	font-weight: var(--og-weight-semibold);
	letter-spacing: var(--og-tracking-wide);
	text-transform: uppercase;
	color: var(--og-text-subtle);
	background: var(--og-bg);
	white-space: nowrap;
}

.og-table tbody tr:last-child td {
	border-bottom: none;
}

.og-table tbody tr:hover {
	background: var(--og-bg);
}

.og-table__num {
	text-align: right;
	white-space: nowrap;
}

/* =================================================================
   Loading, empty and error states
   ================================================================= */

/*
 * A screen is never blank while it waits. A skeleton shows the shape of what
 * is coming, which makes the wait feel shorter and prevents the page jumping
 * when content arrives.
 */

.og-skeleton {
	background: linear-gradient(
		90deg,
		var(--og-bg-sunken) 25%,
		var(--og-border) 37%,
		var(--og-bg-sunken) 63%
	);
	background-size: 400% 100%;
	border-radius: var(--og-radius-sm);
	animation: og-shimmer 1.4s ease-in-out infinite;
}

@keyframes og-shimmer {

	0% {
		background-position: 100% 50%;
	}

	100% {
		background-position: 0 50%;
	}
}

.og-skeleton--text {
	height: 12px;
	margin-bottom: var(--og-space-2);
}

.og-skeleton--title {
	height: 20px;
	width: 45%;
	margin-bottom: var(--og-space-3);
}

.og-skeleton--line-short {
	width: 62%;
}

.og-skeleton--block {
	height: 96px;
}

.og-skeleton--circle {
	width: 44px;
	height: 44px;
	border-radius: 50%;
}

.og-spinner {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2px solid var(--og-border-strong);
	border-top-color: var(--og-primary);
	border-radius: 50%;
	animation: og-spin 640ms linear infinite;
}

/*
 * An empty screen is an invitation to act, so it always carries the action that
 * fills it.
 */

.og-state {
	padding: var(--og-space-7) var(--og-space-5);
	text-align: center;
}

.og-state__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	margin-bottom: var(--og-space-4);
	border-radius: var(--og-radius-full);
	background: var(--og-primary-soft);
	color: var(--og-primary);
	/* A faint ring gives the disc a little presence without adding a border. */
	box-shadow: 0 0 0 6px var(--og-bg-sunken);
}

.og-state__title {
	margin: 0 0 var(--og-space-2);
	font-size: var(--og-text-lg);
	font-weight: var(--og-weight-semibold);
}

.og-state__text {
	max-width: 420px;
	margin: 0 auto var(--og-space-4);
	color: var(--og-text-muted);
	font-size: var(--og-text-sm);
	line-height: var(--og-leading-normal);
}

.og-state--error .og-state__icon {
	background: var(--og-danger-soft);
	color: var(--og-danger);
}

.og-state__actions {
	display: flex;
	justify-content: center;
	gap: var(--og-space-2);
	flex-wrap: wrap;
}

/* =================================================================
   Modal
   ================================================================= */

.og-modal {
	position: fixed;
	inset: 0;
	z-index: var(--og-z-modal);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--og-space-4);
}

.og-modal[hidden] {
	display: none;
}

.og-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(6, 31, 36, 0.55);
	backdrop-filter: blur(2px);
}

.og-modal__panel {
	position: relative;
	width: 100%;
	max-width: 460px;
	max-height: calc(100vh - var(--og-space-7));
	overflow-y: auto;
	background: var(--og-bg-raised);
	border-radius: var(--og-radius-lg);
	box-shadow: var(--og-shadow-lg);
	animation: og-modal-in 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes og-modal-in {

	from {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.og-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--og-space-3);
	padding: var(--og-space-4) var(--og-space-5);
	border-bottom: 1px solid var(--og-border);
}

.og-modal__title {
	margin: 0;
	font-size: var(--og-text-base);
	font-weight: var(--og-weight-semibold);
}

.og-modal__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: var(--og-radius-sm);
	background: transparent;
	color: var(--og-text-muted);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.og-modal__close:hover {
	background: var(--og-bg-sunken);
	color: var(--og-text);
}

.og-modal__body {
	padding: var(--og-space-5);
	font-size: var(--og-text-sm);
}

.og-modal__footer {
	display: flex;
	justify-content: flex-end;
	gap: var(--og-space-2);
	padding: var(--og-space-4) var(--og-space-5);
	border-top: 1px solid var(--og-border);
}

/* =================================================================
   Toast
   ================================================================= */

.og-toasts {
	position: fixed;
	right: var(--og-space-4);
	bottom: var(--og-space-4);
	z-index: var(--og-z-toast);
	display: flex;
	flex-direction: column;
	gap: var(--og-space-2);
	max-width: min(360px, calc(100vw - var(--og-space-6)));
}

.og-toast {
	display: flex;
	align-items: flex-start;
	gap: var(--og-space-3);
	padding: var(--og-space-3) var(--og-space-4);
	border: 1px solid var(--og-border);
	border-left-width: 3px;
	border-radius: var(--og-radius);
	background: var(--og-bg-raised);
	box-shadow: var(--og-shadow);
	font-size: var(--og-text-sm);
	animation: og-toast-in 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.og-toast--success {
	border-left-color: var(--og-success);
}

.og-toast--danger {
	border-left-color: var(--og-danger);
}

.og-toast--info {
	border-left-color: var(--og-info);
}

.og-toast__icon {
	flex-shrink: 0;
	margin-top: 1px;
}

.og-toast--success .og-toast__icon {
	color: var(--og-success);
}

.og-toast--danger .og-toast__icon {
	color: var(--og-danger);
}

.og-toast--info .og-toast__icon {
	color: var(--og-info);
}

.og-toast__text {
	flex: 1;
	min-width: 0;
}

.og-toast.is-leaving {
	animation: og-toast-out 160ms ease-in forwards;
}

@keyframes og-toast-in {

	from {
		opacity: 0;
		transform: translateX(16px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes og-toast-out {

	to {
		opacity: 0;
		transform: translateX(16px);
	}
}

/* =================================================================
   Pagination
   ================================================================= */

.og-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--og-space-1);
	margin-top: var(--og-space-5);
	flex-wrap: wrap;
}

.og-pagination__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 var(--og-space-2);
	border: 1px solid var(--og-border);
	border-radius: var(--og-radius-sm);
	background: var(--og-bg-raised);
	color: var(--og-text-muted);
	font-size: var(--og-text-sm);
	font-weight: var(--og-weight-medium);
	text-decoration: none;
}

.og-pagination__link:hover {
	border-color: var(--og-border-strong);
	color: var(--og-text);
	text-decoration: none;
}

.og-pagination__link.is-current {
	background: var(--og-primary);
	border-color: var(--og-primary);
	color: var(--og-primary-text);
}

/* =================================================================
   Avatar and progress
   ================================================================= */

.og-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: var(--og-radius-full);
	background: var(--og-primary-soft);
	color: var(--og-primary);
	font-size: var(--og-text-sm);
	font-weight: var(--og-weight-semibold);
	overflow: hidden;
	flex-shrink: 0;
}

.og-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.og-avatar--lg {
	width: 56px;
	height: 56px;
	font-size: var(--og-text-lg);
}

.og-progress {
	height: 8px;
	border-radius: var(--og-radius-full);
	background: var(--og-bg-sunken);
	overflow: hidden;
}

.og-progress__bar {
	height: 100%;
	border-radius: inherit;
	background: var(--og-primary);
	transition: width 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.og-progress__bar--coin {
	background: var(--og-coin);
}

.og-progress__bar--success {
	background: var(--og-success);
}

/* =================================================================
   Icon gallery (Design Preview only)
   ================================================================= */

.og-icon-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
	gap: var(--og-space-2);
}

.og-icon-gallery__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--og-space-2);
	padding: var(--og-space-3) var(--og-space-2);
	border: 1px solid var(--og-border);
	border-radius: var(--og-radius);
	color: var(--og-text-muted);
	transition: border-color var(--og-transition), color var(--og-transition);
}

.og-icon-gallery__item:hover {
	border-color: var(--og-primary);
	color: var(--og-primary);
}

.og-icon-gallery__label {
	font-size: var(--og-text-2xs);
	color: var(--og-text-subtle);
	text-align: center;
	word-break: break-word;
}
