/* ==========================================================================
   Public site form fields: the login page look (libs/css/login.css .tsl-field / .tsl-group)
   for every Bootstrap 3 .form-control and .input-group on the front end.

   Loaded ONLY by templates/layout.tpl, straight after custom.css. Admin layouts never load it,
   so admin forms are unchanged.

   - Fields: pill shape, soft green background and border, green text.
   - Focus: a 2px dark green line (1px border + 1px inset shadow, so nothing moves) inside a
     5px light green ring (outline). !important where custom.css forces its own focus border,
     outline: 0 and glow on every input.
   - Input groups (field + addon/button): one pill; on focus the ring goes round the whole group
     and the vertical dividers stay plain.
   Colours come from colors.css (and flip with colors-dark.css).
   ========================================================================== */
:root {
	--tsf-r: 24px;                                                         /* pill radius, as login.css --tsl-r */
	--tsf-r-box: 16px;                                                     /* textareas and multi-selects */
	--tsf-bg: var(--green-light);
	--tsf-line: var(--green-lighter);
	--tsf-text: var(--green-primary);
	--tsf-focus: var(--green-secondary);
	--tsf-ring: color-mix(in srgb, var(--green-secondary) 30%, transparent);
	--tsf-addon-bg: color-mix(in srgb, var(--green-lighter) 25%, var(--green-light));
}

/* ---------- Fields ---------- */
.form-control {
	height: auto;
	min-height: 44px;                 /* also a comfortable touch target */
	padding: 10px 18px;
	border: 1px solid var(--tsf-line);
	border-radius: var(--tsf-r);
	background-color: var(--tsf-bg);
	color: var(--tsf-text);
	box-shadow: none;
}
.form-control::placeholder { color: color-mix(in srgb, var(--tsf-text) 55%, transparent); opacity: 1; }
textarea.form-control,
select[multiple].form-control,
select[size].form-control { border-radius: var(--tsf-r-box); }

/* Drop-downs: the browser's own arrow sits hard against the right edge, where the pill curves in. Draw our own
   chevron 18px in from the edge: two 2px strokes ( \ and / ) meeting at the bottom, in the field's text colour so
   it follows dark mode too. */
select.form-control:not([multiple]):not([size]) {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	padding-right: 44px;
	background-image:
		linear-gradient(45deg, transparent calc(50% - 1px), var(--tsf-text) calc(50% - 1px), var(--tsf-text) calc(50% + 1px), transparent calc(50% + 1px)),
		linear-gradient(135deg, transparent calc(50% - 1px), var(--tsf-text) calc(50% - 1px), var(--tsf-text) calc(50% + 1px), transparent calc(50% + 1px));
	background-position: calc(100% - 25px) 50%, calc(100% - 18px) 50%;
	background-size: 7px 7px, 7px 7px;
	background-repeat: no-repeat;
}
select.form-control::-ms-expand { display: none; }
.input-sm.form-control, .form-group-sm .form-control { min-height: 36px; padding: 6px 14px; }
.input-lg.form-control, .form-group-lg .form-control { min-height: 52px; padding: 12px 22px; }

.form-control:focus {
	border-color: var(--tsf-focus) !important;
	box-shadow: inset 0 0 0 1px var(--tsf-focus) !important;
	outline: 5px solid var(--tsf-ring) !important;
	outline-offset: 0;
}

.form-control[disabled],
.form-control[readonly],
fieldset[disabled] .form-control { background-color: var(--grey-tetradic); color: var(--grey-dark); opacity: 1; }

/* Validation states keep their colours, in the same shape */
.has-error .form-control { border-color: var(--error-border); }
.has-error .form-control:focus {
	border-color: var(--error-border) !important;
	box-shadow: inset 0 0 0 1px var(--error-border) !important;
	outline-color: color-mix(in srgb, var(--error-border) 30%, transparent) !important;
}

/* ---------- Input groups: one pill ---------- */
.input-group-addon {
	border: 1px solid var(--tsf-line);
	border-radius: var(--tsf-r);      /* Bootstrap squares the inner corners */
	background-color: var(--tsf-addon-bg);
	color: var(--tsf-text);
	padding: 6px 18px;
}
.input-group-btn > .btn { border-radius: var(--tsf-r); min-height: 44px; }
/* Plain buttons in a group (e.g. show/hide password) look like the addon, as on the login page */
.input-group-btn > .btn-default { border-color: var(--tsf-line); background-color: var(--tsf-addon-bg); color: var(--tsf-text); padding-left: 18px; padding-right: 18px; }
.input-group-btn > .btn-default:hover { background-color: color-mix(in srgb, var(--green-lighter) 40%, var(--green-light)); }

