/**
 * InsideInk Handwriting Analysis — frontend styles.
 * Scoped under .iha-app to avoid theme conflicts.
 */

.iha-app {
	--iha-ink: #1c1528;
	--iha-ink-soft: #3d3550;
	--iha-paper: #fdfcfa;
	--iha-surface: #f6f3ef;
	--iha-border: #e8e2da;
	--iha-muted: #7a7285;
	--iha-primary: #4a3f8f;
	--iha-primary-hover: #3b3278;
	--iha-accent: #7c6cf0;
	--iha-accent-soft: #ede9ff;
	--iha-success: #1a8f5c;
	--iha-warn: #b86a1f;
	--iha-danger: #c0392b;
	--iha-radius: 18px;
	--iha-radius-sm: 12px;
	--iha-shadow: 0 16px 48px rgba(28, 21, 40, 0.08);
	--iha-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	max-width: 680px;
	margin: 2rem auto;
	color: var(--iha-ink);
	font-family: var(--iha-font);
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}

.iha-app *,
.iha-app *::before,
.iha-app *::after {
	box-sizing: border-box;
}

/* Theme reset inside the tool */
.iha-app button,
.iha-app input[type="file"],
.iha-app input[type="checkbox"] {
	font-family: inherit;
}

.iha-app button {
	letter-spacing: inherit;
	text-transform: none;
}

/* ---------- Card shell ---------- */
.iha-step {
	background: var(--iha-paper);
	border: 1px solid var(--iha-border);
	border-radius: var(--iha-radius);
	box-shadow: var(--iha-shadow);
	padding: clamp(24px, 5vw, 40px);
}

/* ---------- Header ---------- */
.iha-header {
	text-align: center;
	margin-bottom: 28px;
}

.iha-badge {
	display: inline-block;
	margin-bottom: 12px;
	padding: 5px 14px;
	border-radius: 99px;
	background: var(--iha-accent-soft);
	color: var(--iha-primary);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.iha-title {
	margin: 0 0 10px;
	font-size: clamp(1.5rem, 4vw, 2rem);
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--iha-ink);
	line-height: 1.2;
}

.iha-intro {
	margin: 0 auto;
	max-width: 48ch;
	color: var(--iha-muted);
	font-size: 0.98rem;
}

