/* ============================================
   THE GATES - landing page for akiraishi.com
   Closed doors, a scroll, and two paths behind them.
   ============================================ */

:root {
  --gold: #c9a227;
  --gold-light: #e8d48b;
  --gold-dark: #8b6914;
  --brown: #3d2914;
  --brown-light: #5c3d1e;
  --brown-dark: #1a0f05;
  --parchment: #f4e4bc;
  --parchment-dark: #d4c4a0;
  --parchment-light: #faf5e8;

  --font-display: 'Cinzel Decorative', serif;
  --font-heading: 'Cinzel', serif;
  --font-body: 'Cormorant Garamond', serif;

  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
}

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

html {
  scroll-behavior: auto;
}

.gates-body {
  font-family: var(--font-body);
  background: var(--brown-dark);
  color: var(--parchment);
  line-height: 1.6;
  overflow-x: hidden;
}

/* The runway is empty on purpose: it only gives the doors scroll to open along */
.runway {
  height: 320vh;
  pointer-events: none;
}

.gates {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 1;
}

/* ============================================
   THE HALL BEHIND THE DOORS
   ============================================ */

.hall {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 4vh, 3rem);
  padding: clamp(1rem, 4vw, 3rem);
  text-align: center;
  background:
    radial-gradient(ellipse at top, rgba(201, 162, 39, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse at bottom, rgba(61, 41, 20, 0.85) 0%, transparent 55%),
    linear-gradient(180deg, var(--brown-dark) 0%, #0d0705 100%);
  /* revealed by the doors, driven from portal.js */
  opacity: 0;
}

/* ============================================
   THE HALL MOSAIC
   Works drifting behind the doors so the room is
   never empty. Transform-only, so it costs the
   compositor and nothing else.
   ============================================ */

.hall-mosaic {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

/* Keeps the middle calm so the two cards stay readable */
.hall-mosaic::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 55% at 50% 50%, rgba(13, 7, 5, 0.92) 0%, rgba(13, 7, 5, 0.55) 55%, rgba(13, 7, 5, 0.15) 100%);
}

.mosaic-tile {
  position: absolute;
  display: block;
  padding: 3px;
  border: 1px solid rgba(201, 162, 39, 0.35);
  background: rgba(26, 15, 5, 0.6);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  opacity: 0.42;
  will-change: transform;
  animation-duration: 54s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  /* nothing moves while the doors are still shut */
  animation-play-state: paused;
}

.mosaic-tile img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.mosaic-tile.sm { width: clamp(52px, 6vw, 92px); }
.mosaic-tile.md { width: clamp(68px, 8vw, 124px); }
.mosaic-tile.lg { width: clamp(84px, 10vw, 156px); }

.gates.ajar .mosaic-tile {
  animation-play-state: running;
}

.drift-a { animation-name: driftA; }
.drift-b { animation-name: driftB; animation-duration: 67s; }
.drift-c { animation-name: driftC; animation-duration: 78s; }

.drift-b { animation-delay: -12s; }
.drift-c { animation-delay: -27s; }

@keyframes driftA {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-1.4deg); }
  50%      { transform: translate3d(16px, -26px, 0) rotate(1.6deg); }
}

@keyframes driftB {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(1.8deg); }
  50%      { transform: translate3d(-22px, 18px, 0) rotate(-1.2deg); }
}

@keyframes driftC {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.8deg); }
  50%      { transform: translate3d(12px, 24px, 0) rotate(2deg); }
}

.hall-glow {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 80vmin;
  height: 80vmin;
  margin: -40vmin 0 0 -40vmin;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.22) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: hallBreath 7s ease-in-out infinite;
}

@keyframes hallBreath {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 0.85; transform: scale(1.06); }
}

.hall-header {
  position: relative;
  z-index: 2;
}

.hall-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.75rem);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 3px;
  text-shadow: 0 0 30px rgba(201, 162, 39, 0.45);
}

.hall-subtitle {
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 1.6vw, 1rem);
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--parchment-dark);
  margin-top: 0.75rem;
}

/* ============================================
   THE TWO CHOICES
   ============================================ */

.choices {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  width: 100%;
  max-width: 900px;
}

.choice {
  position: relative;
  flex: 1 1 0;
  max-width: 400px;
  padding: 3px;
  background: linear-gradient(180deg, rgba(61, 41, 20, 0.85) 0%, rgba(26, 15, 5, 0.95) 100%);
  border: 2px solid var(--gold-dark);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transform: translateZ(0);
  transition: transform var(--transition-medium), border-color var(--transition-medium), box-shadow var(--transition-medium);
}

/* Inner hairline frame, the same trick the Reliquary cards use */
.choice-frame {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  pointer-events: none;
}