/* The field inside a group shows no ring of its own: the group draws it */
.input-group .form-control:focus {
	border-color: var(--tsf-line) !important;
	box-shadow: none !important;
	outline: 0 !important;
}
.input-group:focus-within {
	border-radius: var(--tsf-r);
	box-shadow: 0 0 0 1px var(--tsf-focus), 0 0 0 6px var(--tsf-ring);
}
/* Outer edges go dark green with the ring; the dividers between the parts stay plain */
.input-group:focus-within > .form-control,
.input-group:focus-within > .input-group-addon,
.input-group:focus-within > .input-group-btn > .btn { border-top-color: var(--tsf-focus) !important; border-bottom-color: var(--tsf-focus) !important; }
.input-group:focus-within > :first-child,
.input-group:focus-within > .input-group-btn:first-child > .btn { border-left-color: var(--tsf-focus) !important; }
.input-group:focus-within > :last-child,
.input-group:focus-within > .input-group-btn:last-child > .btn { border-right-color: var(--tsf-focus) !important; }

/* ---------- Header search (layout.tpl #search-overlay): the magnifier is a submit button ----------
   A dark green circle with a white icon, like the slide-to-submit handle (slide_to_submit.css .sts-handle).
   custom.css .icon-addon.addon-lg sets the field to 46px tall, so a 38px circle at 4px is centred. */
.icon-addon.addon-lg .search-submit {
	top: 4px; left: 4px;
	width: 38px; height: 38px;
	margin: 0; padding: 0;
	display: flex; align-items: center; justify-content: center;
	border: 0; border-radius: 50%;
	background: var(--green-primary);
	color: var(--pure-white, var(--white)) !important; /* stays white in dark mode; custom.css recolours the icon on hover/focus */
	font-size: 16px;
	cursor: pointer;
}
.icon-addon.addon-lg .search-submit:hover { background: var(--green-secondary); }
.icon-addon.addon-lg .search-submit:focus-visible { outline: 3px solid var(--tsf-ring); outline-offset: 2px; }
.icon-addon.addon-lg #searchbox { padding-left: 54px; }
#searchbox::-webkit-search-cancel-button { cursor: pointer; }

/* Quick-search buttons (Online Events, Today, ...): the login page's outline pill buttons (.tsl-btn-outline) */
.search-overlay .search-quick .btn-search {
	margin: 8px 0;
	padding: 14px 26px;
	border: 2px solid var(--green-primary);
	border-radius: var(--tsf-r);
	background-color: var(--white);
	color: var(--green-primary);
	font: 700 18px/1.2 Roboto, "Helvetica Neue", Arial, sans-serif;
	white-space: normal;              /* long names wrap instead of overflowing */
	transition: .15s;
}
.search-overlay .search-quick .btn-search:hover,
.search-overlay .search-quick .btn-search:focus-visible {
	transform: none;                  /* custom.css grows .search-overlay links on hover */
	background-color: var(--green-light);
	color: var(--green-primary);
}
.search-overlay .search-quick .btn-search:focus-visible { outline: 3px solid var(--tsf-ring); outline-offset: 2px; }

/* Divider under the quick searches, then a filled Close button (the login page's primary pill) */
.search-overlay .search-divider { margin: 16px 0; border-top: 1px solid var(--green-lighter); }
.search-overlay .search-close-btn {
	margin: 0 0 24px;
	padding: 14px 26px;
	border: 2px solid var(--green-primary);
	border-radius: var(--tsf-r);
	background-color: var(--green-primary);
	color: var(--pure-white, var(--white));
	font: 700 18px/1.2 Roboto, "Helvetica Neue", Arial, sans-serif;
}
.search-overlay .search-close-btn:hover,
.search-overlay .search-close-btn:focus-visible { background-color: var(--green-secondary); border-color: var(--green-secondary); color: var(--pure-white, var(--white)); }
.search-overlay .search-close-btn:focus-visible { outline: 3px solid var(--tsf-ring); outline-offset: 2px; }

/* ---------- Dark mode (colors-dark.css): text and placeholder need the light ink ---------- */
[data-theme="dark"] .form-control,
[data-theme="dark"] .input-group-addon { color: var(--black); }
[data-theme="dark"] .form-control::placeholder { color: color-mix(in srgb, var(--black) 55%, transparent); }

/* ---------- High contrast (body.high-contrast, custom.css): plain white ring, no shadows ---------- */
.high-contrast .form-control:focus,
.high-contrast .input-group:focus-within { box-shadow: none !important; outline: 3px solid currentColor !important; }
.high-contrast .input-group .form-control:focus { outline: 0 !important; }
