/*
 * GuestPass Portal Stylesheet
 * Mobile-first, self-contained -- no external fonts or CDN imports.
 * Colours are set via CSS custom properties injected by the server (--primary, --accent).
 */

/* =====================================================
   Reset and base
====================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Fallback colours -- overridden by server injection */
  --primary:        #1a1a2e;
  --accent:         #c8a96e;
  --text:           #1a1a1a;
  --text-muted:     #6b7280;
  --text-light:     #9ca3af;
  --bg:             #f5f5f0;
  --card-bg:        #ffffff;
  --border:         #e5e7eb;
  --error:          #dc2626;
  --error-bg:       #fef2f2;
  --success:        #16a34a;
  --radius:         10px;
  --radius-sm:      6px;
  --input-height:   48px;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:      var(--font);
  background-color: var(--bg);
  color:            var(--text);
  min-height:       100dvh;
  display:          flex;
  align-items:      flex-start;
  justify-content:  center;
  padding:          16px;
  padding-bottom:   40px;
}

[x-cloak] { display: none !important; }

/* =====================================================
   Portal wrapper + card
====================================================== */
.portal-wrapper {
  width:      100%;
  max-width:  480px;
  margin-top: 24px;
}

.portal-card {
  background:    var(--card-bg);
  border-radius: var(--radius);
  padding:       28px 24px 32px;
  box-shadow:    0 2px 16px rgba(0, 0, 0, 0.08);
}

.portal-card--centred {
  text-align: center;
  padding:    40px 28px;
}

/* =====================================================
   Logo / branding
====================================================== */
.portal-logo {
  text-align:    center;
  margin-bottom: 20px;
}

.portal-logo img {
  max-height:   72px;
  max-width:    200px;
  width:        auto;
  object-fit:   contain;
}

.portal-org-name {
  font-size:   1.1rem;
  font-weight: 700;
  color:       var(--primary);
  margin-top:  8px;
}

.portal-heading-block {
  margin-bottom: 24px;
}

.portal-heading {
  font-size:   1.35rem;
  font-weight: 700;
  color:       var(--primary);
  line-height: 1.3;
}

.portal-banner {
  display:       block;
  width:         100%;
  max-height:    180px;
  object-fit:    cover;
  border-radius: 8px;
  margin-bottom: 20px;
}

.portal-subheading {
  font-size:   0.9rem;
  color:       var(--text-muted);
  margin-top:  6px;
  line-height: 1.5;
}

/* =====================================================
   Form layout
====================================================== */
form {
  display:        flex;
  flex-direction: column;
  gap:            0;
}

.form-row {
  display:   flex;
  flex-direction: column;
  gap:       0;
}

.form-group {
  display:        flex;
  flex-direction: column;
  margin-bottom:  16px;
}

@media (min-width: 420px) {
  .form-row--half {
    flex-direction: row;
    gap:            12px;
  }

  .form-row--half .form-group {
    flex: 1;
  }
}

/* =====================================================
   Labels
====================================================== */
label {
  font-size:     0.8125rem;
  font-weight:   600;
  color:         var(--text);
  margin-bottom: 5px;
  display:       block;
}

.required {
  color: var(--error);
  margin-left: 2px;
}

.label-hint {
  font-weight: 400;
  color:       var(--text-light);
  font-size:   0.75rem;
  margin-left: 4px;
}

/* =====================================================
   Inputs
====================================================== */
.input {
  width:            100%;
  height:           var(--input-height);
  padding:          0 12px;
  font-size:        1rem;
  font-family:      var(--font);
  color:            var(--text);
  background:       #fff;
  border:           1.5px solid var(--border);
  border-radius:    var(--radius-sm);
  transition:       border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance:       none;
}

