:root {
  --bg: #f8f8f8;
  --card: #ffffff;
  --ink: #0d0d0d;
  --line: #dddddd;
  --muted: #5f5f5f;
  --ok: #1f7a33;
  --danger: #b00020;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--ink);
  padding: 0;
  background: #fafafa;
  overflow-x: hidden;
  overflow-y: hidden;
}

body:not(.ready) .layout {
  opacity: 0;
  visibility: hidden;
}

body.ready .layout {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}

body:not(.ready) form,
body:not(.ready) input,
body:not(.ready) button,
body:not(.ready) select,
body:not(.ready) textarea {
  visibility: hidden !important;
}

.pixel-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.17) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: 0 0;
  animation: pixelDrift 6.8s ease-in-out infinite alternate;
  opacity: 0.42;
  transition: opacity 0.9s ease;
}

.pixel-field::after {
  content: "";
  position: absolute;
  inset: -25%;
  background:
    radial-gradient(70% 40% at 10% 40%, rgba(0, 0, 0, 0.08), transparent 70%),
    radial-gradient(75% 45% at 90% 65%, rgba(0, 0, 0, 0.07), transparent 72%);
  animation: waveShift 7.2s ease-in-out infinite alternate;
}

@keyframes pixelDrift {
  0% {
    transform: translate3d(-12px, 0, 0);
  }
  50% {
    transform: translate3d(12px, -4px, 0);
  }
  100% {
    transform: translate3d(-12px, 0, 0);
  }
}

@keyframes waveShift {
  0% {
    transform: translate3d(-2%, 0, 0) rotate(0.2deg);
  }
  100% {
    transform: translate3d(2%, -1.2%, 0) rotate(-0.2deg);
  }
}

.launch-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.98);
  transition: opacity 0.8s ease, visibility 0.8s ease;
  overflow: hidden;
}

.launch-screen.exit {
  opacity: 0;
  visibility: hidden;
}

.launch-core {
  position: relative;
  width: min(80vw, 420px);
  display: grid;
  gap: 1rem;
  justify-items: center;
  z-index: 2;
}

.launch-logo {
  width: min(68vw, 340px);
  height: auto;
  object-fit: contain;
  animation: logoIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
  z-index: 2;
}

.launch-text {
  width: min(62vw, 260px);
  filter: grayscale(1) contrast(1.2);
  animation: textIn 0.8s ease 0.2s both;
  z-index: 2;
}

.launch-burst {
  display: none;
}

.launch-screen::before {
  content: "";
  position: absolute;
  inset: -4px;
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.23) 1px, transparent 1px);
  background-size: 14px 14px;
  background-position: center;
  clip-path: circle(0% at 50% 50%);
  opacity: 0.95;
  animation: launchExpand 1.65s cubic-bezier(0.22, 1, 0.36, 1) 0.22s forwards;
}

@keyframes logoIn {
  0% {
    opacity: 0;
    transform: scale(0.84);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes textIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes launchExpand {
  0% {
    clip-path: circle(0% at 50% 50%);
    opacity: 1;
  }
  100% {
    clip-path: circle(150% at 50% 50%);
    opacity: 0.15;
  }
}

.layout {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.card-wrap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: min(640px, calc(100vw - 2rem));
}

.card {
  width: 100%;
  margin: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.36));
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  padding: 1.25rem;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  opacity: 0;
  transform: translateY(30px);
  clip-path: inset(45% 45% 45% 45% round 18px);
  transition:
    opacity 0.9s ease,
    transform 0.9s ease,
    clip-path 0.95s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
  max-height: calc(100vh - 170px);
  overflow: auto;
}

body.ready .card {
  opacity: 1;
  transform: translateY(0);
  clip-path: inset(0 0 0 0 round 20px);
}

body.ready .pixel-field {
  opacity: 0.74;
}

.hero {
  display: grid;
  gap: 0.35rem;
}

.route-art {
  width: min(92%, 320px);
  height: auto;
  object-fit: contain;
  margin-bottom: 0.2rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  letter-spacing: 0.01em;
}

