/**
 * CounterWords - accounts, history dashboard, shared results, contact form.
 *
 * Mobile first, matching the tool. Loaded only on the pages that use these
 * templates (see counterwords_needs_account_styles()).
 */

/* ------------------------------------------------------------------ *
 * Shared form furniture
 * ------------------------------------------------------------------ */

.cw-auth-wrap { padding-block: 24px 48px; }

.cw-auth-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	align-items: start;
}

.cw-auth-card {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	padding: 22px;
}
.cw-auth-card h1 { font-size: 1.5rem; margin-bottom: 12px; }
.cw-auth-card h2 { font-size: 1.25rem; margin-bottom: 12px; }
.cw-auth-extra { margin-top: 28px; }

/* One card holding both panes, centred and never full-bleed on a big screen. */
.cw-auth-card--single {
	max-width: 480px;
	margin-inline: auto;
}
.cw-auth-title { font-size: 1.4rem; margin-bottom: 14px; }

/* Segmented switch */
.cw-auth-switch {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px;
	padding: 4px;
	margin-bottom: 22px;
	background: var(--cw-color-bg);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
}
.cw-auth-switch-btn {
	min-height: var(--cw-tap);
	padding: 10px 12px;
	border: 0;
	border-radius: calc(var(--cw-radius-sm) - 2px);
	background: transparent;
	color: var(--cw-color-secondary);
	font: inherit;
	font-weight: 600;
	font-size: 0.92rem;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.cw-auth-switch-btn.is-active,
.cw-auth-switch-btn[aria-selected="true"] {
	background: var(--cw-color-primary);
	color: var(--cw-color-on-primary);
}
.cw-auth-pane[hidden] { display: none; }

/* "No account yet? Create one" */
.cw-auth-swap {
	margin: 18px 0 0;
	padding-top: 16px;
	border-top: 1px solid var(--cw-color-border);
	font-size: 0.92rem;
	color: var(--cw-color-muted);
	text-align: center;
}
.cw-linkbtn {
	background: none;
	border: 0;
	padding: 4px 2px;
	font: inherit;
	font-weight: 600;
	color: var(--cw-color-primary);
	cursor: pointer;
	text-decoration: underline;
}
.cw-linkbtn:hover { text-decoration: none; }

.cw-form-intro,
.cw-form-help {
	font-size: 0.88rem;
	color: var(--cw-color-muted);
}
.cw-form-help { margin-top: 12px; }

.cw-form .cw-field { margin-bottom: 16px; }

.cw-form label {
	display: block;
	font-weight: 600;
	font-size: 0.92rem;
	margin-bottom: 6px;
	color: var(--cw-color-heading);
}

.cw-form input[type="text"],
.cw-form input[type="email"],
.cw-form input[type="password"],
.cw-form textarea {
	width: 100%;
	padding: 12px;
	min-height: var(--cw-tap);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	background: var(--cw-color-card);
	color: var(--cw-color-text);
	font: inherit;
	/* Never below 16px: iOS zooms the page when focusing a smaller field. */
	font-size: 1rem;
}
.cw-form textarea { min-height: 160px; resize: vertical; }

.cw-form input:focus-visible,
.cw-form textarea:focus-visible {
	border-color: var(--cw-color-primary);
}

.cw-field-hint {
	display: block;
	margin-top: 5px;
	font-size: 0.82rem;
	font-weight: 400;
	color: var(--cw-color-muted);
}

.cw-auth-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

/* Honeypot: off-screen rather than display:none, because some bots skip
   hidden fields but not positioned ones. Hidden from assistive tech too. */
.cw-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ------------------------------------------------------------------ *
 * Alerts
 * ------------------------------------------------------------------ */

.cw-alert {
	border: 1px solid transparent;
	border-radius: var(--cw-radius-sm);
	padding: 14px 16px;
	margin-bottom: 20px;
	font-size: 0.95rem;
}
.cw-alert ul { margin: 0; padding-left: 1.2em; }
.cw-alert--success {
	background: rgba(4, 120, 87, 0.09);
	border-color: rgba(4, 120, 87, 0.35);
	color: var(--cw-color-success);
}
.cw-alert--error {
	background: var(--cw-color-warning-bg);
	border-color: rgba(180, 83, 9, 0.35);
	color: var(--cw-color-danger);
}

/* ------------------------------------------------------------------ *
 * Dashboard
 * ------------------------------------------------------------------ */

.cw-dash-head { padding-block: 24px 8px; }
.cw-dash-head h1 { margin-bottom: 6px; }
.cw-dash-sub {
	color: var(--cw-color-muted);
	font-size: 0.92rem;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.cw-dash-totals {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	margin-bottom: 24px;
}

.cw-history {
	list-style: none;
	margin: 0 0 40px;
	padding: 0;
	display: grid;
	gap: 14px;
}

.cw-history-item {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	padding: 18px;
}

.cw-history-head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	margin-bottom: 14px;
}
.cw-history-title { font-size: 1.1rem; margin: 0; overflow-wrap: anywhere; }
.cw-history-date { font-size: 0.82rem; color: var(--cw-color-muted); }

.cw-history-stats {
	list-style: none;
	margin: 0 0 14px;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}
.cw-history-stats li {
	background: var(--cw-color-bg);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	padding: 10px 8px;
	text-align: center;
	min-width: 0;
}
.cw-history-stat-value {
	display: block;
	font-weight: 800;
	color: var(--cw-color-heading);
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
	overflow-wrap: anywhere;
}
.cw-history-stat-label {
	display: block;
	font-size: 0.72rem;
	color: var(--cw-color-muted);
	margin-top: 3px;
}

.cw-history-share { margin: 0 0 14px; }
.cw-history-share label {
	display: block;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--cw-color-muted);
	margin-bottom: 5px;
}
.cw-history-share input {
	width: 100%;
	padding: 10px 12px;
	min-height: var(--cw-tap);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	background: var(--cw-color-bg);
	color: var(--cw-color-text);
	font-family: var(--cw-font-mono);
	font-size: 0.86rem;
}

