/* ============================================================
   SkyCity — Umbraco Forms styling (forms.css)
   Loaded globally via _Layout.cshtml, AFTER site.css.

   Styles the DEFAULT Umbraco Forms theme markup (theme="default")
   rendered by Views/Partials/_PageForm.cshtml. The form only ships
   when a page picks one, so these rules are inert elsewhere.

   Two layers, base FIRST then layout (so layout wins on the few
   properties it sets — exactly as when base lived in site.css and
   this file loaded after it):
     1. BASE  — fields, labels, gold focus glow, mandatory asterisks,
                validation, success message, gold submit button.
     2. LAYOUT — contains the form as a left-aligned card, lets inputs
                fill the card, two-up field grid on wider screens.

   Static file: plain @media only (never @@media).
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   LAYER 1 — BASE (was the UMBRACO FORMS block in site.css)
   ════════════════════════════════════════════════════════════ */

.sc-form {
	max-width: var(--sc-max-width);
	margin: 0 auto;
	padding: 3rem 40px;
	width: 100%;
	font-family: var(--sc-font);
	color: var(--sc-text);
}

.sc-form__heading {
	font-size: 1.75rem;
	font-weight: 800;
	letter-spacing: .01em;
	color: var(--sc-text);
	margin: 0 0 1.75rem;
}

/* ── Form shell ── */
.sc-form .umbraco-forms-form { margin: 0; }
.sc-form .umbraco-forms-page { margin: 0; }

.sc-form fieldset,
.sc-form .umbraco-forms-fieldset {
	border: 0;
	margin: 0 0 1.5rem;
	padding: 0;
	min-width: 0;
}

.sc-form legend,
.sc-form .umbraco-forms-caption {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--sc-text);
	margin: 0 0 1rem;
	padding: 0;
}

.sc-form .umbraco-forms-container { display: block; }

/* ── Individual fields ── */
.sc-form .umbraco-forms-field { margin: 0 0 1.25rem; }

.sc-form .umbraco-forms-label,
.sc-form label {
	display: block;
	font-size: .9375rem;
	font-weight: 600;
	color: var(--sc-text);
	margin: 0 0 .4rem;
}

/* Mandatory indicator (default theme adds .mandatory / a *) */
.sc-form .umbraco-forms-field.mandatory .umbraco-forms-label::after,
.sc-form .field-required::after {
	content: " *";
	color: var(--sc-gold);
	font-weight: 700;
}

/* Suppress the default theme's OWN indicator span. The theme renders
   <span class="umbraco-forms-indicator">*</span> inside the label, which
   inherits --sc-dark and shows as a second, BLACK asterisk next to our gold
   ::after above. The gold one (scoped to .mandatory) is the single source of
   truth, so hide the theme's span. They're separate elements (span vs label
   ::after) — hiding the span leaves the gold asterisk untouched. */
.sc-form .umbraco-forms-indicator { display: none; }

.sc-form .umbraco-forms-field-wrapper { display: block; }

/* ── Text inputs / textarea / select ── */
.sc-form input[type="text"],
.sc-form input[type="email"],
.sc-form input[type="tel"],
.sc-form input[type="url"],
.sc-form input[type="number"],
.sc-form input[type="date"],
.sc-form input[type="password"],
.sc-form input.text,
.sc-form textarea,
.sc-form select {
	width: 100%;
	max-width: 540px;
	font-family: var(--sc-font);
	font-size: 1rem;
	color: var(--sc-text);
	background: var(--sc-white);
	border: 1px solid rgba(0,0,0,.2);
	border-radius: 8px;
	padding: .75rem .9rem;
	transition: border-color .2s, box-shadow .2s;
	box-sizing: border-box;
}

.sc-form textarea {
	min-height: 140px;
	resize: vertical;
	line-height: 1.6;
}

.sc-form input:focus,
.sc-form textarea:focus,
.sc-form select:focus {
	outline: none;
	border-color: var(--sc-gold);
	box-shadow: 0 0 0 3px rgba(220,183,65,.25);
}

.sc-form input::placeholder,
.sc-form textarea::placeholder { color: rgba(0,0,0,.4); }

