/* ==========================================================================
   Avatar Creator — brand.css
   Design tokens + base + shared components. Every page loads this file.
   The visual reference lives at /styleguide.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Rouge: the brand colour. Lipstick red with a pink lean. */
  --rouge-50:  #FFF1F3;
  --rouge-100: #FDE2E6;
  --rouge-200: #F9C3CD;
  --rouge-300: #F295A7;
  --rouge-400: #E8667F;
  --rouge-500: #D63A5E;   /* primary */
  --rouge-600: #B8274B;   /* text-safe rouge on light bg */
  --rouge-700: #93203D;
  --rouge-800: #6E1A31;

  /* Neutrals are warm: tinted towards rose, never grey-blue. */
  --cream:     #FFF8F6;   /* page background */
  --paper:     #FFFFFF;   /* cards, inputs */
  --blush:     #FBEDEB;   /* soft fills, hovers */
  --line:      #EEDCDB;   /* borders */
  --line-strong:#DCC2C3;
  --ink:       #2B1A1F;   /* headings, body */
  --ink-2:     #5E464D;   /* secondary text */
  --ink-3:     #8E777D;   /* hints, placeholders */

  /* Accents, used sparingly. */
  --champagne: #E9C9A8;
  --plum:      #5B2A48;
  --peach:     #FFC7B0;

  /* Feedback */
  --success:   #2F8F6B;
  --success-bg:#E7F5EF;
  --danger:    #C2334D;
  --danger-bg: #FDECEF;
  --warning:   #B7791F;

  /* Type */
  --font-wordmark: "Bodoni Moda", "Didot", "Bodoni 72", "Times New Roman", serif; /* the logo only */
  --font-display: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-xs:  0.75rem;
  --text-sm:  0.875rem;
  --text-md:  1rem;
  --text-lg:  1.125rem;
  --text-xl:  1.375rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.5rem;
  --text-4xl: 3.5rem;

  /* Space (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px;

  /* Shape */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Elevation: rose-tinted shadows, soft and low. */
  --shadow-sm: 0 1px 2px rgba(110, 26, 49, .06);
  --shadow-md: 0 6px 20px -6px rgba(110, 26, 49, .14), 0 2px 6px rgba(110, 26, 49, .05);
  --shadow-lg: 0 24px 60px -20px rgba(110, 26, 49, .28);
  --ring: 0 0 0 4px rgba(214, 58, 94, .16);

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 140ms;
  --t-med: 260ms;
}

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

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

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; }

[hidden] { display: none !important; }

a {
  color: var(--rouge-600);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--rouge-700); text-decoration: underline; }

:focus-visible { outline: 2px solid var(--rouge-500); outline-offset: 3px; border-radius: 6px; }

::selection { background: var(--rouge-200); color: var(--ink); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Typography ---------- */

/* The wordmark: Didone, like a magazine masthead. "Avatar" upright,
   "Creator" in italic — the italic carries the feminine note. */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: .28em;
  font-family: var(--font-wordmark);
  font-optical-sizing: auto;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--rouge-500);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark em { font-style: italic; font-weight: 400; }
.wordmark:hover { color: var(--rouge-600); text-decoration: none; }
.wordmark--lg { font-size: 3rem; }
.wordmark--sm { font-size: 1.25rem; }

.display {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}
.display em { font-style: italic; font-weight: inherit; color: var(--rouge-500); }

h1.display, .display--1 { font-size: clamp(2.25rem, 1.6rem + 2vw, var(--text-4xl)); }
h2.display, .display--2 { font-size: clamp(1.75rem, 1.4rem + 1vw, var(--text-3xl)); }
.display--3 { font-size: var(--text-2xl); }

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--rouge-600);
}

.lede { font-size: var(--text-lg); color: var(--ink-2); margin: 0; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: var(--text-sm); }

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 48px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--btn-h);
  padding: 0 var(--s-6);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: 600 var(--text-md)/1 var(--font-sans);
  letter-spacing: .005em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              box-shadow var(--t-med) var(--ease), transform var(--t-fast) var(--ease), color var(--t-fast);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--block { width: 100%; }
.btn--sm { --btn-h: 38px; padding: 0 var(--s-4); font-size: var(--text-sm); }

