:root {
  --bg: #f2efe8;
  --ink: #0c0c0c;
  --mute: #5f5b55;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --track: -0.04em;
  --mx: 50%;
  --my: 45%;
  --page-pad: clamp(1rem, 3.2vw, 2rem);
  --top-gap: clamp(0.75rem, 2vw, 1rem);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  cursor: default;
  /* Prevent iOS text-size adjust quirks */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  max-width: 100%;
  padding: max(var(--page-pad), env(safe-area-inset-top, 0px))
    max(var(--page-pad), env(safe-area-inset-right, 0px))
    max(var(--page-pad), env(safe-area-inset-bottom, 0px))
    max(var(--page-pad), env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: clamp(0.5rem, 1.5vh, 1rem);
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--top-gap);
  width: 100%;
  min-width: 0;
}

.index {
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(0.55rem, 1.7vw, 0.68rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 400;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

body.is-on .index {
  opacity: 1;
  transform: none;
  transition-delay: 0.15s;
}

.brand {
  align-self: center;
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  line-height: 0.88;
  user-select: none;
  position: relative;
}

.brand__ghost,
.brand__word {
  display: block;
  width: 100%;
  max-width: 100%;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 4rem;
  letter-spacing: var(--track);
  text-transform: uppercase;
  white-space: nowrap;
}

.brand__ghost {
  position: absolute;
  left: 0;
  top: 0;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(12, 12, 12, 0.28);
  opacity: 0;
  transform: translate(0.04em, 0.03em);
  transition: opacity 1s var(--ease);
  pointer-events: none;
  animation: ghostDrift 3.6s ease-in-out infinite;
}

body.is-on .brand__ghost {
  opacity: 1;
  transition-delay: 0.45s;
}

@keyframes ghostDrift {
  0%,
  100% {
    transform: translate(0.05em, 0.03em);
  }
  50% {
    transform: translate(-0.06em, -0.02em);
  }
}

.brand__word {
  position: relative;
  color: var(--ink);
  opacity: 0;
  transform: translateY(28px);
  filter: blur(10px);
  transition:
    opacity 1.1s var(--ease),
    transform 1.1s var(--ease),
    filter 1.1s var(--ease);
}

body.is-on .brand__word {
  opacity: 1;
  transform: none;
  filter: none;
  transition-delay: 0.2s;
}

.brand__letter {
  display: inline-block;
  will-change: transform;
  color: var(--ink);
  animation: letterLift 2.8s ease-in-out infinite;
}

@keyframes letterLift {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-0.12em) scale(1.045);
  }
  60% {
    transform: translateY(0.03em) scale(0.98);
  }
}

.copy {
  max-width: min(28rem, 100%);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 1.8vh, 1.1rem);
  align-self: end;
  padding-bottom: 0.15rem;
  min-width: 0;
}

.headline {
  font-family: "Syne", sans-serif;
  font-weight: 600;
  font-size: clamp(1.15rem, 2.8vw, 1.85rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--ink);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

.lead {
  font-size: clamp(0.72rem, 1.5vw, 0.78rem);
  line-height: 1.65;
  color: var(--mute);
  font-weight: 300;
  max-width: 36em;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

body.is-on .headline {
  opacity: 1;
  transform: none;
  transition-delay: 0.5s;
}

body.is-on .lead {
  opacity: 1;
  transform: none;
  transition-delay: 0.65s;
}

.contact {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  width: clamp(7.25rem, 28vw, 9.5rem);
  min-height: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  text-decoration: none;
  color: var(--bg);
  background: var(--ink);
  border: 1px solid var(--ink);
  font-size: clamp(0.64rem, 1.6vw, 0.72rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  isolation: isolate;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.is-on .contact {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.9s var(--ease) 0.3s,
    transform 0.9s var(--ease) 0.3s,
    background 0.4s var(--ease),
    border-color 0.4s var(--ease);
}

.contact::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #1a1a1a;
  transform: translateX(-101%);
  transition: transform 0.45s var(--ease);
  z-index: 0;
}

.contact__label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0 0.65rem;
  text-align: center;
  color: var(--bg);
  transition: color 0.35s ease, opacity 0.3s ease;
}

.contact__label::after {
  content: attr(data-hover);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 0.4rem;
  font-size: clamp(0.48rem, 1.3vw, 0.58rem);
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 300;
  color: rgba(242, 239, 232, 0.85);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.35s ease 0.05s,
    transform 0.4s var(--ease) 0.05s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hover reveal only when a real hover device exists */
@media (hover: hover) and (pointer: fine) {
  .contact:hover,
  .contact:focus-visible {
    outline: none;
    background: #1a1a1a;
    border-color: #1a1a1a;
  }

  .contact:hover::before,
  .contact:focus-visible::before {
    transform: translateX(0);
  }

  .contact:hover .contact__label,
  .contact:focus-visible .contact__label {
    color: transparent;
  }

  .contact:hover .contact__label::after,
  .contact:focus-visible .contact__label::after {
    opacity: 1;
    transform: none;
  }
}

@media (hover: none), (pointer: coarse) {
  .contact:active,
  .contact:focus-visible {
    outline: none;
    background: #1a1a1a;
  }

  .contact:focus-visible::before {
    transform: none;
  }
}

/* ——— Breakpoints ——— */

@media (max-width: 720px) {
  :root {
    --page-pad: 1.1rem;
  }

  .index {
    letter-spacing: 0.1em;
  }

  .brand__ghost {
    -webkit-text-stroke-width: 1px;
  }

  .headline__break {
    display: none;
  }

  .copy {
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  .index {
    max-width: 42%;
  }

  .contact {
    width: 7.1rem;
    min-height: 2.5rem;
    height: 2.5rem;
    letter-spacing: 0.1em;
  }

  .brand__letter {
    /* Slightly calmer motion on small screens */
    animation-duration: 3.4s;
  }

  @keyframes letterLift {
    0%,
    100% {
      transform: translateY(0) scale(1);
    }
    40% {
      transform: translateY(-0.07em) scale(1.02);
    }
    60% {
      transform: translateY(0.015em) scale(0.995);
    }
  }

  @keyframes ghostDrift {
    0%,
    100% {
      transform: translate(0.03em, 0.02em);
    }
    50% {
      transform: translate(-0.035em, -0.015em);
    }
  }
}

/* Short viewports (landscape phones, small laptops) */
@media (max-height: 520px) {
  .page {
    gap: 0.35rem;
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }

  .brand__word {
    transform: translateY(12px);
  }

  .copy {
    gap: 0.5rem;
  }

  .headline {
    font-size: clamp(1rem, 3.5vh, 1.35rem);
  }

  .lead {
    font-size: 0.7rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .brand__letter,
  .brand__ghost {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand__word,
  .brand__ghost,
  .headline,
  .lead,
  .index,
  .contact {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }

  .brand__letter {
    animation: none !important;
  }
}
