/*
 * Case converter page.
 *
 * Reads entirely from the theme's design tokens, so it follows the Customizer
 * palette and dark mode without a second set of rules.
 *
 * As elsewhere in this theme, every grid and flex child that can receive long
 * text carries min-width: 0. Grid items default to min-width: auto and refuse
 * to shrink below their content, which is what caused horizontal overflow
 * before.
 */

/*
 * .site-main is the content + sidebar grid, so its direct children become grid
 * items. State the single column explicitly rather than relying on the
 * no-sidebar body class, exactly as .cw-tool-main does.
 */
.site-main.cw-case-page {
	grid-template-columns: 1fr;
	gap: 0;
}

/* ------------------------------------------------------------------ *
 * Header
 * ------------------------------------------------------------------ */

.cw-case-header {
	text-align: center;
	padding-block: 28px 22px;
	min-width: 0;
}
.cw-case-title {
	font-size: clamp(1.75rem, 4vw, 2.4rem);
	line-height: 1.15;
	margin: 0 0 12px;
}
.cw-case-lede {
	max-width: 62ch;
	margin-inline: auto;
	color: var(--cw-color-text);
}

/* ------------------------------------------------------------------ *
 * The tool
 * ------------------------------------------------------------------ */

.cw-case-app {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	padding: 16px;
	min-width: 0;
}

/*
 * Conversion buttons sit ABOVE the box, not below it.
 *
 * On a phone the on-screen keyboard covers the lower half of the viewport the
 * moment the textarea is focused. Controls placed under the box would be
 * hidden exactly when they are needed.
 */
.cw-case-actions {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 10px;
	margin-bottom: 14px;
}

.cw-case-btn {
	min-width: 0;
	min-height: var(--cw-tap);
	padding: 12px 10px;
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	background: var(--cw-color-bg);
	color: var(--cw-color-heading);
	font: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.cw-case-btn:hover,
.cw-case-btn:focus-visible {
	background: var(--cw-color-primary);
	border-color: var(--cw-color-primary);
	color: var(--cw-color-on-primary);
}
.cw-case-btn:active { transform: translateY(1px); }

/* The label carries the case it produces, so it must not be restyled. */
.cw-case-btn-label { text-transform: none; }

.cw-case-input {
	display: block;
	width: 100%;
	min-width: 0;
	min-height: 260px;
	padding: 14px;
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	background: var(--cw-color-editor-bg);
	color: var(--cw-color-editor-text);
	font-family: var(--cw-font-body);
	font-size: 1rem;
	line-height: 1.6;
	resize: vertical;
}
.cw-case-input:focus-visible {
	outline: 2px solid var(--cw-color-primary);
	outline-offset: 1px;
	border-color: var(--cw-color-primary);
}

/* ------------------------------------------------------------------ *
 * Counts and secondary tools
 * ------------------------------------------------------------------ */

.cw-case-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 12px;
	min-width: 0;
}

.cw-case-counts {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	font-size: 0.9rem;
	color: var(--cw-color-muted);
	min-width: 0;
}
.cw-case-counts strong {
	color: var(--cw-color-primary);
	font-variant-numeric: tabular-nums;
}

.cw-case-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	min-width: 0;
}
.cw-case-tools .cw-btn { gap: 6px; }
.cw-case-tools .cw-btn[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}
.cw-case-clear:hover,
.cw-case-clear:focus-visible { color: var(--cw-color-danger); border-color: var(--cw-color-danger); }

.cw-case-status {
	margin: 10px 0 0;
	min-height: 1.4em;
	font-size: 0.88rem;
	color: var(--cw-color-success);
}

.cw-case-privacy {
	display: flex;
	align-items: center;
	gap: 7px;
	margin: 6px 0 0;
	font-size: 0.85rem;
	color: var(--cw-color-muted);
}
.cw-case-privacy svg { flex: 0 0 auto; }

/* ------------------------------------------------------------------ *
 * What each case does
 * ------------------------------------------------------------------ */

