/* Base: tokens, reset, type, shared components (button, field, dialog, toast, chrome). */

:root {
  --bg: #140c11;
  --bg-raised: #1c1118;
  --bg-sunk: #0f080c;
  --cream: #f4e9dc;
  --cream-deep: #e6d3bf;
  --ink: #2b1921;
  --ink-soft: #5d4a52;
  --text: #f4e9dc;
  --text-2: rgba(244, 233, 220, 0.74);
  --text-3: rgba(244, 233, 220, 0.56);
  --line: rgba(244, 233, 220, 0.14);
  --line-strong: rgba(244, 233, 220, 0.28);
  --wine: #5a2230;
  --rose: #e98b99;
  --gold: #e3b678;
  --danger: #e98b99;

  --font-display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --r-1: 8px;
  --r-2: 14px;
  --r-3: 22px;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;

  --gutter: 20px;
  --page: 1120px;
  --tap: 44px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  background: var(--bg);
  color-scheme: dark;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 450;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(233, 139, 153, 0.35);
  color: #fff;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: currentColor;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: -120px;
  left: 12px;
  padding: 12px 16px;
  border-radius: var(--r-1);
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  position: fixed;
  z-index: 300;
  inset: auto 20px 20px;
  padding: 16px;
  border-radius: var(--r-2);
  background: var(--cream);
  color: var(--ink);
}

/* Layout */

.page {
  display: flex;
  min-height: 100svh;
  flex-direction: column;
}

.wrap {
  width: min(100% - 2 * var(--gutter), var(--page));
  margin-inline: auto;
}

.wrap--narrow {
  width: min(100% - 2 * var(--gutter), 720px);
  margin-inline: auto;
}

/* Brand and site header */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--tap);
  color: var(--text);
  white-space: nowrap;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}

.chip-count {
  opacity: 0.7;
  font-weight: 400;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--gold);
}

.brand-arc--inner {
  stroke: var(--rose);
  opacity: 0.6;
}

.site-header {
  padding-top: calc(10px + var(--safe-top));
  border-bottom: 1px solid var(--line);
}

.site-header--back {
  padding-top: var(--safe-top);
}

.site-header--back .header-actions {
  justify-self: end;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Language picker */

.lang-picker {
  position: relative;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.lang-trigger:hover {
  border-color: var(--line-strong);
}

.lang-current {
  display: inline-flex;
  gap: 8px;
}

.lang-code {
  color: var(--text-3);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  align-self: center;
}

.lang-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.lang-picker .lang-globe {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  width: 232px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.lang-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  text-align: left;
}

.lang-option:hover,
.lang-option.is-active {
  background: rgba(244, 233, 220, 0.07);
}

.lang-option-code {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lang-option-name {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.lang-option-check {
  color: var(--gold);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  pointer-events: none;
}

.btn--primary {
  background: var(--cream);
  color: var(--ink);
}

.btn--primary:hover {
  background: #fff6ea;
}

.btn--secondary,
.btn--ghost {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn--secondary:hover,
.btn--ghost:hover {
  border-color: var(--text-2);
  background: rgba(244, 233, 220, 0.05);
}

.btn--danger {
  background: var(--danger);
  color: #2b0f16;
}

.btn--small {
  min-height: var(--tap);
  padding-inline: 18px;
  font-size: var(--fs-sm);
}

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

.btn.is-busy {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-busy::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--ink);
  border-right-color: transparent;
  border-radius: 50%;
  content: '';
  animation: spin 0.7s linear infinite;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  color: var(--text);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}

.text-link:hover {
  text-decoration-color: var(--gold);
}

.icon-button {
  display: inline-grid;
  width: var(--tap);
  height: var(--tap);
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.icon-button[aria-pressed='true'] {
  border-color: rgba(227, 182, 120, 0.5);
  color: var(--gold);
}

.icon-button--danger:hover {
  border-color: rgba(233, 139, 153, 0.5);
  color: var(--danger);
}

/* Fields */

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

.field-label {
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.field-hint {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.input,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--bg-sunk);
  color: var(--text);
}

.textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.5;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:focus,
.textarea:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(227, 182, 120, 0.2);
}

.input[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--danger);
}

/* Footer */

.footer {
  margin-top: auto;
  padding: 32px 0 calc(32px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}

.footer-note {
  flex: 1 1 100%;
  max-width: 60ch;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
  margin-inline-start: -8px;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: 8px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--text);
}

/* Dialog */

.dialog-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: rgba(8, 4, 7, 0.78);
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}

.dialog-backdrop.is-open {
  opacity: 1;
}

.dialog-backdrop.is-closing {
  opacity: 0;
}

.dialog {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  background: var(--bg-raised);
}

.dialog-title {
  font-size: 1.75rem;
}

.dialog-text {
  margin-top: 12px;
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin-top: 24px;
}

.dialog-actions .btn {
  width: 100%;
}

@media (min-width: 520px) {
  .dialog-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .dialog-actions .btn {
    width: auto;
  }
}

body.has-dialog {
  overflow: hidden;
}

/* Toast */

.toast-host {
  position: fixed;
  z-index: 120;
  right: var(--gutter);
  bottom: calc(var(--gutter) + var(--safe-bottom));
  left: var(--gutter);
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  animation: rise 0.22s var(--ease);
}

.toast--error {
  border-color: rgba(233, 139, 153, 0.5);
}

.toast.is-leaving {
  opacity: 0;
  transition: opacity 0.25s;
}

/* Loading and states */

.loading-screen {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  gap: 12px;
  min-height: 60svh;
  color: var(--text-3);
}

.loading-mark {
  width: 36px;
  height: 36px;
  color: var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
}

.loading-text {
  font-size: var(--fs-sm);
}

.music-player-host {
  position: fixed;
  left: -10000px;
  bottom: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.music-player-frame {
  width: 1px;
  height: 1px;
  border: 0;
}

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

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