/* ============================================================
   Peptiva — region chooser
   Motion rules used throughout:
   - only transform / opacity are animated (GPU, no layout)
   - entrances: strong ease-out; ambient loops: ease-in-out;
     constant drift: linear; press feedback: 160ms
   - hover effects only on real pointers; motion respects
     prefers-reduced-motion
   ============================================================ */

:root {
  color-scheme: light;

  --cream: #F3ECE3;
  --surface: #FCF8F2;
  --ink: #2A2118;
  --ink-2: #6F5F49;
  --muted: #9C8B70;

  --gold-900: #6E5228;
  --gold-700: #8C6A3C;
  --gold-500: #B08C55;
  --gold-400: #C4A469;
  --gold-300: #D8BE8C;
  --gold-100: #F4E9D3;
  --gold-line: rgba(176, 140, 85, 0.36);
  --gold-line-strong: rgba(176, 140, 85, 0.85);
  --metal: linear-gradient(115deg, #8C6A3C 0%, #B8935A 28%, #EBD8AC 50%, #B8935A 72%, #8C6A3C 100%);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --radius: 18px;
  --font-display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

::selection { background: var(--gold-300); color: var(--ink); }

/* ---------- ambient background ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-glow {
  position: absolute;
  left: 50%;
  top: 22%;
  width: 640px;
  height: 640px;
  margin: -320px 0 0 -320px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(214, 185, 130, 0.50) 0%,
    rgba(214, 185, 130, 0.20) 30%,
    rgba(243, 236, 227, 0) 66%);
  animation: breathe 9s var(--ease-in-out) infinite;
}

.bg-helix {
  position: absolute;
  top: -400px;
  width: 200px;
  height: 2400px;
  color: var(--gold-500);
  opacity: 0.15;
}
.bg-helix--r { right: -64px; animation: drift 80s linear infinite; }
.bg-helix--l { left: -64px; display: none; opacity: 0.10; animation: drift-mirror 110s linear infinite; }
@media (min-width: 880px) { .bg-helix--l { display: block; } }

.dust {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--gold-400);
  box-shadow: 0 0 6px 1px rgba(200, 165, 100, 0.45);
  opacity: 0;
  animation: float var(--d) ease-in-out var(--delay) infinite;
}

.bg-grain {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.8; }
  50%      { transform: scale(1.07); opacity: 1; }
}
@keyframes drift {
  to { transform: translate3d(0, -400px, 0); }
}
@keyframes drift-mirror {
  from { transform: scaleX(-1) translate3d(0, 0, 0); }
  to   { transform: scaleX(-1) translate3d(0, -400px, 0); }
}
@keyframes float {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  15%  { opacity: 0.6; }
  85%  { opacity: 0.25; }
  100% { transform: translate3d(var(--dx), -120px, 0); opacity: 0; }
}

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

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(32px + env(safe-area-inset-top, 0px)) 20px calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ---------- brand ---------- */

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 30px;
}

.logo {
  width: 108px;
  margin-bottom: 20px;
  filter: drop-shadow(0 14px 22px rgba(120, 90, 40, 0.16));
}
.logo-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
/* one warm light sweep across the mark, then a rest; repeats every 7s */
.logo-shine {
  transform: translateX(-60px) skewX(-18deg);
  animation: logo-shine 7s var(--ease-in-out) 0.9s infinite;
}
@keyframes logo-shine {
  0%   { transform: translateX(-60px) skewX(-18deg); }
  20%  { transform: translateX(440px) skewX(-18deg); }
  100% { transform: translateX(440px) skewX(-18deg); }
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 36px;
  line-height: 1;
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* balances the trailing letter-spacing so the word sits centred */
  text-transform: uppercase;
  background: var(--metal);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
}
.rule span {
  width: 56px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-500));
}
.rule span:last-child { background: linear-gradient(90deg, var(--gold-500), transparent); }
.rule i {
  width: 5px;
  height: 5px;
  background: var(--gold-500);
  transform: rotate(45deg);
}

.subtitle {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ---------- region cards ---------- */

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 16px 14px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--gold-line);
  box-shadow:
    0 1px 2px rgba(60, 40, 10, 0.05),
    0 12px 32px -16px rgba(120, 90, 40, 0.30);
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  transition:
    transform 160ms var(--ease-out),
    border-color 200ms ease,
    box-shadow 200ms ease,
    color 220ms ease;
}
/* gold fill that fades in when a region is chosen */
.link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, #9A7746 0%, #C3A063 55%, #A8874F 100%);
  opacity: 0;
  transition: opacity 240ms ease;
}
/* light sheen that sweeps across on hover */
.link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.5) 50%, transparent 62%);
  transform: translateX(-110%);
}
.link:active { transform: scale(0.97); }
.link:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 4px;
}