/* ---------- Hidden file input ---------- */
.iha-file-input {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* ---------- Upload area ---------- */
.iha-upload-area {
	position: relative;
	min-height: 200px;
}

/* Empty dropzone */
.iha-dropzone {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 220px;
	padding: 36px 24px;
	border: 2px dashed #cfc6e8;
	border-radius: var(--iha-radius-sm);
	background: linear-gradient(180deg, #faf8ff 0%, var(--iha-surface) 100%);
	text-align: center;
	cursor: pointer;
	outline: none;
	transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.iha-dropzone:hover,
.iha-dropzone:focus-visible {
	border-color: var(--iha-accent);
	background: #f5f2ff;
	box-shadow: 0 0 0 4px rgba(124, 108, 240, 0.12);
}

.iha-dropzone.is-dragging {
	border-color: var(--iha-primary);
	background: var(--iha-accent-soft);
	box-shadow: 0 0 0 4px rgba(74, 63, 143, 0.15);
}

.iha-dropzone[hidden] {
	display: none !important;
}

.iha-dropzone__icon-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 72px;
	margin-bottom: 16px;
	border-radius: 50%;
	background: #fff;
	color: var(--iha-primary);
	box-shadow: 0 4px 16px rgba(74, 63, 143, 0.12);
}

.iha-dropzone__title {
	margin: 0 0 6px;
	font-size: 1.08rem;
	font-weight: 700;
	color: var(--iha-ink);
}

.iha-dropzone__text {
	margin: 0 0 8px;
	font-size: 0.92rem;
	color: var(--iha-ink-soft);
}

.iha-dropzone__hint {
	margin: 0;
	font-size: 0.8rem;
	color: var(--iha-muted);
}

/* File preview card */
.iha-file-card {
	border: 1px solid var(--iha-border);
	border-radius: var(--iha-radius-sm);
	background: #fff;
	overflow: hidden;
	box-shadow: 0 4px 20px rgba(28, 21, 40, 0.06);
}

.iha-file-card[hidden] {
	display: none !important;
}

.iha-file-card__media {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 180px;
	max-height: 360px;
	padding: 16px;
	background: repeating-linear-gradient(
		0deg,
		transparent,
		transparent 27px,
		#ebe6df 27px,
		#ebe6df 28px
	), var(--iha-surface);
}

.iha-file-card__img {
	display: block;
	max-width: 100%;
	max-height: 320px;
	width: auto;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 8px 28px rgba(28, 21, 40, 0.14);
	object-fit: contain;
}

.iha-file-card__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 18px;
	border-top: 1px solid var(--iha-border);
	background: #fff;
}

.iha-file-card__info {
	min-width: 0;
	flex: 1;
}

.iha-file-card__name {
	display: block;
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--iha-ink);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.iha-file-card__size {
	display: block;
	margin-top: 2px;
	font-size: 0.78rem;
	color: var(--iha-muted);
}

.iha-file-card__actions {
	display: flex;
	flex-shrink: 0;
	gap: 6px;
}

.iha-link-btn {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	padding: 6px 12px !important;
	border: 1px solid var(--iha-border) !important;
	border-radius: 8px !important;
	background: #fff !important;
	color: var(--iha-primary) !important;
	font-size: 0.82rem !important;
	font-weight: 600 !important;
	line-height: 1.2 !important;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
	width: auto !important;
	min-width: 0 !important;
	height: auto !important;
	box-shadow: none !important;
}

.iha-link-btn:hover {
	background: var(--iha-accent-soft) !important;
	border-color: var(--iha-accent) !important;
}

.iha-link-btn--danger {
	color: var(--iha-danger) !important;
}

.iha-link-btn--danger:hover {
	background: #fdecec !important;
	border-color: #f5c2c2 !important;
}

/* ---------- Tip box ---------- */
.iha-tip-box {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-top: 18px;
	padding: 14px 16px;
	border-radius: var(--iha-radius-sm);
	background: var(--iha-surface);
	border: 1px solid var(--iha-border);
}

.iha-tip-box__icon {
	flex-shrink: 0;
	margin-top: 2px;
	color: var(--iha-primary);
}

.iha-tip-box p {
	margin: 0;
	font-size: 0.86rem;
	color: var(--iha-ink-soft);
	line-height: 1.5;
}

/* ---------- Consent ---------- */
.iha-consent {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	margin: 20px 0;
	padding: 14px 16px;
	border-radius: var(--iha-radius-sm);
	background: #fff;
	border: 1px solid var(--iha-border);
	font-size: 0.86rem;
	color: var(--iha-muted);
	cursor: pointer;
}

.iha-consent input {
	margin-top: 3px;
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	accent-color: var(--iha-primary);
	cursor: pointer;
}

/* ---------- Buttons ---------- */
.iha-btn {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	padding: 15px 24px !important;
	border: none !important;
	border-radius: var(--iha-radius-sm) !important;
	font-size: 1rem !important;
	font-weight: 700 !important;
	line-height: 1.2 !important;
	cursor: pointer;
	transition: transform 0.12s, box-shadow 0.2s, background 0.2s;
	height: auto !important;
	min-height: 0 !important;
	box-sizing: border-box !important;
}

.iha-btn__icon {
	flex-shrink: 0;
}

.iha-btn--primary {
	background: linear-gradient(135deg, var(--iha-primary) 0%, var(--iha-accent) 100%) !important;
	color: #fff !important;
	box-shadow: 0 8px 24px rgba(74, 63, 143, 0.32);
}

.iha-btn--primary:hover {
	transform: translateY(-1px);
	box-shadow: 0 12px 32px rgba(74, 63, 143, 0.4);
}

.iha-btn--primary:active {
	transform: translateY(0);
}

.iha-btn--primary:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

.iha-btn--ghost {
	background: transparent !important;
	color: var(--iha-primary) !important;
	border: 1.5px solid var(--iha-border) !important;
	margin-top: 24px;
	box-shadow: none !important;
}

.iha-btn--ghost:hover {
	border-color: var(--iha-primary) !important;
	background: var(--iha-accent-soft) !important;
}

/* ---------- Error ---------- */
.iha-error {
	margin: 0 0 16px;
	padding: 13px 16px;
	border-radius: var(--iha-radius-sm);
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #991b1b;
	font-size: 0.88rem;
	line-height: 1.45;
}

.iha-error[hidden] {
	display: none !important;
}

/* ---------- Loading ---------- */
.iha-step--loading {
	text-align: center;
	padding: 56px 32px;
}

.iha-loader-ring {
	width: 52px;
	height: 52px;
	margin: 0 auto 24px;
	border: 3px solid var(--iha-border);
	border-top-color: var(--iha-primary);
	border-radius: 50%;
	animation: iha-spin 0.85s linear infinite;
}

@keyframes iha-spin {
	to { transform: rotate(360deg); }
}

.iha-loading__title {
	margin: 0 0 8px;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--iha-ink);
}

