/* Material Design Theme for Nikuda */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Noto+Sans+Hebrew:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

/* Reset & Base */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	--md-primary: #5c6bc0;
	--md-primary-dark: #3949ab;
	--md-primary-light: #c5cae9;
	--md-accent: #ff7043;
	--md-accent-dark: #e64a19;
	--md-bg: #fafafa;
	--md-surface: #fff;
	--md-on-surface: #212121;
	--md-on-surface-secondary: #757575;
	--md-divider: #e0e0e0;
	--md-shadow-1: 0 1px 3px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 24%);
	--md-shadow-2: 0 3px 6px rgb(0 0 0 / 16%), 0 3px 6px rgb(0 0 0 / 23%);
	--md-shadow-3: 0 10px 20px rgb(0 0 0 / 19%), 0 6px 6px rgb(0 0 0 / 23%);
	--md-radius: 8px;
	--md-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

	/* Surface-derived colors (overridden in dark mode) */
	--md-disabled-bg: #f5f5f5;
	--md-disabled-btn-bg: #bdbdbd;
	--md-toast-bg: #323232;
	--md-blockquote-bg: #f5f5fa;
	--md-scrollbar-thumb: #bdbdbd;
	--md-scrollbar-thumb-hover: #9e9e9e;
	--md-logo-filter: invert(1);
}

/* Explicit dark mode (theme toggle set to "dark") */
:root[data-theme="dark"] {
	--md-primary: #7986cb;
	--md-primary-dark: #9fa8da;
	--md-primary-light: #3949ab;
	--md-accent: #ff8a65;
	--md-accent-dark: #ff7043;
	--md-bg: #121212;
	--md-surface: #1e1e1e;
	--md-on-surface: #e0e0e0;
	--md-on-surface-secondary: #9e9e9e;
	--md-divider: #373737;
	--md-shadow-1: 0 1px 3px rgb(0 0 0 / 50%), 0 1px 2px rgb(0 0 0 / 60%);
	--md-shadow-2: 0 3px 6px rgb(0 0 0 / 55%), 0 3px 6px rgb(0 0 0 / 65%);
	--md-shadow-3: 0 10px 20px rgb(0 0 0 / 60%), 0 6px 6px rgb(0 0 0 / 65%);
	--md-disabled-bg: #2a2a2a;
	--md-disabled-btn-bg: #424242;
	--md-toast-bg: #424242;
	--md-blockquote-bg: #262633;
	--md-scrollbar-thumb: #555;
	--md-scrollbar-thumb-hover: #777;
	--md-logo-filter: none;
}

/* OS-aware dark mode — applies only when the toggle is following the OS
   (data-theme="os" or unset), so an explicit light/dark choice always wins. */
@media (prefers-color-scheme: dark) {
	:root[data-theme="os"],
	:root:not([data-theme]) {
		--md-primary: #7986cb;
		--md-primary-dark: #9fa8da;
		--md-primary-light: #3949ab;
		--md-accent: #ff8a65;
		--md-accent-dark: #ff7043;
		--md-bg: #121212;
		--md-surface: #1e1e1e;
		--md-on-surface: #e0e0e0;
		--md-on-surface-secondary: #9e9e9e;
		--md-divider: #373737;
		--md-shadow-1: 0 1px 3px rgb(0 0 0 / 50%), 0 1px 2px rgb(0 0 0 / 60%);
		--md-shadow-2: 0 3px 6px rgb(0 0 0 / 55%), 0 3px 6px rgb(0 0 0 / 65%);
		--md-shadow-3: 0 10px 20px rgb(0 0 0 / 60%), 0 6px 6px rgb(0 0 0 / 65%);
		--md-disabled-bg: #2a2a2a;
		--md-disabled-btn-bg: #424242;
		--md-toast-bg: #424242;
		--md-blockquote-bg: #262633;
		--md-scrollbar-thumb: #555;
		--md-scrollbar-thumb-hover: #777;
		--md-logo-filter: none;
	}
}

html {
	font-size: 16px;
	height: 100%;
}

body {
	font-family: "Noto Sans Hebrew", Roboto, Arial, sans-serif;
	background: var(--md-bg);
	color: var(--md-on-surface);
	min-height: 100%;
	display: flex;
	flex-direction: row;
	gap: 24px;
	padding: 24px;
}

/* Logo watermark */
.nikuda_label {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	opacity: 0.15;
	z-index: 1;
	max-width: 500px;
	filter: var(--md-logo-filter);
	pointer-events: none;
	user-select: none;
}

/* Left Panel - Controls */
.access {
	/* grows with wide screens: 380px up to ~1190px wide, 32vw above, capped at 600px */
	flex: 0 0 clamp(380px, 32vw, 600px);
	height: calc(100vh - 48px);
	background: var(--md-surface);
	border-radius: var(--md-radius);
	box-shadow: var(--md-shadow-1);
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 20px;
	overflow-y: auto;
	border: none;
}