.flag {
  flex: none;
  width: 46px;
  height: 46px;
  padding: 2px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--gold-300), var(--gold-700));
  box-shadow: 0 3px 8px -2px rgba(120, 90, 40, 0.35);
}
.flag-inner {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
}
.flag-inner svg {
  display: block;
  width: 100%;
  height: 100%;
}

.text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.name {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.02em;
}
.meta {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 220ms ease;
}

.pill {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-700);
  background: var(--gold-100);
  border: 1px solid rgba(176, 140, 85, 0.45);
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}
.pill[hidden] { display: none; }
.link.is-suggested { border-color: var(--gold-line-strong); }

.arrow {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--gold-700);
  transition: transform 200ms var(--ease-out), color 220ms ease;
}
.arrow svg { display: block; width: 100%; height: 100%; }

@media (hover: hover) and (pointer: fine) {
  .link:hover {
    border-color: var(--gold-line-strong);
    box-shadow:
      0 2px 4px rgba(60, 40, 10, 0.05),
      0 18px 40px -16px rgba(120, 90, 40, 0.42);
  }
  .link:hover .arrow { transform: translateX(4px); }
  .link:hover::after { animation: card-sheen 800ms var(--ease-out); }
}
@keyframes card-sheen {
  to { transform: translateX(110%); }
}

/* ---------- chosen / leaving ---------- */

.link.is-chosen {
  border-color: transparent;
  color: #FFF8EC;
  transform: scale(1.02);
  box-shadow: 0 16px 36px -14px rgba(120, 90, 40, 0.6);
}
.link.is-chosen::before { opacity: 1; }
.link.is-chosen .meta { color: rgba(255, 248, 236, 0.82); }
.link.is-chosen .arrow { color: inherit; transform: translateX(6px); }
.link.is-chosen .pill { display: none; }
.link.is-chosen .flag { box-shadow: 0 3px 10px -2px rgba(60, 40, 10, 0.4); }

.is-leaving .item:not(.is-chosen-item) {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 220ms ease, transform 220ms var(--ease-out);
}
.is-leaving .brand,
.is-leaving .foot {
  opacity: 0.35;
  transition: opacity 260ms ease;
}

/* ---------- footer ---------- */

.foot {
  margin-top: 30px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: center;
}
.foot p { margin: 0; }

/* ---------- entrance (one-time, staggered) ---------- */

@keyframes rise    { from { opacity: 0; transform: translateY(14px); } }
@keyframes logo-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes rule-in { from { opacity: 0; transform: scaleX(0.3); } }
@keyframes fade    { from { opacity: 0; } }

/* `backwards` fill: the element holds its hidden state during the delay,
   then hands control back to normal styles so hover/active transforms work. */
.logo     { animation: logo-in 900ms var(--ease-out) backwards; }
.wordmark { animation: rise 700ms var(--ease-out) 140ms backwards; }
.rule     { animation: rule-in 700ms var(--ease-out) 240ms backwards; }
.subtitle { animation: rise 600ms var(--ease-out) 300ms backwards; }
.item     { animation: rise 600ms var(--ease-out) var(--delay, 0ms) backwards; }
.item:nth-child(1) { --delay: 380ms; }
.item:nth-child(2) { --delay: 450ms; }
.item:nth-child(3) { --delay: 520ms; }
.foot     { animation: fade 900ms ease 760ms backwards; }

/* direct redirect (/rs, ?to=rs): no entrance, straight to the chosen state */
.is-direct .logo, .is-direct .wordmark, .is-direct .rule,
.is-direct .subtitle, .is-direct .item, .is-direct .foot { animation: none; }

/* ---------- larger screens ---------- */

@media (min-width: 720px) {
  .logo { width: 120px; }
  .wordmark { font-size: 40px; }
  .brand { margin-bottom: 36px; }
}

/* ---------- reduced motion: keep fades, drop movement ---------- */

@media (prefers-reduced-motion: reduce) {
  .logo, .wordmark, .rule, .subtitle, .item, .foot {
    animation: fade 400ms ease backwards;
  }
  .bg-glow, .bg-helix, .dust, .logo-shine, .link::after { animation: none; }
  .link, .arrow, .item, .meta { transition: none; }
  .link:active, .link.is-chosen { transform: none; }
}