.input:focus {
  outline:      none;
  border-color: var(--primary);
  box-shadow:   0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.input--error {
  border-color: var(--error);
  background:   var(--error-bg);
}

.input--error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.input--yob {
  max-width: 130px;
}

/* Remove number input spinners */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.input[type="number"] { -moz-appearance: textfield; }

.error-msg {
  font-size:  0.775rem;
  color:      var(--error);
  margin-top: 4px;
  font-weight: 500;
}

/* =====================================================
   Flutter question (radio group)
====================================================== */
.flutter-fieldset {
  border:  none;
  padding: 0;
}

.flutter-legend {
  font-size:     0.8125rem;
  font-weight:   600;
  color:         var(--text);
  margin-bottom: 10px;
  display:       block;
  width:         100%;
}

.radio-group {
  display:        flex;
  flex-direction: column;
  gap:            8px;
}

@media (min-width: 380px) {
  .radio-group {
    flex-direction: row;
    flex-wrap:      wrap;
    gap:            8px;
  }
}

.radio-label {
  display:      flex;
  align-items:  center;
  gap:          8px;
  padding:      10px 14px;
  background:   #f9fafb;
  border:       1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor:       pointer;
  font-size:    0.875rem;
  font-weight:  normal;
  transition:   border-color 0.15s, background 0.15s;
  flex:         1;
  min-width:    100px;
  user-select:  none;
}

.radio-label:hover {
  border-color: var(--accent);
  background:   color-mix(in srgb, var(--accent) 8%, #fff);
}

.radio-label input[type="radio"] {
  position: absolute;
  opacity:  0;
  width:    0;
  height:   0;
}

.radio-label:has(input:checked) {
  border-color: var(--accent);
  background:   color-mix(in srgb, var(--accent) 12%, #fff);
  font-weight:  600;
}

.radio-custom {
  width:        16px;
  height:       16px;
  border:       2px solid var(--border);
  border-radius: 50%;
  flex-shrink:  0;
  transition:   border-color 0.15s;
}

.radio-label:has(input:checked) .radio-custom {
  border-color:     var(--accent);
  background:       var(--accent);
  box-shadow:       inset 0 0 0 3px #fff;
}

/* =====================================================
   Marketing checkbox
====================================================== */
.checkbox-label {
  display:     flex;
  align-items: flex-start;
  gap:         10px;
  cursor:      pointer;
  font-weight: normal;
  font-size:   0.875rem;
  line-height: 1.5;
}

.checkbox-input {
  position: absolute;
  opacity:  0;
  width:    0;
  height:   0;
}

.checkbox-custom {
  display:       flex;
  align-items:   center;
  justify-content: center;
  width:         20px;
  height:        20px;
  min-width:     20px;
  border:        2px solid var(--border);
  border-radius: 4px;
  margin-top:    1px;
  transition:    border-color 0.15s, background 0.15s;
  background:    #fff;
}

.checkbox-label:has(.checkbox-input:checked) .checkbox-custom {
  background:   var(--primary);
  border-color: var(--primary);
}

.checkbox-label:has(.checkbox-input:checked) .checkbox-custom::after {
  content:     '';
  display:     block;
  width:       5px;
  height:      9px;
  border:      2px solid #fff;
  border-top:  none;
  border-left: none;
  transform:   rotate(45deg) translate(-1px, -1px);
}

.checkbox-text {
  color:       var(--text);
  line-height: 1.5;
}

/* =====================================================
   GDPR notice
====================================================== */
.gdpr-notice {
  background:    #f9fafb;
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:       12px 14px;
  margin-bottom: 20px;
  margin-top:    4px;
}

.gdpr-notice p {
  font-size:   0.775rem;
  color:       var(--text-muted);
  line-height: 1.55;
}

.gdpr-link {
  color:           var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight:     600;
}

.gdpr-link:hover {
  color: var(--accent);
}

/* =====================================================
   Connect button
====================================================== */
.btn-connect {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  gap:              8px;
  width:            100%;
  height:           52px;
  padding:          0 24px;
  font-size:        1rem;
  font-weight:      700;
  font-family:      var(--font);
  color:            #fff;
  background:       var(--primary);
  border:           none;
  border-radius:    var(--radius-sm);
  cursor:           pointer;
  text-decoration:  none;
  transition:       opacity 0.15s, transform 0.1s;
  -webkit-appearance: none;
}

.btn-connect:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-connect:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-connect:disabled {
  opacity: 0.65;
  cursor:  not-allowed;
}

.btn-connect--outline {
  background:   transparent;
  color:        var(--primary);
  border:       2px solid var(--primary);
}

.btn-connect--ghost {
  background:   var(--accent);
  color:        var(--primary);
  margin-top:   8px;
}

/* =====================================================
   Loading spinner (inline)
====================================================== */
.loading-text {
  display:     flex;
  align-items: center;
  gap:         8px;
}

.spinner-sm {
  display:       inline-block;
  width:         16px;
  height:        16px;
  border:        2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation:     spin 0.7s linear infinite;
  flex-shrink:   0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================================================
   State screens (success / error / age restricted)
====================================================== */
.state-icon {
  font-size:     2.5rem;
  margin-bottom: 16px;
  display:       block;
}

.state-icon--success { color: var(--success); }
.state-icon--error   { color: var(--error); font-weight: 900; }
.state-icon--warning { }

.state-heading {
  font-size:     1.35rem;
  font-weight:   700;
  color:         var(--primary);
  margin-bottom: 12px;
}

.state-body {
  font-size:     0.9rem;
  color:         var(--text-muted);
  line-height:   1.6;
  margin-bottom: 8px;
}

.state-body--small {
  font-size: 0.8rem;
  margin-top: 12px;
}

.state-redirect {
  color:     var(--accent);
  font-weight: 600;
  margin-top: 8px;
}

/* =====================================================
   Focus styles (accessibility)
====================================================== */
:focus-visible {
  outline:        3px solid var(--accent);
  outline-offset: 2px;
  border-radius:  2px;
}

/* =====================================================
   Responsive tweaks
====================================================== */
@media (max-width: 360px) {
  .portal-card {
    padding: 20px 16px 24px;
  }

  .input--yob {
    max-width: 100%;
  }
}

@media (min-width: 480px) {
  body {
    padding:    24px;
    align-items: center;
    min-height: 100dvh;
  }

  .portal-wrapper {
    margin-top: 0;
  }

  .portal-card {
    padding: 36px 36px 40px;
  }
}