.choice-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 2.5vw, 1.75rem);
}

.choice-icon {
  width: clamp(48px, 7vw, 72px);
  height: clamp(48px, 7vw, 72px);
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
  transition: transform var(--transition-medium);
}

.choice-title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  color: var(--gold);
  letter-spacing: 1px;
}

.choice-tagline {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--parchment-dark);
}

.choice-desc {
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  color: var(--parchment);
  max-width: 26ch;
}

.choice-enter {
  margin-top: 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gold-light);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast);
}

.choice-arrow {
  display: inline-block;
  transition: transform var(--transition-medium);
}

.choice:hover,
.choice:focus-visible {
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 35px rgba(201, 162, 39, 0.25);
  outline: none;
}

.choice:hover .choice-icon,
.choice:focus-visible .choice-icon {
  transform: scale(1.08);
}

.choice:hover .choice-enter,
.choice:focus-visible .choice-enter {
  border-bottom-color: var(--gold-dark);
}

.choice:hover .choice-arrow,
.choice:focus-visible .choice-arrow {
  transform: translateX(4px);
}

/* A path that is not open yet: dimmed, no lift, no preview, and a warning where "Enter" would be */
.choice.is-closed {
  cursor: not-allowed;
  border-style: dashed;
  border-color: var(--gold-dark);
}

.choice.is-closed .choice-body > :not(.choice-warning) {
  opacity: 0.55;
}

.choice.is-closed:hover {
  transform: none;
  border-color: var(--gold-dark);
  box-shadow: none;
}

.choice.is-closed:hover .choice-icon {
  transform: none;
}

.choice.is-closed .preview {
  display: none;
}

.choice-warning {
  margin-top: 0.5rem;
  padding: 0.45rem 0.8rem;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1.4;
  text-align: center;
  color: #e8b4a0;
  border: 1px solid rgba(200, 90, 60, 0.6);
  background: rgba(120, 30, 15, 0.35);
}

.choice.is-refused {
  animation: choice-refused 0.4s ease;
}

@keyframes choice-refused {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .choice.is-refused { animation: none; }
}

/* ============================================
   HOVER PREVIEW OF THE OTHER PAGE
   ============================================ */

.preview {
  position: absolute;
  bottom: calc(100% + 1rem);
  left: 50%;
  width: min(300px, 78vw);
  padding: 0.5rem;
  border: 1px solid var(--gold-dark);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translate(-50%, 12px) scale(0.94);
  transform-origin: bottom center;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
  will-change: transform, opacity;
}

.choice:hover .preview,
.choice:focus-visible .preview {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.preview-dark {
  background: linear-gradient(180deg, #241608 0%, #0d0705 100%);
}

.preview-light {
  background: linear-gradient(180deg, var(--parchment-light) 0%, var(--parchment-dark) 100%);
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.preview-dark .preview-bar {
  color: var(--gold);
  border-bottom: 1px solid rgba(201, 162, 39, 0.35);
}

.preview-light .preview-bar {
  color: var(--brown);
  border-bottom: 1px solid rgba(139, 105, 20, 0.35);
}

.preview-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
}

.preview-page {
  display: block;
  padding: 0.5rem 0.4rem 0.4rem;
}

.preview-heading {
  display: block;
  width: 45%;
  height: 6px;
  margin: 0 auto 0.5rem;
  border-radius: 3px;
  background: var(--gold);
  opacity: 0.8;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.preview-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(139, 105, 20, 0.5);
}

.preview-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 0.5rem;
}

.preview-lines span {
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.25;
}

.preview-dark .preview-lines { color: var(--parchment); }
.preview-light .preview-lines { color: var(--brown); }

.preview-lines span:nth-child(2) { width: 85%; }
.preview-lines span:nth-child(3) { width: 60%; }

.preview-caption {
  display: block;
  padding: 0.45rem 0.4rem 0.2rem;
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

.preview-dark .preview-caption { color: var(--gold-light); }
.preview-light .preview-caption { color: var(--gold-dark); }

/* ============================================
   THE DOORS
   ============================================ */

.doors {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 30;
  pointer-events: none;
}

.door {
  width: 50.2%; /* slight overlap so no seam shows when closed */
  height: 100%;
  object-fit: cover;
  will-change: transform;
  backface-visibility: hidden;
}

.door-left {
  object-position: right center;
}

.door-right {
  object-position: left center;
}

/* ============================================
   SCROLL INVITATION
   ============================================ */

.invitation {
  position: absolute;
  left: 50%;
  bottom: clamp(2rem, 8vh, 5rem);
  transform: translateX(-50%);
  z-index: 40;
  width: min(90vw, 480px);
  padding: 1.35rem 1.75rem 1.1rem;
  text-align: center;
  /* a bronze plaque on the door, so the words stay readable over the gold */
  background: linear-gradient(180deg, rgba(26, 15, 5, 0.93) 0%, rgba(13, 7, 5, 0.95) 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.invitation::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 162, 39, 0.5);
  pointer-events: none;
}

.invitation-title {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 2.2vw, 1.25rem);
  color: var(--gold);
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
  margin-bottom: 0.5rem;
}

.invitation-text {
  font-family: var(--font-heading);
  font-size: clamp(0.7rem, 1.6vw, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--parchment);
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.9);
}