.message {
  margin: 0;
  color: #202020;
  line-height: 1.4;
  min-height: 1.2em;
}

form {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.52rem;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: #111;
  padding: 0.76rem 0.82rem;
  font-size: 16px;
  transition:
    border-color 0.24s ease,
    box-shadow 0.24s ease,
    transform 0.24s ease;
}

input:focus {
  outline: none;
  border-color: #000;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

button:not(.dash-tab):not(.logout-icon),
#continue-link {
  margin-top: 0.44rem;
  border-radius: 999px;
  border: 1px solid #000;
  background: #000;
  color: #fff;
  font-weight: 700;
  font-size: 0.94rem;
  padding: 0.72rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  min-height: 44px;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

button:not(.ghost-btn):not(.dash-tab):not(.logout-icon):hover,
#continue-link:hover {
  transform: translateY(-2px);
  background: #101010;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

button:not(.ghost-btn):not(.dash-tab):not(.logout-icon):active,
#continue-link:active {
  transform: translateY(0);
}

button:not(.dash-tab):not(.logout-icon):disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

#continue-link {
  display: inline-block;
  margin-top: 1rem;
}

.success {
  color: var(--ok);
}

.error {
  color: var(--danger);
}

.hidden {
  display: none;
}

.profile-card {
  max-height: calc(100vh - 190px);
}

.profile-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.6rem;
}

.profile-row {
  font-size: 0.94rem;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.14);
  padding-bottom: 0.3rem;
}

.profile-grid h2 {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  padding: 0.33rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.45);
}

.activity-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.32rem;
  font-size: 0.88rem;
}

.dashboard-card {
  max-height: calc(100vh - 170px);
  overflow: auto;
}

.dashboard-view {
  margin-top: 0.8rem;
  opacity: 0;
  transform: translateY(8px) scale(0.995);
  pointer-events: none;
  transition:
    opacity 0.34s ease,
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.dashboard-view.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.loading-wrap {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 0.6rem;
  text-align: center;
  color: #2a2a2a;
}

.loading-wrap p {
  animation: textPulse 1.1s ease-in-out infinite;
}

.loader {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-top-color: #111;
  animation: spin 0.9s linear infinite;
}

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

@keyframes textPulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.dash-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.dash-top h2 {
  margin: 0;
  font-size: 1.15rem;
}

.dash-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 1fr 1fr;
}

.dash-panel {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.42);
  transform: translateY(6px);
  opacity: 0.94;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease;
}

.dash-panel:hover {
  transform: translateY(0);
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.56);
}

.dash-panel.is-enter {
  animation: panelIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dash-panel h3 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
}

.site-footer {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  align-items: center;
  text-align: center;
  gap: 0.18rem;
  width: max-content;
  pointer-events: none;
}

.site-footer img {
  width: min(20vw, 78px);
  height: auto;
  object-fit: contain;
}

.site-footer .copy {
  font-size: 0.75rem;
  color: #1f1f1f;
  text-align: center;
  line-height: 1.35;
}

