/* The title hangs over the live yard. Geometry marked "from the art" is measured on title-sign.webp. */
body.at-yard { overflow: hidden; }
body.at-yard .shell { width: 100%; padding: 0; }

/* The same painting the board draws, so the yard is there before the board is. */
body.at-yard .field-backdrop { background: #4c5340 url("./art/gatehouse-yard.webp") center/100% 100% no-repeat; }
@media (orientation: portrait) {
  body.at-yard .field-backdrop { background-image: url("./art/gatehouse-portrait.webp"); }
}
body.at-yard .crossing-frame,
body.at-yard .arena { background: transparent; }
body.at-yard .arena { cursor: default; }
body.at-yard .scene-rack,
body.at-yard .watch-actions,
body.at-yard .scene-note,
body.at-yard .board-alert,
body.at-yard .field-delivery { display: none !important; }

.home {
  /* From the art: title-sign.webp is 1494 by 1000 before scaling. */
  --sign: min(88vw, 40svh, 440px);
  --sign-ratio: 1.4946;
  --hook: 94.5%;
  --ledge: 19%;
  --plank: 58px;
  position: fixed;
  z-index: 2;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  overflow: hidden;
  pointer-events: none;
}

.home h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* If the painted sign cannot load, the name is still there. */
.home:not(.has-sign).intro-settled h1 {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
  margin-top: max(74px, 12svh);
  font: 800 clamp(34px, 10vw, 64px)/0.95 var(--body);
  color: #ffe9b0;
  text-shadow: 0 2px #7a4a22, 0 5px 0 #2c1d14, 0 8px 18px #1b130c;
}
.home:not(.has-sign) .title-stage { display: none; }

.title-stage {
  position: relative;
  grid-row: 1;
  width: var(--sign);
  aspect-ratio: var(--sign-ratio, 1.5);
  margin-top: calc(var(--sign) * 0.05 + 34px + env(safe-area-inset-top));
}
.title-drop,
.title-swing { position: absolute; inset: 0; }
.title-drop { transform-origin: 50% 0; }
/* The ropes meet well above the screen, so the whole sign swings from there. */
.title-swing { transform-origin: 50% -90%; }
.intro-waiting .title-drop { visibility: hidden; }
/* The ropes carry on up past the top of the screen. */
.title-swing::before {
  content: "";
  position: absolute;
  inset: auto 0 calc(100% - 1px);
  height: 130%;
  background: url("./art/title-rope.webp") left bottom/100% auto repeat-y;
}
.title-sign {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 9px #2a1c1070);
  user-select: none;
}

.title-lamp {
  position: absolute;
  left: var(--at);
  top: var(--hook, 86%);
  width: 13%;
  margin-left: -6.5%;
  transform-origin: 50% 3%;
}
.title-lamp img {
  display: block;
  width: 100%;
  filter: drop-shadow(0 5px 4px #2a1c1066);
}
.title-glow {
  position: absolute;
  inset: 30% -85% -38%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 46%, #ffd98ad9, #ffab4a66 34%, #ff9a3c00 68%);
  mix-blend-mode: screen;
  pointer-events: none;
}
.intro-waiting .title-glow { opacity: 0; }

.title-peek {
  position: absolute;
  left: 21%;
  bottom: calc(100% - var(--ledge));
  width: 35%;
  z-index: 1;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.title-peek[data-side="1"] { left: auto; right: 19%; }
.title-peek img {
  display: block;
  width: 100%;
  height: 100%;
  transform: translateY(104%);
  transform-origin: 50% 100%;
}
.title-peek.flipped { scale: -1 1; }

.title-leaf {
  position: absolute;
  width: 9px;
  height: 6px;
  border-radius: 80% 10% 80% 10%;
  background: linear-gradient(120deg, #d9c04a, #8a9a3b);
  box-shadow: inset -1px -1px 0 #5c6a2a;
  opacity: 0;
  pointer-events: none;
}
.title-leaf:nth-of-type(odd) { background: linear-gradient(120deg, #e8b84e, #b9772e); box-shadow: inset -1px -1px 0 #7a4a22; }

.title-ghost {
  position: fixed;
  z-index: 6;
  inset: auto;
  pointer-events: none;
}

.home-actions {
  grid-row: 3;
  display: grid;
  justify-items: center;
  gap: 7px;
  width: min(86vw, 340px);
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  pointer-events: auto;
}
.intro-waiting .home-actions > * { opacity: 0; }
.home-actions p {
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: #2a2014cc;
  color: #ffeec8;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}
.home-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

/* Painted planks. The copper ends keep their shape and only the timber stretches. */
.plank {
  display: grid;
  place-items: center;
  width: 100%;
  height: var(--plank);
  padding: 0 0 2px;
  border: solid transparent;
  border-width: 0 calc(var(--plank) * 0.6);
  border-image: var(--plank-art) 0 112 0 112 fill / 0 calc(var(--plank) * 112 / 185) stretch;
  background: none;
  font-family: var(--body);
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.01em;
  filter: drop-shadow(0 5px 5px #1e150c8c);
  transition: filter 0.16s var(--lift), transform 0.12s var(--lift);
}
.plank-main {
  --plank-art: url("./art/title-plank.webp");
  color: #3a2110;
  font-size: clamp(18px, 5.4vw, 22px);
  text-shadow: 0 1px 0 #ffe9b5b0;
}
.plank-side {
  --plank: 46px;
  --plank-art: url("./art/title-plank-side.webp");
  border-image-slice: 0 70 0 70 fill;
  border-image-width: 0 calc(var(--plank) * 70 / 113);
  border-width: 0 calc(var(--plank) * 0.5);
  color: #fff0cc;
  font-size: clamp(13px, 3.9vw, 15px);
  text-shadow: 0 1px 2px #10201e;
}
.plank:hover:not(:disabled) { filter: drop-shadow(0 5px 5px #1e150c8c) brightness(1.08); }
.plank:active:not(:disabled) { transform: translateY(2px) scale(0.985); }
.plank:disabled { opacity: 1; filter: drop-shadow(0 5px 5px #1e150c8c) saturate(0.55) brightness(0.86); }
.plank:focus-visible { outline-offset: 1px; border-radius: 12px; }
.sheet[data-view="result-win"] .sheet-actions .plank {
  --plank: 44px;
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  padding: 0 4px 2px;
  border-inline-width: 10px;
  font-size: clamp(12px, 2vw, 15px);
  box-shadow: none;
}

/* At rest the sign barely stirs and the lanterns breathe. */
.intro-settled .title-swing { animation: sign-sway 6.4s ease-in-out infinite; }
.intro-settled .title-lamp { animation: lamp-sway 4.1s ease-in-out infinite; }
.intro-settled .title-lamp:nth-of-type(odd) { animation-duration: 4.7s; animation-delay: -1.3s; }
.intro-settled .title-glow { animation: lamp-breathe 3.3s ease-in-out infinite; }
@keyframes sign-sway {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(0.45deg); }
  75% { transform: rotate(-0.45deg); }
}
@keyframes lamp-sway {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(1.7deg); }
  75% { transform: rotate(-1.7deg); }
}
@keyframes lamp-breathe {
  0%, 100% { opacity: 1; }
  43% { opacity: 0.8; }
  57% { opacity: 0.93; }
  71% { opacity: 0.76; }
}

/* Wide screens: the sign grows, and the three planks sit in one row under the yard. */
@media (min-aspect-ratio: 5/4) {
  .home { --sign: min(46vw, 56svh, 520px); --plank: 56px; }
  .home-actions {
    grid-template-columns: 1fr minmax(0, 1.32fr) 1fr;
    align-items: center;
    column-gap: 12px;
    width: min(94vw, 700px);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .home-actions p { grid-column: 1 / -1; }
  .home-links { display: contents; }
  .home-actions [data-action="map"] { grid-area: 2 / 1; }
  .home-actions #continue { grid-area: 2 / 2; }
  .home-actions [data-action="guide"] { grid-area: 2 / 3; }
  .plank-main { font-size: clamp(17px, 2.1vw, 22px); }
  .plank-side { font-size: clamp(13px, 1.5vw, 15px); }
}
@media (min-aspect-ratio: 5/4) and (max-height: 480px) {
  .home { --sign: min(40vw, 60svh); --plank: 46px; }
  .home-actions { width: min(84vw, 520px); gap: 4px; padding-bottom: max(5px, env(safe-area-inset-bottom)); }
  .home-actions p { display: none; }
}

.intro-calm .title-swing,
.intro-calm .title-lamp,
.intro-calm .title-glow { animation: none; }