.iha-loading__sub {
	margin: 0 auto;
	max-width: 42ch;
	color: var(--iha-muted);
	font-size: 0.92rem;
}

/* ---------- Result ---------- */
.iha-result__headline-wrap {
	text-align: center;
	margin-bottom: 8px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--iha-border);
}

.iha-result__eyebrow {
	display: inline-block;
	margin-bottom: 8px;
	padding: 4px 12px;
	border-radius: 99px;
	background: var(--iha-accent-soft);
	color: var(--iha-primary);
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.iha-result__headline {
	margin: 0;
	font-size: clamp(1.35rem, 3.5vw, 1.85rem);
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--iha-ink);
	line-height: 1.25;
}

.iha-result__quality {
	text-align: center;
	font-size: 0.84rem;
	color: var(--iha-muted);
	font-style: italic;
	margin: 10px 0 0;
}

.iha-result__overview {
	margin: 20px 0 28px;
	font-size: 1.05rem;
	text-align: center;
	color: var(--iha-ink-soft);
	line-height: 1.65;
}

/* Cards */
.iha-card {
	background: #fff;
	border: 1px solid var(--iha-border);
	border-radius: var(--iha-radius-sm);
	padding: 22px;
	margin-bottom: 16px;
}

.iha-card__title {
	margin: 0 0 16px;
	font-size: 1rem;
	font-weight: 700;
	color: var(--iha-ink);
}

.iha-card__text {
	margin: 0;
	color: var(--iha-ink-soft);
	line-height: 1.6;
}