.btn--primary {
  background: linear-gradient(180deg, var(--rouge-400) -40%, var(--rouge-500) 60%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 20px -8px rgba(214, 58, 94, .6);
}
.btn--primary:hover {
  color: #fff;
  background: linear-gradient(180deg, var(--rouge-500) -40%, var(--rouge-600) 60%);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 12px 26px -10px rgba(214, 58, 94, .7);
}

.btn--secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover { color: var(--ink); background: var(--blush); border-color: var(--rouge-200); }

.btn--ghost { background: transparent; color: var(--rouge-600); }
.btn--ghost:hover { background: var(--rouge-50); color: var(--rouge-700); }

.btn--danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(194, 51, 77, .7);
}
.btn--danger:hover { color: #fff; background: #A82540; }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: rgba(194, 51, 77, .35); }
.btn--danger-ghost:hover { color: #A82540; background: var(--danger-bg); border-color: var(--danger); }

/* Loading state: <button class="btn" aria-busy="true"> */
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn--secondary[aria-busy="true"]::after { border-color: var(--rouge-100); border-top-color: var(--rouge-500); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form fields ---------- */
.form { display: grid; gap: var(--s-5); }

.field { display: grid; gap: 6px; }

.field__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }

.label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}
.label__aside { font-size: var(--text-sm); font-weight: 500; }

.control { position: relative; display: flex; align-items: center; }

.control__icon {
  position: absolute;
  left: 15px;
  width: 18px; height: 18px;
  color: var(--ink-3);
  pointer-events: none;
  transition: color var(--t-fast) var(--ease);
}

.input {
  width: 100%;
  height: 52px;
  padding: 0 var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  font: 500 var(--text-md)/1.2 var(--font-sans);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease), background var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}
.control__icon ~ .input { padding-left: 44px; }
.control:has(.control__action) .input { padding-right: 52px; }

.input::placeholder { color: var(--ink-3); font-weight: 400; opacity: 1; }
.input:hover { border-color: var(--rouge-200); }
.input:focus { outline: none; border-color: var(--rouge-400); box-shadow: var(--ring); }
.control:focus-within .control__icon { color: var(--rouge-500); }

/* Kill the blue/yellow browser autofill tint. */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--rouge-50) inset;
  transition: background-color 9999s;
}

.field.is-invalid .input { border-color: var(--danger); background: #FFFBFB; }
.field.is-invalid .input:focus { box-shadow: 0 0 0 4px rgba(194, 51, 77, .14); }
.field.is-invalid .control__icon { color: var(--danger); }
.field.is-valid .input { border-color: color-mix(in srgb, var(--success) 45%, var(--line-strong)); }

.field__error {
  display: none;
  margin: 0;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--danger);
  font-weight: 500;
}
.field__error::before {
  content: "";
  flex: none;
  width: 14px; height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.field.is-invalid .field__error { display: flex; }

/* Icon button inside a control (e.g. show/hide password). */
.control__action {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.control__action:hover { background: var(--blush); color: var(--rouge-600); }
.control__action svg { width: 20px; height: 20px; }
.control__action .icon-hide { display: none; }
.control__action[aria-pressed="true"] .icon-show { display: none; }
.control__action[aria-pressed="true"] .icon-hide { display: block; }

/* Password strength: four segments filled by data-score 0–4. */
.strength { display: grid; gap: 6px; }
.strength__bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.strength__bars span {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background var(--t-med) var(--ease);
}
.strength__label { font-size: var(--text-xs); color: var(--ink-3); font-weight: 500; min-height: 1em; }
.strength[data-score="1"] .strength__bars span:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] .strength__bars span:nth-child(-n+2) { background: var(--warning); }
.strength[data-score="3"] .strength__bars span:nth-child(-n+3) { background: var(--rouge-400); }
.strength[data-score="4"] .strength__bars span { background: var(--success); }

/* Checkbox */
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  font-size: var(--text-sm);
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1.45;
}
.check input {
  flex: none;
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-med);
}
.check input::after {
  content: "";
  width: 10px; height: 6px;
  border: 2px solid #fff;
  border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform var(--t-fast) var(--ease);
}
.check input:checked { background: var(--rouge-500); border-color: var(--rouge-500); }
.check input:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input:focus-visible { outline: none; box-shadow: var(--ring); }
.check:hover input:not(:checked) { border-color: var(--rouge-300); }
.field.is-invalid .check input { border-color: var(--danger); }

/* Toggle switch: <label class="switch"><input type="checkbox"><span>Label</span></label> */
.switch { display: flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input {
  flex: none;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px; height: 26px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  cursor: pointer;
  transition: background var(--t-med) var(--ease), box-shadow var(--t-med);
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(43, 26, 31, .25);
  transition: transform var(--t-med) var(--ease);
}
.switch input:checked { background: var(--rouge-500); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: none; box-shadow: var(--ring); }

/* Divider with text: <div class="divider">or</div> */
.divider {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: var(--s-2);
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 14px var(--s-4);
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--t-med) var(--ease) both;
  pointer-events: auto;
}
.toast::before {
  content: "";
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rouge-300);
  box-shadow: 0 0 0 4px rgba(242, 149, 167, .2);
}
.toast > span { flex: 1; }
.toast__action {
  flex: none;
  margin: -6px -6px -6px 0;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .12);
  color: var(--rouge-200);
  font: 600 var(--text-sm)/1 var(--font-sans);
  cursor: pointer;
}
.toast__action:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.toast.is-leaving { animation: toast-out var(--t-med) var(--ease) both; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