.invitation-arrow {
  width: 14px;
  height: 14px;
  margin: 0.9rem auto 0.6rem;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  animation: nudgeDown 2s ease-in-out infinite;
}

@keyframes nudgeDown {
  0%, 100% { transform: rotate(45deg) translate(0, 0); opacity: 0.6; }
  50%      { transform: rotate(45deg) translate(5px, 5px); opacity: 1; }
}

.invitation-hint {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--parchment-dark);
  opacity: 0.75;
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.9);
}

/* ============================================
   ENTERING ANIMATION
   ============================================ */

.veil {
  position: fixed;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--parchment-light) 0%, var(--gold) 40%, var(--brown-dark) 100%);
  transform: translate(var(--veil-x, 50vw), var(--veil-y, 50vh)) scale(0);
  opacity: 0;
  z-index: 60;
  pointer-events: none;
  will-change: transform, opacity;
}

.veil.rising {
  opacity: 1;
  transform: translate(var(--veil-x, 50vw), var(--veil-y, 50vh)) scale(420);
  transition: transform 0.55s cubic-bezier(0.45, 0, 0.2, 1), opacity 0.35s ease;
}

.gates.entering .choice {
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.3s ease;
}

.gates.entering .choice:not(.is-chosen) {
  opacity: 0;
  transform: translateY(16px) scale(0.96);
}

.gates.entering .choice.is-chosen {
  transform: translateY(-10px) scale(1.05);
  border-color: var(--gold-light);
  box-shadow: 0 0 60px rgba(232, 212, 139, 0.45);
}

.gates.entering .preview {
  opacity: 0 !important;
}

.gates.entering .invitation {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gates.entering .door {
  transition: transform 0.5s cubic-bezier(0.55, 0, 0.35, 1);
}

/* ============================================
   CURSOR (matches the Reliquary)
   ============================================ */

@media (hover: hover) and (pointer: fine) {
  .gates-body,
  .gates-body a {
    cursor: none;
  }
}

.magical-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  pointer-events: none;
  z-index: 99999;
  transform: translate3d(var(--cursor-x, 0), var(--cursor-y, 0), 0) scale(var(--cursor-scale, 1));
  will-change: transform;
  backface-visibility: hidden;
}

.magical-cursor.hover { --cursor-scale: 1.2; }

/* ============================================
   NOSCRIPT FALLBACK
   ============================================ */

.noscript-links {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: var(--brown-dark);
}

.noscript-links a {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  border: 2px solid var(--gold-dark);
  padding: 1rem 2rem;
  text-decoration: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Touch devices have no hover: drop the previews and keep the cards compact */
@media (hover: none) {
  .preview {
    display: none;
  }
}

/* Not enough headroom above the cards to float a preview */
@media (max-height: 700px) {
  .preview {
    display: none;
  }
}

@media (max-width: 760px) {
  .choices {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .choice {
    width: 100%;
    max-width: 340px;
  }

  .choice-body {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 0.25rem 0.9rem;
    padding: 1rem;
  }

  .choice-icon {
    width: 46px;
    height: 46px;
  }

  .choice-title {
    flex: 1 1 auto;
  }

  .choice-tagline {
    flex: 1 1 100%;
    padding-left: calc(46px + 0.9rem);
  }

  .choice-desc,
  .choice-enter {
    flex: 1 1 100%;
    padding-left: calc(46px + 0.9rem);
    max-width: none;
  }

  .hall {
    gap: 1.5rem;
  }

  .invitation {
    bottom: 1.5rem;
  }

  .invitation-hint {
    display: none;
  }
}

/* Short screens: keep everything inside the fixed stage */
@media (max-height: 560px) {
  .hall-subtitle,
  .choice-desc {
    display: none;
  }

  .invitation {
    bottom: 0.5rem;
    padding: 0.5rem;
  }
}

@media (max-width: 760px) {
  /* half the tiles is plenty on a phone, and half the paint */
  .mosaic-tile:nth-child(even) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hall-glow,
  .invitation-arrow,
  .mosaic-tile {
    animation: none;
  }

  .choice,
  .preview,
  .choice-icon,
  .choice-arrow {
    transition: none;
  }
}