/* Unpunctuated words */
.unpunctuated {
	color: red;
	text-decoration: underline wavy red;
}

/* Material text inputs */
.access_text {
	display: block;
	width: 100%;
	font-family: "Noto Sans Hebrew", Roboto, Arial, sans-serif;
	font-size: 1.125rem;
	line-height: 1.6;
	padding: 12px 16px;
	border: 1px solid var(--md-divider);
	border-radius: var(--md-radius);
	background: var(--md-surface);
	color: var(--md-on-surface);
	transition: border-color var(--md-transition), box-shadow var(--md-transition);
	text-align: right;
	margin: 0;
	overflow: hidden;
}

.access_text:focus {
	outline: none;
	border-color: var(--md-primary);
	box-shadow: 0 0 0 3px var(--md-primary-light);
}

.access_text:disabled {
	background: var(--md-disabled-bg);
	color: var(--md-on-surface-secondary);
}

textarea.access_text {
	resize: none;
	height: 320px;
	overflow-y: auto;
	flex-shrink: 0;
}

/* Material raised buttons */
.access_button {
	display: block;
	width: 100%;
	padding: 12px 24px;
	flex-shrink: 0;
	font-family: "Noto Sans Hebrew", Roboto, Arial, sans-serif;
	font-size: 0.9375rem;
	font-weight: 500;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #fff;
	background: var(--md-primary);
	border: none;
	border-radius: var(--md-radius);
	cursor: pointer;
	box-shadow: var(--md-shadow-1);
	transition: background var(--md-transition), box-shadow var(--md-transition), transform var(--md-transition);
	text-align: center;
}

.access_button:disabled {
	background: var(--md-disabled-btn-bg);
	color: #fff;
	cursor: not-allowed;
	box-shadow: none;
}

.access_button:hover:not(:disabled) {
	background: var(--md-primary-dark);
	box-shadow: var(--md-shadow-2);
	transform: translateY(-1px);
}

.access_button:active:not(:disabled) {
	box-shadow: var(--md-shadow-1);
	transform: translateY(0);
}

/* Paragraph method chooser under the paragraph button */
.method-option {
	display: flex;
	align-items: center;
	gap: 8px;
	font-family: "Noto Sans Hebrew", Roboto, Arial, sans-serif;
	font-size: 0.9375rem;
	color: var(--md-on-surface-secondary);
	cursor: pointer;
}

.method-option select {
	font: inherit;
	padding: 4px 8px;
	color: var(--md-on-surface);
	background: var(--md-surface);
	border: 1px solid var(--md-divider);
	border-radius: var(--md-radius);
}

/* Answer / Results panel */
.answer_text {
	flex: 1;
	height: calc(100vh - 48px);
	background: var(--md-surface);
	border-radius: var(--md-radius);
	box-shadow: var(--md-shadow-1);
	padding: 32px;
	font-size: 1.5rem;
	line-height: 2;
	text-align: right;
	overflow-y: auto;
	float: none;
	margin: 0;
	display: flex;
	flex-direction: column;
}

/* Suggestion dropdown */
#SuggestionBox {
	position: absolute;
	width: 280px;
	max-height: 300px;
	overflow-y: auto;
	background: var(--md-surface);
	border: none;
	border-radius: var(--md-radius);
	box-shadow: var(--md-shadow-3);
	padding: 8px 0;
	opacity: 1;
	z-index: 10;
	color: var(--md-on-surface);
}

#SuggestionList {
	list-style: none;
	padding: 0;
	margin: 0;
}

#SuggestionList li {
	cursor: pointer;
	list-style-type: none;
	padding: 10px 16px;
	font-size: 1.1rem;
	transition: background var(--md-transition);
	color: var(--md-on-surface);
}

#SuggestionList li:hover {
	background: var(--md-primary-light);
	font-weight: 500;
	opacity: 1;
}

/* MeNaked section (manual punctuation editor) */
#MeNaked {
	display: flex;
	flex-direction: column;
	gap: 12px;
	flex-shrink: 0;
}

#MeNaked.me-naked-hidden {
	visibility: hidden;
}

#QuickyAns {
	font-size: 2rem;
	text-align: center;
	padding: 16px;
	min-height: 48px;
}

/* Deployed-version stamp (filled by nikuda.js from app/version), sits at
   the bottom of the answer card below the buttons */
#VersionInfo {
	text-align: center;
	line-height: 1.5;
	font-size: 0.6875rem;
	color: var(--md-on-surface-secondary);
	margin-top: 8px;
}

/* Toast notification */
#Toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%) translateY(100px);
	padding: 12px 24px;
	background: var(--md-toast-bg);
	color: #fff;
	font-size: 0.875rem;
	border-radius: var(--md-radius);
	box-shadow: var(--md-shadow-2);
	z-index: 200;
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	pointer-events: none;
	max-width: 80vw;
	text-align: center;
	white-space: pre-line;
}