/* ── Radio / checkbox lists ──────────────────────────────────
   Actual markup on this build (confirmed from the DOM):
     <div class="checkboxlist">          (or .radiobuttonlist)
       <div><input type=...><label>…</label></div>   ← one wrapper div per option
       <div><input type=...><label>…</label></div>
     </div>
   Each OPTION is its own wrapper <div>, input-first, with the label
   after it. So we don't touch the input/label order at all — we just
   stack the option wrappers and flex each one: box on the left, label
   on the right, vertically centred. Works identically for both lists. */
.sc-form .checkboxlist,
.sc-form .radiobuttonlist {
	display: flex;
	flex-direction: column;
	gap: .5rem;
}

/* Each option row: [box] [label] */
.sc-form .checkboxlist > div,
.sc-form .radiobuttonlist > div {
	display: flex;
	align-items: center;
	gap: .55rem;
}

.sc-form .checkboxlist label,
.sc-form .radiobuttonlist label {
	display: inline;
	font-weight: 500;
	margin: 0;
	cursor: pointer;
}

/* Box sizing (also covers any standalone checkbox, e.g. Data Consent).
   flex-shrink:0 stops a long label squashing the box. */
.sc-form input[type="radio"],
.sc-form input[type="checkbox"] {
	width: 1.05rem;
	height: 1.05rem;
	flex-shrink: 0;
	accent-color: var(--sc-gold);
	margin: 0;
}

/* Field help text */
.sc-form .umbraco-forms-tooltip,
.sc-form .help-text,
.sc-form small {
	display: block;
	font-size: .8125rem;
	color: rgba(0,0,0,.55);
	margin-top: .35rem;
}

/* ── Validation ── */
.sc-form .field-validation-error,
.sc-form .validation-summary-errors {
	color: #b3261e;
	font-size: .8125rem;
	font-weight: 600;
	margin-top: .35rem;
}
.sc-form .validation-summary-errors {
	background: rgba(179,38,30,.08);
	border: 1px solid rgba(179,38,30,.3);
	border-radius: 8px;
	padding: .85rem 1rem;
	margin: 0 0 1.5rem;
}
.sc-form .validation-summary-errors ul { margin: 0; padding-left: 1.25rem; }
.sc-form input.input-validation-error,
.sc-form textarea.input-validation-error,
.sc-form select.input-validation-error {
	border-color: #b3261e;
}

/* ── Success message ──
   The default theme renders this as an inline <span> (confirmed from the live
   DOM). Box styles — border/background/radius/padding — on an inline element
   wrap per line-box, so a multi-line message draws a staggered double border
   with the text spilling out. display:block makes it a single clean card. */
.sc-form .umbraco-forms-submitmessage {
	display: block;
	background: rgba(220,183,65,.12);
	border: 1px solid var(--sc-gold);
	border-radius: var(--sc-radius-card);
	padding: 1.5rem 1.75rem;
	font-size: 1.0625rem;
	line-height: 1.6;
	color: var(--sc-text);
}

/* ── Submit button — mirror .sc-btn / .sc-btn--gold ── */
.sc-form .umbraco-forms-navigation { margin-top: 1.75rem; }

.sc-form button[type="submit"],
.sc-form input[type="submit"],
.sc-form .umbraco-forms-navigation .btn,
.sc-form .umbraco-forms-navigation input[type="button"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	padding: .75rem 1.75rem;
	border: 2px solid var(--sc-gold);
	border-radius: var(--sc-radius-btn);
	background: var(--sc-gold);
	color: var(--sc-text);
	font-family: var(--sc-font);
	font-size: .875rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	transition: opacity .2s, background .2s, color .2s, border-color .2s;
	white-space: nowrap;
}

.sc-form button[type="submit"]:hover,
.sc-form input[type="submit"]:hover,
.sc-form .umbraco-forms-navigation .btn:hover {
	opacity: .88;
}

.sc-form button[type="submit"]:focus-visible,
.sc-form input[type="submit"]:focus-visible {
	outline: 2px solid var(--sc-gold);
	outline-offset: 3px;
}

@media (max-width: 1024px) {
	.sc-form { padding: 2.5rem 1.5rem; }
}

