/* ═══ Ratapihan Portaali – kirjautuminen, rekisteröinti ja salasanan palautus ═══
   Sama tumma ilme kuin työpöytä- ja mobiiliportaalissa: keltainen logo-kiila, lasikortti, keltainen pääpainike. */
@font-face { font-family: "NunitoRegular"; font-weight: 200 1000; font-display: swap; src: url("fonts/nunito-latin-wght-normal.woff2") format("woff2"); }

:root {
	--bg: #242933;
	--card: rgba(46, 52, 64, .78);
	--line: rgba(255, 255, 255, .09);
	--line2: rgba(255, 255, 255, .16);
	--text: #ECEFF4;
	--muted: #A7B0C0;
	--yellow: #A3BE8C;
	--blue: #81A1C1;
	--green: #A3BE8C;
	--red: #BF616A;
	--safe-t: env(safe-area-inset-top, 0px);
	--safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); height: 100%; overscroll-behavior: none; }
body {
	margin: 0;
	min-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: calc(92px + var(--safe-t)) 16px calc(24px + var(--safe-b));
	font-family: "Nunito", "NunitoRegular", system-ui, sans-serif;
	color: var(--text);
	background: var(--bg);
	position: relative;
	overflow-x: hidden;
}
button, input { font-family: inherit; }

/* Tausta: rata-/korjaamokuva sumennettuna + tumma verho + keltainen hehku */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -2;
	background: url("ratapiha_bg.jpg") center / cover no-repeat;
	filter: blur(14px) saturate(.9);
	transform: scale(1.1);
}
body::after {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	background:
		radial-gradient(640px 420px at 50% 42%, rgba(163, 190, 140, .10), transparent 70%),
		linear-gradient(180deg, rgba(36, 41, 51, .72), rgba(36, 41, 51, .9));
}