.cw-case-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 18px;
}
.cw-case-card {
	min-width: 0;
	padding: 20px;
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
}
.cw-case-card h3 { margin: 0 0 10px; font-size: 1.05rem; }
.cw-case-card p { margin: 0; color: var(--cw-color-text); font-size: 0.94rem; }

/* The worked example, shown in the case it describes. */
.cw-case-example {
	margin-bottom: 10px !important;
	padding: 10px 12px;
	border-inline-start: 3px solid var(--cw-color-primary);
	background: var(--cw-color-bg);
	border-radius: var(--cw-radius-sm);
	font-family: var(--cw-font-mono);
	font-size: 0.86rem !important;
	color: var(--cw-color-heading) !important;
	overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ *
 * When to use which
 * ------------------------------------------------------------------ */

.cw-case-use-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 18px 26px;
}
.cw-case-use { min-width: 0; }
.cw-case-use h3 {
	font-size: 1rem;
	margin: 0 0 6px;
	color: var(--cw-color-primary);
}
.cw-case-use p { margin: 0; color: var(--cw-color-text); font-size: 0.93rem; }

/* ------------------------------------------------------------------ *
 * FAQ
 * ------------------------------------------------------------------ */

.cw-case-faq-item {
	border-bottom: 1px solid var(--cw-color-border);
}
.cw-case-faq-item summary {
	cursor: pointer;
	list-style: none;
	padding: 14px 34px 14px 0;
	position: relative;
	min-height: var(--cw-tap);
	display: flex;
	align-items: center;
}
.cw-case-faq-item summary::-webkit-details-marker { display: none; }
.cw-case-faq-item summary h3 {
	margin: 0;
	font-size: 1.02rem;
	font-weight: 600;
	color: var(--cw-color-heading);
}
.cw-case-faq-item summary::after {
	content: "";
	position: absolute;
	inset-inline-end: 6px;
	top: 50%;
	width: 10px; height: 10px;
	margin-top: -6px;
	border-inline-end: 2px solid var(--cw-color-muted);
	border-block-end: 2px solid var(--cw-color-muted);
	transform: rotate(45deg);
	transition: transform 0.18s ease;
}
.cw-case-faq-item[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.cw-case-faq-item p {
	margin: 0 0 16px;
	padding-inline-end: 34px;
	color: var(--cw-color-text);
}
.cw-case-faq-item summary:focus-visible {
	outline: 2px solid var(--cw-color-primary);
	outline-offset: 2px;
	border-radius: var(--cw-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
	.cw-case-faq-item summary::after { transition: none; }
	.cw-case-btn { transition: none; }
}

/* ------------------------------------------------------------------ *
 * Related
 * ------------------------------------------------------------------ */

.cw-case-related {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	padding: 24px 20px;
}
.cw-case-related h2 { margin-top: 0; font-size: 1.2rem; }
.cw-case-related p { margin: 0; color: var(--cw-color-text); }

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 1023px) {
	.cw-case-use-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
	.cw-case-grid { grid-template-columns: minmax(0, 1fr); }
	/*
	 * Two columns of two, not a single column of four. Four full-width rows
	 * pushed the text box itself below the fold on a phone, which is the one
	 * thing this page cannot afford.
	 */
	.cw-case-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.cw-case-bar { justify-content: flex-start; }
	.cw-case-tools { width: 100%; }
	.cw-case-tools .cw-btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 600px) {
	.cw-case-use-grid { grid-template-columns: minmax(0, 1fr); }
	.cw-case-app { padding: 12px; }
	.cw-case-input { min-height: 200px; }
	.cw-case-btn { font-size: 0.88rem; padding: 11px 6px; }

	/*
	 * Tighten the intro on a phone. The heading and description pushed the text
	 * box down to roughly 480px, which is most of a small viewport before the
	 * keyboard even opens. The copy still reads; it just takes less room.
	 */
	.cw-case-header { padding-block: 18px 14px; }
	.cw-case-title { margin-bottom: 8px; }
	.cw-case-lede { font-size: 0.95rem; }
}