@media (max-width: 600px) {
	.sc-form { padding: 2rem 1.5rem; }
	.sc-form__heading { font-size: 1.4rem; }
	.sc-form input[type="text"],
	.sc-form input[type="email"],
	.sc-form input[type="tel"],
	.sc-form input[type="url"],
	.sc-form input[type="number"],
	.sc-form input[type="date"],
	.sc-form input.text,
	.sc-form textarea,
	.sc-form select { max-width: 100%; }
	.sc-form button[type="submit"],
	.sc-form input[type="submit"],
	.sc-form .umbraco-forms-navigation .btn { width: 100%; }
}

/* ════════════════════════════════════════════════════════════
   LAYER 2 — LAYOUT (card containment, two-up grid)
   ════════════════════════════════════════════════════════════ */

/* ── Contain the form as a card, left-aligned to the body copy ── */
.sc-form {
	max-width: 820px;
	margin-left: 0;          /* override site.css `margin: 0 auto` so the */
	margin-right: auto;      /* card hugs the left edge of the content column */
	padding: clamp(1.75rem, 4vw, 3rem);
	background: var(--sc-white);
	border: 1px solid rgba(0, 0, 0, .08);
	border-radius: var(--sc-radius-card);
	box-shadow: 0 12px 34px rgba(0, 0, 0, .07);
}

/* ── Heading with a short gold rule beneath ──────────────── */
.sc-form__heading {
	position: relative;
	padding-bottom: .9rem;
	margin-bottom: 1.9rem;
}
.sc-form__heading::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 56px;
	height: 3px;
	background: var(--sc-gold);
	border-radius: 2px;
}

/* ── Inputs fill their cell (override site.css 540px cap) ──── */
.sc-form input[type="text"],
.sc-form input[type="email"],
.sc-form input[type="tel"],
.sc-form input[type="url"],
.sc-form input[type="number"],
.sc-form input[type="date"],
.sc-form input[type="password"],
.sc-form input.text,
.sc-form textarea,
.sc-form select {
	max-width: 100%;
}

/* ── Two-column field layout on wider screens ────────────────
   The default theme holds all fields as children of
   .umbraco-forms-container. Grid that container so fields pair
   up in source order. Row spacing comes from each field's own
   bottom margin (site.css), so row-gap stays 0.
   NOTE: if the theme nests fields under an extra row/col wrapper
   on this install, move `display:grid` to that wrapper instead. */
@media (min-width: 768px) {
	.sc-form .umbraco-forms-container {
		display: grid;
		grid-template-columns: 1fr 1fr;
		column-gap: 1.5rem;
		row-gap: 0;
		/* Bottom-align cells so the INPUTS line up across a row even when one
		   field carries a help line (e.g. "Date and time" has a hint, its
		   neighbour doesn't) — without this the commented field pushes its
		   input lower than the field beside it. */
		align-items: end;
	}

	/* Textareas (the default theme's `.longanswer` field) always span the full
	   width of the grid. A textarea is the natural "last item" on most enquiry
	   forms and looks wrong boxed into a half-width cell. */
	.sc-form .umbraco-forms-field.longanswer {
		grid-column: 1 / -1;
	}

	/* No lone half-width field floating in the two-column grid. The very last
	   field, when it lands in an odd (left-column) position — i.e. an odd field
	   count — spans the full width. No `:has()` here, so this rule stands on its
	   own even on an engine that can't parse `:has()`. */
	.sc-form .umbraco-forms-field:last-child:nth-child(odd) {
		grid-column: 1 / -1;
	}

	/* A short field sitting immediately before a full-width textarea, when it
	   lands in an odd (left-column) position, would otherwise be stranded beside
	   the textarea's new full-width row — so span it full width too. Kept in its
	   OWN rule (NOT grouped with the plain selector above): an engine that can't
	   parse `:has()` drops the whole comma group it appears in, so isolating it
	   stops it taking the orphan rule down with it. Single, non-nested `:has()` —
	   the earlier breakage was a NESTED `:has(... :has(...))`. */
	.sc-form .umbraco-forms-field:nth-child(odd):has(+ .umbraco-forms-field.longanswer) {
		grid-column: 1 / -1;
	}

	/* Radio / checkbox lists read better full width too. The semantic
	   default theme wraps each list in a <fieldset>, so also span any
	   fieldset that is a direct child of the container — this stops the
	   checkbox group being squeezed into a half-width cell (which is what
	   made it look cramped/staggered while the radios rendered cleanly). */
	.sc-form .umbraco-forms-container > fieldset,
	.sc-form .umbraco-forms-field.checkboxlist,
	.sc-form .umbraco-forms-field.radiobuttonlist,
	.sc-form .umbraco-forms-field:has(.checkboxlist),
	.sc-form .umbraco-forms-field:has(.radiobuttonlist) {
		grid-column: 1 / -1;
	}

	/* Standalone SINGLE checkbox fields (Data Consent, single Checkbox) — full width.
	   These render as one <input type=checkbox> in the wrapper, NOT inside a
	   .checkboxlist group, so none of the group rules above catch them and they get
	   squeezed into a half-width cell — e.g. the "I am over 18 and would like to hear
	   from SkyCity Auckland" consent line wrapping into a narrow column. Class-based
	   rule first (works on any engine), then an isolated structural :has() fallback
	   for whatever field-type class the install actually emits. Kept in SEPARATE
	   blocks — never group :has() with a plain selector (§7): an engine that can't
	   parse :has() drops the entire comma group it sits in. */
	.sc-form .umbraco-forms-field.dataconsent,
	.sc-form .umbraco-forms-field.checkbox {
		grid-column: 1 / -1;
	}
	.sc-form .umbraco-forms-field:has(> .umbraco-forms-field-wrapper input[type="checkbox"]):not(:has(.checkboxlist)):not(:has(.radiobuttonlist)) {
		grid-column: 1 / -1;
	}
}