.iha-card--summary {
	background: linear-gradient(135deg, #f8f6ff, var(--iha-paper));
	border-color: #ddd5ff;
}

.iha-card--strength {
	border-left: 4px solid var(--iha-success);
}

.iha-card--growth {
	border-left: 4px solid var(--iha-warn);
}

.iha-cols {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

@media (max-width: 560px) {
	.iha-cols {
		grid-template-columns: 1fr;
	}

	.iha-file-card__footer {
		flex-direction: column;
		align-items: stretch;
	}

	.iha-file-card__actions {
		justify-content: flex-end;
	}
}

.iha-bullets {
	margin: 0;
	padding-left: 20px;
}

.iha-bullets li {
	margin-bottom: 8px;
	color: var(--iha-ink-soft);
}

.iha-bullets li:last-child {
	margin-bottom: 0;
}

/* Traits */
.iha-trait {
	margin-bottom: 18px;
}

.iha-trait:last-child {
	margin-bottom: 0;
}

.iha-trait__head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 8px;
}

.iha-trait__name {
	font-weight: 600;
	font-size: 0.92rem;
	color: var(--iha-ink);
}

.iha-trait__score {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	color: var(--iha-primary);
	font-size: 0.88rem;
}

.iha-trait__bar {
	height: 8px;
	background: #ebe6f5;
	border-radius: 99px;
	overflow: hidden;
}

.iha-trait__fill {
	display: block;
	height: 100%;
	border-radius: 99px;
	background: linear-gradient(90deg, var(--iha-primary), var(--iha-accent));
	width: 0;
	transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.iha-trait__summary {
	margin: 6px 0 0;
	font-size: 0.84rem;
	color: var(--iha-muted);
}

/* Dimensions accordion */
.iha-dim {
	border-bottom: 1px solid var(--iha-border);
}

.iha-dim:last-child {
	border-bottom: none;
}

.iha-dim__feature {
	cursor: pointer;
	padding: 14px 28px 14px 0;
	font-weight: 600;
	font-size: 0.92rem;
	color: var(--iha-ink);
	list-style: none;
	position: relative;
}

.iha-dim__feature::-webkit-details-marker {
	display: none;
}

.iha-dim__feature::after {
	content: "+";
	position: absolute;
	right: 4px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--iha-primary);
	font-size: 1.3rem;
	font-weight: 400;
	line-height: 1;
}

.iha-dim[open] .iha-dim__feature::after {
	content: "−";
}

.iha-dim__body {
	padding: 0 0 14px;
}

.iha-dim__obs,
.iha-dim__intp {
	margin: 0 0 8px;
	font-size: 0.9rem;
	color: var(--iha-ink-soft);
	line-height: 1.55;
}

.iha-dim__intp strong,
.iha-dim__obs strong {
	color: var(--iha-ink);
}

/* Disclaimer */
.iha-disclaimer {
	margin: 20px 0 0;
	padding-top: 16px;
	border-top: 1px solid var(--iha-border);
	font-size: 0.78rem;
	color: var(--iha-muted);
	text-align: center;
	line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
	.iha-trait__fill,
	.iha-btn,
	.iha-dropzone,
	.iha-loader-ring {
		transition: none;
		animation: none;
	}
}

/* ---------- Result actions ---------- */
.iha-result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 8px;
}

.iha-btn--half {
	flex: 1 1 200px;
	width: auto !important;
}

/* ---------- Lead capture modal ---------- */
body.iha-modal-open {
	overflow: hidden;
}

.iha-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.iha-modal[hidden] {
	display: none !important;
}

.iha-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(28, 21, 40, 0.55);
	backdrop-filter: blur(4px);
}

.iha-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 440px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 32px 28px;
	background: var(--iha-paper);
	border-radius: var(--iha-radius);
	box-shadow: 0 24px 64px rgba(28, 21, 40, 0.25);
	animation: iha-modal-in 0.25s ease;
}

@keyframes iha-modal-in {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

.iha-modal__step[hidden] {
	display: none !important;
}

.iha-modal__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin: 0 auto 16px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--iha-success), #2ecc71);
	color: #fff;
	font-size: 1.5rem;
	font-weight: 700;
	box-shadow: 0 8px 20px rgba(26, 143, 92, 0.35);
}

.iha-modal__title {
	margin: 0 0 10px;
	font-size: 1.35rem;
	font-weight: 700;
	text-align: center;
	color: var(--iha-ink);
}

.iha-modal__text {
	margin: 0 0 22px;
	font-size: 0.92rem;
	text-align: center;
	color: var(--iha-muted);
	line-height: 1.55;
}

.iha-lead-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.iha-field label {
	display: block;
	margin-bottom: 5px;
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--iha-ink-soft);
}

.iha-field input {
	display: block;
	width: 100%;
	padding: 11px 14px !important;
	border: 1px solid var(--iha-border) !important;
	border-radius: 10px !important;
	background: #fff !important;
	font-size: 0.95rem !important;
	color: var(--iha-ink) !important;
	line-height: 1.4 !important;
	height: auto !important;
	box-shadow: none !important;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.iha-field input:focus {
	outline: none;
	border-color: var(--iha-accent) !important;
	box-shadow: 0 0 0 3px rgba(124, 108, 240, 0.2) !important;
}

.iha-modal-error {
	padding: 10px 12px;
	border-radius: 8px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #991b1b;
	font-size: 0.85rem;
}

.iha-modal-error[hidden] {
	display: none !important;
}