/* CarNord-logo vasempaan yläkulmaan */
.auth-brand {
	position: fixed;
	top: var(--safe-t);
	left: 0;
	z-index: 5;
	height: 72px;
	padding: 0 24px;
	display: flex;
	align-items: center;
}
.auth-brand img { height: 40px !important; display: block; animation: logoIn .5s .22s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes brandIn { from { transform: translateX(-30px) scaleX(0); } to { transform: none; } }
@keyframes logoIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

/* Kortti */
.login-box {
	position: relative;
	width: 100%;
	max-width: 400px;
	padding: 26px 22px 22px;
	border-radius: 24px;
	background: var(--card);
	border: 1px solid var(--line2);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
	-webkit-backdrop-filter: blur(18px) saturate(1.2);
	backdrop-filter: blur(18px) saturate(1.2);
	display: flex;
	flex-direction: column;
	gap: 14px;
	animation: cardIn .55s .1s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }
.login-box::before {
	/* ohut keltainen kiila kortin yläkulmassa */
	content: "";
	position: absolute;
	top: 0;
	left: 22px;
	width: 64px;
	height: 4px;
	border-radius: 0 0 4px 4px;
	background: var(--yellow);
	clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

/* Vanha logo-rivi piiloon (logo on nyt yläkulman kiilassa) */
.login-logo-row { display: none; }

.login-box h2 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -.3px; color: #fff; }
.auth-sub { margin: -8px 0 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
.info-text { margin: -4px 0 2px; font-size: 14px; font-weight: 600; line-height: 1.5; color: #C2C9D6; }

/* Kentät */
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > label { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: #9AA3B3; }
.auth-input { position: relative; display: flex; align-items: center; }
.auth-input > svg { position: absolute; left: 14px; color: #8C95A6; pointer-events: none; transition: color .2s ease; }
.login-box input {
	width: 100%;
	height: 52px;
	padding: 0 14px;
	border-radius: 14px;
	border: 1px solid rgba(255, 255, 255, .18);
	background: rgba(0, 0, 0, .38);
	color: #fff;
	font-size: 16px;
	font-weight: 700;
	outline: none;
	transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.auth-input > svg ~ input { padding-left: 44px; }
.auth-input .eye + input, .auth-input input:has(+ .eye) { padding-right: 48px; }
.login-box input::placeholder { color: #6C7689; font-weight: 600; }
.login-box input:hover { border-color: rgba(255, 255, 255, .3); }
.login-box input:focus { border-color: var(--blue); background: rgba(0, 0, 0, .5); box-shadow: 0 0 0 3px rgba(129, 161, 193, .25); }
.auth-input:focus-within > svg { color: #A9C1D9; }
.login-box input:-webkit-autofill {
	-webkit-text-fill-color: #fff;
	-webkit-box-shadow: 0 0 0 100px #1b1d21 inset;
	caret-color: #fff;
}
.eye {
	position: absolute;
	right: 6px;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #8C95A6;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.eye:hover { color: #fff; background: rgba(255, 255, 255, .06); }

/* Pääpainike (keltainen kuten portaaleissa) */
.login-box > button, #loginBtn, #registerBtn, #resetBtn {
	position: relative;
	overflow: hidden;
	height: 54px;
	margin-top: 4px;
	border: 0;
	border-radius: 16px;
	background: var(--yellow);
	color: #242933;
	font-size: 17px;
	font-weight: 900;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	box-shadow: 0 10px 26px rgba(163, 190, 140, .28);
	transition: transform .12s ease, filter .15s ease, box-shadow .2s ease;
}
.login-box > button:hover, #loginBtn:hover, #registerBtn:hover, #resetBtn:hover { filter: brightness(1.06); box-shadow: 0 12px 30px rgba(163, 190, 140, .38); }
.login-box > button:active, #loginBtn:active, #registerBtn:active { transform: scale(.985); }
.enter-press { filter: brightness(1.08) !important; transform: scale(.985) !important; }

/* Latausanimaatio: ratapölkyt liikkuvat painikkeen alareunassa */
.login-box.loading { pointer-events: none; }
.login-box.loading > *:not(#loginBtn):not(#registerBtn):not(#resetBtn):not(.spinner) { opacity: .45; transition: opacity .25s ease; }
.login-box.loading #loginBtn::after, .login-box.loading #registerBtn::after, .login-box.loading #resetBtn::after {
	content: "";
	position: absolute;
	left: -24px;
	right: 0;
	bottom: 0;
	height: 5px;
	background: repeating-linear-gradient(90deg, #242933 0 12px, transparent 12px 24px);
	opacity: .55;
	animation: rail .5s linear infinite;
}
@keyframes rail { to { transform: translateX(24px); } }
.spinner { display: none !important; }

/* Linkit */
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 2px; }
.forgot-link {
	font-size: 14px;
	font-weight: 700;
	color: #C2C9D6;
	text-decoration: none;
	text-align: center;
	cursor: pointer;
	transition: color .15s ease;
}
.forgot-link:hover { color: var(--yellow); }
.forgot-link b { color: var(--yellow); font-weight: 800; }
.login-box > .forgot-link { align-self: center; }

/* Viimeksi kirjautuneet: käyttäjät rinnakkain, salasanakenttä rullautuu esiin valitun alle */
.user-shortcuts { display: flex; flex-direction: column; gap: 8px; }
.user-shortcuts:empty { display: none; }
.shortcuts-title { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: #9AA3B3; }
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.shortcut-user {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-width: 0;
	padding: 10px 6px 8px;
	border-radius: 16px;
	border: 1px solid var(--line2);
	background: rgba(255, 255, 255, .04);
	color: var(--text);
	cursor: pointer;
	transition: border-color .2s ease, background .2s ease, transform .15s ease;
}
.shortcut-user:hover { background: rgba(255, 255, 255, .07); transform: translateY(-1px); }
.shortcut-user.open { border-color: rgba(163, 190, 140, .7); background: rgba(163, 190, 140, .08); }
.user-icon { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 900; color: #242933; background: var(--yellow); box-shadow: 0 0 0 0 rgba(163, 190, 140, .0); transition: box-shadow .25s ease; }
.shortcut-user.open .user-icon { box-shadow: 0 0 0 4px rgba(163, 190, 140, .22); }
.user-name { max-width: 100%; font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-pass-container { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.3, .8, .3, 1); }
.quick-pass-container.open { grid-template-rows: 1fr; }
.quick-pass-inner { min-height: 0; overflow: hidden; }
.quick-pass-row { display: flex; gap: 8px; padding-top: 4px; }
.quick-pass-row input { height: 46px; }
.quick-login-btn {
	width: 46px;
	height: 46px;
	flex-shrink: 0;
	border: 0;
	border-radius: 12px;
	background: var(--yellow);
	color: #242933;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.quick-login-btn:hover { filter: brightness(1.06); }
.auth-divider { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; color: #8C95A6; text-transform: uppercase; letter-spacing: .5px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.auth-divider[hidden] { display: none; }

/* Yhteystiedot */
.company-info { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 14px; margin-top: 2px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 600; color: #8C95A6; text-align: center; }
.company-name { font-size: 13px; font-weight: 800; color: #C2C9D6; }

.login-footer {
	margin-top: 18px;
	text-align: center;
	font-size: 12px;
	font-weight: 700;
	color: rgba(255, 255, 255, .45);
	pointer-events: none;
}

/* Ilmoitus */
.toast {
	position: fixed;
	left: 50%;
	top: auto;
	bottom: calc(24px + var(--safe-b));
	z-index: 50;
	max-width: calc(100% - 32px);
	padding: 12px 16px 12px 14px;
	border-radius: 14px;
	border: 1px solid var(--line2) !important;
	border-left: 4px solid var(--red) !important;
	background: #3B4252 !important;
	color: #fff;
	font-size: 14px;
	font-weight: 800;
	box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, 12px);
	transition: opacity .25s ease, transform .25s ease;
}
.toast.ok { border-left-color: var(--green) !important; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
	body { justify-content: flex-start; padding-top: calc(80px + var(--safe-t)); padding-bottom: calc(12px + var(--safe-b)); }
	.login-box { gap: 12px; }
	.company-info { padding-top: 10px; }
	.login-footer { margin-top: 12px; }
	.login-box { padding: 24px 18px 20px; }
	.auth-brand { height: 60px; }
	.auth-brand img { height: 40px; }
}
@media (prefers-reduced-motion: reduce) { .auth-brand, .auth-brand img, .login-box { animation: none; } }
.shortcut-grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
@media (max-width: 480px) {
	.shortcut-user { padding: 8px 4px 7px; gap: 4px; border-radius: 14px; }
	.user-icon { width: 36px; height: 36px; font-size: 16px; }
	.user-name { font-size: 13px; }
	.login-box h2 { font-size: 24px; }
	.login-box input { height: 48px; }
	#loginBtn { height: 50px; }
}

.auth-foot { margin: 22px auto 0; color: #7B8598; font-size: 13px; font-weight: 700; text-align: center; }