@media (max-width: 560px) {
  .card-wrap {
    top: 47%;
    width: calc(100vw - 1rem);
  }

  .card {
    border-radius: 16px;
    padding: 0.95rem;
    max-height: calc(100vh - 150px);
  }

  .route-art {
    width: min(95%, 270px);
  }

  .site-footer img {
    width: min(26vw, 74px);
  }

  .site-footer .copy {
    font-size: 0.7rem;
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .dash-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Mobile launch sizing fix (no desktop impact) */
@media (max-width: 640px) {
  .launch-core {
    width: min(92vw, 320px);
    gap: 0.72rem;
  }

  .launch-logo {
    width: min(78vw, 240px);
  }

  .launch-text {
    width: min(66vw, 190px);
  }
}

/* Global post-loading motion: slide + spring */
@keyframes springInUp {
  0% {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.985);
  }
  60% {
    opacity: 1;
    transform: translate3d(0, -4px, 0) scale(1.006);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes springInSide {
  0% {
    opacity: 0;
    transform: translate3d(-18px, 0, 0) scale(0.985);
  }
  65% {
    opacity: 1;
    transform: translate3d(4px, 0, 0) scale(1.004);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

body.ready .card .hero > *,
body.ready .card form > *,
body.ready .card > #continue-link,
body.ready .card > .message,
body.ready .card > .success,
body.ready .card > .error {
  opacity: 0;
  animation: springInUp 0.62s cubic-bezier(0.22, 1.08, 0.32, 1) forwards;
}

body.ready .card .hero > *:nth-child(1) { animation-delay: 0.03s; }
body.ready .card .hero > *:nth-child(2) { animation-delay: 0.09s; }
body.ready .card .hero > *:nth-child(3) { animation-delay: 0.15s; }

body.ready .card form > *:nth-child(1) { animation-delay: 0.12s; }
body.ready .card form > *:nth-child(2) { animation-delay: 0.16s; }
body.ready .card form > *:nth-child(3) { animation-delay: 0.20s; }
body.ready .card form > *:nth-child(4) { animation-delay: 0.24s; }
body.ready .card form > *:nth-child(5) { animation-delay: 0.28s; }
body.ready .card form > *:nth-child(6) { animation-delay: 0.32s; }
body.ready .card form > *:nth-child(7) { animation-delay: 0.36s; }

body.ready .card > #continue-link {
  animation-delay: 0.34s;
}

body.ready .site-footer img,
body.ready .site-footer .copy {
  opacity: 0;
  animation: springInSide 0.7s cubic-bezier(0.22, 1.08, 0.32, 1) forwards;
}

body.ready .site-footer img { animation-delay: 0.24s; }
body.ready .site-footer .copy { animation-delay: 0.31s; }

/* Horizon typography replacement for former text-images */
@font-face {
  font-family: "Horizon";
  src: url("/assets/fonts/horizon.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --brand-font: "Horizon", "Avenir Next", "Helvetica Neue", sans-serif;
}

.brand-logo-text {
  font-family: var(--brand-font);
  font-size: clamp(2.2rem, 8vw, 4.2rem);
  letter-spacing: 0.04em;
  line-height: 0.9;
  text-transform: uppercase;
  text-align: center;
  color: #0d0d0d;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

.brand-sub-text {
  font-family: var(--brand-font);
  font-size: clamp(0.9rem, 2.2vw, 1.3rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  color: #1f1f1f;
}

.brand-route-text {
  margin: 0;
  font-family: var(--brand-font);
  font-size: clamp(1.1rem, 3.8vw, 2rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  color: #101010;
}

.launch-logo.brand-logo-text,
.launch-text.brand-sub-text {
  width: auto;
  height: auto;
  object-fit: initial;
  filter: none;
}

.route-art.brand-route-text {
  width: auto;
  height: auto;
  object-fit: initial;
  margin-bottom: 0.18rem;
}

@media (max-width: 640px) {
  .brand-logo-text {
    font-size: clamp(1.58rem, 10vw, 2.5rem);
    white-space: nowrap;
  }

  .brand-sub-text {
    font-size: clamp(0.76rem, 4vw, 1rem);
    letter-spacing: 0.12em;
  }

  .brand-route-text {
    font-size: clamp(0.95rem, 6vw, 1.45rem);
  }
}


/* Hard no-wrap brand title */
.launch-logo.brand-logo-text,
.brand-logo-text {
  display: inline-block;
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  hyphens: none !important;
}

@media (max-width: 640px) {
  .launch-logo.brand-logo-text {
    font-size: clamp(1.46rem, 8.3vw, 2.15rem);
    letter-spacing: 0.03em;
  }
}

/* E-ROK premium particle field */
.particle-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  transition: opacity 0.9s ease;
}

body.ready .particle-field {
  opacity: 0.62;
}

@media (prefers-reduced-motion: reduce) {
  .particle-field {
    opacity: 0.24;
  }
}
