/*
 * event-app design system
 *
 * Mobile-first, plain modern CSS served via Propshaft (no build step).
 * Taken from cockpit's application.css + themes/planet.css (Planet design
 * system: https://planet-group.github.io/Planet/UX-Styleguide.html), trimmed
 * to what this app uses. Components reference tokens, never raw values.
 */

:root {
  /* Planet tokens */
  --planet-primary: #0000FF;
  --planet-secondary: #D4FF00;
  --planet-black: #000000;
  --planet-white: #ffffff;
  --planet-tint: #DCDCDC;
  --planet-input-fill: #ECECEC;
  --planet-neutral: #F5F5F5;

  /* Color */
  --color-bg: var(--planet-neutral);
  --color-surface: var(--planet-white);
  --color-border: var(--planet-tint);
  --color-text: var(--planet-black);
  --color-text-muted: rgba(0, 0, 0, 0.5);
  --color-primary: var(--planet-primary);
  --color-primary-contrast: var(--planet-white);
  --color-danger: #b42318;

  /* Typography */
  --font-sans: "neue-haas-grotesk-display", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-h3: 2.5rem;
  --text-h2: clamp(3.5rem, 6vw, 5rem);
  --weight-body: 500;
  --weight-display: 600;

  /* Spacing & shape */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius: 24px;

  /* Layout */
  --content-max-width: 80rem;

  /* Form fields: one width and one look for every control */
  --field-width: 28rem;
  --field-radius: 12px;
}

/* Phones: the pinned desktop display sizes are far too large on ~390px. */
@media (max-width: 767.98px) {
  :root {
    --text-h3: 1.5rem;
    --text-h2: 2.25rem;
  }
}

/* --- Reset & base ------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-body);
  line-height: 1.4;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* `hidden` must win over component display rules (.btn is inline-flex). */
[hidden] {
  display: none !important;
}

/* Every clickable control: <button>, submit inputs (f.submit), .btn links,
   selects and radio/checkbox inputs. Disabled ones keep the not-allowed
   cursor from .btn:disabled. */
button:not(:disabled),
input[type="submit"]:not(:disabled),
input[type="radio"]:not(:disabled),
input[type="checkbox"]:not(:disabled),
select:not(:disabled),
.btn:not(:disabled),
summary {
  cursor: pointer;
}

/* Material Icons: cap width so ligature fallback text cannot blow up the
   layout before the webfont arrives. */
.material-icons-outlined {
  display: inline-block;
  flex-shrink: 0;
  font-family: "Material Icons Outlined", sans-serif;
  font-size: 24px;
  width: 1em;
  max-width: 1em;
  line-height: 1;
  overflow-x: hidden;
  overflow-y: visible;
  white-space: nowrap;
  speak: never;
  font-style: normal;
  font-weight: normal;
  letter-spacing: normal;
  text-transform: none;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
}

h1,
h2,
h3 {
  font-weight: var(--weight-display);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-block: 0 var(--space-3);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Accessibility ------------------------------------------------------ */

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-surface);
  padding: var(--space-2) var(--space-4);
  z-index: 100;
}

.skip-link:focus {
  left: var(--space-2);
}

/* --- Header: transparent on the canvas ------------------------------------ */

.site-header__inner {
  padding: var(--space-4) clamp(var(--space-4), 3vw, var(--space-8));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-header__brand {
  color: var(--planet-primary);
  font-weight: var(--weight-display);
  font-size: var(--text-h3);
  letter-spacing: -0.01em;
  line-height: 1;
}

.site-header__brand:hover {
  text-decoration: none;
  opacity: 0.75;
}

/* No mobile drawer: the few header items simply wrap. */
.site-header__nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.site-header__user {
  font-weight: var(--weight-display);
}

.site-header .btn {
  min-height: 2.5rem;
  padding: 0.4rem 0.85rem;
  white-space: nowrap;
}

.locale-switcher select {
  border: 0;
  border-bottom: 1px solid var(--planet-black);
  border-radius: 0;
  background: transparent;
  padding: var(--space-1) 0;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-body);
  cursor: pointer;
}

.locale-switcher select:focus {
  outline: none;
  border-bottom-color: var(--planet-primary);
}

/* --- Main --------------------------------------------------------------- */