.cw-history-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}
.cw-history-actions form { margin: 0; }

.cw-btn--danger {
	background: transparent;
	color: var(--cw-color-danger);
	border-color: var(--cw-color-border);
}
.cw-btn--danger:hover,
.cw-btn--danger:focus {
	background: var(--cw-color-warning-bg);
	color: var(--cw-color-danger);
}

/* ------------------------------------------------------------------ *
 * Save-to-history panel inside the tool
 * ------------------------------------------------------------------ */

.cw-save-panel {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	padding: 20px;
	margin-top: 16px;
}

.cw-save-head {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin-bottom: 18px;
}
.cw-save-head .cw-icon {
	color: var(--cw-color-primary);
	margin-top: 2px;
}
.cw-save-panel h2 {
	font-size: 1.1rem;
	margin: 0 0 4px;
}
.cw-save-panel .cw-form-intro { margin: 0; }
.cw-save-panel .cw-note { margin-top: 12px; }

.cw-save-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 14px;
	align-items: start;
}
.cw-save-row .cw-field { margin-bottom: 0; }

/* The button lines up with the input, not with the hint text below it. */
.cw-save-submit .cw-btn { width: 100%; }

.cw-save-optin { margin-top: 6px; }

/* ------------------------------------------------------------------ *
 * Shared result
 * ------------------------------------------------------------------ */

.cw-shared-result {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	padding: 22px;
	margin-block: 24px 40px;
}
.cw-shared-head { margin-bottom: 20px; }
.cw-shared-head h1 { font-size: 1.5rem; margin-bottom: 6px; overflow-wrap: anywhere; }
.cw-shared-meta { font-size: 0.88rem; color: var(--cw-color-muted); margin: 0; }
.cw-shared-meta code {
	font-family: var(--cw-font-mono);
	background: var(--cw-color-bg);
	border: 1px solid var(--cw-color-border);
	border-radius: 4px;
	padding: 1px 6px;
}

.cw-shared-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	margin-bottom: 18px;
}

/* ------------------------------------------------------------------ *
 * Wider screens
 * ------------------------------------------------------------------ */

@media (min-width: 640px) {
	.cw-dash-totals,
	.cw-history-stats,
	.cw-shared-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
	.cw-save-row {
		grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
	}
	/* Nudge the button down so it sits level with the input, not the label. */
	.cw-save-submit { padding-top: 27px; }
	.cw-save-submit .cw-btn { width: auto; }
	.cw-auth-card { padding: 28px; }
}

@media (min-width: 900px) {
	.cw-auth-wrap { max-width: 960px; margin-inline: auto; }
	.cw-history-stats { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