/* ── Submit sits clear of the last field ─────────────────── */
.sc-form .umbraco-forms-navigation {
	margin-top: 2rem;
}

/* ── Mobile: card goes edge-to-edge so it never feels cramped ── */
@media (max-width: 600px) {
	.sc-form {
		border-left: 0;
		border-right: 0;
		border-radius: 0;
		box-shadow: none;
		padding-left: 1.25rem;
		padding-right: 1.25rem;
	}
}

/* ── Pop-up enquiry form (native <dialog>) ───────────────────── */
.sc-form-dialog {
	width: min(640px, calc(100vw - 2rem));
	max-height: 90vh;
	padding: 0;                  /* padding lives on the inner scroll wrapper now */
	border: 0;
	border-radius: var(--sc-radius-card);
	box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
	position: relative;
	overflow: hidden;            /* clip the inner scrollbar so the rounded corners stay clean */
}
/* A native <dialog> is display:none until opened (showModal() sets [open]). That
   hide comes from the UA stylesheet, and ANY author `display` on the element beats
   it regardless of specificity — so putting `display:flex` on the base rule above
   made the CLOSED dialog render in normal flow: the form appeared stranded at the
   foot of the page even with the pop-up toggle on. Scope the flex layout to the
   open state and keep the closed state hidden, so the form shows only once the
   hero CTA calls showModal(). */
.sc-form-dialog:not([open]) { display: none; }
.sc-form-dialog[open] { display: flex; flex-direction: column; }
.sc-form-dialog::backdrop { background: rgba(0, 0, 0, .6); }

/* Inner scroll region — THIS scrolls, not the <dialog>. Keeping scroll off the
   dialog means: (a) the dialog's overflow:hidden + border-radius clip the
   scrollbar to the rounded corners (no squared-off edge beside the scrollbar),
   and (b) the absolutely-positioned close button is pinned to the dialog and
   never scrolls away. min-height:0 lets the flex child shrink so overflow kicks
   in; scrollbar-gutter reserves the lane so content doesn't jump when it appears. */
.sc-form-dialog__scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 2.75rem 1.75rem 2rem;
	scrollbar-gutter: stable;
}

.sc-form-dialog__close {
	position: absolute;
	top: .6rem;
	right: .6rem;
	z-index: 3;                  /* above the scroll region and its scrollbar */
	width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: var(--sc-white);  /* solid chip so it reads as intentional over content/scrollbar */
	color: var(--sc-text);
	box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
	cursor: pointer;
}
.sc-form-dialog__close:hover { background: #f4f4f4; }