.site-main {
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding: 2.5rem clamp(1.5rem, 3vw, 3rem) 5rem;
}

.page {
  max-width: 40rem;
}

.page__intro {
  color: var(--color-text-muted);
  margin-block: 0 var(--space-6);
}

/* --- Buttons: pills ------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: var(--weight-display);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  width: auto;
  max-width: 100%;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  --btn-fill: var(--planet-primary);
  background: var(--btn-fill);
  color: var(--planet-white);
}

.btn--primary:hover {
  --btn-fill: var(--planet-black);
  background: var(--btn-fill);
}

.btn--ghost {
  --btn-fill: transparent;
  background: transparent;
  color: var(--planet-black);
  border-color: var(--planet-black);
}

.btn--ghost:hover {
  --btn-fill: var(--planet-black);
  background: var(--btn-fill);
  border-color: var(--btn-fill);
  color: var(--planet-white);
}

/* Fade only the fill — label stays full strength. */
.btn:disabled,
.btn.btn--primary:disabled,
.btn.btn--ghost:disabled {
  cursor: not-allowed;
  pointer-events: none;
  background: color-mix(in srgb, var(--btn-fill, transparent) 70%, transparent) !important;
  border-color: transparent !important;
}

.btn.btn--ghost:disabled {
  border-color: currentColor !important;
  opacity: 0.45;
}

.btn--wide {
  width: 100%;
}

/* --- Flash messages ------------------------------------------------------ */

/* Toast layer: fixed top-center, outside the document flow, so showing and
   dismissing flashes never moves the page content. */
.flash-stack {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: var(--space-2);
  width: min(560px, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}

.flash {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-radius: 24px;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-display);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--planet-black) 12%, transparent);
  pointer-events: auto;
  animation: flash-in 240ms ease-out;
}