#Toast.toast-visible {
	transform: translateX(-50%) translateY(0);
	opacity: 1;
}

/* Help overlay */
.help {
	display: none;
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: min(700px, 90vw);
	max-height: 85vh;
	padding: 32px;
	background: var(--md-surface);
	border: none;
	border-radius: 12px;
	box-shadow: var(--md-shadow-3);
	color: var(--md-on-surface);
	z-index: 100;
	cursor: default;
	overflow-y: auto;
	line-height: 1.8;
	font-size: 0.9375rem;
}

.help h1 {
	font-size: 1.75rem;
	font-weight: 500;
	color: var(--md-primary-dark);
	margin-bottom: 16px;
	padding-bottom: 12px;
	border-bottom: 2px solid var(--md-primary-light);
}

.help b em {
	color: var(--md-primary);
	font-size: 1rem;
}

.help blockquote {
	margin: 12px 16px;
	padding: 12px 16px;
	border-right: 4px solid var(--md-primary-light);
	background: var(--md-blockquote-bg);
	border-radius: 0 var(--md-radius) var(--md-radius) 0;
}

.help a {
	color: var(--md-primary);
	text-decoration: none;
	font-weight: 500;
}

.help a:hover {
	text-decoration: underline;
}

/* Help backdrop */
.help::before {
	content: '';
	position: fixed;
	inset: 0;
	background: var(--md-surface);
	z-index: -1;
}

/* Separator (unused but kept) */
.access_separator {
	height: 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
	width: 8px;
}

::-webkit-scrollbar-track {
	background: transparent;
}

::-webkit-scrollbar-thumb {
	background: var(--md-scrollbar-thumb);
	border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
	background: var(--md-scrollbar-thumb-hover);
}

/* Bottom buttons container */
.bottom-buttons {
	margin-top: auto;
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

.bottom-buttons button {
	padding: 8px 20px;
	background: var(--md-primary);
	color: #fff;
	border: none;
	border-radius: var(--md-radius);
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 500;
	cursor: pointer;
	box-shadow: var(--md-shadow-2);
	transition: background var(--md-transition), box-shadow var(--md-transition);
}

.bottom-buttons button:hover {
	background: var(--md-primary-dark);
	box-shadow: var(--md-shadow-3);
}

/* Responsive */
@media (width <= 900px) {
	body {
		flex-direction: column;
		padding: 16px;
		gap: 16px;
	}

	.access {
		flex: none;
		width: 100%;
		height: auto;
		max-height: none;
	}

	.answer_text {
		width: 100%;
		height: auto;
		min-height: 200px;
		max-height: none;
	}

	.nikuda_label {
		display: none;
	}

	.help {
		width: 95vw;
		max-height: 90vh;
		padding: 20px;
		font-size: 0.875rem;
	}
}

/* Guided demo (src/js/demo.js): a balloon pointing at one control at a time */
.demo-balloon {
	position: fixed;
	z-index: 300;
	width: min(340px, calc(100vw - 16px));
	padding: 16px 18px 14px;
	background: var(--md-surface);
	color: var(--md-on-surface);
	border: 2px solid var(--md-accent);
	border-radius: 12px;
	box-shadow: var(--md-shadow-3);
	font-size: 1rem;
	line-height: 1.6;
	text-align: right;
}

.demo-count {
	font-size: 0.75rem;
	color: var(--md-on-surface-secondary);
	margin-bottom: 4px;
}

.demo-actions {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}

.demo-actions button {
	padding: 6px 18px;
	border: none;
	border-radius: var(--md-radius);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.demo-next {
	background: var(--md-accent);
	color: #fff;
}

.demo-next:hover:not(:disabled) {
	background: var(--md-accent-dark);
}

.demo-next:disabled {
	background: var(--md-disabled-btn-bg);
	cursor: wait;
}

.demo-stop {
	background: transparent;
	color: var(--md-on-surface-secondary);
}

.demo-stop:hover {
	color: var(--md-on-surface);
}

/* The arrow is a rotated square on the balloon's edge, toward the target */
.demo-arrow {
	position: absolute;
	width: 14px;
	height: 14px;
	margin-left: -7px;
	background: var(--md-surface);
	border: 2px solid var(--md-accent);
	transform: rotate(45deg);
}

.demo-below .demo-arrow {
	top: -9px;
	border-right: none;
	border-bottom: none;
}

.demo-above .demo-arrow {
	bottom: -9px;
	border-left: none;
	border-top: none;
}

.demo-center .demo-arrow {
	display: none;
}

/* The control the balloon points at */
.demo-target {
	outline: 3px solid var(--md-accent);
	outline-offset: 3px;
	border-radius: var(--md-radius);
	animation: demo-pulse 1.2s ease-in-out infinite;
}

@keyframes demo-pulse {
	50% {
		outline-color: transparent;
	}
}

@media (prefers-reduced-motion: reduce) {
	.demo-target {
		animation: none;
	}
}