@keyframes flash-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.flash.is-dismissing {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.flash__icon {
  flex: none;
  font-size: 20px;
}

.flash__message {
  flex: 1;
  min-width: 0;
}

.flash__close {
  flex: none;
  display: inline-flex;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  opacity: 0.55;
}

.flash__close:hover {
  opacity: 1;
}

.flash__close .material-icons-outlined {
  font-size: 18px;
}

/* CI banners: notice = Planet blue with acid icon, alert = acid with black text. */
.flash--notice {
  background: var(--planet-primary);
  color: var(--planet-white);
}

.flash--notice .flash__icon {
  color: var(--planet-secondary);
}

.flash--alert {
  background: var(--planet-secondary);
  color: var(--planet-black);
}

/* --- Confirm modal -------------------------------------------------------- */

.confirm-dialog {
  /* Fixed + inset: 0 + margin: auto centers it in the viewport regardless
     of scroll (confirm_dialog.js corrects for iOS zoom inline). */
  position: fixed;
  inset: 0;
  height: fit-content;
  margin: auto;
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  max-width: 26rem;
  width: calc(100vw - 2 * var(--space-4));
  background: var(--planet-white);
  box-shadow: 0 24px 64px color-mix(in srgb, var(--planet-black) 25%, transparent);
}

.confirm-dialog::backdrop {
  background: color-mix(in srgb, var(--planet-black) 40%, transparent);
}

.confirm-dialog__body {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: var(--space-6);
}

.confirm-dialog__body p {
  margin: 0;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* --- Login: editorial, no card ---------------------------------------------- */

.login-card {
  max-width: 34rem;
  margin: 16vh auto 0;
}

.login-card::before {
  content: "";
  display: block;
  width: 4rem;
  height: 2px;
  background: var(--planet-primary);
  margin-bottom: var(--space-6);
}

.login-card h1 {
  font-size: var(--text-h2);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-4);
}

.login-card__note {
  color: var(--color-text-muted);
  margin-block: 0 var(--space-8);
}

.login-card .btn {
  width: auto;
  padding: 0.75rem 1.75rem;
}

/* --- Forms: filled inputs ----------------------------------------------------- */

.form {
  display: grid;
  gap: var(--space-6);
}

.form__field {
  display: grid;
  gap: var(--space-2);
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.form__field label,
.form__field legend {
  font-weight: var(--weight-display);
  font-size: var(--text-sm);
}

.form__field legend {
  padding: 0;
  margin-block-end: var(--space-2);
}

/* Every control box shares one width and one look: white surface, light
   grey border, rounded corners (.form__choices, .form__range, textarea). */
.form__choices,
.form__range,
.form__field textarea {
  width: 100%;
  max-width: var(--field-width);
  background: var(--color-surface);
  border: 1px solid var(--planet-tint);
  border-radius: var(--field-radius);
}

.form__field textarea {
  padding: var(--space-3) var(--space-4);
  font: inherit;
  color: var(--color-text);
  resize: vertical;
}

.form__field textarea:focus-visible {
  outline: 2px solid var(--planet-primary);
  outline-offset: -2px;
}

/* Radio list: stacked rows, each a whole touch target with a drawn radio dot
   and a one-line hint. Deliberately not pills — those mean "do something". */
.form__choices {
  display: grid;
  overflow: hidden;
}

/* Horizontal variant (dog count): dot above the number. Items share the
   free space (flex-grow), so the space around each number flexes with the
   field width, the first and last item reach the field edges, and the
   dividers sit exactly between neighbours. */
.form__choices--row {
  display: flex;
}

.form__choices--row .form__choice {
  flex: 1 1 auto;
}

.form__choices--row .form__choice + .form__choice {
  border-top: 0;
  border-left: 1px solid var(--planet-tint);
}

.form__choice--compact {
  grid-template-columns: none;
  justify-items: center;
  gap: var(--space-1);
  padding: var(--space-3);
  font-variant-numeric: tabular-nums;
}

.form__choice--compact .form__choice-dot {
  grid-row: auto;
}

/* Slider with its live value ("12 km", "1000+ km", "–" while unset). */
.form__range {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.form__range input[type="range"] {
  flex: 1;
  min-width: 0;
  margin: 0;
  accent-color: var(--planet-primary);
  cursor: pointer;
}

.form__range input[type="range"]:focus-visible {
  outline: 2px solid var(--planet-primary);
  outline-offset: 4px;
}

/* Fixed width so the value changing never moves the slider. */
.form__range-value {
  flex: none;
  min-width: 5.5rem;
  text-align: right;
  font-weight: var(--weight-display);
  font-variant-numeric: tabular-nums;
}

.form__choice {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
}

.form__choice + .form__choice {
  border-top: 1px solid var(--planet-tint);
}

.form__choice:hover {
  background: var(--planet-neutral);
}

.form__choice-dot {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--planet-tint);
}

.form__choice-title {
  font-weight: var(--weight-display);
}

.form__choice-hint {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Selected: blue ring with a filled blue dot. The dot is a centered radial
   background, not a child element — no sub-pixel rounding, always dead center. */
.form__choice:has(input:checked) .form__choice-dot {
  border-color: var(--planet-primary);
  background: radial-gradient(circle closest-side, var(--planet-primary) 62%, transparent 66%);
}

/* Keyboard users still need to see where they are. */
.form__choice:has(input:focus-visible) {
  outline: 2px solid var(--planet-primary);
  outline-offset: -2px;
}

/* The row is the control: the native radio stays in the DOM (keyboard +
   screen readers) but is not drawn — .form__choice-dot shows its state. */
.form__choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.form__hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* --- Profile picture --------------------------------------------------------- */

.avatar-field__label {
  font-weight: var(--weight-display);
  font-size: var(--text-sm);
}

/* Says up front that every new photo becomes a manga portrait. CI yellow so
   nobody misses it. */
.manga-notice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  max-width: var(--field-width);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--field-radius);
  background: var(--planet-secondary);
  color: var(--planet-black);
}

.manga-notice__icon {
  font-size: 1.5rem;
}

.manga-notice__title {
  margin: 0;
  font-weight: var(--weight-display);
}

.manga-notice__text {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
}

.avatar-field__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Gallery frame: portrait 4:5 picture on a white mat, black hairline,
   soft shadow. Clean and rectangular. */
.avatar-frame {
  width: 12rem;
  max-width: 100%;
  margin: 0;
}

.avatar-frame__mat {
  padding: 12px;
  background: var(--planet-white);
  border: 1px solid var(--planet-black);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--planet-black) 12%, transparent);
}

.avatar-frame__window {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--planet-primary);
}

/* Manga portrait in progress: dim the picture, spinner on top. */
.avatar-frame__busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--planet-white) 55%, transparent);
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--planet-primary);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.avatar-status {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
}

.avatar-manga {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  max-width: var(--field-width);
}

.avatar-manga__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.avatar-manga__status {
  margin: 0;
  font-weight: var(--weight-display);
  color: var(--planet-primary);
}

.avatar-manga__error,
.avatar-field__note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-danger);
}

.avatar-field__note {
  color: var(--color-text-muted);
}

/* "Wer bist du?" — the photo with one clickable box per detected face. */
/* JS sets aspect-ratio and width to the photo's own shape, so the face boxes
   (positioned in %) line up exactly — no letterboxing. */
.face-picker {
  position: relative;
  margin-inline: auto;
  max-width: 100%;
}

.face-picker__image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--field-radius);
}

.face-picker__box {
  position: absolute;
  border: 3px solid var(--planet-white);
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 0 0 1px var(--planet-black), 0 4px 12px color-mix(in srgb, var(--planet-black) 30%, transparent);
  padding: 0;
}

.face-picker__box:hover,
.face-picker__box:focus-visible {
  border-color: var(--planet-primary);
  outline: none;
  background: color-mix(in srgb, var(--planet-primary) 15%, transparent);
}

.avatar-frame__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-frame__initials {
  color: var(--planet-secondary);
  font-size: var(--text-h3);
  font-weight: var(--weight-display);
  letter-spacing: -0.02em;
}

/* Webcam dialog — same shell as the confirm dialog. */
.camera-dialog {
  position: fixed;
  inset: 0;
  height: fit-content;
  margin: auto;
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  max-width: 30rem;
  width: calc(100vw - 2 * var(--space-4));
  background: var(--planet-white);
  box-shadow: 0 24px 64px color-mix(in srgb, var(--planet-black) 25%, transparent);
}

.camera-dialog::backdrop {
  background: color-mix(in srgb, var(--planet-black) 40%, transparent);
}

.camera-dialog__body {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.camera-dialog__body h2 {
  margin: 0;
}

/* 4:5 stage = exactly what gets captured (same shape as the frame). */
.camera-dialog__stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  /* Narrower on short screens so the 4:5 shape always fits; never distort. */
  width: min(100%, calc(60vh * 4 / 5));
  margin-inline: auto;
  overflow: hidden;
  border-radius: var(--field-radius);
  background: var(--planet-black);
}

.camera-dialog__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Selfie view: mirrored like a mirror (the photo matches it). */
  transform: scaleX(-1);
}

.camera-dialog__error {
  margin: 0;
  padding: var(--space-6);
  color: var(--planet-white);
  text-align: center;
}

.camera-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* --- Utilities ---------------------------------------------------------------- */

.btn--with-icon {
  gap: var(--space-1);
}

.btn--with-icon .material-icons-outlined {
  font-size: 18px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Admin ------------------------------------------------------------------ */

.admin-panel {
  margin-block-start: var(--space-8);
  padding-block-start: var(--space-6);
  border-top: 1px solid var(--planet-tint);
}

/* --- Profile layout ----------------------------------------------------------- */

/* Desktop: fields on the left, the picture block on the right. The picture
   comes first in the markup, so on phones it stays on top. It spans the 5
   left rows (dogs, diet, km, info, save). */
@media (min-width: 768px) {
  .page--profile {
    max-width: 60rem;
  }

  .form--profile {
    grid-template-columns: minmax(0, var(--field-width)) minmax(0, 1fr);
    column-gap: clamp(var(--space-8), 6vw, 5rem);
    align-items: start;
  }

  .form--profile > * {
    grid-column: 1;
  }

  .form--profile > .avatar-field {
    grid-column: 2;
    grid-row: 1 / span 5;
  }
}

/* --- iOS zoom guard ----------------------------------------------------------- */

/* iOS zooms the page when a focused control renders under 16px, which knocks
   the fixed confirm dialog out of view. Keep focusable fields at 16px on
   touch phones. */
@media (max-width: 767.98px) and (pointer: coarse) {
  .form__field input,
  .form__field textarea,
  .locale-switcher select {
    font-size: var(--text-base);
  }
}
